From 0a64988240cd11a01d994fedc6dc485abd1693ce Mon Sep 17 00:00:00 2001 From: "Uwe.Tews" Date: Fri, 8 May 2009 11:34:21 +0000 Subject: [PATCH] - fixed bug of {nocache} tag in included templates --- change_log.txt | 3 +++ libs/sysplugins/internal.compile_include.php | 8 ++++++-- libs/sysplugins/internal.template.php | 15 +++++++++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/change_log.txt b/change_log.txt index a455dca2..f016dbdc 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,6 @@ +05/08/2009 +- fixed bug of {nocache} tag in included templates + 05/06/2009 - allow that plugins_dir folder names can end without directory separator diff --git a/libs/sysplugins/internal.compile_include.php b/libs/sysplugins/internal.compile_include.php index 7204b334..c43acee1 100644 --- a/libs/sysplugins/internal.compile_include.php +++ b/libs/sysplugins/internal.compile_include.php @@ -45,7 +45,11 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase { } } // default for included templates - $_caching = SMARTY_CACHING_OFF; + if ($compiler->template->caching) { + $_caching = SMARTY_CACHING_LIFETIME_CURRENT; + } else { + $_caching = SMARTY_CACHING_OFF; + } /* * if the {include} tag provides individual parameter for caching * it will not be included into the common cache file and treated like @@ -89,7 +93,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase { if (isset($_assign)) { $_output .= "\$_smarty_tpl->assign($_assign,\$_smarty_tpl->smarty->fetch(\$_template)); ?>"; } else { - $_output .= "echo \$_smarty_tpl->smarty->fetch(\$_template); ?>"; + $_output .= "\$_template->processInclude(); ?>"; } if ($_parent_scope != SMARTY_LOCAL_SCOPE) { $_output .= "updateParentVariables($_parent_scope); ?>"; diff --git a/libs/sysplugins/internal.template.php b/libs/sysplugins/internal.template.php index 5e3c5aa9..eb0e54e6 100644 --- a/libs/sysplugins/internal.template.php +++ b/libs/sysplugins/internal.template.php @@ -90,9 +90,9 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { $this->security = $this->smarty->security; $this->cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($this->caching_type); $this->parent = $_parent; - $this->properties['file_dependency'] = array(); + $this->properties['file_dependency'] = array(); // dummy local smarty variable - $this->tpl_vars['smarty'] = new Smarty_Variable; + $this->tpl_vars['smarty'] = new Smarty_Variable; // Template resource $this->template_resource = $template_resource; // parse resource name @@ -272,8 +272,8 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { $this->properties = unserialize($_matches[1]); if (!empty($this->properties['function'])) { foreach ($this->properties['function'] as $_name => $_data) { - $this->smarty->template_functions[$_name]['compiled'] = str_replace(array('_%n'), array("\n"), $_data['compiled']); - $this->smarty->template_functions[$_name]['parameter'] = $_data['parameter']; + $this->smarty->template_functions[$_name]['compiled'] = str_replace(array('_%n'), array("\n"), $_data['compiled']); + $this->smarty->template_functions[$_name]['parameter'] = $_data['parameter']; } } } @@ -472,6 +472,13 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { } } + function processInclude() + { + $_smarty_tpl = $this; + $_start_time = $this->_get_time(); + eval("?>" . $this->getCompiledTemplate()); + $this->render_time += $this->_get_time() - $_start_time; + } /** * Returns the rendered HTML output *