1<?php 2/* 3 * Gallery - a web based photo album viewer and editor 4 * Copyright (C) 2000-2008 Bharat Mediratta 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or (at 9 * your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, but 12 * WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 19 */ 20 21/** 22 * This ItemAddOption allows the user to choose to create thumbnails when the image is uploaded. 23 * @package GalleryCore 24 * @subpackage UserInterface 25 * @author Bharat Mediratta <bharat@menalto.com> 26 * @version $Revision: 17580 $ 27 */ 28class CreateThumbnailOption extends ItemAddOption { 29 30 /** 31 * @see ItemAddOption::loadTemplate 32 */ 33 function loadTemplate(&$template, &$form, $item) { 34 return array(null, 'modules/core/templates/CreateThumbnailOption.tpl', 'modules_core'); 35 } 36 37 /** 38 * @see ItemAddOption::isAppropriate 39 */ 40 function isAppropriate() { 41 return array(null, true); 42 } 43 44 /** 45 * @see ItemAddOption::handleRequestAfterAdd 46 */ 47 function handleRequestAfterAdd($form, $items) { 48 $errors = $warnings = $itemIds = array(); 49 foreach ($items as $item) { 50 $itemIds[] = $item->getId(); 51 } 52 if (empty($form['CreateThumbnailOption']['createThumbnail'])) { 53 return array(null, $errors, $warnings); 54 } 55 56 list ($ret, $thumbTable) = GalleryCoreApi::fetchThumbnailsByItemIds($itemIds); 57 if ($ret) { 58 return array($ret, null, null); 59 } 60 61 foreach ($items as $item) { 62 $itemId = $item->getId(); 63 if (!empty($thumbTable[$itemId])) { 64 $thumbnail = $thumbTable[$item->getId()]; 65 list ($ret) = 66 GalleryCoreApi::rebuildDerivativeCacheIfNotCurrent($thumbnail->getId()); 67 if ($ret) { 68 return array($ret, null, null); 69 } 70 } 71 } 72 return array(null, $errors, $warnings); 73 } 74} 75?> 76