protected function _includeResourceFiles($view, $output) { if ($view instanceof Joy_View_Layout) { $culture = Joy_Context_Culture::getInstance(); $response = Joy_Context_Response::getInstance(); $site_root = trim($this->config->application->get("application/site_root"), "/"); $app_script = sprintf("%s/%s.initial.js", get_class($this->_current->controller), $this->_current->action->name, $culture->getLocale()); $page_script = sprintf("%s/%s.js", get_class($this->_current->controller), $this->_current->action->name); // Script Files Injection $scripts = (array) $response->getScripts(); $scripts = array_reverse($scripts); array_push($scripts, $app_script); $scripts = array_reverse($scripts); array_push($scripts, $page_script); foreach ($scripts as $script) { if (strpos($script, "http") === FALSE) { $script = $site_root ? sprintf("/%s/%s", $site_root, trim($script, "/")) : sprintf("/%s", trim($script, "/")); } $page_scripts .= sprintf("<script type='text/javascript' src='%s'></script>\n", $script); } $output = str_replace("<!-- @Page.Javascripts -->", $page_scripts, $output); // Style Files Injection $styles = (array) $response->getStyles(); foreach ($styles as $style) { if (strpos($style, "http") === FALSE) { $style = $site_root ? sprintf("/%s/%s", $site_root, trim($style, "/")) : sprintf("/%s", trim($style, "/")); } $page_styles .= sprintf("<link rel='stylesheet' type='text/css' href='%s' media='all' />\n", $style); } $output = str_replace("<!-- @Page.Stylesheets -->", $page_styles, $output); } }
/** * _init * @return void */ protected function _init() { $this->culture = Joy_Context_Culture::getInstance(); $this->session = Joy_Context_Session::getInstance(); $this->request = Joy_Context_Request::getInstance(); $this->response = Joy_Context_Response::getInstance(); $this->user = Joy_Context_User::getInstance(); $this->cookie = Joy_Context_Cookie::getInstance(); $this->server = Joy_Context_Server::getInstance(); $this->models = Joy_Context_Model::getInstance(); }
public function __toString() { $render = Joy_Context_Response::getInstance()->getRender(); $output = ""; foreach ($this->_stack as $stack) { try { list($class, $params) = each($stack); $ref = new Joy_Reflection($class); $view = $ref->newInstance(array($params)); $output .= $render->execute($view); } catch (Exception $ex) { $output .= $ex->getMessage(); } } return $output; }
public function execute($view) { parent::execute($view); $response = Joy_Context_Response::getInstance(); $scriptFile = $view->getScript(); if (file_exists($scriptFile)) { $content = sprintf("/* %s */\n", $view->getId()); $content .= file_get_contents($scriptFile); @preg_match_all('/\\$__i18n\\[[\\"|\'](.+)[\\"|\']\\]/', $content, $matches); $locale = $view->getLocale(); if (!empty($matches[1])) { for ($i = 0; $i < count($matches[1]); $i++) { $key = $matches[1][$i]; $text = $locale[$key] ? $locale[$key] : $key; $content = str_replace($matches[0][$i], "'{$text}'", $content); } } $content = str_replace("\$__i18n", $translate, $content); $response->appendContent($content); } return $response->getContent(); }
public function __construct() { $this->response = Joy_Context_Response::getInstance(); $this->config = Joy_Config::getInstance(); }