From b52cbe9adb78724b927ed871fa1dc564d1673546 Mon Sep 17 00:00:00 2001 From: "Uwe.Tews" Date: Fri, 30 Jul 2010 13:09:52 +0000 Subject: [PATCH] - bugfix passing scope attributes in doublequoted strings did not work at {include} {assign} and {append} --- change_log.txt | 3 ++ .../smarty_internal_compile_append.php | 9 +++-- .../smarty_internal_compile_assign.php | 7 ++-- .../smarty_internal_compile_config_load.php | 40 +++++++++---------- .../smarty_internal_compile_extends.php | 2 +- .../smarty_internal_compile_include.php | 19 ++++----- 6 files changed, 43 insertions(+), 37 deletions(-) diff --git a/change_log.txt b/change_log.txt index fb979c5c..24f09fe7 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,6 @@ +30/07/2010 +- bugfix passing scope attributes in doublequoted strings did not work at {include} {assign} and {append} + 25/07/2010 - another bugfix of change from 23/07/2010 when compiling modifer diff --git a/libs/sysplugins/smarty_internal_compile_append.php b/libs/sysplugins/smarty_internal_compile_append.php index d60d8089..48eda0cb 100644 --- a/libs/sysplugins/smarty_internal_compile_append.php +++ b/libs/sysplugins/smarty_internal_compile_append.php @@ -41,11 +41,12 @@ class Smarty_Internal_Compile_Append extends Smarty_Internal_CompileBase { $_attr = $this->_get_attributes($args); if (isset($_attr['scope'])) { - if ($_attr['scope'] == '\'parent\'') { + $_attr['scope'] = trim($_attr['scope'], "'\""); + if ($_attr['scope'] == 'parent') { $_scope = SMARTY_PARENT_SCOPE; - } elseif ($_attr['scope'] == '\'root\'') { + } elseif ($_attr['scope'] == 'root') { $_scope = SMARTY_ROOT_SCOPE; - } elseif ($_attr['scope'] == '\'global\'') { + } elseif ($_attr['scope'] == 'global') { $_scope = SMARTY_GLOBAL_SCOPE; } } @@ -58,4 +59,4 @@ class Smarty_Internal_Compile_Append extends Smarty_Internal_CompileBase { } } -?> +?> \ No newline at end of file diff --git a/libs/sysplugins/smarty_internal_compile_assign.php b/libs/sysplugins/smarty_internal_compile_assign.php index 9d907278..29881e87 100644 --- a/libs/sysplugins/smarty_internal_compile_assign.php +++ b/libs/sysplugins/smarty_internal_compile_assign.php @@ -41,11 +41,12 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase { $_attr = $this->_get_attributes($args); if (isset($_attr['scope'])) { - if ($_attr['scope'] == '\'parent\'') { + $_attr['scope'] = trim($_attr['scope'], "'\""); + if ($_attr['scope'] == 'parent') { $_scope = SMARTY_PARENT_SCOPE; - } elseif ($_attr['scope'] == '\'root\'') { + } elseif ($_attr['scope'] == 'root') { $_scope = SMARTY_ROOT_SCOPE; - } elseif ($_attr['scope'] == '\'global\'') { + } elseif ($_attr['scope'] == 'global') { $_scope = SMARTY_GLOBAL_SCOPE; } } diff --git a/libs/sysplugins/smarty_internal_compile_config_load.php b/libs/sysplugins/smarty_internal_compile_config_load.php index 0dd1ba82..199e9c4e 100644 --- a/libs/sysplugins/smarty_internal_compile_config_load.php +++ b/libs/sysplugins/smarty_internal_compile_config_load.php @@ -1,25 +1,25 @@ compiler = $compiler; @@ -36,13 +36,13 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase { } $scope = '$_smarty_tpl->smarty'; if (isset($_attr['scope'])) { - if ($_attr['scope'] == '\'local\'') { + $_attr['scope'] = trim($_attr['scope'], "'\""); + if ($_attr['scope'] == 'local') { $scope = '$_smarty_tpl'; - } elseif ($_attr['scope'] == '\'parent\'') { + } elseif ($_attr['scope'] == 'parent') { $scope = '$_smarty_tpl->parent'; } } - // create config object $_output = "smarty, \$_smarty_tpl);"; $_output .= "\$_config->loadConfigVars($section, $scope); ?>"; @@ -50,4 +50,4 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase { } } -?> +?> \ No newline at end of file diff --git a/libs/sysplugins/smarty_internal_compile_extends.php b/libs/sysplugins/smarty_internal_compile_extends.php index fca17422..f07e80d9 100644 --- a/libs/sysplugins/smarty_internal_compile_extends.php +++ b/libs/sysplugins/smarty_internal_compile_extends.php @@ -67,7 +67,7 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase { $compiler->template->template_source = $_template->getTemplateSource(); $compiler->template->template_filepath = $_template->getTemplateFilepath(); $compiler->abort_and_recompile = true; - return ' '; + return ''; } protected function saveBlockData($block_content, $block_tag, $template) diff --git a/libs/sysplugins/smarty_internal_compile_include.php b/libs/sysplugins/smarty_internal_compile_include.php index d2f7484a..89b451e3 100644 --- a/libs/sysplugins/smarty_internal_compile_include.php +++ b/libs/sysplugins/smarty_internal_compile_include.php @@ -40,13 +40,13 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase { // needs code for cached page but no cache file $tpl->caching = 9999; } - if ($this->compiler->template->mustCompile) { + if ($this->compiler->template->mustCompile) { // make sure whole chain gest compiled $tpl->mustCompile = true; } if ($tpl->resource_object->usesCompiler && $tpl->isExisting()) { // get compiled code - $compiled_tpl = $tpl->getCompiledTemplate(); + $compiled_tpl = $tpl->getCompiledTemplate(); // merge compiled code for {function} tags $compiler->template->properties['function'] = array_merge($compiler->template->properties['function'], $tpl->properties['function']); // merge filedependency by evaluating header code @@ -77,11 +77,12 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase { $_parent_scope = SMARTY_LOCAL_SCOPE; if (isset($_attr['scope'])) { - if ($_attr['scope'] == '\'parent\'') { + $_attr['scope'] = trim($_attr['scope'], "'\""); + if ($_attr['scope'] == 'parent') { $_parent_scope = SMARTY_PARENT_SCOPE; - } elseif ($_attr['scope'] == '\'root\'') { + } elseif ($_attr['scope'] == 'root') { $_parent_scope = SMARTY_ROOT_SCOPE; - } elseif ($_attr['scope'] == '\'global\'') { + } elseif ($_attr['scope'] == 'global') { $_parent_scope = SMARTY_GLOBAL_SCOPE; } } @@ -103,13 +104,13 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase { $_cache_lifetime = 'null'; } if (isset($_attr['nocache'])) { - if ($_attr['nocache'] == 'true') { + if (trim($_attr['nocache'], "'\"") == 'true') { $this->compiler->tag_nocache = true; $_caching = SMARTY_CACHING_OFF; } } if (isset($_attr['caching'])) { - if ($_attr['caching'] == 'true') { + if (trim($_attr['caching'], "'\"") == 'true') { $_caching = SMARTY_CACHING_LIFETIME_CURRENT; } else { $this->compiler->tag_nocache = true; @@ -128,7 +129,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase { $_output .= "\$_template->assign('$_key',$_value);"; } } else { - $this->compiler->trigger_template_error('variable passing not allowed in parent/global scope'); + $this->compiler->trigger_template_error('variable passing not allowed in parent/global scope', $this->compiler->lex->taglineno); } } // was there an assign attribute @@ -152,4 +153,4 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase { } } -?> +?> \ No newline at end of file