/** * Compiles code for the {extends} tag * * @param array $args array with attributes from parser * @param object $compiler compiler object * @return string compiled code */ public function compile($args, $compiler) { $this->compiler = $compiler; $this->smarty = $compiler->smarty; $this->required_attributes = array('file'); // check and get attributes $_attr = $this->_get_attributes($args); $_smarty_tpl = $compiler->template; // $include_file = ''; eval('$include_file = ' . $_attr['file'] . ';'); // create template object $_template = new Smarty_Template($include_file, $this->smarty, $compiler->template); // save file dependency $compiler->template->properties['file_dependency']['F' . abs(crc32($_template->getTemplateFilepath()))] = array($_template->getTemplateFilepath(), $_template->getTemplateTimestamp()); $_old_source = $compiler->template->template_source; if (preg_match_all('/(' . $this->smarty->left_delimiter . 'block(.+?)' . $this->smarty->right_delimiter . ')/', $_old_source, $s, PREG_OFFSET_CAPTURE) != preg_match_all('/(' . $this->smarty->left_delimiter . '\\/block(.*?)' . $this->smarty->right_delimiter . ')/', $_old_source, $c, PREG_OFFSET_CAPTURE)) { $this->compiler->trigger_template_error(" unmatched {block} {/block} pairs"); } $block_count = count($s[0]); for ($i = 0; $i < $block_count; $i++) { $block_content = str_replace($this->smarty->left_delimiter . '$smarty.parent' . $this->smarty->right_delimiter, '%%%%SMARTY_PARENT%%%%', substr($_old_source, $s[0][$i][1] + strlen($s[0][$i][0]), $c[0][$i][1] - $s[0][$i][1] - strlen($s[0][$i][0]))); $this->saveBlockData($block_content, $s[0][$i][0], $compiler->template); } $compiler->template->template_source = $_template->getTemplateSource(); $compiler->abort_and_recompile = true; return ' '; }
/** * Opens a window for the Smarty Debugging Consol and display the data */ public static function display_debug($smarty) { // prepare information of assigned variables $_assigned_vars = $smarty->tpl_vars; ksort($_assigned_vars); $_config_vars = $smarty->config_vars; ksort($_config_vars); $ldelim = $smarty->left_delimiter; $rdelim = $smarty->right_delimiter; $smarty->left_delimiter = '{'; $smarty->right_delimiter = '}'; $_template = new Smarty_Template($smarty->debug_tpl, $smarty); $_template->caching = false; $_template->force_compile = false; $_template->security = false; $_template->cache_id = null; $_template->compile_id = null; $_template->assign('template_data', self::$template_data); $_template->assign('assigned_vars', $_assigned_vars); $_template->assign('config_vars', $_config_vars); $_template->assign('execution_time', microtime(true) - $smarty->start_time); echo $smarty->fetch($_template); $smarty->left_delimiter = $ldelim; $smarty->right_delimiter = $rdelim; }
/** * Opens a window for the Smarty Debugging Consol and display the data */ public static function display_debug($smarty) { // prepare information of assigned variables $_assigned_vars = $smarty->tpl_vars; ksort($_assigned_vars); $_config_vars = $smarty->config_vars; ksort($_config_vars); $_template = new Smarty_Template($smarty->debug_tpl, $smarty); $_template->caching = false; $_template->force_compile = false; $_template->security = false; $_template->cache->data_id = null; $_template->compile_id = null; $_template->assign('template_data', self::$template_data); $_template->assign('assigned_vars', $_assigned_vars); $_template->assign('config_vars', $_config_vars); $_template->assign('execution_time', $smarty->_get_time() - $smarty->start_time); echo $smarty->fetch($_template); }
<?php if (!defined('SMARTY_DIR')) { exit('no direct access allowed'); } $_smarty_tpl->decodeProperties('a:1:{s:15:"file_dependency";a:3:{s:10:"F384501455";a:2:{i:0;s:21:"./templates/index.tpl";i:1;i:1257977415;}s:11:"F1129582534";a:2:{i:0;s:22:"./templates/header.tpl";i:1;i:1257977415;}s:11:"F1159251177";a:2:{i:0;s:22:"./templates/footer.tpl";i:1;i:1257977415;}}}'); /* Smarty version Smarty3-SVN$Rev: 3286 $, created on 2009-11-12 11:53:15 compiled from "./templates/index.tpl" */ $_config = new Smarty_Internal_Config("test.conf", $_smarty_tpl->smarty, $_smarty_tpl); $_config->loadConfigVars("setup", $_smarty_tpl->smarty); $_template = new Smarty_Template("header.tpl", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id); $_template->assign('title', 'foo'); $_template->caching = 1; $_tpl_stack[] = $_smarty_tpl; $_smarty_tpl = $_template; /* Smarty version Smarty3-SVN$Rev: 3286 $, created on 2009-11-12 11:53:15 compiled from "./templates/header.tpl" */ ?> <HTML> <HEAD> <?php echo $_smarty_tpl->smarty->plugin_handler->popup_init(array(array('src' => "/javascripts/overlib.js"), $_smarty_tpl->smarty, $_smarty_tpl), 'function'); ?> <TITLE><?php echo $_smarty_tpl->getVariable('title')->value; ?> - <?php echo '<?php echo $_smarty_tpl->getVariable(\'Name\')->value;?> '; ?> </TITLE>
This is an example of the html_select_date function: <form> <?php echo $_smarty_tpl->smarty->plugin_handler->html_select_date(array(array('start_year' => 1998, 'end_year' => 2010), $_smarty_tpl->smarty, $_smarty_tpl), 'function'); ?> </form> This is an example of the html_select_time function: <form> <?php echo $_smarty_tpl->smarty->plugin_handler->html_select_time(array(array('use_24_hours' => false), $_smarty_tpl->smarty, $_smarty_tpl), 'function'); ?> </form> This is an example of the html_options function: <form> <select name=states> <?php echo $_smarty_tpl->smarty->plugin_handler->html_options(array(array('values' => $_smarty_tpl->getVariable('option_values')->value, 'selected' => $_smarty_tpl->getVariable('option_selected')->value, 'output' => $_smarty_tpl->getVariable('option_output')->value), $_smarty_tpl->smarty, $_smarty_tpl), 'function'); ?> </select> </form> <?php $_template = new Smarty_Template("footer.tpl", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id); $_template->caching = 9999; echo $_template->getRenderedTemplate(); unset($_template);