Example #1
0
 /**
  * Returns the page number in the gallery of this album
  *
  * @return int
  */
 function getGalleryPage()
 {
     global $_zp_gallery;
     if ($this->index == null) {
         $this->index = array_search($this->name, $_zp_gallery->getAlbums(0));
     }
     return floor($this->index / galleryAlbumsPerPage() + 1);
 }
/**
 * Checks for URL page out-of-bounds for "standard" themes
 * Note: This function assumes that an "index" page will display albums
 * and the pagination be determined by them. Any other "index" page strategy needs to be
 * handled by the theme itself.
 *
 * @param boolean $request
 * @param string $gallery_page
 * @param int $page
 * @return boolean will be true if all is well, false if a 404 error should occur
 */
function checkPageValidity($request, $gallery_page, $page)
{
    global $_zp_gallery, $_firstPageImages, $_oneImagePage, $_zp_zenpage, $_zp_current_category;
    $count = NULL;
    switch ($gallery_page) {
        case 'album.php':
        case 'search.php':
            $albums_per_page = max(1, getOption('albums_per_page'));
            $pageCount = (int) ceil(getNumAlbums() / $albums_per_page);
            $imageCount = getNumImages();
            if ($_oneImagePage) {
                if ($_oneImagePage === true) {
                    $imageCount = min(1, $imageCount);
                } else {
                    $imageCount = 0;
                }
            }
            $images_per_page = max(1, getOption('images_per_page'));
            $count = $pageCount + (int) ceil(($imageCount - $_firstPageImages) / $images_per_page);
            break;
        case 'index.php':
            if (galleryAlbumsPerPage() != 0) {
                $count = (int) ceil($_zp_gallery->getNumAlbums() / galleryAlbumsPerPage());
            }
            break;
        case 'news.php':
            if (in_context(ZP_ZENPAGE_NEWS_CATEGORY)) {
                $count = count($_zp_current_category->getArticles());
            } else {
                $count = count($_zp_zenpage->getArticles());
            }
            $count = (int) ceil($count / ZP_ARTICLES_PER_PAGE);
            break;
        default:
            $count = zp_apply_filter('checkPageValidity', NULL, $gallery_page, $page);
            break;
    }
    if ($page > $count) {
        $request = false;
        //	page is out of range
    }
    return $request;
}
 /**
  * Get Albums will create our $albums array with a fully populated set of Album
  * names in the correct order.
  *
  * Returns an array of albums (a pages worth if $page is not zero)
  *
  * @param int $page An option parameter that can be used to return a slice of the array.
  * @param string $sorttype the kind of sort desired
  * @param string $direction set to a direction to override the default option
  *
  * @return  array
  */
 function getAlbums($page = 0, $sorttype = null, $direction = null)
 {
     // Have the albums been loaded yet?
     if (is_null($this->albums) || $sorttype . $direction !== $this->lastalbumsort) {
         $albumnames = $this->loadAlbumNames();
         $key = $this->getGallerySortKey($sorttype);
         if (is_null($direction)) {
             if (getOption('gallery_sortdirection')) {
                 $key .= ' DESC';
             }
         } else {
             $key .= ' ' . $direction;
         }
         $albums = sortAlbumArray(NULL, $albumnames, $key);
         // Store the values
         $this->albums = $albums;
         $this->lastalbumsort = $sorttype . $direction;
     }
     if ($page == 0) {
         return $this->albums;
     } else {
         return array_slice($this->albums, galleryAlbumsPerPage() * ($page - 1), galleryAlbumsPerPage());
     }
 }
Example #4
0
 /**
  * Get Albums will create our $albums array with a fully populated set of Album
  * names in the correct order.
  *
  * Returns an array of albums (a pages worth if $page is not zero)
  *
  * @param int $page An option parameter that can be used to return a slice of the array.
  * @param string $sorttype the kind of sort desired
  * @param string $direction set to a direction to override the default option
  * @param bool $care set to false if the order of the albums does not matter
  * @param bool $mine set true/false to override ownership
  *
  * @return  array
  */
 function getAlbums($page = 0, $sorttype = null, $direction = null, $care = true, $mine = NULL)
 {
     // Have the albums been loaded yet?
     if ($mine || is_null($this->albums) || $care && $sorttype . $direction !== $this->lastalbumsort) {
         $albumnames = $this->loadAlbumNames();
         $key = $this->getAlbumSortKey($sorttype);
         $albums = $this->sortAlbumArray(NULL, $albumnames, $key, $direction, $mine);
         // Store the values
         $this->albums = $albums;
         $this->lastalbumsort = $sorttype . $direction;
     }
     if ($page == 0) {
         return $this->albums;
     } else {
         return array_slice($this->albums, galleryAlbumsPerPage() * ($page - 1), galleryAlbumsPerPage());
     }
 }
Example #5
0
 /**
  * Returns the page number in the gallery or the parent album of this album
  *
  * @return int
  */
 function getGalleryPage()
 {
     global $_zp_gallery;
     if ($this->index == null) {
         if (is_null($parent = $this->getParent())) {
             $albums = $_zp_gallery->getAlbums(0);
         } else {
             $albums = $parent->getAlbums(0);
         }
         $this->index = array_search($this->name, $albums);
     }
     return floor($this->index / galleryAlbumsPerPage() + 1);
 }
/**
 * Returns the number of pages for the current object
 *
 * @param bool $oneImagePage set to true if your theme collapses all image thumbs
 * or their equivalent to one page. This is typical with flash viewer themes
 *
 * @return int
 */
function getTotalPages($oneImagePage = false)
{
    global $_zp_gallery, $_zp_current_album, $_firstPageImages;
    if (in_context(ZP_ALBUM | ZP_SEARCH)) {
        $albums_per_page = max(1, getOption('albums_per_page'));
        if (in_context(ZP_SEARCH)) {
            $pageCount = ceil(getNumAlbums() / $albums_per_page);
        } else {
            $pageCount = ceil(getNumAlbums() / $albums_per_page);
        }
        $imageCount = getNumImages();
        if ($oneImagePage) {
            if ($oneImagePage === true) {
                $imageCount = min(1, $imageCount);
            } else {
                $imageCount = 0;
            }
        }
        $images_per_page = max(1, getOption('images_per_page'));
        $pageCount = $pageCount + ceil(($imageCount - $_firstPageImages) / $images_per_page);
        return $pageCount;
    } else {
        if (in_context(ZP_INDEX)) {
            if (galleryAlbumsPerPage() != 0) {
                return ceil($_zp_gallery->getNumAlbums() / galleryAlbumsPerPage());
            } else {
                return NULL;
            }
        } else {
            return null;
        }
    }
}