/** * テンプレートの設定 * @param $templateName * @access private */ protected function setVariables($templateName, $obj) { // Hidden値の設定 // Flexyを生成する前に $this->_hidden に値を代入しておく // Flexyから $this->_hidden が利用される $hidden = Container::getInstance()->getComponent('Laiz_Action_Component_Hidden'); if ($hidden instanceof Laiz_Action_Component_Hidden) { foreach ($hidden->getHiddens() as $key => $value) { if (is_array($value)) { foreach ($value as $hiddenName => $hiddenValue) { $this->setHidden($key, $hiddenName, $hiddenValue); } } } } $options = array('templateDir' => $this->TEMPLATE_DIR, 'multiSource' => true, 'compileDir' => $this->FLEXY_COMPILE_DIR, 'numberFormat' => ', 0', 'forceCompile' => $this->FLEXY_FORCE_COMPILE); // ユーザ独自の設定 if ($this->_flexyOptions) { $options = array_merge($options, $this->_flexyOptions); } $rep = error_reporting(); error_reporting($rep & E_ALL); // PEARの関係上Strictエラーを除外する $this->flexy = new Fly_Flexy($options); // Hidden値の設定 //$this->flexy->setHiddens($this->_hiddens); $this->flexy->compile($templateName); $this->_elements = $this->flexy->getElements(); error_reporting($rep); $this->_setVariables($obj); $this->_obj = $obj; }
function compilefile($file, $data = array(), $options = array(), $elements = array()) { $options = $options + array('templateDir' => dirname(__FILE__) . '/templates', 'forceCompile' => true, 'fatalError' => HTML_TEMPLATE_FLEXY_ERROR_RETURN, 'url_rewrite' => 'images/:/myproject/images/', 'compileDir' => dirname(__FILE__) . '/results1'); // basic options.. echo "\n\n===Compiling {$file}===\n\n"; $options['compileDir'] = dirname(__FILE__) . '/results1'; $x = new HTML_Template_Flexy($options); $res = $x->compile($file); if ($res !== true) { echo "===Compile failure==\n" . $res->toString() . "\n"; return; } echo "\n\n===Compiled file: {$file}===\n"; echo file_get_contents($x->compiledTemplate); if (!empty($options['show_elements'])) { print_r($x->getElements()); } if (!empty($options['show_words'])) { print_r(unserialize(file_get_contents($x->gettextStringsFile))); } echo "\n\n===With data file: {$file}===\n"; $data = (object) $data; $x->outputObject($data, $elements); }
} } } } // }}} // {{{ output $_flexy_options = array('locale' => 'ja', 'charset' => 'Shift_JIS', 'compileDir' => $_conf['compile_dir'] . DIRECTORY_SEPARATOR . 'ic2', 'templateDir' => P2EX_LIB_DIR . '/ic2/templates', 'numberFormat' => ''); $flexy = new HTML_Template_Flexy($_flexy_options); $flexy->compile('ic2s.tpl.html'); if (!$isPopUp && (!empty($upfiles) || P2Util::hasInfoHtml())) { $showForm = false; } else { $showForm = true; } // フォームを修正 $elements = $flexy->getElements(); if ($showForm) { $form_attr = array('action' => $_SERVER['SCRIPT_NAME'] . '?upload=1', 'accept-charset' => $_conf['accept_charset']); $elements['fileupload']->setAttributes($form_attr); $elements['MAX_FILE_SIZE']->setValue($maxsize); $elements['popup']->setValue($isPopUp); if ($isPopUp) { $elements['fileupload']->setAttributes('target="_self"'); } else { $elements['fileupload']->setAttributes('target="read"'); } } // テンプレート変数 $view = new stdClass(); $view->php_self = $_SERVER['SCRIPT_NAME']; $view->STYLE = $STYLE;