public function __construct() { parent::__construct(); $config = Config::getInstance()->get('view_manager'); $this->config = $config['module'][Router::getInstance()->getModule()]; $this->viewstack = isset($this->config['template_path_stack']) ? $this->config['template_path_stack'] : ""; // get the variables given }
protected function __construct() { $this->headScript = HeadScript::getInstance(); $this->headLink = HeadLink::getInstance(); $this->headTitle = HeadTitle::getInstance(); $this->inlineScript = InlineScript::getInstance(); $this->headMeta = HeadMeta::getInstance(); $this->url = Url::getInstance(); $this->router = Router::getInstance(); $this->translator = Translator::getInstance(); }
public function __construct($arrayOfItems = array()) { parent::__construct(); $config = Config::getInstance()->get('view_manager'); $this->config = $config['module'][Router::getInstance()->getModule()]; $this->viewstack = isset($this->config['template_path_stack']) ? $this->config['template_path_stack'] : ""; // get the variables given foreach ($arrayOfItems as $key => $value) { $this->{$key} = $value; } }
public function init() { $config = Config::getInstance()->get('translator'); $module = Router::getInstance()->getModule(); $dir = $config['module'][$module]['directory']; $content = file_get_contents($dir . $this->locale . ".po"); preg_match_all('$msgid "[^"]*$', $content, $keys); foreach ($keys[0] as $key) { $Keys[] = rtrim(substr($key, 7), "\""); } // array_shift($Keys); // get the first item from the header preg_match_all('$msgstr "[^"]*"$', $content, $values); array_shift($Keys); array_shift($values[0]); array_walk($values[0], function (&$key) { $key = rtrim($key, "\""); $key = substr($key, strlen("msgstr ") + 1, strlen($key)); }); $this->textdomain = array_combine($Keys, $values[0]); }
public function setRouter(\System\StdLib\MvcEvent\Router $router) { $this->routes = $router->getRoute(); }
/** * The redirector method * @param string $routeName The route name specified in routing configuration * @param array $options Options to that route * @throws \Exception */ public function toRoute($routeName, $options = array()) { $router = Config::getInstance()->get('router'); // check if there is a route with that name in the configuration if (array_key_exists($routeName, $router['routes'])) { // literal route, so return the basepath to it if ($router['routes'][$routeName]['type'] == "Literal") { $route['controller'] = $router['routes'][$routeName]['options']['defaults']['controller']; $route['module'] = $router['routes'][$routeName]['options']['defaults']['module']; $route['action'] = $router['routes'][$routeName]['options']['defaults']['action']; Router::getInstance()->setRoute($route); } elseif ($router['routes'][$routeName]['type'] == "Segment") { $options = array_merge($options, $router['routes'][$routeName]['options']['defaults']); Router::getInstance()->setRoute($options); } else { throw new \Exception("Invalid configuration for route '{$routeName}'"); } } else { throw new \Exception("No route specified with name '{$routeName}'"); } try { $newrouter = Router::getInstance(); // assign a new controller $controller = $newrouter->getController(); // and action $action = $newrouter->getAction(); $c = new $controller(); $view = $c->{$action}(); $c->getLayout()->render($view); } catch (\RuntimeException $e) { die($e->getMessage()); } catch (\Exception $e) { die($e->getMessage()); $this->displayFatalErrors($e); } exit; // terminate the request }
/** * */ private function getFromCache() { $name = "head" . md5(Router::getInstance()->getController() . Router::getInstance()->getAction()) . ".min.js"; $this->scriptfiles = array(array('src' => $this->getJsUrl() . $name, 'type' => "text/javascript", 'conditionals' => false, "attributes" => array())); }
/** * Merge the javascript files in their order * into one file, named by the current controller.action."js" md5 hash placed in the js directory */ private function merge() { $content = "/* Cached at " . date("Y-m-d H:i:s") . " */"; foreach ($this->links as $link) { $filename = str_replace($this->getCssUrl(), $this->getCssDir(), $link['href']); // get the filename $content .= file_get_contents($filename); // append the content } $name = md5(Router::getInstance()->getController() . Router::getInstance()->getAction()) . ".min.css"; file_put_contents($this->getCssDir() . $name, $content); // put the merged content into a file $this->links = array(); array_push($this->links, array('href' => $this->getCssUrl() . $name, 'media' => 'screen', 'extras' => array(), 'conditionals' => false)); }
public function __construct() { parent::__construct(); $this->config = $this->view_config['module'][Router::getInstance()->getModule()]; $this->template_stack = $this->config['email_template_stack']; }