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 view will show confirmation of newly added items 23 * @package GalleryCore 24 * @subpackage UserInterface 25 * @author Bharat Mediratta <bharat@menalto.com> 26 * @version $Revision: 17580 $ 27 */ 28class ItemAddConfirmationView extends GalleryView { 29 30 /** 31 * @see GalleryView::loadTemplate 32 */ 33 function loadTemplate(&$template, &$form) { 34 global $gallery; 35 36 list ($ret, $item) = $this->getItem(); 37 if ($ret) { 38 return array($ret, null); 39 } 40 $itemId = $item->getId(); 41 42 /* 43 * We know what kind of operation happened, but for now let's compress 44 * it down so that the template doesn't have to know. 45 */ 46 $status = $template->getVariable('status'); 47 $uploaded = 0; 48 if (!empty($status['addedFiles'])) { 49 $count = sizeof($status['addedFiles']); 50 for ($i = 0; $i < $count; $i++) { 51 list ($ret, $entity) = GalleryCoreApi::loadEntitiesById( 52 $status['addedFiles'][$i]['id'], 'GalleryItem'); 53 if (!$ret) { 54 $status['addedFiles'][$i]['exists'] = true; 55 $uploaded++; 56 } else if ($ret->getErrorCode() & (ERROR_MISSING_OBJECT | ERROR_BAD_PARAMETER)) { 57 $status['addedFiles'][$i]['exists'] = false; 58 } else { 59 return array($ret, null); 60 } 61 } 62 } else { 63 $status['addedFiles'] = array(); 64 } 65 66 $ItemAddConfirmation = array(); 67 $ItemAddConfirmation['count'] = $uploaded; 68 $ItemAddConfirmation['status'] = $status; 69 70 $template->setVariable('ItemAddConfirmation', $ItemAddConfirmation); 71 $template->setVariable('controller', ''); 72 return array(null, array('body' => 'modules/core/templates/ItemAddConfirmation.tpl')); 73 } 74 75 /** 76 * @see GalleryView::getViewDescription 77 */ 78 function getViewDescription() { 79 list ($ret, $core) = GalleryCoreApi::loadPlugin('module', 'core'); 80 if ($ret) { 81 return array($ret, null); 82 } 83 84 return array(null, $core->translate('add items confirmation')); 85 } 86} 87?> 88