From 25270df6bdb0e11455399bd7d8ffcd76d0265bab Mon Sep 17 00:00:00 2001 From: "Uwe.Tews" Date: Thu, 26 Nov 2009 22:49:56 +0000 Subject: [PATCH] - correct line number on unknown tag error message - changed {include} compiled code --- change_log.txt | 2 ++ .../smarty_internal_compile_include.php | 15 +++++---------- libs/sysplugins/smarty_internal_template.php | 12 ++++++------ .../smarty_internal_templatecompilerbase.php | 2 +- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/change_log.txt b/change_log.txt index 50fdcf4a..ae707918 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,5 +1,7 @@ 11/26/2009 - bugfix on nested doublequoted strings +- correct line number on unknown tag error message +- changed {include} compiled code 11/25/2009 - allow the following writing for boolean: true, TRUE, True, false, FALSE, False diff --git a/libs/sysplugins/smarty_internal_compile_include.php b/libs/sysplugins/smarty_internal_compile_include.php index baa73402..e946ac01 100644 --- a/libs/sysplugins/smarty_internal_compile_include.php +++ b/libs/sysplugins/smarty_internal_compile_include.php @@ -100,11 +100,10 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase { $_parent_scope = SMARTY_GLOBAL_SCOPE; } } + $_caching= 'null'; // default for included templates if ($this->compiler->template->caching && !$this->compiler->nocache) { $_caching = 9999; - } else { - $_caching = SMARTY_CACHING_OFF; } /* * if the {include} tag provides individual parameter for caching @@ -115,7 +114,9 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase { $_cache_lifetime = $_attr['cache_lifetime']; $this->compiler->tag_nocache = true; $_caching = SMARTY_CACHING_LIFETIME_CURRENT; - } + } else { + $_cache_lifetime = 'null'; + } if (isset($_attr['nocache'])) { if ($_attr['nocache'] == 'true') { $this->compiler->tag_nocache = true; @@ -131,7 +132,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase { } } // create template object - $_output = "smarty, \$_smarty_tpl, \$_smarty_tpl->cache_id, \$_smarty_tpl->compile_id);"; + $_output = "smarty, \$_smarty_tpl, \$_smarty_tpl->cache_id, \$_smarty_tpl->compile_id, $_caching, $_cache_lifetime);"; // delete {include} standard attributes unset($_attr['file'], $_attr['assign'], $_attr['cache_lifetime'], $_attr['nocache'], $_attr['caching'], $_attr['scope']); // remaining attributes must be assigned as smarty variable @@ -145,12 +146,6 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase { $this->compiler->trigger_template_error('variable passing not allowed in parent/global scope'); } } - // add caching parameter if required - if (isset($_cache_lifetime)) { - $_output .= "\$_template->cache_lifetime = $_cache_lifetime;"; - $_caching = SMARTY_CACHING_LIFETIME_CURRENT; - } - $_output .= "\$_template->caching = $_caching;"; // was there an assign attribute if (isset($_assign)) { $_output .= "\$_smarty_tpl->assign($_assign,\$_template->getRenderedTemplate()); ?>"; diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index a282bf45..4c5073db 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -76,15 +76,15 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { * @param mixed $_cache_id cache id or null * @param mixed $_compile_id compile id or null */ - public function __construct($template_resource, $smarty, $_parent = null, $_cache_id = null, $_compile_id = null) + public function __construct($template_resource, $smarty, $_parent = null, $_cache_id = null, $_compile_id = null, $_caching = null, $_cache_lifetime = null) { $this->smarty = $smarty; // Smarty parameter $this->cache_id = $_cache_id === null ? $this->smarty->cache_id : $_cache_id; $this->compile_id = $_compile_id === null ? $this->smarty->compile_id : $_compile_id; $this->force_compile = $this->smarty->force_compile; - $this->caching = $this->smarty->caching; - $this->cache_lifetime = $this->smarty->cache_lifetime; + $this->caching = $_caching === null ? $this->smarty->caching : $_caching; + $this->cache_lifetime = $_cache_lifetime === null ?$this->smarty->cache_lifetime : $_cache_lifetime; $this->force_cache = $this->smarty->force_cache; $this->cacher_class = $this->smarty->cacher_class; $this->caching_type = $this->smarty->default_caching_type; @@ -573,10 +573,10 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { } else { $_return = call_user_func_array($this->smarty->default_template_handler_func, array($this->resource_type, $this->resource_name, &$this->template_source, &$this->template_timestamp, $this)); - if ($_return == true) { - return $file; - } elseif (is_string($_return)) { + if (is_string($_return)) { return $_return; + } elseif ($_return === true) { + return $file; } } } diff --git a/libs/sysplugins/smarty_internal_templatecompilerbase.php b/libs/sysplugins/smarty_internal_templatecompilerbase.php index 6f9ce3ce..8d7859bd 100644 --- a/libs/sysplugins/smarty_internal_templatecompilerbase.php +++ b/libs/sysplugins/smarty_internal_templatecompilerbase.php @@ -235,7 +235,7 @@ class Smarty_Internal_TemplateCompilerBase { { // get template source line which has error if (!isset($line)) { - $line = $this->lex->line; + $line = $this->lex->line; } $match = preg_split("/\n/", $this->lex->data); $error_text = 'Syntax Error in template "' . $this->template->getTemplateFilepath() . '" on line ' . $line . ' "' . $match[$line-1] . '" ';