<?php
/*
* Gallery2Flickr
*
* A bridge between your gallery2 installation and flickr.com
*
* File: FlickrImportSet.inc
*
* Displays available photos for importing.
*
* 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: FlickrImportSet.inc 10 2008-01-18 09:39:31Z luciferc $
* @author Gunnar Wrobel <hide@address.com>
*/
/**
* @package Gallery2Flickr
* @subpackage UserInterface
*/
class FlickrImportSetController extends GalleryController {
/**
* @see GalleryController::handleRequest()
*/
function handleRequest($form) {
global $gallery;
$itemId = GalleryUtilities::getRequestVariables('itemId');
$redirect = array();
$status = array();
$error = array();
if (isset($form['action']['import'])) {
$pid_keys = array_keys($form['action']['import']);
$pid = $pid_keys[0];
GalleryCoreApi::requireOnce('modules/Gallery2Flickr/classes/Gallery2Flickr.class.php');
$f2g = new FlickrToGallery();
if ($f2g->import_image($pid, $itemId)) {
/* Send the user to the set import page */
$redirect['view'] = 'Gallery2Flickr.FlickrImportSet';
$redirect['itemId'] = (int)$itemId;
$redirect['pid'] = $pid;
$redirect['sid'] = $form['sid'];
$status['imported'] = 1;
} else {
$error[] = 'form[error][import]';
}
}
$results['status'] = $status;
$results['error'] = $error;
$results['redirect'] = $redirect;
return array(null, $results);
}
}
/**
* @package Flickr
* @subpackage UserInterface
*
*/
class FlickrImportSetView 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();
$sid = GalleryUtilities::getRequestVariables('sid');
$Flickr = array();
$Flickr['item'] = (array)$item;
$Flickr['set'] = $f2g->flickr->photosets_getInfo($sid);
$Flickr['sid'] = $sid;
$Flickr['uid'] = $f2g->flickr->people_getInfo($Flickr['set']['owner']);
$Flickr['photos'] = $f2g->flickr->photosets_getPhotos($sid);
for ($i = 0; $i < count($Flickr['photos']['photo']); $i++) {
$Flickr['photos']['photo'][$i]['thumb'] = $f2g->flickr->buildPhotoURL($Flickr['photos']['photo'][$i], 'thumbnail');
}
$template->setVariable('Flickr', $Flickr);
return array(null, array('body' => 'modules/Gallery2Flickr/templates/FlickrImportSet.tpl'));
}
}
?>