3
3
* Gallery - a web based photo album viewer and editor
4
* Copyright (C) 2000-2007 Bharat Mediratta
4
* Copyright (C) 2000-2008 Bharat Mediratta
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.
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.
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.
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 $
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.
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.
33
32
if (!isset($UPGRADE_LOOP)) {
37
36
if ($UPGRADE_LOOP == 2) {
41
if (!isset($gallery->version)) {
40
if (!isset($gallery->version)) {
42
41
require_once(dirname(__FILE__) . '/init.php');
56
55
if (!$gallery->user->isAdmin() && empty($upgrade_albumname)) {
57
echo _("You are not allowed to perform this action!");
56
echo _("You are not allowed to perform this action!");
61
60
$albumDB = new AlbumDB(FALSE);
63
function reload_button() {
66
print "<input type=\"button\" name=\"done\" value=\"" . _("Done") ."\" onclick='location.reload()'>";
77
function process($album=null) {
62
function process($album = null) {
81
print "<b>" . _("Progress") .":</b>";
65
echo addProgressbar('mainProgessbar', gTranslate('core', "Total Progress:"));
67
echo addProgressbar('albumProgessbar', gTranslate('core', "Album Progress:"));
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"]) .
85
74
// Upgrade the album
86
75
if ($album->integrityCheck()) {
87
76
$album->save(array(), 0);
79
echo "\n<script type=\"text/javascript\">updateProgressBar('mainProgessbar', '',100)</script>";
80
echo "\n<script type=\"text/javascript\">updateProgressBar('albumProgessbar', '',100)</script>";
83
$count = sizeof($albumDB->outOfDateAlbums);
84
$onePercent = 100/$count;
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) {
93
92
// Retrieve the album
94
93
$album = $albumDB->getAlbumByName($albumName);
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"]) .
98
99
// Upgrade the album
99
100
if ($album->integrityCheck()) {
100
101
$album->save(array(), 0);
104
echo "\n<script type=\"text/javascript\">updateProgressBar('mainProgessbar', '',". ceil($i * $onePercent) .")</script>";
113
<title><?php echo _("Upgrade Albums") ?></title>
114
<?php common_header(); ?>
116
<body dir="<?php echo $gallery->direction ?>" class="popupbody">
117
<div class="popuphead"><?php echo _("Upgrade Albums") ?></div>
121
echo _("The following albums in your gallery were created with an older version of the software and are out of date.");
123
echo _("This is not a problem!");
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.");
127
echo _("None of your photos will be harmed in any way by this process.");
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.");
111
/* Start HTML output */
112
printPopupStart(gTranslate('core', "Upgrade Albums"), '', 'left');
134
114
if (isset($upgrade_albumname)) {
135
115
$album = new Album();
136
116
$album->load($upgrade_albumname);
139
if (isset($album) && $album->versionOutOfDate()) {
146
if (isset($upgradeall) && sizeof($albumDB->outOfDateAlbums)) {
118
if ($album->versionOutOfDate()) {
123
elseif (isset($upgradeall) && sizeof($albumDB->outOfDateAlbums)) {
154
if (!sizeof($albumDB->outOfDateAlbums)) {
155
print "<b>". _("All albums are up to date.") ."</b>";
128
if (sizeof($albumDB->outOfDateAlbums) == 0) {
129
print "<b>". gTranslate('core', "All albums are up to date.") ."</b>";
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.");
134
echo gTranslate('core', "This is not a problem!");
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.");
138
echo gTranslate('core', "None of your photos will be harmed in any way by this process.");
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.");
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>');
163
echo "\n<table align=\"center\">";
148
$updateList = new galleryTable();
150
$updateList->setAttrs(array('align' => 'center'));
164
152
foreach ($albumDB->outOfDateAlbums as $albumName) {
165
153
$album = $albumDB->getAlbumByName($albumName);
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>';
155
$updateList->addElement(array(
156
'content' => $album->fields["title"],
157
'cellArgs' => array('class' => 'g-emphasis')));
159
$updateList->addElement(array(
160
'content' => gTranslate('core', "One item", "%d items", $album->numPhotos(1), gTranslate('core', "Empty"), true),
161
'cellArgs' => array('class' => 'right')));
163
$updateList->addElement(array('content' => galleryLink(
164
makeGalleryUrl('upgrade_album.php', array(
165
'upgrade_albumname' => $album->fields['name'],
167
gTranslate('core', "upgrade"), '', '', true)));
170
echo $updateList->render();
178
print '<form name="close" action="#">';
179
print '<input type="button" name="close" value="'. _("Done") .'" onclick="opener.location.reload(); parent.close()">';
183
print gallery_validation_link("upgrade_album.php");
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();'); ?>