function perform() { $galleryResources = new GalleryResources(); $galleryAlbums = new GalleryAlbums(); $browseRootAlbum = $this->_albumId == 0 && $this->_albumName == ""; // check which template we should use if ($browseRootAlbum) { $template = VIEW_ALBUMS_TEMPLATE; } else { $template = VIEW_ALBUM_TEMPLATE; } // initialize the view and check if it was cached $this->_view = new BlogView($this->_blogInfo, $template, SMARTY_VIEW_CACHE_CHECK, array("albumId" => $this->_albumId, "albumName" => $this->_albumName)); if ($this->_view->isCached()) { // nothing to do if it is cached! return true; } // fetch the album we're trying to browse if ($browseRootAlbum) { // fetch only the first level albums $blogAlbums = $galleryAlbums->getChildAlbums(0, $this->_blogInfo->getId(), true); if (count($blogAlbums) == 0) { $this->_view = new ErrorView($this->_blogInfo); $this->_view->setValue("message", "error_no_albums_defined"); } else { $this->notifyEvent(EVENT_ALBUMS_LOADED, array("albums" => &$blogAlbums)); $this->_view->setValue("albums", $blogAlbums); } } else { // the third parameter is telling _not_ to fetch all those albums that have // been disabled and are not to be shown in the page when browsing the album if ($this->_albumName) { $album = $galleryAlbums->getAlbumByName($this->_albumName, $this->_blogInfo->getId(), true, true); } else { $album = $galleryAlbums->getAlbum($this->_albumId, $this->_blogInfo->getId(), true, true); } // check if the album was correctly fetched if (!$album) { $this->_view = new ErrorView($this->_blogInfo); $this->_view->setValue("message", "error_fetching_album"); $this->setCommonData(); return false; } $this->notifyEvent(EVENT_ALBUM_LOADED, array("album" => &$blogAlbum)); // put the album to the template $this->_view->setValue("album", $album); } // if all went fine, continue $this->setCommonData(); // and return everything normal return true; }
function render() { // get the page from the request $this->_page = $this->getCurrentPageFromRequest(); // and the current album $galleryAlbums = new GalleryAlbums(); $galleryResources = new GalleryResources(); if ($this->_albumId > ROOT_ALBUM_ID && $this->_page > 0) { $album = $galleryAlbums->getAlbum($this->_albumId, $this->_blogInfo->getId()); if (!$album || $album == "") { $this->_albumId = ROOT_ALBUM_ID; } else { //$resources = $album->getResources(); $resources = $galleryResources->getUserResources($this->_blogInfo->getId(), $this->_albumId, $this->_resourceType, $this->_page, DEFAULT_ITEMS_PER_PAGE); $numResources = $galleryResources->getNumUserResources($this->_blogInfo->getId(), $this->_albumId, $this->_resourceType); } } else { $albums = $galleryAlbums->getChildAlbums($this->_albumId, $this->_blogInfo->getId()); $resources = array(); } // get a list with the nested albums $userAlbums = $galleryAlbums->getNestedAlbumList($this->_blogInfo->getId()); // event about the albums we just loaded $this->notifyEvent(EVENT_ALBUMS_LOADED, array("albums" => &$userAlbums)); $this->setValue("albumsList", $userAlbums); // fetch some statistics and continue $quotaUsage = GalleryResourceQuotas::getBlogResourceQuotaUsage($this->_blogInfo->getId()); $totalResources = $galleryResources->getNumResources($this->_blogInfo->getId()); $currentQuota = GalleryResourceQuotas::getBlogResourceQuota($this->_blogInfo->getId()); $this->setValue("quotausage", $quotaUsage); $this->setValue("totalresources", $totalResources); $this->setValue("quota", $currentQuota); // and now export info about the albums and so on but only // if we're browsing the first page only (albums do not appear anymore after the first page) $this->setValue("album", $album); if ($this->_albumId > ROOT_ALBUM_ID && $this->_page < 2) { $this->setValue("albums", $album->getChildren()); } else { $this->setValue("albums", $albums); } // event about the resources $this->notifyEvent(EVENT_RESOURCES_LOADED, array("resources" => &$resources)); $this->setValue("resources", $resources); // finally, create and export the pager $pager = new Pager($this->_pagerUrl, $this->_page, $numResources, DEFAULT_ITEMS_PER_PAGE); $this->setValue("pager", $pager); parent::render(); }
function render() { // fetch the child albums of the current top level album $galleryAlbums = new GalleryAlbums(); $albums = $galleryAlbums->getChildAlbums($this->_albumId, $this->_blogInfo->getId()); // get some info about the parent album if it's different from the // top level album if ($this->_albumId > 0) { $album = $galleryAlbums->getAlbum($this->_albumId, $this->_blogInfo->getId()); } // fetch the albums for this blog $this->setValue("albums", $albums); $this->setValue("albumid", $this->_albumId); $this->setValue("album", $album); parent::render(); }