public function dispatch() { $helper = HelperFactory::getHelper("Http"); $conf = $helper->parseGet($_GET); try { $staticRoute = $this->getCotrollerByAlias(ucfirst($conf["controller"])); if ($staticRoute !== false) { $conf["controller"] = $staticRoute['controller']; if ($staticRoute['action'] != '') { $conf["action"] = $staticRoute['action']; } } $controller = ControllerFactory::getController(ucfirst($conf["controller"])); $controller->applyFilters($conf); $action = $conf["action"] . "Action"; $controller->startUp($conf); call_user_func_array(array($controller, $action), $conf["param"]); $controller->render($conf["action"]); } catch (Doctrine_Connection_Exception $e) { exit($e->getMessage()); ErrorHandler::displayError("Found a Doctrine connection error.<br>\n\t\t\t\t\t\t\t\t\t \tMake suere that you have started the Doctrine\n\t\t\t\t\t\t\t\t\t \tsubsystem.<br>"); } catch (MissingControllerException $e) { exit("<h1>ERROR</h1><br><h2>Missing Controller</h2>"); } catch (MissingClassException $e) { exit("<h1>ERROR</h1><br><h2>Missing class</h2>"); } catch (Exception $e) { exit($e->getMessage()); $controller = ControllerFactory::getController("_404"); $controller->startUp(); $controller->render("index"); } }
protected function getPageLink($str, $options, $page) { $html = HelperFactory::getHelper("Html"); $params = array("page:" . $page); $params = array_merge($this->controler->getPassedArgs(), $params); $link = $html->link(array("controller" => str_replace("Controller", "", get_class($this->controler)), "class" => $options["class"], "title" => $str, "action" => $this->controler->getAction(), "params" => $params)); return $link; }
public function getModulesList() { $ann = HelperFactory::getHelper("Annotations"); $ctls = $this->getControllers(); print "<pre>"; foreach ($ctls as $controller) { $rc = new ReflectionClass($controller); $annotations = $ann->parse($rc->getDocComment()); if ($annotations !== false) { if (isset($annotations["@useAcl"]) && $annotations["@useAcl"] == "true") { echo $this->getModuleName($controller, $annotations); $this->getControllerActions($controller); } } } }
/** * Contructor initializes $viewBaseDir and loads all Helpers and * models. * Then it initializes i18n support. */ public function __construct() { $this->viewBaseDir = CLASSPATH . "/views/"; //Los models if (isset($this->defaultUses)) { foreach ($this->defaultUses as $model) { $varName = $model; $varName[0] = strtolower($varName[0]); $this->{$varName} = ModelFactory::getModel($model); } } if (isset($this->uses)) { foreach ($this->uses as $model) { $varName = $model; $varName[0] = strtolower($varName[0]); $this->{$varName} = ModelFactory::getModel($model); } } //Los helpers if (isset($this->defaultHelpers)) { foreach ($this->defaultHelpers as $helper) { $varName = $helper; $varName[0] = strtolower($varName[0]); $this->{$varName} = HelperFactory::getHelper($helper); $this->{$varName}->startUp($this); } } if (isset($this->helpers)) { foreach ($this->helpers as $helper) { $varName = $helper; $varName[0] = strtolower($varName[0]); $this->{$varName} = HelperFactory::getHelper($helper); $this->{$varName}->startUp($this); } } //i18n $i18nFileName = strtolower(str_replace("Controller", "", get_class($this))) . '.' . $this->viewLocale . '.po'; I18nHelper::getInstance()->loadPoFile(I18N_PATH . '/' . $i18nFileName); }
/** * Return a links for the parametes * * @param Array $params The parameter from which to build the link. * The paremeters are as follows: * 'controller' the controller name * 'title' the label to be shown for the anchor * 'options' array with html options * @return unknown_type */ public function link($params) { $href = HelperFactory::getHelper("Http")->getControllerUrl($params); $htmlOptions = $this->parseOptionsHTML($params); $link = '<a href="' . $href . '"'; if (isset($params["class"])) { $link .= ' class="' . $params["class"] . '"'; } $link .= $htmlOptions . ' >' . $params["title"] . '</a>'; return $link; }