Location: PHPKode > projects > Gallery2flickr > Gallery2Flickr/FlickrExport.inc
<?php
/*
 * Gallery2Flickr
 *
 * A bridge between your gallery2 installation and flickr.com
 *
 * File:       FlickrExport.inc
 *
 *             Export an image or an album to flickr.
 *
 * Copyright:
 *             (c) 2006 - 2007 hide@address.com
 *             Distributed under the terms of the GNU General Public License v2
 *
 * Author(s):
 *             Gunnar Wrobel <hide@address.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
 * 02110-1301, USA.
 *
 * (Gallery2Flickr is a module for Gallery2 - a web based photo album
 *  viewer and editor - Copyright for Gallery2: (C) 2000-2006 Bharat
 *  Mediratta)
 *

 */
/**
 * @package Gallery2Flickr
 * @subpackage UserInterface
 * @version $Id: FlickrExport.inc 10 2008-01-18 09:39:31Z luciferc $
 * @author Gunnar Wrobel <hide@address.com>
 */

/**
 * @package Gallery2Flickr
 * @subpackage UserInterface
 */
class FlickrExportController extends GalleryController {
    /**
     * @see GalleryController::handleRequest()
     */
    function handleRequest($form) {
	global $gallery;

	$itemId = GalleryUtilities::getRequestVariables('itemId');

	$redirect = array();
	$status = array();
	$error = array();

	if (isset($form['action']['export']) || isset($form['action']['streamexport'])) {

	  $sid = null;
	  if (isset($form['action']['export'])) {
	    $sid_keys = array_keys($form['action']['export']);
	    $sid = $sid_keys[0];
	  }

	  GalleryCoreApi::requireOnce('modules/Gallery2Flickr/classes/Gallery2Flickr.class.php');
	  $f2g = new FlickrToGallery();

	  if (isset($form['permissions'])) {
	    $permissions = $form['permissions'];
	  } else {
	    $permissions = 'none';
	  }

	  if ($f2g->export($itemId, $sid, $permissions)) {
	    /* Send the user to the export page */
	    $redirect['view'] = 'Gallery2Flickr.FlickrExport';
	    $redirect['itemId'] = (int)$itemId;
	    $redirect['sid'] = $sid;
	    $status['exported'] = 1;
	  } else {
	    $error[] = 'form[error][export]';
	  }
	}

	$results['status'] = $status;
	$results['error'] = $error;
	$results['redirect'] = $redirect;

	return array(null, $results);
    }
}

/**
 * @package Flickr
 * @subpackage UserInterface
 *
 */
class FlickrExportView extends GalleryView {

    /**
     * @see GalleryView::loadTemplate
     */
    function loadTemplate(&$template, &$form) {
	/* Load our item */
	list ($ret, $item) = $this->_getItem();
	if ($ret) {
	    return array($ret, null);
	}

	GalleryCoreApi::requireOnce('modules/Gallery2Flickr/classes/Gallery2Flickr.class.php');
	$f2g = new FlickrToGallery();

	$Flickr = array();
	$Flickr['perm'] = 'none';
	$Flickr['item'] = (array)$item;
	if ($item->getCanContainChildren()) {
	  $Flickr['album'] = 1;
	}
	$Flickr['sets'] = $f2g->flickr->photosets_getList();
	$template->setVariable('Flickr', $Flickr);

	return array(null, array('body' => 'modules/Gallery2Flickr/templates/FlickrExport.tpl'));
    }
}
?>
Return current item: Gallery2flickr