/** * 表示処理 * * @access protected */ protected function output() { if ($this->_encoding) { echo mb_convert_encoding($this->flexy->bufferedOutputObject($this->_obj, $this->_elements), $this->_encoding['to'], $this->_encoding['from']); } else { $this->flexy->outputObject($this->_obj, $this->_elements); } }
function outputBody() { if ($this->timer) { $this->timer->setMarker(__CLASS__ . '::outputBody - start'); } $ff = HTML_FlexyFramework::get(); $proj = $ff->project; // DB_DataObject::debugLevel(1); $m = DB_DAtaObject::factory('Builder_modules'); $m->get('name', $proj); //var_dump($m->path);exit; // needs to modify the template directory?? // use the builder_module == app name // look for part with same name. if (empty($ff->Pman_Builder['from_filesystem'])) { $template_engine = new HTML_Template_Flexy(array('templateDir' => $m->path)); } else { $template_engine = new HTML_Template_Flexy(); } $template_engine->debug = 1; //print_R($template_engine); $template_engine->compile($this->template); if ($this->elements) { /* BC crap! */ $this->elements = HTML_Template_Flexy_Factory::setErrors($this->elements, $this->errors); } $template_engine->elements = $this->elements; if ($this->timer) { $this->timer->setMarker(__CLASS__ . '::outputBody - render template'); } //DB_DataObject::debugLevel(1); $template_engine->outputObject($this, $this->elements); if ($this->timer) { $this->timer->setMarker(__CLASS__ . '::outputBody - end'); } }
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); }
function display() { $output = new HTML_Template_Flexy(array('templateDir' => MAX_PATH . '/lib/max/Admin/Inventory/themes', 'compileDir' => MAX_PATH . '/var/templates_compiled', 'flexyIgnore' => true)); $codes = $this->codes; $this->codes = array(); if (is_array($codes)) { foreach ($codes as $v) { $k = count($this->codes); $v['id'] = "tag_{$k}"; $v['name'] = "tag[{$k}]"; $v['autotrackname'] = "autotrack[{$k}]"; $v['autotrack'] = isset($v['autotrack']) ? $v['autotrack'] : false; $v['rank'] = $k + 1; $v['move_up'] = $k > 0; $v['move_down'] = $k < count($codes) - 1; $this->codes[] = $v; } } // Display page content $output->compile('TrackerAppend.html'); $output->outputObject($this); }
/** * static version which does new, compile and output all in one go. * * See outputObject($t) for more details. * * @version 01/12/14 * @access public * @author Alan Knowles * @param object object to output as $t * @param filename of template * @return string - result */ function &staticQuickTemplate($file, &$t) { $template = new HTML_Template_Flexy(); $template->compile($file); $template->outputObject($t); }
/** * output a template (optionally with flexy object & element.) * * @param string name of flexy template. * @param object object as per HTML_Template_Flexy:outputObject * @param array elements array as per HTML_Template_Flexy:outputObject * * @return none * @access public */ function display($templatename, $object = null, $elements = array()) { // some standard stuff available to a smarty template.. $this->vars['SCRIPT_NAME'] = $_SERVER['SCRIPT_NAME']; $o = PEAR::getStaticProperty('HTML_Template_Flexy', 'options'); require_once 'HTML/Template/Flexy.php'; $t = new HTML_Template_Flexy(); $t->compile($templatename); $object = $object !== null ? $object : new StdClass(); foreach ($this->vars as $k => $v) { $object->{$k} = $v; } $t->outputObject($object, $elements); }
break; case 'multifile': include_once "HTML/Template/Flexy.php"; $options = array('templateDir' => "inputWidgets/templates", 'compileDir' => "inputWidgets/templates"); $obj = new stdClass(); $obj->KEY = $key; $obj->JAVASCRIPT = "<script>var key = '" . $key . "'</script>"; $tmp = unserialize($value); if (is_array($tmp)) { foreach ($tmp as $tk => $tv) { $obj->FILAS[]['nombre'] = $tv; } } $output = new HTML_Template_Flexy($options); $output->compile('multifile.html'); $retval = $output->bufferedOutputObject($obj); break; default: $retval = "<input type='{$type}' name='{$key}' value='{$value}'>"; break; } return $retval; } $options = array('templateDir' => 'templates', 'compileDir' => 'tmp'); $output = new HTML_Template_Flexy($options); $output->compile("form.html"); $tpl->CONTENT = $output->bufferedOutputObject($tpl); $output = new HTML_Template_Flexy($options); $output->compile("popup.html"); $output->outputObject($tpl);
/** * output the default template with the editing facilities. * * @return none * @access public */ function outputDefaultTemplate() { $o = array('compileDir' => ini_get('session.save_path') . '/HTML_Template_Flexy_Translate', 'templateDir' => dirname(__FILE__) . '/templates'); $x = new HTML_Template_Flexy($o); $x->compile('translator.html'); $x->outputObject($this); }
$view = new stdClass(); $view->php_self = $_SERVER['SCRIPT_NAME']; $view->STYLE = $STYLE; $view->skin = $skin_en; $view->hint = $_conf['detect_hint']; $view->isPopUp = $isPopUp; $view->showForm = $showForm; $view->info_msg = P2Util::getInfoHtml(); $view->upfiles = $upfiles; $view->maxfilesize = $maxsize_si; $view->maxpostsize = ini_get('post_max_size'); $view->extra_headers = $_conf['extra_headers_ht']; $view->extra_headers_x = $_conf['extra_headers_xht']; // ページを表示 P2Util::header_nocache(); $flexy->outputObject($view, $elements); // }}} // {{{ 関数 // {{{ ic2_check_uploaded_file() /** * アップロードされた各画像ファイルを検証する。 * 問題がなければ ic2_register_uploaded_file() にファイル情報を渡し、 * 問題があればエラーメッセージ(文字列)を返す。 */ function ic2_check_uploaded_file($path, $name, $type, $filesize, $tmpname, $errcode) { global $_conf, $ini, $err_fmt; global $mimemap, $mimeregex, $maxsize, $maxwidth, $maxheight; $path_ht = htmlspecialchars($path, ENT_QUOTES); // アップロード失敗のとき if ($errcode != UPLOAD_ERR_OK) {
/** * A private method to do part of the work of the * {@link OA_Admin_Statistics_Common::output()} method. * * @access private * @param array $aElements An optional array of output elements to display. */ function _output($aElements = array()) { global $graphFilter; // Prepare the Flexy output object $oOutput = new HTML_Template_Flexy(array('templateDir' => $this->templateDir, 'compileDir' => MAX_PATH . '/var/templates_compiled')); // Add global variables for backwards compatibility if (OA_Permission::isAccount(OA_ACCOUNT_ADVERTISER)) { $GLOBALS['clientid'] = OA_Permission::getEntityId(); } elseif (OA_Permission::isAccount(OA_ACCOUNT_TRAFFICKER)) { $GLOBALS['affiliateid'] = OA_Permission::getEntityId(); } // Add the current page's entity/breakdown values to the page // parameters before generating this page's URI $this->aPageParams['entity'] = $this->entity; $this->aPageParams['breakdown'] = $this->breakdown; // Generate URI used to add other parameters $this->_generatePageURI(); $this->assetPath = OX::assetPath(); phpAds_PageHeader($this->pageId, $this->getHeaderModel()); // Welcome text if (!empty($this->welcomeText)) { echo "<br/>"; echo $this->welcomeText; echo "<br/><br/><br/>"; } // Show the page sections phpAds_ShowSections($this->aPageSections, $this->aPageParams, $openNewTable = false); $graphVals = $graphFilter; // Set columns shown by default if (!is_array($graphVals)) { if (isset($this->aColumns['sum_views'])) { $graphVals[] = 'sum_views'; } if (isset($this->aColumns['sum_clicks'])) { $graphVals[] = 'sum_clicks'; } } // Prepare the data required for displaying graphs $graphFilterArray = $graphVals; $imageFormat = null; if (!extension_loaded('gd')) { $this->aGraphData['noGraph'] = true; } else { $imgPath = rtrim(MAX::constructURL(MAX_URL_IMAGE), '/'); if (!function_exists('imagecreate')) { $this->aGraphData['noGraph'] = $GLOBALS['strGDnotEnabled']; } else { $tmpUrl = MAX::constructURL(MAX_URL_ADMIN) . 'stats-showgraph.php?' . $_SERVER['QUERY_STRING']; if (is_array($graphFilterArray)) { foreach ($graphFilterArray as $k => $v) { $tmpUrl .= '&graphFields[]=' . $v; } } } $formSubmitLink = explode("/", $_SERVER['REQUEST_URI']); $formSubmitLink = $formSubmitLink[count($formSubmitLink) - 1]; $this->aGraphData['imgPath'] = $imgPath; $this->aGraphData['tmpUrl'] = $tmpUrl; $this->aGraphData['queryString'] = $_SERVER['QUERY_STRING']; $this->aGraphData['formSubmitLink'] = $formSubmitLink; } // Set the Flexy tags to open/close Javascript $this->scriptOpen = "\n<script type=\"text/javascript\"> <!--\n"; $this->scriptClose = "\n//--> </script>\n"; // Set whether to automatically display the Graph div, will return true if user has just changed the 'graphFields' value $this->autoShowGraph = strpos($_SERVER['QUERY_STRING'], 'graphFields'); // Set the language vars for statistics display $this->strShowGraphOfStatistics = $GLOBALS['strShowGraphOfStatistics']; $this->strExportStatisticsToExcel = $GLOBALS['strExportStatisticsToExcel']; // Set-up Flexy form for displaying graph $aElements['graphFilter[]'] = new HTML_Template_Flexy_Element(); $aElements['graphFilter[]']->setValue($graphVals); if ($this->_isEmptyResultArray()) { $this->disableGraph = true; } // Display page content $oOutput->compile($this->template); $oOutput->outputObject($this, $aElements); $this->_savePrefs(); phpAds_PageFooter(); }
/** * The body Output layer. * * compiles the template * At present there is no caching in here.. - this may change latter.. * * used by putting {outputBody} in the main template. * @access public */ function outputBody() { $template_engine = new HTML_Template_Flexy(); $template_engine->compile($this->template); if ($this->elements) { /* BC crap! */ $this->elements = HTML_Template_Flexy_Factory::setErrors($this->elements, $this->errors); } $template_engine->elements = $this->elements; $template_engine->outputObject($this, $this->elements); }
$AddrRules['zip'][0] = array('Zip code is required', 'required'); $AddrRules['zip'][1] = array('Zip code is numeric only', 'numeric'); $AddrRules['city'][0] = array('City is required', 'required'); $AddrRules['city'][1] = array('City is letters only', 'lettersonly'); $form->addGroupRule('address', $AddrRules); // Tries to validate the form if ($form->validate()) { // Form is validated, then freezes the data $form->freeze(); $form->process('myProcess', false); echo "\n<hr>\n"; } // setup a template object $options =& PEAR::getStaticProperty('HTML_Template_Flexy', 'options'); $options = array('templateDir' => './templates', 'compileDir' => './templates/build', 'forceCompile' => 1, 'debug' => 0, 'local' => 'en'); $template = new HTML_Template_Flexy($options); $renderer =& new HTML_QuickForm_Renderer_ObjectFlexy($template); $renderer->setLabelTemplate("label.html"); $renderer->setHtmlTemplate("html.html"); $form->accept($renderer); $view = new StdClass(); $view->form = $renderer->toObject(); $template->compile("flexy-static.html"); // capture the array stucture ob_start(); print_r($view->form); $view->static_object = ob_get_contents(); ob_end_clean(); // render and display the template $template->outputObject($view);
<?php //! HTML_Template_Flexyのサンプル require_once 'HTML/Template/Flexy.php'; // テンプレートファイルを置くフォルダ define('TEMPLATE_PATH', '/home/yamauchi/templates'); // オプション設定 $options = array('locale' => 'jp', 'charset' => 'UTF-8', 'templateDir' => TEMPLATE_PATH, 'compileDir' => TEMPLATE_PATH . '/templates_c', 'plugins' => array('PpFlexyPlugin' => TEMPLATE_PATH . '/ppFlexyPlugin.php')); // htmlspecialcharsに指定する文字エンコーディングを設定 ※注意:特別な対策です! $GLOBALS['HTML_Template_Flexy']['options']['charset'] = $options['charset']; // Flexyオブジェクトを作成 $flexy = new HTML_Template_Flexy($options); // 表示データ用オブジェクト $dobj = new stdClass(); $dobj->val = '楽しい夏休み'; // コンパイルして表示する $flexy->compile('p15flexy.html'); $flexy->outputObject($dobj);
} elseif (strpos($K, 'color') !== false) { $STYLE[$K] = p2_correct_css_color($V); } elseif (strpos($K, 'background') !== false) { $STYLE[$K] = 'url("' . addslashes($V) . '")'; } } if ($updated_fontconfig['enabled']) { p2_fontconfig_apply_custom(); } else { $skin_en = preg_replace('/&_=[^&]*/', '', $skin_en) . '&_=' . rawurlencode($skin_uniq); } $controllerObject->STYLE = $STYLE; $controllerObject->skin = $skin_en; $controllerObject->p2vid = P2_VERSION_ID; // 出力 $flexy->outputObject($controllerObject, $elements); // {{{ p2_fontconfig_load_skin_setting() /** * カスタム設定で上書きされていないスキン設定を読み込む */ function p2_fontconfig_load_skin_setting() { global $_conf, $STYLE; $skindata = array(); $fontfamily = isset($STYLE['fontfamily.orig']) ? $STYLE['fontfamily.orig'] : (isset($STYLE['fontfamily']) ? $STYLE['fontfamily'] : ''); $skindata['fontfamily'] = p2_fontconfig_implode_fonts($fontfamily); $fontfamily_bold = isset($STYLE['fontfamily_bold.orig']) ? $STYLE['fontfamily_bold.orig'] : (isset($STYLE['fontfamily_bold']) ? $STYLE['fontfamily_bold'] : ''); $skindata['fontfamily_bold'] = p2_fontconfig_implode_fonts($fontfamily_bold); $fontfamily_aa = isset($_conf['expack.am.fontfamily.orig']) ? $_conf['expack.am.fontfamily.orig'] : (isset($_conf['expack.am.fontfamily']) ? $_conf['expack.am.fontfamily'] : ''); $skindata['fontfamily_aa'] = p2_fontconfig_implode_fonts($fontfamily_aa); $normal = $skindata['fontfamily_bold'] == '' ? '' : 'normal';