/** * Prints the jQuery JS setup for the upload limiting * * @return string */ function uploadLimiterJS($defaultJS) { $js = ''; if (!zp_loggedin(MANAGE_ALL_ALBUM_RIGHTS)) { $target = 'function uploadify_onSelectOnce(event, data) {'; $i = strpos($defaultJS, $target); if ($i !== false) { $j = strpos($defaultJS, '}', $i + strlen($target)); $body = trim(substr($defaultJS, $i + strlen($target), $j)); if (!empty($dody)) { echo gettext("There is a plugin conflict with <em>image_upload_limiter</em>"); } $js = substr($defaultJS, 0, $i) . substr($defaultJS, $j + 1); } $albumlist = array(); genAlbumList($albumlist); $rootrights = accessAllAlbums(UPLOAD_RIGHTS); $limitalbums = getUploadLimitedAlbums($albumlist); $imagenumber = getUploadImagesInAlbum($albumlist); $js .= "\$(document).ready(function() {\n\t\t\t\t\t\t\t\t\t\$('#uploadswitch').hide();\n\t\t\t\t\t\t});"; if (getOption('imageuploadlimit_newalbum')) { $js .= "\n\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\t\$('#newalbumbox,#albumtext').hide();\n\t\t\t\t});"; } $js .= "\n\tfunction generateUploadlimit(selectedalbum,limitalbums) {\n\t\t\$('#uploadlimitmessage').remove();\n\t\tvar imagenumber = new Array(" . $imagenumber . ");\n\t\tvar message = '';\n\t\tvar uploadlimit = " . getOption('imageuploadlimit') . ";\n\t\tvar imagesleft = '';\n\t\t\$.each(limitalbums, function(key,value) {\n\t\t\tif(value == selectedalbum) {\n\t\t\t\tif(imagenumber[key] >= uploadlimit) {\n\t\t\t\t\timagesleft = 0;\n\t\t\t\t} else if (imagenumber[key] < uploadlimit) {\n\t\t\t\t\timagesleft = uploadlimit - imagenumber[key];\n\t\t\t\t}\n\t\t\t\tif(imagesleft === 0) {\n\t\t\t \t\$('#fileUploadbuttons').hide();\n\t\t\t \tqueuelimit = 0;\n\t\t\t \tmessage = '" . gettext('The album exceeded the image number limit. You cannot upload more images!') . "';\n\t\t\t\t\t//alert(message);\n\t\t\t\t\t\$('#albumselect').prepend('<span id=\"uploadlimitmessage\" style=\"color:red;\">'+message+'<br /><br /></span>');\n\t\t\t\t} else {\n\t\t\t\t\tqueuelimit = imagesleft;\n\t\t\t\t\tmessage = '" . gettext("Maximum number of images left for this album: ") . "'+imagesleft;\n\t\t\t\t\t//alert(message);\n\t\t\t\t \$('#albumselect').prepend('<span id=\"uploadlimitmessage\" style=\"color:green\">'+message+'<br /><br /></span>');\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn queuelimit;\n\t}"; $js .= "var limitalbums = new Array(" . $limitalbums . ");"; if (isset($_GET['album']) && !empty($_GET['album'])) { // if we upload $selectedalbum = sanitize($_GET['album']); $js .= "var selectedalbum = '" . $selectedalbum . "';"; } else { if ($rootrights) { $js .= "var selectedalbum = '';"; // choose the first entry of the select list if nothing is selected and the user has root rights (so root no message...) } else { $js .= "var selectedalbum = limitalbums[0];"; // choose the first entry of the select list if nothing is selected and no rootrights } } $js .= "\n\tvar queuelimit = generateUploadlimit(selectedalbum,limitalbums);\n\tvar value = '';\n\tvar newalbum = '';\n\n\t\$(document).ready(function() {\n\t\t// normal album selection\n\t\t\$('#albumselectmenu').change(function() {\n\t\t\t\$('#fileUpload').uploadifyClearQueue(); // to be sure that no selections for other albums are kept\n\t\t\tselectedalbum = \$('#albumselectmenu').val();\n\t\t\tqueuelimit = generateUploadlimit(selectedalbum,limitalbums);\n\t\t});\n\t\t// new toplevel album\n\t\t\$('#albumtitle').keyup(function () {\n\t\t\t\tvalue = \$('#albumtitle').val();\n\t\t\t\tif(value != '') {\n\t\t\t\t\tqueuelimit = " . getOption('imageuploadlimit') . ";\n\t\t\t\t}\n\t\t});\n\t\t// new subalbum\n\t\t\$('#newalbumcheckbox').change(function() {\n\t\t\t\$('#albumtitle').keyup(function () {\n\t\t\t\tvalue = \$('#albumtitle').val();\n\t\t\t\tqueuelimit = " . getOption('imageuploadlimit') . ";\n\t\t\t});\n\t\t});\n\t\t\$('#fileUpload').uploadifySettings('queueSizeLimit'," . getOption('imageuploadlimit') . ");\n\t});\n\t"; } return $js; }
function form_album($message = '') { global $gallery; $gallery = new Gallery(); $albumlist = array(); genAlbumList($albumlist); $this->header(); echo '<script language="javascript" type="text/javascript">'; echo 'window.totalinputs = 5;'; echo "\n\n"; echo 'var albumArray = new Array ('; $separator = ''; foreach ($albumlist as $key => $value) { echo $separator . "'" . addslashes($key) . "'"; $separator = ", "; } echo ');'; echo "\n\n"; echo '</script>'; echo '<h2>Select the album you want to use</h2>'; if ($message != '') { echo "<p>" . htmlspecialchars($message) . "</p>"; } echo '<form method="post" id="select" action="' . FULLWEBPATH . '/' . basename(__FILE__) . '?cmd=finish">'; echo '<input type="hidden" name="folder" value="" />'; echo '<div id="albumselect">'; echo '<select id="" name="albumselect" onChange="albumSwitch(this)">'; echo '<option value="" selected="true">A new album...</option>'; $bglevels = array('#fff', '#f8f8f8', '#efefef', '#e8e8e8', '#dfdfdf', '#d8d8d8', '#cfcfcf', '#c8c8c8'); $checked = "checked=\"false\""; foreach ($albumlist as $fullfolder => $albumtitle) { $singlefolder = $fullfolder; $saprefix = ""; $salevel = 0; if ($_GET['album'] == $fullfolder) { $selected = " SELECTED=\"true\" "; if (!isset($_GET['new'])) { $checked = ""; } } else { $selected = ""; } // Get rid of the slashes in the subalbum, while also making a subalbum prefix for the menu. while (strstr($singlefolder, '/') !== false) { $singlefolder = substr(strstr($singlefolder, '/'), 1); $saprefix = " » " . $saprefix; $salevel++; } echo '<option value="' . $fullfolder . '"' . ($salevel > 0 ? ' style="background-color: ' . $bglevels[$salevel] . '; border-bottom: 1px dotted #ccc;"' : '') . "{$selected}>" . $saprefix . $singlefolder . "</option>\n"; } echo '</select>'; echo '<fieldset id="albumtext"><legend>Create a new album</legend><div>'; echo '<label>Title:'; echo '<input id="albumtitle" size="22" type="text" name="albumtitle" value="" onKeyUp="updateFolder(this, \'folderdisplay\', \'autogen\');" />'; echo '</label>'; echo '<label>Folder:'; echo '<input id="folderdisplay" size="18" type="text" name="folderdisplay" disabled="true" onKeyUp="validateFolder(this);"/>'; echo '<label>'; echo '<input type="checkbox" name="autogenfolder" id="autogen" checked="true" onClick="toggleAutogen(\'folderdisplay\', \'albumtitle\', this);" />'; echo 'Auto-generate'; echo '</label>'; echo '</label>'; echo '<div id="foldererror" style="display: none;">That name is already in use</div>'; echo '</div></fieldset></div>'; echo '</form>'; $this->buttonsEnableBack = true; $this->buttonsEnableNext = true; $this->onNext = 'select.folder.value = select.folderdisplay.value; select.submit();'; $this->footer(); }
function genAlbumList(&$list, $curAlbum = NULL, $rights = UPLOAD_RIGHTS) { global $_zp_gallery; if (is_null($curAlbum)) { $albums = array(); $albumsprime = $_zp_gallery->getAlbums(0); foreach ($albumsprime as $album) { // check for rights $albumobj = newAlbum($album); if ($albumobj->isMyItem($rights)) { $albums[] = $album; } } } else { $albums = $curAlbum->getAlbums(0); } if (is_array($albums)) { foreach ($albums as $folder) { $album = newAlbum($folder); if ($album->isDynamic()) { if ($rights == ALL_ALBUMS_RIGHTS) { $list[$album->getFileName()] = $album->getTitle(); } } else { $list[$album->getFileName()] = $album->getTitle(); genAlbumList($list, $album, $rights); /* generate for subalbums */ } } } }
<?php } } } if ($subtab != "albuminfo") { ?> <!-- page trailer --> <?php } /* * * MULTI-ALBUM ************************************************************************** */ } else { if (isset($_GET['massedit'])) { // one time generation of this list. $mcr_albumlist = array(); genAlbumList($mcr_albumlist); $albumdir = ""; if (isset($_GET['album'])) { $folder = sanitize_path($_GET['album']); $album = newAlbum($folder); if ($album->isMyItem(ALBUM_RIGHTS)) { $albums = $album->getAlbums(); $pieces = explode('/', $folder); $albumdir = "&album=" . pathurlencode($folder) . '&tab=subalbuminfo'; } else { $albums = array(); } } else { $albumsprime = $_zp_gallery->getAlbums(); $albums = array(); foreach ($albumsprime as $folder) {
/** * Prints all albums of the Zenphoto gallery as a partial drop down menu (<option></option> parts). * * @param string $current set to the album name selected (if any) * * @return string */ function printAlbumsSelector($current) { global $_zp_gallery; $albumlist = array(); genAlbumList($albumlist, NULL, ALL_ALBUMS_RIGHTS); ?> <select id="albumselector" name="albumselect"> <?php foreach ($albumlist as $key => $value) { $albumobj = newAlbum($key); $albumname = $albumobj->name; if ($albumname == $current) { $selected = ' selected="selected"'; } else { $selected = ''; } $level = substr_count($albumname, "/"); $arrow = ""; for ($count = 1; $count <= $level; $count++) { $arrow .= "» "; } echo "<option value = '" . html_encode($albumobj->name) . "'" . $selected . '>'; echo $arrow . $albumobj->getTitle() . unpublishedZenphotoItemCheck($albumobj) . "</option>"; } ?> </select> <?php }
$formAction = upload_head(); echo "\n</head>"; echo "\n<body>"; printLogoAndLinks(); ?> <div id="main"> <?php printTabs(); ?> <div id="content"> <?php if (!empty($zenphoto_tabs['upload']['subtabs'])) { printSubtabs(); } $albumlist = array(); genAlbumList($albumlist); // remove dynamic albums--can't upload to them foreach ($albumlist as $key => $albumname) { if (hasDynamicAlbumSuffix($key) && !is_dir(ALBUM_FOLDER_SERVERPATH . $key)) { unset($albumlist[$key]); } } ?> <script type="text/javascript"> // <!-- <![CDATA[ // Array of album names for javascript functions. var albumArray = new Array( <?php $separator = ''; foreach ($albumlist as $key => $value) { echo $separator . "'" . addslashes($key) . "'";