コード例 #1
0
 function perform()
 {
     $galleryResources = new GalleryResources();
     $galleryAlbums = new GalleryAlbums();
     // initialize the view
     $this->_view = new BlogView($this->_blogInfo, VIEW_RESOURCE_TEMPLATE, SMARTY_VIEW_CACHE_CHECK, array("resourceId" => $this->_resourceId, "resourceName" => $this->_resourceName, "albumName" => $this->_albumName, "albumId" => $this->_albumId));
     // if it's cached, do nothing
     if ($this->_view->isCached()) {
         return true;
     }
     // otherwise continue as normal...
     // try to find the album to which this resource belongs
     if ($this->_albumName) {
         $album = $galleryAlbums->getAlbumByName($this->_albumName, $this->_blogInfo->getId(), false, false);
         if (!$album) {
             $this->_view = new ErrorView($this->_blogInfo);
             $this->_view->setValue("message", "error_fetching_resource");
             $this->setCommonData();
             return false;
         }
         $this->_albumId = $album->getId();
     }
     // fetch the album we're trying to browse
     if ($this->_resourceName != "") {
         $resource = $galleryResources->getResourceFile($this->_blogInfo->getId(), $this->_resourceName, $this->_albumId);
     } else {
         $resource = $galleryResources->getResource($this->_resourceId, $this->_blogInfo->getId(), $this->_albumId);
     }
     // check if the album was correctly fetched
     if (!$resource) {
         $this->_view = new ErrorView($this->_blogInfo);
         $this->_view->setValue("message", "error_fetching_resource");
         $this->setCommonData();
         return false;
     }
     // if all went fine, continue loading the next and previous resources so that
     // navigation can be made easier...
     $nextResource = $galleryResources->getNextResource($resource);
     $prevResource = $galleryResources->getPreviousResource($resource);
     // generate events for all the resources we just loaded
     $this->notifyEvent(EVENT_RESOURCE_LOADED, array("resource" => &$resource));
     if ($nextResource) {
         $this->notifyEvent(EVENT_RESOURCE_LOADED, array("resource" => &$nextResource));
     }
     if ($prevResource) {
         $this->notifyEvent(EVENT_RESOURCE_LOADED, array("resource" => &$prevResource));
     }
     $this->_view->setValue("resource", $resource);
     $this->_view->setValue("prevresource", $prevResource);
     $this->_view->setValue("nextresource", $nextResource);
     $this->setCommonData();
     // and return everything normal
     return true;
 }
コード例 #2
0
 function perform()
 {
     // initialize the plugin manager, needed to inform plugins of the EVENT_RESOURCE_LOADED
     // event, in case any of them is waiting for it! This obviously slows things down but
     // hey, what can I do? Users ask and I deliver...
     $this->_pm =& PluginManager::getPluginManager();
     $this->_pm->setBlogInfo($this->_blogInfo);
     $this->_userInfo = $this->_blogInfo->getOwnerInfo();
     $this->_pm->setUserInfo($this->_userInfo);
     // and fetch the resource
     $resources = new GalleryResources();
     if ($this->_resName) {
         $resource = $resources->getResourceFile($this->_blogInfo->getId(), $this->_resName);
     } else {
         $resource = $resources->getResource($this->_resId, $this->_blogInfo->getId());
     }
     if (!$resource) {
         // return 404 not found because the resource wasn't found
         $this->_view = new ResourceServerView();
         $this->_view->addHeaderResponse("HTTP/1.1 404 Not Found");
         $this->_view->addHeaderResponse("Status: 404 Not Found");
         $this->_view->addHeaderResponse("X-pLog-Error: Resource {$this->_resId} not found");
         return false;
     }
     // we need to let plugins know that we have successfully loaded a resource
     $this->notifyEvent(EVENT_RESOURCE_LOADED, array("resource" => &$resource));
     // generate the correct view with the resource data...
     $this->_view = new ResourceServerView($resource, $this->_mode);
     return true;
 }