コード例 #1
0
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // load the resource
     $resourceId = $this->_request->getValue("resourceId");
     $resources = new GalleryResources();
     // initialize the view we're going to use
     $this->_view = new AdminResourcesListView($this->_blogInfo);
     // fetch the resource first, to get some info about it
     $resource = $resources->getResource($resourceId, $this->_blogInfo->getId());
     if (!$resource) {
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_resource"));
         $this->setCommonData();
         return false;
     }
     // if the resource was loaded ok...
     $this->notifyEvent(EVENT_PRE_RESOURCE_DELETE, array("resource" => &$resource));
     // remove it
     $res = $resources->deleteResource($resourceId, $this->_blogInfo->getId());
     if ($res) {
         $this->_view->setSuccessMessage($this->_locale->pr("resource_deleted_ok", $resource->getFileName()));
         $this->notifyEvent(EVENT_PRE_RESOURCE_DELETE, array("resource" => &$resource));
         // clear the cache if everything went fine
         CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     } else {
         $this->_view->setErrorMessage($this->_locale->pr("error_deleting_resource", $resource->getFileName()));
     }
     // return the view
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * deletes resources from the list
  */
 function _deleteResources()
 {
     // load the resource
     $resources = new GalleryResources();
     // loop through the array of resource ids and
     // remove them all
     foreach ($this->_resourceIds as $resourceId => $value) {
         // fetch the resource first, to get some info about it
         $resource = $resources->getResource($resourceId, $this->_blogInfo->getId());
         if (!$resource) {
             $this->_errorMessage .= $this->_locale->pr("error_deleting_resource2", $resourceId) . "<br/>";
         } else {
             $this->notifyEvent(EVENT_PRE_RESOURCE_DELETE, array("resource" => &$resource));
             // and now remove it
             $res = $resources->deleteResource($resourceId, $this->_blogInfo->getId());
             if ($res) {
                 $this->_totalOk++;
                 if ($this->_totalOk > 1) {
                     $this->_successMessage = $this->_locale->pr("items_deleted_ok", $this->_totalOk);
                 } else {
                     $this->_successMessage .= $this->_locale->pr("item_deleted_ok", $resource->getFileName());
                 }
                 $this->notifyEvent(EVENT_PRE_RESOURCE_DELETE, array("resource" => &$resource));
             } else {
                 $this->_errorMessage .= $this->_locale->pr("error_deleting_resource", $resource->getFileName()) . "<br/>";
             }
         }
     }
     return true;
 }