1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
|
<?php
/*
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2006 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*
* $Id: rearrange.php 13338 2006-03-27 15:32:14Z jenst $
*/
?>
<?php
require_once(dirname(__FILE__) . '/init.php');
if (!isset($gallery->album) || !$gallery->user->canWriteToAlbum($gallery->album)) {
echo _("You are not allowed to perform this action!");
exit;
}
$rearrList = getRequestVar('rearrList');
if (!empty($rearrList)) {
$gallery->album->rearrangePhotos(explode(',',$rearrList));
$gallery->album->save(array(i18n("Images rearranged")));
dismissAndReload();
return;
}
$rows = $gallery->album->fields["rows"];
$cols = $gallery->album->fields["cols"];
$numPhotos = $gallery->album->numPhotos(1);
doctype() ?>
<html>
<head>
<title><?php echo $gallery->app->galleryTitle ?> :: <?php echo sprintf (_("Rearrange Album: %s"),$gallery->album->fields["title"]) ?></title>
<?php common_header(); ?>
<script language="javascript" type="text/javascript">
var sel = -1, list = new Array();
function save() {
var s = '';
for (i=1; i<list.length; i++) {
if (i>1) s+=',';
s+=list[i];
}
document.forms['rearr_form'].rearrList.value = s;
document.forms['rearr_form'].submit();
}
function copy(from, to) {
to.src = from.src;
to.width = from.width;
to.height = from.height;
to.style.border = from.style.border;
}
function doclick(idx) {
if (sel < 0) {
sel=idx;
savedFromBorder = document.getElementById('im_'+sel).style.border;
document.getElementById('im_'+sel).style.borderStyle='dashed';
} else {
if (idx != sel) {
var sv = new Object()
var si;
var dir = (sel<idx)?1:-1;
sv.style = new Object();
copy(document.getElementById('im_'+sel), sv);
si = list[sel];
for (i=sel; i!=idx; i+=dir) {
copy(document.getElementById('im_'+(i+dir)),
document.getElementById('im_'+i));
list[i] = list[i+dir];
}
copy(sv, document.getElementById('im_'+idx));
list[idx] = si;
}
document.getElementById('im_'+idx).style.border = savedFromBorder;
sel = -1;
}
}
</script>
</head>
<body dir="<?php echo $gallery->direction ?>" class="popupbody">
<div class="popuphead"><?php echo sprintf (_("Rearrange Album: %s"),$gallery->album->fields["title"]) ?></div>
<div class="admin" align="center">
<?php
echo _("Here you can rearrange your pictures easily. Just click on the item you want to reorder. Then click on the item at which position you want it to be.");
$explainTable = new galleryTable;
$explainTable->setCaption(_("Meaning of the borderstyle"), 'attention');
$explainTable->setAttrs(array('width' => 300, 'cellspacing' => 3, 'cellpadding' => 2));
$explainTable->setColumnCount(4);
$explainTable->addElement(array('content' => _("Picture"), 'cellArgs' => array('style' => 'text-align: center; border: 2px solid black')));
$explainTable->addElement(array('content' => _("Movie"), 'cellArgs' => array('style' => 'text-align: center; border: 2px dotted black')));
$explainTable->addElement(array('content' => _("Subalbum") , 'cellArgs' => array('style' => 'text-align: center; border: 3px double black')));
$explainTable->addElement(array('content' => _("Selected") , 'cellArgs' => array('style' => 'text-align: center; border: 2px dashed black')));
$explainTable->addElement(array('content' => _("Visible") , 'cellArgs' => array('colspan' => 2, 'style' => 'text-align: center; color: green')));
$explainTable->addElement(array('content' => _("Hidden") , 'cellArgs' => array('colspan' => 2, 'style' => 'text-align: center; color: red')));
?>
<br><br><center><?php echo $explainTable->render(); ?></center>
</div>
<div class="popup" align="center">
<?php
echo makeFormIntro('rearrange.php',array('name' => 'rearr_form'));
?>
<input type="hidden" name="rearrList" value="">
<?php
$pictureTable = new galleryTable();
$pictureTable->setAttrs(array('width' => '100%', 'cellspacing' => 0, 'cellpadding' => 2));
$pictureTable->setColumnCount($cols);
$pictureTable->addElement(array(
'content' => '<input type="button" onclick="save();return false" value="' . _("save") .'">'.
'<input type="button" onclick="window.close();return false" value="'. _("cancel") .'">',
'cellArgs' => array('colspan' => $cols, 'align' => 'right')));
$list = array();
$j = 1;
$page = 1;
for ($i = getNextPhoto(0), $i = 1; $i <= $numPhotos; $i = getNextPhoto($i)) {
if ($j++==($cols*$rows) || $page == 1) {
$pictureTable->addElement(array(
'content' => sprintf(_("******* Page %s *******"), $page),
'cellArgs' => array('colspan' => $cols, 'align' => 'center')));
$j = 1;
$page++;
}
$attrs = 'id="im_'.$i.'" onclick="doclick('.$i.')" style="padding: 2px; border: '
. ($gallery->album->isHidden($i) ? ' red' : ' green');
if ($gallery->album->isAlbum($i)) {
$myAlbumName = $gallery->album->getAlbumName($i);
$myAlbum = new Album();
$myAlbum->load($myAlbumName);
$tag = $myAlbum->getHighlightTag(0,$attrs. ' 3px double"');
} elseif ($gallery->album->isMovieByIndex($i)) {
$tag = $gallery->album->getThumbnailTag($i,0,$attrs.' 2px dotted"');
} else {
$tag = $gallery->album->getThumbnailTag($i,0,$attrs.' 2px solid"');
}
$pictureTable->addElement(array('content' => $tag, 'cellArgs' => array('align' => 'center')));
$list[] = $i;
}
$pictureTable->addElement(array(
'content' => '<input type="button" onclick="save();return false" value="' . _("save") .'">'.
'<input type="button" onclick="window.close();return false" value="'. _("cancel") .'">',
'cellArgs' => array('colspan' => $cols, 'align' => 'right')));
echo $pictureTable->render();
?>
</form>
</div>
<?php print gallery_validation_link("rearrange.php", true); ?>
<script language="javascript" type="text/javascript">
<?php
foreach ($list as $key=>$value) {
echo "list[".($key+1)."]=$value;\n";
}
?>
</script>
</body>
</html>
|