From f149804f3e965d34a7935121bcfa277490a2b4e6 Mon Sep 17 00:00:00 2001 From: "Uwe.Tews" Date: Thu, 12 Nov 2009 21:32:46 +0000 Subject: [PATCH] - added scope to Smarty variables in the {block} tag compiler --- change_log.txt | 1 + libs/sysplugins/smarty_internal_compile_extend.php | 6 +++--- libs/sysplugins/smarty_internal_resource_extend.php | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/change_log.txt b/change_log.txt index 35cb84dc..a580ea04 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,5 +1,6 @@ 11/12/2009 - fixed variable filenames in {include_php} and {insert} +- added scope to Smarty variables in the {block} tag compiler 11/11/2009 - fixed {foreachelse}, {forelse}, {sectionelse} compiled code at nocache variables diff --git a/libs/sysplugins/smarty_internal_compile_extend.php b/libs/sysplugins/smarty_internal_compile_extend.php index d4b06cb9..63098b6d 100644 --- a/libs/sysplugins/smarty_internal_compile_extend.php +++ b/libs/sysplugins/smarty_internal_compile_extend.php @@ -43,20 +43,20 @@ class Smarty_Internal_Compile_Extend extends Smarty_Internal_CompileBase { 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]); + $this->saveBlockData($block_content, $s[0][$i][0],$compiler->template); } $compiler->template->template_source = $_template->getTemplateSource(); $compiler->abort_and_recompile = true; return ' '; } - protected function saveBlockData($block_content, $block_tag) + protected function saveBlockData($block_content, $block_tag,$template) { if (0 == preg_match('/(.?)(name=)([^ ]*)/', $block_tag, $_match)) { $this->compiler->trigger_template_error("\"" . $block_tag . "\" missing name attribute"); } else { // compile block content - $_tpl = $this->smarty->createTemplate('string:' . $block_content); + $_tpl = $this->smarty->createTemplate('string:' . $block_content,null,null,$template); $_tpl->template_filepath = $this->compiler->template->getTemplateFilepath(); // $_tpl->suppressFileDependency = true; $_compiled_content = $_tpl->getCompiledTemplate(); diff --git a/libs/sysplugins/smarty_internal_resource_extend.php b/libs/sysplugins/smarty_internal_resource_extend.php index 36878deb..a2eaa040 100644 --- a/libs/sysplugins/smarty_internal_resource_extend.php +++ b/libs/sysplugins/smarty_internal_resource_extend.php @@ -95,7 +95,7 @@ class Smarty_Internal_Resource_Extend { for ($_i = 0; $_i < $_block_count; $_i++) { $_block_content = str_replace($this->smarty->left_delimiter . '$smarty.parent' . $this->smarty->right_delimiter, '%%%%SMARTY_PARENT%%%%', substr($_content, $_open[0][$_i][1] + strlen($_open[0][$_i][0]), $_close[0][$_i][1] - $_open[0][$_i][1] - strlen($_open[0][$_i][0]))); - $this->saveBlockData($_block_content, $_open[0][$_i][0]); + $this->saveBlockData($_block_content, $_open[0][$_i][0],$this->template); } } else { $template->template_source = $_content; @@ -103,13 +103,13 @@ class Smarty_Internal_Resource_Extend { } } } - protected function saveBlockData($block_content, $block_tag) + protected function saveBlockData($block_content, $block_tag,$template) { if (0 == preg_match('/(.?)(name=)([^ ]*)/', $block_tag, $_match)) { $this->smarty->trigger_error("\"" . $block_tag . "\" missing name attribute"); } else { // compile block content - $_tpl = $this->smarty->createTemplate('string:' . $block_content); + $_tpl = $this->smarty->createTemplate('string:' . $block_content,null,null,$template); $_tpl->template_filepath = $this->template->getTemplateFilepath(); // $_tpl->suppressFileDependency = true; $_compiled_content = $_tpl->getCompiledTemplate();