~ubuntu-branches/ubuntu/quantal/gallery2/quantal

« back to all changes in this revision

Viewing changes to modules/core/ItemAddConfirmation.inc

  • Committer: Bazaar Package Importer
  • Author(s): Michael C. Schultheiss
  • Date: 2005-11-29 15:50:12 UTC
  • Revision ID: james.westby@ubuntu.com-20051129155012-wtophp03lu01kdgl
Tags: upstream-2.0.2
ImportĀ upstreamĀ versionĀ 2.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/*
 
3
 * $RCSfile: ItemAddConfirmation.inc,v $
 
4
 *
 
5
 * Gallery - a web based photo album viewer and editor
 
6
 * Copyright (C) 2000-2005 Bharat Mediratta
 
7
 *
 
8
 * This program is free software; you can redistribute it and/or modify
 
9
 * it under the terms of the GNU General Public License as published by
 
10
 * the Free Software Foundation; either version 2 of the License, or (at
 
11
 * your option) any later version.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful, but
 
14
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 * General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program; if not, write to the Free Software
 
20
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
 
21
 */
 
22
 
 
23
/**
 
24
 * @version $Revision: 1.8 $ $Date: 2005/08/23 03:49:02 $
 
25
 * @package GalleryCore
 
26
 * @subpackage UserInterface
 
27
 * @author Bharat Mediratta <bharat@menalto.com>
 
28
 */
 
29
 
 
30
/**
 
31
 * This view will show the confirmation that an user has been edited successfully
 
32
 *
 
33
 * @package GalleryCore
 
34
 * @subpackage UserInterface
 
35
 *
 
36
 */
 
37
class ItemAddConfirmationView extends GalleryView {
 
38
 
 
39
    /**
 
40
     * @see GalleryView::loadTemplate
 
41
     */
 
42
    function loadTemplate(&$template, &$form) {
 
43
        global $gallery;
 
44
 
 
45
        $itemId = GalleryUtilities::getRequestVariables('itemId');
 
46
        list ($ret, $item) = GalleryCoreApi::loadEntitiesById($itemId);
 
47
        if ($ret->isError()) {
 
48
            return array($ret->wrap(__FILE__, __LINE__), null);
 
49
        }
 
50
 
 
51
        /*
 
52
         * We know what kind of operation happened, but for now let's compress
 
53
         * it down so that the template doesn't have to know.
 
54
         */
 
55
        $status = $template->getVariable('status');
 
56
        if (!empty($status['addedFiles'])) {
 
57
            $count = sizeof($status['addedFiles']);
 
58
            for ($i = 0; $i < $count; $i++) {
 
59
                list ($ret, $entity) =
 
60
                    GalleryCoreApi::loadEntitiesById($status['addedFiles'][$i]['id']);
 
61
                if ($ret->isSuccess()) {
 
62
                    $status['addedFiles'][$i]['exists'] = true;
 
63
                } else if ($ret->getErrorCode() & ERROR_MISSING_OBJECT) {
 
64
                    $status['addedFiles'][$i]['exists'] = false;
 
65
                } else {
 
66
                    return array($ret->wrap(__FILE__, __LINE__), null);
 
67
                }
 
68
            }
 
69
        } else {
 
70
            $count = 0;
 
71
            $status['addedFiles'] = array();
 
72
        }
 
73
 
 
74
        $ItemAddConfirmation = array();
 
75
        $ItemAddConfirmation['count'] = $count;
 
76
        $ItemAddConfirmation['status'] = $status;
 
77
 
 
78
        $template->setVariable('ItemAddConfirmation', $ItemAddConfirmation);
 
79
        $template->setVariable('controller', '');
 
80
        return array(GalleryStatus::success(),
 
81
                     array('body' => 'modules/core/templates/ItemAddConfirmation.tpl'));
 
82
    }
 
83
 
 
84
    /**
 
85
     * @see GalleryView::getViewDescription()
 
86
     */
 
87
    function getViewDescription() {
 
88
        list ($ret, $core) = GalleryCoreApi::loadPlugin('module', 'core');
 
89
        if ($ret->isError()) {
 
90
            return array($ret->wrap(__FILE__, __LINE__), null);
 
91
        }
 
92
 
 
93
        return array(GalleryStatus::success(), $core->translate('add items confirmation'));
 
94
    }
 
95
}
 
96
?>