コード例 #1
0
/**
 * A printAlbumMenu() helper function for the list menu mode of printAlbumMenu() that only
 * generates an list item, as a link if not the current album
 * Not for standalone use.
 *
 * @param object $album the album oject
 * @param string $option2 the value of $option of the printAlbumMenu()
 * @param string $css One of the both css_active values of the printAlbumMenu()
 * @param string $albumpath the albumpath for mod_rewrite or not
 * @param string $mode "list" for list mode link, "jump" for jump mode link
 * @param int	$level level number for jump mode (0 toplevel, 1-4 sublevel)
 * @return string
 */
function createAlbumMenuLink($album, $option2, $css, $albumpath, $mode, $level = '')
{
    if ($option2 === "count" and $album->getNumImages() > 0) {
        $count = " (" . $album->getNumImages() . ")";
    } else {
        $count = "";
    }
    switch ($mode) {
        case "list":
            if (getAlbumID() == $album->getAlbumID()) {
                $link = "<li" . $css . ">" . $album->getTitle() . $count;
            } else {
                $link = "<li><a href='" . htmlspecialchars($albumpath . pathurlencode($album->name)) . "' title='" . html_encode($album->getTitle()) . "'>" . html_encode($album->getTitle()) . "</a>" . $count;
            }
            break;
        case "jump":
            $arrow = "&raquo; ";
            switch ($level) {
                case 0:
                    $arrow = "";
                    break;
                case 1:
                    $arrow = $arrow;
                    break;
                case 2:
                    $arrow = $arrow . $arrow;
                    break;
                case 3:
                    $arrow = $arrow . $arrow . $arrow;
                    break;
                case 4:
                    $arrow = $arrow . $arrow . $arrow . $arrow;
                    break;
            }
            $selected = checkSelectedAlbum($album->name, "album");
            $link = "<option {$selected} value='" . htmlspecialchars($albumpath . pathurlencode($album->name)) . "'>" . $arrow . strip_tags($album->getTitle()) . $count . "</option>";
            break;
    }
    echo $link;
}
コード例 #2
0
/**
* Prints a dropdown menu of all albums(not context sensitive)
* Is used by the wrapper function printAlbumMenu() if the options "jump" is choosen. For standalone use, too.
*
* Usage: add the following to the php page where you wish to use these menus:
* enable this extension on the zenphoto admin plugins tab;
* Call the function printAlbumMenuJump() at the point where you want the menu to appear.
*
* @param string $option "count" for a image counter in brackets behind the album name, "" = for no image numbers
* @param string $indexname insert the name (default "Gallery Index") how you want to call the link to the gallery index, insert "" if you don't use it, it is not printed then.
* @param bool $firstimagelink If set to TRUE and if the album has images the link will point to page of the first image instead the album thumbnail page
* @param string $css_class see printAlbumMenuList
* @param bool $skipform If set to false this prints a full form option select list (default), if set to true it will only print the options
*/
function printAlbumMenuJump($option = "count", $indexname = "Gallery Index", $firstimagelink = false, $showsubs = NULL, $skipform = false)
{
    global $_zp_gallery, $_zp_current_album, $_zp_gallery_page;
    if (!is_null($_zp_current_album) || $_zp_gallery_page == 'album.php') {
        $currentfolder = $_zp_current_album->name;
    }
    if (is_null($showsubs)) {
        $showsubs = ALBUM_MENU_SHOWSUBS;
    }
    if ($showsubs && !is_numeric($showsubs)) {
        $showsubs = 9999999999.0;
    }
    if (!$skipform) {
        ?>
	<script type="text/javaScript">
		// <!-- <![CDATA[
		function gotoLink(form) {
		var OptionIndex=form.ListBoxURL.selectedIndex;
		parent.location = form.ListBoxURL.options[OptionIndex].value;
		}
		// ]]> -->
	</script>
	<form name="AutoListBox" action="#">
		<p>
			<select name="ListBoxURL" size="1" onchange="gotoLink(this.form);">
				<?php 
        if (!empty($indexname)) {
            $selected = checkSelectedAlbum("", "index");
            ?>
					<option <?php 
            echo $selected;
            ?>
 value="<?php 
            echo html_encode(getGalleryIndexURL());
            ?>
"><?php 
            echo $indexname;
            ?>
</option>
					<?php 
        }
    }
    $albums = getNestedAlbumList(null, $showsubs, false);
    foreach ($albums as $album) {
        $albumobj = newAlbum($album['name'], true);
        $count = '';
        if ($option == "count") {
            $numimages = $albumobj->getNumImages();
            if ($numimages != 0) {
                $count = " (" . $numimages . ")";
            }
        }
        $sortorder = count($album['sort_order']);
        $arrow = '';
        if ($sortorder > 1) {
            for ($c = 1; $c != $sortorder; $c++) {
                $arrow .= '» ';
            }
        }
        $selected = checkSelectedAlbum($albumobj->name, "album");
        if ($firstimagelink && $numimages != 0) {
            $link = "<option {$selected} value='" . html_encode($albumobj->getImage(0)->getLink()) . "'>" . $arrow . getBare($albumobj->getTitle()) . $count . "</option>";
        } else {
            $link = "<option {$selected} value='" . html_encode($albumobj->getLink(1)) . "'>" . $arrow . getBare($albumobj->getTitle()) . $count . "</option>";
        }
        echo $link;
    }
    if (!$skipform) {
        ?>
			</select>
		</p>
	</form>
	<?php 
    }
}
コード例 #3
0
/**
 * Handles a single album level for printAlbumMenuJump
 *
 * @param array $albums list of album names
 * @param string $showcount see printAlbumMenuJump
 * @param string $albumpath path of the page album
 * @param bool $firstimagelink If set to TRUE and if the album has images the link will point to page of the first image instead the album thumbnail page
 * @param int $level current level
 */
function printAlbumMenuJumpAlbum($albums, $option, $albumpath, $firstimagelink, $level = 1)
{
    global $_zp_gallery;
    foreach ($albums as $album) {
        $subalbum = new Album($_zp_gallery, $album, true);
        if ($option === "count" and $subalbum->getNumImages() > 0) {
            $count = " (" . $subalbum->getNumImages() . ")";
        } else {
            $count = "";
        }
        $arrow = str_replace(':', '&raquo; ', str_pad("", $level - 1, ":"));
        $selected = checkSelectedAlbum($subalbum->name, "album");
        if ($firstimagelink && $subalbum->getNumImages() != 0) {
            $imgurl = getFirstImageOfAlbum($subalbum);
            $link = "<option {$selected} value='" . $imgurl . "'>" . $arrow . strip_tags($subalbum->getTitle()) . $count . "</option>";
        } else {
            $link = "<option {$selected} value='" . html_encode($albumpath . pathurlencode($subalbum->name)) . "'>" . $arrow . strip_tags($subalbum->getTitle()) . $count . "</option>";
        }
        echo $link;
        $subalbums = $subalbum->getAlbums();
        if (!empty($subalbums)) {
            printAlbumMenuJumpAlbum($subalbums, $option, $albumpath, $firstimagelink, $level + 1);
        }
    }
}