示例#1
0
文件: PHPTAL.php 项目: hasanozgan/joy
 public function execute($view)
 {
     parent::execute($view);
     return $view->render();
     $context = Joy_Context::getInstance();
     $resource = $view->getResourceList();
     $context->response->addScript($resource["javascripts"]);
     $context->response->addStyle($resource["stylesheets"]);
     $application = $context->config->application->get("application");
     $application["i18n"] = $view->getLocale();
     $tpl = new PHPTAL();
     $tpl->setSource($view->getTemplate());
     $tpl->import = new Joy_Render_Template_Importer($view);
     $tpl->application = $application;
     $tpl->get = (array) $view->assignAll();
     return $tpl->execute();
 }
示例#2
0
 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();
 }