/** * 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; }
/** * Constructor * @param string $tplName The name of the Template file (without .xml) * @throws \Exception */ public function __construct($tplName) { $this->templateFile = BUZZSEO_DIR . DIRECTORY_SEPARATOR . 'tal' . DIRECTORY_SEPARATOR . $tplName . '.xml'; if (!is_readable($this->templateFile)) { throw new \Exception(sprintf(__('File %s does not exist.', 'buzz-seo'), $this->templateFile), 404); } // Construct PHPTAL object parent::__construct(); // Add translator $this->TalTranslator = new Services\Translation(); $this->TalTranslator->useDomain('buzz-seo'); $this->setTranslator($this->TalTranslator); // Render as HTML5 $this->setOutputMode(\PHPTAL::HTML5); // Strip comments $this->stripComments(true); // Set source $this->setTemplate($this->templateFile); }