~ubuntu-branches/ubuntu/lucid/gallery/lucid

« back to all changes in this revision

Viewing changes to upgrade_album.php

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Lesicnik
  • Date: 2008-08-08 10:51:25 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20080808105125-6qyhpf7krzxnjeh4
Tags: 1.5.8-1ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/postrm:
    + Delete config.php and htaccess on purge.
* debian/control:
  - Added Homepage field.
* Removed the ubuntu specific po files and using
  debian / upstream provided po files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
2
/*
3
3
 * Gallery - a web based photo album viewer and editor
4
 
 * Copyright (C) 2000-2007 Bharat Mediratta
5
 
 * 
 
4
 * Copyright (C) 2000-2008 Bharat Mediratta
 
5
 *
6
6
 * This program is free software; you can redistribute it and/or modify
7
7
 * it under the terms of the GNU General Public License as published by
8
8
 * the Free Software Foundation; either version 2 of the License, or (at
9
9
 * your option) any later version.
10
 
 * 
 
10
 *
11
11
 * This program is distributed in the hope that it will be useful, but
12
12
 * WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
14
 * General Public License for more details.
15
 
 * 
 
15
 *
16
16
 * You should have received a copy of the GNU General Public License
17
17
 * along with this program; if not, write to the Free Software
18
18
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
19
19
 *
20
 
 * $Id: upgrade_album.php 15632 2007-01-02 06:01:08Z jenst $
 
20
 * $Id: upgrade_album.php 241 2008-07-28 09:53:00Z jens $
21
21
 */
22
 
?>
23
 
<?php
 
22
 
24
23
/*
25
24
 * This page is designed to work in standalone mode AND to be included
26
25
 * from init.php, so be certain not to require init.php twice.  We
27
26
 * can't use require_once() here because some older versions of PHP4
28
27
 * barf on require_once() with a variable parameter.
29
28
 *
30
 
 * Since init.php will also include this file under some circumstances, 
 
29
 * Since init.php will also include this file under some circumstances,
31
30
 * we want to keep track to see  if we're in an include loop.  If so, return.
32
31
 */
33
32
if (!isset($UPGRADE_LOOP)) {
34
 
        $UPGRADE_LOOP=0;
 
33
        $UPGRADE_LOOP = 0;
35
34
}
36
35
$UPGRADE_LOOP++;
37
36
if ($UPGRADE_LOOP == 2) {
38
37
        return;
39
38
}
40
39
 
41
 
if (!isset($gallery->version)) { 
 
40
if (!isset($gallery->version)) {
42
41
        require_once(dirname(__FILE__) . '/init.php'); 
43
42
}
44
43
 
54
53
 
55
54
// Hack check
56
55
if (!$gallery->user->isAdmin() && empty($upgrade_albumname)) {
57
 
        echo _("You are not allowed to perform this action!");
58
 
        exit;
 
56
                echo _("You are not allowed to perform this action!");
 
57
                exit;
59
58
}
60
59
 
61
60
$albumDB = new AlbumDB(FALSE);
62
61
 
63
 
function reload_button() {
64
 
        print "<center>";
65
 
        print "<form>";
66
 
        print "<input type=\"button\" name=\"done\" value=\"" . _("Done") ."\" onclick='location.reload()'>";
67
 
        print "</form>";
68
 
        print "</center>";
69
 
}
70
 
 
71
 
function end_file() {
72
 
        print "\n</div>";
73
 
        print "\n</body>";
74
 
        print "\n</html>";
75
 
}
76
 
 
77
 
function process($album=null) {
 
62
function process($album = null) {
78
63
        global $albumDB;
79
64
 
80
 
        print "<br>";
81
 
        print "<b>" . _("Progress") .":</b>";
82
 
        print "<ul>";
 
65
        echo addProgressbar('mainProgessbar', gTranslate('core', "Total Progress:"));
 
66
        echo "\n<br>";
 
67
        echo addProgressbar('albumProgessbar', gTranslate('core', "Album Progress:"));
 
68
 
83
69
        if ($album) {
84
 
                print "<b>". _("Album") . ": " . $album->fields["title"] . "</b><br>";
 
70
                echo '<br><span class="g-emphasis">' .
 
71
                  sprintf(gTranslate('core', "Album: %s"), $album->fields["title"]) .
 
72
                  "</span>\n";
 
73
 
85
74
                // Upgrade the album
86
75
                if ($album->integrityCheck()) {
87
76
                        $album->save(array(), 0);
88
77
                }
89
 
                print "<br>";
90
 
        } else {
 
78
 
 
79
                echo "\n<script type=\"text/javascript\">updateProgressBar('mainProgessbar', '',100)</script>";
 
80
                echo "\n<script type=\"text/javascript\">updateProgressBar('albumProgessbar', '',100)</script>";
 
81
        }
 
82
        else {
 
83
                $count = sizeof($albumDB->outOfDateAlbums);
 
84
                $onePercent = 100/$count;
 
85
                $i = 0;
 
86
 
 
87
                echo '<br><div class="g-emphasis"><i>' . gTranslate('core', "Statusbox") . '</i></div>';
 
88
                echo gTranslate('core', "Please ensure there are no errors.");
 
89
                echo '<div class="albumUpgradeStatus">';
91
90
                foreach ($albumDB->outOfDateAlbums as $albumName) {
92
 
 
 
91
                        $i++;
93
92
                        // Retrieve the album
94
93
                        $album = $albumDB->getAlbumByName($albumName);
95
94
 
96
 
                        print "<b>". _("Album") . ": " . $album->fields["title"] . "</b><br>";
 
95
                        echo "\n<div class=\"g-emphasis\">".
 
96
                                 sprintf(gTranslate('core', "Album: %s"), $album->fields["title"]) .
 
97
                                 "</div>";
97
98
 
98
99
                        // Upgrade the album
99
100
                        if ($album->integrityCheck()) {
100
101
                                $album->save(array(), 0);
101
102
                        }
102
103
 
103
 
                        print "<br>";
 
104
                        echo "\n<script type=\"text/javascript\">updateProgressBar('mainProgessbar', '',". ceil($i * $onePercent) .")</script>";
 
105
                        print "<br><br>";
104
106
                }
 
107
                echo "</div>";
105
108
        }
106
 
        print "</ul>";
107
109
}
108
110
 
109
 
doctype();
110
 
?>
111
 
<html>
112
 
<head>
113
 
  <title><?php echo _("Upgrade Albums") ?></title>
114
 
  <?php common_header(); ?>
115
 
</head>
116
 
<body dir="<?php echo $gallery->direction ?>" class="popupbody">
117
 
<div class="popuphead"><?php echo _("Upgrade Albums") ?></div>
118
 
<div class="popup">
119
 
<p>
120
 
<?php 
121
 
        echo _("The following albums in your gallery were created with an older version of the software and are out of date.");
122
 
        echo '<br>';
123
 
        echo _("This is not a problem!");
124
 
        echo '<br><br>';
125
 
        echo _("We can upgrade them.  This may take some time for large albums but we'll try to keep you informed as we proceed.");
126
 
        echo '<br>';
127
 
        echo _("None of your photos will be harmed in any way by this process.");
128
 
        echo '<br>';
129
 
        echo _("Rest assured, that if this process takes a long time now, it's going to make your gallery run more efficiently in the future.");
130
 
?>  
131
 
</p>
 
111
/* Start HTML output */
 
112
printPopupStart(gTranslate('core', "Upgrade Albums"), '', 'left');
132
113
 
133
 
<?php
134
114
if (isset($upgrade_albumname)) {
135
115
        $album = new Album();
136
116
        $album->load($upgrade_albumname);
137
 
}
138
 
 
139
 
if (isset($album) && $album->versionOutOfDate()) {
140
 
        process($album);
141
 
        reload_button();
142
 
        end_file();
143
 
        exit;
144
 
}
145
 
 
146
 
if (isset($upgradeall) && sizeof($albumDB->outOfDateAlbums)) {
 
117
 
 
118
        if ($album->versionOutOfDate()) {
 
119
                process($album);
 
120
                $actionDone = true;
 
121
        }
 
122
}
 
123
elseif (isset($upgradeall) && sizeof($albumDB->outOfDateAlbums)) {
147
124
        process();
148
 
        reload_button();
149
 
        end_file();
150
 
        exit;
 
125
        $actionDone = true;
151
126
}
152
 
        
153
127
 
154
 
if (!sizeof($albumDB->outOfDateAlbums)) {
155
 
        print "<b>". _("All albums are up to date.") ."</b>";
156
 
} else {
 
128
if (sizeof($albumDB->outOfDateAlbums) == 0) {
 
129
        print "<b>". gTranslate('core', "All albums are up to date.") ."</b>";
 
130
}
 
131
elseif (!isset($actionDone)) {
 
132
        echo gTranslate('core', "Some albums in your gallery were created with an older version of the software and are out of date.");
 
133
        echo '<br>';
 
134
        echo gTranslate('core', "This is not a problem!");
 
135
        echo '<p>';
 
136
        echo gTranslate('core', "We can upgrade them.  This may take some time for large albums but we'll try to keep you informed as we proceed.");
 
137
        echo '<br>';
 
138
        echo gTranslate('core', "None of your photos will be harmed in any way by this process.");
 
139
        echo '<br>';
 
140
        echo gTranslate('core', "Rest assured, that if this process takes a long time now, it's going to make your gallery run more efficiently in the future.");
157
141
 
158
142
        echo "\n<p>";
159
 
        echo sprintf(_("The following albums need to be upgraded.  You can process them individually by clicking the upgrade link next to the album that you desire, or you can just %s."),
160
 
                '<a class="error" href="' . makeGalleryUrl("upgrade_album.php", array("upgradeall" => 1, 'type' => 'popup')) . '"><b>' . _("upgrade them all at once") . '</b></a>');
 
143
        echo sprintf(gTranslate('core', "The following albums need to be upgraded.  You can process them individually by clicking the upgrade link next to the album that you desire, or you can just %s."),
 
144
                '<a class="g-error" href="' . makeGalleryUrl("upgrade_album.php", array("upgradeall" => 1, 'type' => 'popup')) . '"><b>' . gTranslate('core', "upgrade them all at once") . '</b></a>');
161
145
 
162
146
        echo '</p>';
163
 
        echo "\n<table align=\"center\">";
 
147
 
 
148
        $updateList = new galleryTable();
 
149
 
 
150
        $updateList->setAttrs(array('align' => 'center'));
 
151
 
164
152
        foreach ($albumDB->outOfDateAlbums as $albumName) {
165
153
                $album = $albumDB->getAlbumByName($albumName);
166
 
                echo "\n<tr>";
167
 
                echo '<td><a href="';
168
 
                echo makeGalleryUrl("upgrade_album.php", 
169
 
                        array("upgrade_albumname" => $album->fields["name"], 'type' => 'popup'));
170
 
                echo '">['. _("upgrade") .']</a></td>';
171
 
                echo '<td><b>'. $album->fields["title"] . '</b></td>';
172
 
                echo '<td>('. $album->numPhotos(1) .' '. _("items"). ')</td>';
173
 
                echo '</tr>';
 
154
 
 
155
                $updateList->addElement(array(
 
156
                  'content' => $album->fields["title"],
 
157
                  'cellArgs' => array('class' => 'g-emphasis')));
 
158
 
 
159
                $updateList->addElement(array(
 
160
                        'content' => gTranslate('core', "One item", "%d items", $album->numPhotos(1), gTranslate('core', "Empty"), true),
 
161
                        'cellArgs' => array('class' => 'right')));
 
162
 
 
163
                $updateList->addElement(array('content' => galleryLink(
 
164
                        makeGalleryUrl('upgrade_album.php', array(
 
165
                                'upgrade_albumname' => $album->fields['name'],
 
166
                                'type' => 'popup')),
 
167
                        gTranslate('core', "upgrade"), '', '', true)));
174
168
        }
175
 
        echo "\n</table>\n";
 
169
 
 
170
        echo $updateList->render();
176
171
}
177
 
 
178
 
        print '<form name="close" action="#">';
179
 
        print '<input type="button" name="close" value="'. _("Done") .'" onclick="opener.location.reload(); parent.close()">';
180
 
        print '</form>';
181
 
 
182
 
        echo "\n</div>";
183
 
        print gallery_validation_link("upgrade_album.php");
184
172
?>
 
173
        <form action="#" class="center">
 
174
        <?php echo gButton("reloadButton", gTranslate('core', "Reload"), 'location.reload()'); ?>
 
175
        <?php echo gButton("closeButton", gTranslate('core', "Close Window"), 'parent.close() ; location.reload();'); ?>
 
176
        </form>
 
177
 
 
178
</div>
 
179
 
185
180
</body>
186
181
</html>