/**
 * 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();
        genAlbumUploadList($albumlist);
        $rootrights = accessAllAlbums(UPLOAD_RIGHTS);
        $uploadtype = zp_getcookie('uploadtype');
        $limitalbums = getUploadLimitedAlbums($albumlist);
        $imagenumber = getUploadImagesInAlbum($albumlist);
        if ($uploadtype == "httpupload") {
            $js .= "\$(document).ready(function() {\n\t\t\t\t\t\t\t\t\t\t\$('#albumselect').hide();\n\t\t\t\t\t\t\t});";
        } else {
            $js .= "\$(document).ready(function() {\n\t\t\t\t\t\t\t\t\t\t\$('#uploadswitch').hide();\n\t\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}";
        /*
        if($uploadtype == "httpupload") {
        	$js .= "$('#albumselect').hide();";
        }
        */
        $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;
}
echo "\n</head>";
echo "\n<body>";
printLogoAndLinks();
echo "\n" . '<div id="main">';
printTabs('edit');
echo "\n" . '<div id="content">';
echo "<h1>" . gettext("zenphoto Create Dynamic Album") . "</h1>\n";
if (isset($_POST['savealbum'])) {
    // we fell through, some kind of error
    echo "<div class=\"errorbox space\">";
    echo "<h2>" . gettext("Failed to save the album file") . "</h2>";
    echo "</div>\n";
}
$gallery = new Gallery();
$albumlist = array();
genAlbumUploadList($albumlist);
$params = trim(zp_getCookie('zenphoto_image_search_params'));
$search->setSearchParams($params);
$fields = $search->fields;
$words = trim($search->words);
$images = $search->getImages(0);
foreach ($images as $image) {
    $folder = $image['folder'];
    $filename = $image['filename'];
    $imagelist[] = '/' . $folder . '/' . $filename;
}
$subalbums = $search->getAlbums(0);
foreach ($subalbums as $folder) {
    getSubalbumImages($folder);
}
$albumname = trim($words);
/**
 * Prints all albums of the Zenphoto gallery as a partial drop down menu (<option></option> parts).
 *
 * @return string
 */
function printAlbumsSelector()
{
    global $_zp_gallery;
    $albumlist;
    genAlbumUploadList($albumlist);
    ?>
	<select id="albumselector" name="albumselect">
	<?php 
    foreach ($albumlist as $key => $value) {
        $albumobj = new Album($_zp_gallery, $key);
        $albumname = $albumobj->name;
        $level = substr_count($albumname, "/");
        $arrow = "";
        for ($count = 1; $count <= $level; $count++) {
            $arrow .= "&raquo; ";
        }
        echo "<option value='" . html_encode($albumobj->name) . "'>";
        echo $arrow . $albumobj->getTitle() . unpublishedZenphotoItemCheck($albumobj) . "</option>";
    }
    ?>
	</select>
	<?php 
}
Ejemplo n.º 4
0
<?php 
            }
        }
    }
    if ($subtab != "albuminfo") {
        ?>
<!-- page trailer -->

<?php 
    }
    /*** MULTI-ALBUM ***************************************************************************/
} else {
    if (isset($_GET['massedit'])) {
        // one time generation of this list.
        $mcr_albumlist = array();
        genAlbumUploadList($mcr_albumlist);
        if (isset($_GET['saved'])) {
            if (isset($_GET['mismatch'])) {
                echo "\n<div class=\"errorbox fade-message\">";
                echo "\n<h2>" . gettext("Your passwords did not match") . "</h2>";
                echo "\n</div>";
            } else {
                echo "\n<div class=\"messagebox fade-message\">";
                echo "\n<h2>" . gettext("Changes applied") . "</h2>";
                echo "\n</div>";
            }
        }
        $albumdir = "";
        if (isset($_GET['album'])) {
            $folder = sanitize_path($_GET['album']);
            $album = new Album($gallery, $folder);
Ejemplo n.º 5
0
function genAlbumUploadList(&$list, $curAlbum = NULL)
{
    $gallery = new Gallery();
    $albums = array();
    if (is_null($curAlbum)) {
        $albumsprime = $gallery->getAlbums(0);
        foreach ($albumsprime as $album) {
            // check for rights
            $albumobj = new Album($gallery, $album);
            if ($albumobj->isMyItem(UPLOAD_RIGHTS)) {
                $albums[] = $album;
            }
        }
    } else {
        $albums = $curAlbum->getAlbums(0);
    }
    if (is_array($albums)) {
        foreach ($albums as $folder) {
            $album = new Album($gallery, $folder);
            if (!$album->isDynamic()) {
                $list[$album->getFolder()] = $album->getTitle();
                genAlbumUploadList($list, $album);
                /* generate for subalbums */
            }
        }
    }
}