From 6c9fa0cbd23387738faac84aea5c549b7a52e6ca Mon Sep 17 00:00:00 2001 From: messju Date: Tue, 29 Jul 2003 08:26:22 +0000 Subject: [PATCH] moved _smarty_include() back into Smarty.class.php --- libs/Smarty.class.php | 54 ++++++++++++++++++++++++++ libs/Smarty_Compiler.class.php | 3 +- libs/core/core.smarty_include.php | 63 ------------------------------- 3 files changed, 55 insertions(+), 65 deletions(-) delete mode 100644 libs/core/core.smarty_include.php diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 2ca0b7a6..e5f96156 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -1940,6 +1940,60 @@ class Smarty } + /** + * called for included templates + * + * @param string $_smarty_include_tpl_file + * @param string $_smarty_include_vars + */ + + // $_smarty_include_tpl_file, $_smarty_include_vars + + function _smarty_include($params, &$smarty) + { + if ($smarty->debugging) { + $_params = array(); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); + $debug_start_time = smarty_core_get_microtime($_params, $smarty); + $smarty->_smarty_debug_info[] = array('type' => 'template', + 'filename' => $params['smarty_include_tpl_file'], + 'depth' => ++$smarty->_inclusion_depth); + $included_tpls_idx = count($smarty->_smarty_debug_info) - 1; + } + + $smarty->_tpl_vars = array_merge($smarty->_tpl_vars, $params['smarty_include_vars']); + + // config vars are treated as local, so push a copy of the + // current ones onto the front of the stack + array_unshift($smarty->_config, $smarty->_config[0]); + + $_smarty_compile_path = $smarty->_get_compile_path($params['smarty_include_tpl_file']); + + + if ($smarty->_is_compiled($params['smarty_include_tpl_file'], $_smarty_compile_path) + || $smarty->_compile_resource($params['smarty_include_tpl_file'], $_smarty_compile_path)) + { + include($_smarty_compile_path); + } + + // pop the local vars off the front of the stack + array_shift($smarty->_config); + + $smarty->_inclusion_depth--; + + if ($smarty->debugging) { + // capture time for debugging info + $_params = array(); + require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); + $smarty->_smarty_debug_info[$included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $smarty) - $debug_start_time; + } + + if ($smarty->caching) { + $smarty->_cache_info['template'][$params['smarty_include_tpl_file']] = true; + } + } + + /** * wrapper for include() retaining $this * @return mixed diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index e8f725df..07b5a557 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -881,8 +881,7 @@ class Smarty_Compiler extends Smarty { $_params = "array('smarty_include_tpl_file' => " . $include_file . ", 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))"; - - $output .= "require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.smarty_include.php');\nsmarty_core_smarty_include($_params, \$this);\n" . + $output .= "\$this->_smarty_include($_params, \$this);\n" . "\$this->_tpl_vars = \$_smarty_tpl_vars;\n" . "unset(\$_smarty_tpl_vars);\n"; diff --git a/libs/core/core.smarty_include.php b/libs/core/core.smarty_include.php deleted file mode 100644 index 6ba3053f..00000000 --- a/libs/core/core.smarty_include.php +++ /dev/null @@ -1,63 +0,0 @@ -debugging) { - $_params = array(); - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); - $debug_start_time = smarty_core_get_microtime($_params, $smarty); - $smarty->_smarty_debug_info[] = array('type' => 'template', - 'filename' => $params['smarty_include_tpl_file'], - 'depth' => ++$smarty->_inclusion_depth); - $included_tpls_idx = count($smarty->_smarty_debug_info) - 1; - } - - $smarty->_tpl_vars = array_merge($smarty->_tpl_vars, $params['smarty_include_vars']); - - // config vars are treated as local, so push a copy of the - // current ones onto the front of the stack - array_unshift($smarty->_config, $smarty->_config[0]); - - $_smarty_compile_path = $smarty->_get_compile_path($params['smarty_include_tpl_file']); - - - if ($smarty->_is_compiled($params['smarty_include_tpl_file'], $_smarty_compile_path) - || $smarty->_compile_resource($params['smarty_include_tpl_file'], $_smarty_compile_path)) - { - $smarty->_include($_smarty_compile_path); - } - - // pop the local vars off the front of the stack - array_shift($smarty->_config); - - $smarty->_inclusion_depth--; - - if ($smarty->debugging) { - // capture time for debugging info - $_params = array(); - require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); - $smarty->_smarty_debug_info[$included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $smarty) - $debug_start_time; - } - - if ($smarty->caching) { - $smarty->_cache_info['template'][$params['smarty_include_tpl_file']] = true; - } -} - -/* vim: set expandtab: */ - -?>