function printNewsHTML($num)
 {
     if (!$_REQUEST['words']) {
         return;
     }
     global $_zp_current_zenpage_news, $_zp_current_search;
     if (!defined('CROP_NEWS')) {
         define('CROP_NEWS', TRUE);
     }
     save_context();
     add_context(ZP_ZENPAGE_NEWS_ARTICLE);
     $u = 0;
     processExpired('zenpage_news');
     $articles = $_zp_current_search->getSearchNews();
     if (count($articles) == 0) {
         return;
     }
     $articles = $this->sortArticles($articles, 'id');
     echo "<div id='snr'>";
     echo "<div>Also found " . count($articles) . " news";
     if (count($articles) > 3) {
         echo " - showing the last 3</div>";
     } else {
         echo "</div>";
     }
     echo "</div>";
     $len = count($articles);
     for ($u = $len - 1; $u >= 0 && $u > $len - 4; $u--) {
         $news = $articles[$u];
         $_zp_current_zenpage_news = new ZenpageNews($news['titlelink']);
         Utils::render("tiles/news/template.php");
     }
     restore_context();
 }
/**
 * Returns pages from the current page object/search/or parent pages based on context
 * Updates $_zp_zenpage_curent_page and returns true if there is another page to be delivered
 * @return boolean
 */
function next_page()
{
    global $_zp_zenpage, $_zp_next_pagelist, $_zp_current_search, $_zp_current_zenpage_page, $_zp_current_page_restore;
    if (func_num_args() != 0) {
        //	These parameters are deprecated
        Zenpage_internal_deprecations::next_page();
    }
    if (is_null($_zp_next_pagelist)) {
        if (in_context(ZP_SEARCH)) {
            $_zp_next_pagelist = $_zp_current_search->getPages(NULL, false, NULL, NULL, NULL);
        } else {
            if (in_context(ZP_ZENPAGE_PAGE)) {
                if (!is_null($_zp_current_zenpage_page)) {
                    $_zp_next_pagelist = $_zp_current_zenpage_page->getPages(NULL, false, NULL, NULL, NULL);
                }
            } else {
                $_zp_next_pagelist = $_zp_zenpage->getPages(NULL, true, NULL, NULL, NULL);
            }
        }
        save_context();
        add_context(ZP_ZENPAGE_PAGE);
        $_zp_current_page_restore = $_zp_current_zenpage_page;
    }
    while (!empty($_zp_next_pagelist)) {
        $page = new ZenpagePage(array_shift($_zp_next_pagelist));
        if (zp_loggedin() && $page->isMyItem(LIST_RIGHTS) || $page->checkForGuest()) {
            $_zp_current_zenpage_page = $page;
            return true;
        }
    }
    $_zp_next_pagelist = NULL;
    $_zp_current_zenpage_page = $_zp_current_page_restore;
    restore_context();
    return false;
}
/**
 * Returns the next image on a page.
 * sets $_zp_current_image to the next image in the album.
 * Returns true if there is an image to be shown
 *
 * @param bool $all set to true disable pagination
 * @param int $firstPageCount the number of images which can go on the page that transitions between albums and images
 * 							Normally this parameter should be NULL so as to use the default computations.
 * @param bool $mine overridePassword the password check
 * @return bool
 *
 * @return bool
 */
function next_image($all = false, $firstPageCount = NULL, $mine = NULL)
{
    global $_zp_images, $_zp_current_image, $_zp_current_album, $_zp_page, $_zp_current_image_restore, $_zp_current_search, $_zp_gallery, $_firstPageImages;
    if ($mine != NULL && gettype($mine) != 'boolean' || func_num_args() > 3) {
        internal_deprecations::next_image();
    }
    if (is_null($firstPageCount)) {
        $firstPageCount = $_firstPageImages;
    }
    $imagePageOffset = getTotalPages(2);
    /* gives us the count of pages for album thumbs */
    if ($all) {
        $imagePage = 1;
        $firstPageCount = 0;
    } else {
        $_firstPageImages = $firstPageCount;
        /* save this so pagination can see it */
        $imagePage = $_zp_page - $imagePageOffset;
    }
    if ($firstPageCount > 0 && $imagePageOffset > 0) {
        $imagePage = $imagePage + 1;
        /* can share with last album page */
    }
    if ($imagePage <= 0) {
        return false;
        /* we are on an album page */
    }
    if (is_null($_zp_images)) {
        if (in_context(ZP_SEARCH)) {
            $_zp_images = $_zp_current_search->getImages($all ? 0 : $imagePage, $firstPageCount, NULL, NULL, true, $mine);
        } else {
            $_zp_images = $_zp_current_album->getImages($all ? 0 : $imagePage, $firstPageCount, NULL, NULL, true, $mine);
        }
        if (empty($_zp_images)) {
            return NULL;
        }
        $_zp_current_image_restore = $_zp_current_image;
        $img = array_shift($_zp_images);
        $_zp_current_image = newImage($_zp_current_album, $img, true, true);
        save_context();
        add_context(ZP_IMAGE);
        return true;
    } else {
        if (empty($_zp_images)) {
            $_zp_images = NULL;
            $_zp_current_image = $_zp_current_image_restore;
            restore_context();
            return false;
        } else {
            $img = array_shift($_zp_images);
            $_zp_current_image = newImage($_zp_current_album, $img, true, true);
            return true;
        }
    }
}
示例#4
0
            $minigalstat = true;
            break;
        case "latest-mtime":
            echo gettext('Latest Images');
            $minigalstat = true;
            break;
        case "mostrated":
            echo gettext('Most Rated Images');
            $minigalstat = true;
            break;
        case "toprated":
            echo gettext('Top Rated Images');
            $minigalstat = true;
            break;
        case "specific":
            save_context();
            $album = new Album($_zp_gallery, $zpgal_minigalspecified);
            makeAlbumCurrent($album);
            echo getAlbumTitle();
            break;
    }
    ?>
			</div>
			<div id="homegal-wrap">
				<div class="container" id="home-right">
					<div class="content">
						<div class="slideshow-container">
							<div id="loading" class="loader"></div>
							<div id="slideshow" class="slideshow"></div>
						</div>
						<div id="caption" class="caption-container">
示例#5
0
/**
 * Prints an image or album statistic slideshow using the {@link http://galleria.io/  jQuery plugin Galleria}
 *
 * See readme/documentation for usage:
 * Call directly in a template file or codeblock.
 *
 * NOTE: movie and audio files not supported.
 *
 * @param string $type return statistics of either 'images' or 'albums'
 * @param integer $number the number of items to get (images or albums, depending on $type set)
 * @param string $option
 *  	"popular" for the most popular
 *		"latest" for the latest uploaded by id (Discovery)
 * 		"latest-date" for the latest by date
 * 		"latest-mtime" for the latest by mtime
 *   	"latest-publishdate" for the latest by publishdate
 *      "mostrated" for the most voted
 *		"toprated" for the best voted
 *		"latestupdated" for the latest updated
 *		"random" for random order (yes, strictly no statistical order...)
 * @param string $albumfolder foldername of a specific album to pull items from
 * @param bool $collection only if $albumfolder is set: true if you want to get statistics from this album and all of its subalbums
 * @param bool $linkslides true to link to image or album on slide, else click advances slideshow instead
 * @param mixed $autoplay true to autoplay slideshow with interval set in options, false to start with slideshow stopped.  Set integer in milliseconds to autoplay at that interval (Ex. 4000), overriding plugin option set.
 * @param integer $threshold the minimum number of ratings an image must have to be included in the list. (Default 0)
 *
 */
function printGslideshowStatistic($type, $number, $option, $albumfolder = '', $collection = false, $linkslides = true, $autoplay = true, $threshold = 0)
{
    save_context();
    $data = 'data';
    $embedded = true;
    $forceheight = true;
    $imagenumber = 0;
    $albumtitle = '';
    $returnpath = '';
    require_once SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/image_album_statistics.php';
    if ($type == 'album' || $type == 'albums') {
        $albums = getAlbumStatistic($number, $option, $albumfolder);
    } else {
        $images = getImageStatistic($number, $option, $albumfolder, $collection, $threshold);
    }
    ?>

			<script>
				var data = [

	<?php 
    if ($type == 'album' || $type == 'albums') {
        $c = 1;
        foreach ($albums as $album) {
            $tempalbum = newAlbum($album['folder']);
            $albumpath = html_encode(rewrite_path("/" . pathurlencode($tempalbum->name), "index.php?album=" . pathurlencode($tempalbum->name)));
            $albumthumb = $tempalbum->getAlbumThumbImage();
            $image = newImage($tempalbum, $albumthumb->filename);
            $ext = isImagePhoto($image);
            if ($ext) {
                makeImageCurrent($image);
                echo '{' . "\n";
                echo 'thumb: \'' . getCustomSizedImageMaxSpace(getOption('gslideshow_thumbsize'), getOption('gslideshow_thumbsize')) . '\',' . "\n";
                echo 'image: \'' . getCustomSizedImageMaxSpace(getOption('gslideshow_mediumsize'), getOption('gslideshow_mediumsize')) . '\',' . "\n";
                echo 'big: \'' . getCustomSizedImageMaxSpace(getOption('gslideshow_bigsize'), getOption('gslideshow_bigsize')) . '\',' . "\n";
                echo 'title: \'' . html_encode($tempalbum->getTitle()) . '\',' . "\n";
                $desc = $tempalbum->getDesc();
                $desc = str_replace("\r\n", '<br />', $desc);
                $desc = str_replace("\r", '<br />', $desc);
                echo 'description: \'' . js_encode($desc) . '\',' . "\n";
                echo 'link: \'' . $albumpath . '\'' . "\n";
                if ($c == $number) {
                    echo '}' . "\n";
                } else {
                    echo '},' . "\n";
                }
            }
            $c++;
        }
        echo "\n";
    } else {
        $c = 1;
        foreach ($images as $image) {
            $ext = isImagePhoto($image);
            if ($ext) {
                makeImageCurrent($image);
                echo '{' . "\n";
                echo 'thumb: \'' . getCustomSizedImageMaxSpace(getOption('gslideshow_thumbsize'), getOption('gslideshow_thumbsize')) . '\',' . "\n";
                echo 'image: \'' . getCustomSizedImageMaxSpace(getOption('gslideshow_mediumsize'), getOption('gslideshow_mediumsize')) . '\',' . "\n";
                echo 'big: \'' . getCustomSizedImageMaxSpace(getOption('gslideshow_bigsize'), getOption('gslideshow_bigsize')) . '\',' . "\n";
                echo 'title: \'' . html_encode($image->getTitle()) . '\',' . "\n";
                $desc = $image->getDesc();
                $desc = str_replace("\r\n", '<br />', $desc);
                $desc = str_replace("\r", '<br />', $desc);
                echo 'description: \'' . js_encode($desc) . '\',' . "\n";
                echo 'link: \'' . html_encode($image->getLink()) . '\'' . "\n";
                if ($c == $number) {
                    echo '}' . "\n";
                } else {
                    echo '},' . "\n";
                }
            }
            $c++;
        }
        echo "\n";
    }
    ?>
				];
			</script>
			<?php 
    printGalleriaRun($data, $linkslides, $autoplay, $embedded, $forceheight, $imagenumber, $albumtitle, $returnpath);
    restore_context();
    // needed if the slideshow is for example called directly via album object before the next_album loop on index.php
}
/**
 * Returns pages from the current page object/search/or parent pages based on context
 * Updates $_zp_CMS_curent_page and returns true if there is another page to be delivered
 * @return boolean
 */
function next_page()
{
    global $_zp_CMS, $_zp_next_pagelist, $_zp_current_search, $_zp_current_page, $_zp_current_page_restore;
    if ($_zp_CMS->pages_enabled && is_null($_zp_next_pagelist)) {
        if (in_context(ZP_SEARCH)) {
            $_zp_next_pagelist = $_zp_current_search->getPages(NULL, false, NULL, NULL, NULL);
        } else {
            if (in_context(ZP_ZENPAGE_PAGE)) {
                if (!is_null($_zp_current_page)) {
                    $_zp_next_pagelist = $_zp_current_page->getPages(NULL, false, NULL, NULL, NULL);
                }
            } else {
                $_zp_next_pagelist = $_zp_CMS->getPages(NULL, true, NULL, NULL, NULL);
            }
        }
        save_context();
        add_context(ZP_ZENPAGE_PAGE);
        $_zp_current_page_restore = $_zp_current_page;
    }
    while (!empty($_zp_next_pagelist)) {
        $page = newPage(array_shift($_zp_next_pagelist));
        if (zp_loggedin() && $page->isMyItem(LIST_RIGHTS) || $page->checkForGuest()) {
            $_zp_current_page = $page;
            return zp_apply_filter('next_object_loop', true, $_zp_current_page);
        }
    }
    $_zp_next_pagelist = NULL;
    $_zp_current_page = $_zp_current_page_restore;
    restore_context();
    return zp_apply_filter('next_object_loop', false, $_zp_current_page);
}
/**
 * Sets the image passed as the current image
 *
 * @param object $image the image to become current
 */
function makeImageCurrent($image)
{
    if (!is_object($image)) {
        return;
    }
    global $_zp_current_album, $_zp_current_image;
    $_zp_current_image = $image;
    $_zp_current_album = $_zp_current_image->getAlbum();
    save_context();
    set_context(ZP_INDEX | ZP_ALBUM | ZP_IMAGE);
}
/**
 * Returns the next image on a page.
 * sets $_zp_current_image to the next image in the album.
 * Returns true if there is an image to be shown
 *
 * @param bool $all set to true disable pagination
 * @param int $firstPageCount the number of images which can go on the page that transitions between albums and images
 * @param string $sorttype overrides the default sort type
 * @param string $sortdirection overrides the default sort direction.
 * @param bool $overridePassword the password check
 * @return bool
 *
 * @return bool
 */
function next_image($all = false, $firstPageCount = 0, $sorttype = null, $sortdirection = NULL, $overridePassword = false)
{
    global $_zp_images, $_zp_current_image, $_zp_current_album, $_zp_page, $_zp_current_image_restore, $_zp_conf_vars, $_zp_current_search, $_zp_gallery;
    if (!$overridePassword) {
        if (checkforPassword()) {
            return false;
        }
    }
    $imagePageOffset = getTotalPages(true) - 1;
    /* gives us the count of pages for album thumbs */
    if ($all) {
        $imagePage = 1;
    } else {
        $_zp_conf_vars['images_first_page'] = $firstPageCount;
        /* save this so pagination can see it */
        $imagePage = $_zp_page - $imagePageOffset;
    }
    if ($firstPageCount > 0 && $imagePageOffset > 0) {
        $imagePage = $imagePage + 1;
        /* can share with last album page */
    }
    if ($imagePage <= 0) {
        return false;
        /* we are on an album page */
    }
    if (is_null($_zp_images)) {
        if (in_context(ZP_SEARCH)) {
            $searchtype = true;
            $_zp_images = $_zp_current_search->getImages($all ? 0 : $imagePage, $firstPageCount);
        } else {
            if ($_zp_current_album->isDynamic()) {
                $searchtype = true;
                $search = $_zp_current_album->getSearchEngine();
                $_zp_images = $search->getImages($all ? 0 : $imagePage, $firstPageCount);
            } else {
                $_zp_images = $_zp_current_album->getImages($all ? 0 : $imagePage, $firstPageCount, $sorttype, $sortdirection);
            }
        }
        if (empty($_zp_images)) {
            return false;
        }
        $_zp_current_image_restore = $_zp_current_image;
        $img = array_shift($_zp_images);
        if (is_array($img)) {
            $_zp_current_image = newImage(new Album($_zp_gallery, $img['folder']), $img['filename']);
        } else {
            $_zp_current_image = newImage($_zp_current_album, $img);
        }
        save_context();
        add_context(ZP_IMAGE);
        return true;
    } else {
        if (empty($_zp_images)) {
            $_zp_images = NULL;
            $_zp_current_image = $_zp_current_image_restore;
            restore_context();
            return false;
        } else {
            $img = array_shift($_zp_images);
            if (is_array($img)) {
                $_zp_current_image = newImage(new Album($_zp_gallery, $img['folder']), $img['filename']);
            } else {
                $_zp_current_image = newImage($_zp_current_album, $img);
            }
            return true;
        }
    }
}
 function getGalleryPageAlbums()
 {
     global $_zp_gallery, $_zp_page, $_zp_themeroot;
     $res = "<div id='albums'>";
     save_context();
     set_context(ZP_INDEX);
     $_zp_page = $contextPage;
     $u = 0;
     $folders = $_zp_gallery->getAlbums($this->galleryPage ? $this->galleryPage : 1);
     $_zp_page = NULL;
     $arr = array();
     $top = $this->getAncestorAlbum();
     foreach ($folders as $folder) {
         $cls = '';
         //Workaround the (breaking) weird thumb url if album is empty. Note that we really should check recursively
         $alb = new Album($_zp_gallery, $folder);
         $subalbs = method_exists($alb, 'getSubalbums') ? $alb->getSubalbums() : $alb->getAlbums();
         if (count($subalbs) == 0 && $alb->getNumImages() == 0) {
             $customThumb = "{$_zp_themeroot}/resources/images/opa/bg-b-20.png";
         } else {
             $thumb = $alb->getAlbumThumbImage();
             $customThumb = $thumb->getCustomImage(NULL, 90, 90, 90, 90, NULL, NULL, false);
         }
         if (isset($top) && method_exists($top, 'getFolder') && $folder == $top->getFilename()) {
             $cls = ' over';
         }
         $res .= "<span class='album{$cls}'> " . "<a href='" . $alb->getAlbumLink() . "'>" . "<img width='90' height='90' src='{$customThumb}' " . "\t   album='" . $alb->name . "' /> " . "</a>" . "<div class='caption'>" . $alb->getTitle() . "</div>" . "</span>";
         $u++;
     }
     while ($u < 3) {
         $res .= "<span class='subalbum subalbum-{$u}'> " . "<img width='90' height='90' class='empty' src='{$_zp_themeroot}/resources/images/opa/bg-b-20.png' /> " . "</span>";
         $u++;
     }
     restore_context($context);
     $_zp_page = $pageParam;
     $res .= "</div>";
     return $res;
 }