/**
  * Carries out the specified action
  */
 function perform()
 {
     // load the resource
     $this->_resourceDescription = Textfilter::filterAllHTML($this->_request->getValue("resourceDescription"));
     $this->_albumId = $this->_request->getValue("albumId");
     $this->_resourceId = $this->_request->getValue("resourceId");
     $resources = new GalleryResources();
     $resource = $resources->getResource($this->_resourceId, $this->_blogInfo->getId());
     // update the fields we'd like to update
     $resource->setAlbumId($this->_albumId);
     $resource->setDescription($this->_resourceDescription);
     // send the event
     $this->notifyEvent(EVENT_PRE_RESOURCE_UPDATE, array("resource" => &$resource));
     // and update it in the db
     $result = $resources->updateResource($resource);
     if (!$result) {
         $this->_view = new AdminResourcesListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_resource"));
     } else {
         // check which submit button was pressed
         if ($this->_request->getValue("regenerate") != "") {
             return Controller::setForwardAction("regeneratePreview");
         }
         $this->_view = new AdminResourcesListView($this->_blogInfo);
         $this->_view->setSuccessMessage($this->_locale->pr("resource_updated_ok", $resource->getFileName()));
         $this->notifyEvent(EVENT_POST_RESOURCE_UPDATE, array("resource" => &$resource));
         // clear the cache
         CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     }
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 function perform()
 {
     // get the search terms that have already been validated...
     $this->_searchTerms = $this->_request->getValue("searchTerms");
     // check if the search feature is disabled in this site...
     $config =& Config::getConfig();
     if (!$config->getValue("search_engine_enabled")) {
         $this->_view = new ErrorView($this->_blogInfo, "error_search_engine_disabled");
         $this->setCommonData();
         return false;
     }
     // create the view and make sure that it hasn't been cached
     $this->_view = new BlogTemplatedView($this->_blogInfo, VIEW_SEARCH_TEMPLATE, array("searchTerms" => $this->_searchTerms));
     if ($this->_view->isCached()) {
         return true;
     }
     $searchEngine = new SearchEngine();
     $searchResults = $searchEngine->search($this->_blogInfo->getId(), $this->_searchTerms);
     // MARKWU: I add the searchterms variable for smarty/plog template
     $searchTerms = $searchEngine->getAdaptSearchTerms($this->_searchTerms);
     // if no search results, return an error message
     if (count($searchResults) == 0) {
         $this->_view = new ErrorView($this->_blogInfo, "error_no_search_results");
         $this->setCommonData();
         return true;
     }
     // if only one search result, we can see it straight away
     if (count($searchResults) == 1) {
         // we have to refill the $_REQUEST array, since the next action
         // is going to need some of the parameters
         $request =& HttpVars::getRequest();
         $searchResult = array_pop($searchResults);
         $article = $searchResult->getArticle();
         $request["articleId"] = $article->getId();
         $request["blogId"] = $this->_blogInfo->getId();
         HttpVars::setRequest($request);
         // since there is only one article, we can use the ViewArticleAction action
         // to display that article, instead of copy-pasting the code and doing it here.
         // You just have to love MVC and OOP :)
         return Controller::setForwardAction("ViewArticle");
     }
     // or else, show a list with all the posts that match the requested
     // search terms
     $this->_view->setValue("searchresults", $searchResults);
     // MARKWU: Now, I can use the searchterms to get the keyword
     $this->_view->setValue("searchterms", $searchTerms);
     // MARKWU:
     $config =& Config::getConfig();
     $urlmode = $config->getValue("request_format_mode");
     $this->_view->setValue("urlmode", $urlmode);
     $this->setCommonData();
     return true;
 }
 /**
  * after executing the current action we will not show the results but 
  * transfer the execution flow to another action. In other words, the Controller
  * will detect that the processing is being passed to another Action class and
  * instead of calling Action::getView() right after Action::perform() it will
  * call the perform() method of the next action in the flow. It is only possible
  * to specify one action to forward to at a time, but this feature can be used
  * as many times as needed.
  *
  * @param actionKey The key of the action to which we're forwarding the process flow. This
  * is <b>not</b> the class name of the action but the <b>key</b> name to which the
  * action class has been assigned.
  * @return Always true
  */
 function setForwardAction($nextActionKey)
 {
     Controller::setForwardAction($nextActionKey, $this);
     return true;
 }
Example #4
0
 function perform()
 {
     // we can detect whether plog is already installed or not and direct users to the right
     // place
     if (WizardTools::isNewInstallation()) {
         $this->_view = new WizardView("intro");
     } else {
         Controller::setForwardAction("Update1");
         return false;
     }
     $this->setCommonData();
     return true;
 }