示例#1
0
 /**
  * This method is used to process the data into the view and than return it to the main method that will handle what to do.
  * It also uses buffer to handle that content.
  *
  * @author Klederson Bueno <*****@*****.**>
  * @version 0.1a
  *
  * @param String $___phpBurnFilePath
  * @param Array $__phpBurnData
  * @return String
  */
 public function processViewData($___phpBurnFilePath, $__phpBurnData)
 {
     $tpl = new PHPTAL($___phpBurnFilePath);
     $tpl->setOutputMode(PHPTAL::HTML5);
     $tr = new PHPTAL_GetTextTranslator();
     // set language to use for this session (first valid language will
     // be used)
     $tr->setLanguage('pt_BR.utf8', 'pt_BR');
     // register gettext domain to use
     $tr->addDomain('system', SYS_BASE_PATH . 'locale');
     // specify current domain
     $tr->useDomain('system');
     // tell PHPTAL to use our translator
     $tpl->setTranslator($tr);
     foreach ($__phpBurnData as $index => $value) {
         if (is_string($value)) {
             $value = PhpBURN_Views::lazyTranslate($value, $_SESSION['lang']);
         }
         $tpl->{$index} = $value;
     }
     ob_start();
     try {
         echo $tpl->execute();
     } catch (Exception $e) {
         echo $e;
     }
     $___phpBurnBufferStored = ob_get_contents();
     //
     //        //Cleaning the buffer for new sessions
     ob_clean();
     return $___phpBurnBufferStored;
 }
示例#2
0
 /**
  * Sets the translator
  *
  * @param null $language
  * @param string $domain
  * @param string $translatorClass
  */
 public function setTranslator($languages = ['en'], $domain = 'messages', $translatorClass = '\\PHPTAL_GetTextTranslator')
 {
     $translator = new $translatorClass($this);
     $languages = !is_array($languages) ? [$languages] : $languages;
     call_user_func_array([$translator, 'setLanguage'], $languages);
     $translator->setEncoding($this->translationSettings['encoding']);
     $translator->addDomain($domain);
     $this->phptal->setTranslator($translator);
 }
示例#3
0
 /**
  *
  * @return PHPTAL
  */
 protected function getTAL()
 {
     try {
         if (!$this->TAL instanceof PHPTAL) {
             $this->TAL = new PHPTAL($this->getPathTemplate());
         }
         $translator = new LBoxTranslator($this->getPathTemplate());
         // zajistit existenci ciloveho adresare PHP kodu pro TAL:
         $phptalPhpCodeDestination = LBoxUtil::fixPathSlashes(LBoxConfigSystem::getInstance()->getParamByPath("output/tal/PHPTAL_PHP_CODE_DESTINATION"));
         LBoxUtil::createDirByPath($phptalPhpCodeDestination);
         $this->TAL->setTranslator($translator);
         $this->TAL->setForceReparse(LBoxConfigSystem::getInstance()->getParamByPath("output/tal/PHPTAL_FORCE_REPARSE"));
         $this->TAL->setPhpCodeDestination($phptalPhpCodeDestination);
         $this->TAL->SELF = $this;
         return $this->TAL;
     } catch (Exception $e) {
         throw $e;
     }
 }
示例#4
0
 private function display_tal(midgardmvc_core_request $request, $content, array $data)
 {
     $tal = new PHPTAL($request->get_template_identifier());
     $tal->setPhpCodeDestination($this->midgardmvc->cache->template->get_cache_directory());
     $tal->uimessages = false;
     if ($this->midgardmvc->configuration->enable_uimessages) {
         if ($this->midgardmvc->uimessages->has_messages() && $this->midgardmvc->uimessages->can_view()) {
             $tal->uimessages = $this->midgardmvc->uimessages->render();
         }
     }
     $tal->midgardmvc = $this->midgardmvc;
     $tal->request = $request;
     // FIXME: Remove this once Qaiku has upgraded
     $tal->MIDCOM = $this->midgardmvc;
     foreach ($data as $key => $value) {
         $tal->{$key} = $value;
     }
     $tal->setSource($content);
     $translator =& $this->midgardmvc->i18n->set_translation_domain($request->get_component()->name);
     $tal->setTranslator($translator);
     try {
         $content = $tal->execute();
     } catch (PHPTAL_TemplateException $e) {
         throw new midgardmvc_exception("PHPTAL: {$e->srcFile} line {$e->srcLine}: " . $e->getMessage());
     }
     return $content;
 }
示例#5
0
 private function display_tal($content, $data)
 {
     // We use the PHPTAL class
     if (!class_exists('PHPTAL')) {
         require 'PHPTAL.php';
     }
     // FIXME: Rethink whole tal modifiers concept
     include_once 'TAL/modifiers.php';
     $tal = new PHPTAL($this->get_cache_identifier());
     $tal->uimessages = false;
     if ($this->midgardmvc->configuration->enable_uimessages) {
         if ($this->midgardmvc->uimessages->has_messages() && $this->midgardmvc->uimessages->can_view()) {
             $tal->uimessages = $this->midgardmvc->uimessages->render();
         }
     }
     $tal->midgardmvc = $this->midgardmvc;
     // FIXME: Remove this once Qaiku has upgraded
     $tal->MIDCOM = $this->midgardmvc;
     foreach ($data as $key => $value) {
         $tal->{$key} = $value;
     }
     $tal->setSource($content);
     $translator =& $this->midgardmvc->i18n->set_translation_domain($this->midgardmvc->context->component);
     $tal->setTranslator($translator);
     try {
         $content = $tal->execute();
     } catch (PHPTAL_TemplateException $e) {
         throw new midgardmvc_exception("PHPTAL: {$e->srcFile} line {$e->srcLine}: " . $e->getMessage());
     }
     return $content;
 }