Exemplo n.º 1
0
 public function render()
 {
     $result = false;
     if (method_exists($this, "_beforeRender")) {
         $result = $this->_beforeRender();
         if ($result == -1) {
             // We are not authenticated to use this action
             ErrorHandler::displayForbiddenError();
             return false;
         }
         if ($result === 0) {
             // Some error has ocurred
             ErrorHandler::displayNotFoundError();
             return false;
         }
         if ($result === 1) {
             // Ok, dispatch the action
             try {
                 require_once $this->_controllerFile;
                 $controllerObj = new $this->_controllerName();
                 if (method_exists($controllerObj, $this->_action)) {
                     $action = $this->_action;
                     $controllerObj->{$action}();
                 } else {
                     ErrorHandler::displayNotFoundError();
                     trigger_error("Dispatcher | Error: Action {$action} does not exists in controller {$this->_controllerName}", E_USER_WARNING);
                 }
             } catch (Exception $ex) {
                 trigger_error("Dispatcher | An unexpected exception has been produced while trying to dispatch {$action} in controller {$this->_controllerName}: {$ex->getMessage()} ", E_USER_WARNING);
             }
         } else {
             ErrorHandler::displayNotFoundError();
             return false;
         }
     }
     if (method_exists($this, "_afterRender")) {
         $result = $this->_afterRender();
         return $result;
     }
 }
Exemplo n.º 2
0
 /**
  * Tries to render a view of a plugin
  *
  * @param $view string The name of the view
  * @return void
  */
 public function renderView($view)
 {
     try {
         $route = "";
         $route .= $this->getPluginsPath();
         $route .= DS;
         $route .= $this->getPluginName();
         $route .= DS . "view" . DS;
         $route .= $view . ".php";
         if (file_exists($route)) {
             include $route;
         } else {
             ErrorHandler::displayNotFoundError();
         }
     } catch (Exception $ex) {
         trigger_error("PLUGIN | Plugin {$this->getPluginName()} cannot render view {$view}", E_USER_WARNING);
     }
 }
 /**
  * Render a view
  *
  * @param  string $view The name of the view
  * @access public
  * @return void
  */
 public function renderView($view)
 {
     try {
         $route = "";
         $config = Config::getInstance();
         $route .= $config->getmodulePath();
         $route .= "/";
         $route .= $this->_getControllerName();
         $route .= "/";
         $route .= $config->getviewPath();
         $route .= "/";
         $route .= $view . ".php";
         if (file_exists($route)) {
             include $route;
         } else {
             ErrorHandler::displayNotFoundError();
         }
     } catch (Exception $ex) {
         print $ex->getMessage();
     }
 }
Exemplo n.º 4
0
 /**
  * Dispatches an error
  *
  * @return bool
  */
 private function _dispatchError()
 {
     if ($this->_hasResult === false && $this->_router->getType() != "plugin") {
         $engine = new AppEngine();
         $engine->setParams("index", "index", "indexFirst");
         $engine->render();
         ErrorHandler::displayNotFoundError();
         $engine->setParams("index", "index", "indexLast");
         $engine->render();
         return true;
     }
     return false;
 }