From cf50ede71ab7aab8e0c25af4cedd5afcd90af00f Mon Sep 17 00:00:00 2001 From: "uwe.tews@googlemail.com" Date: Sat, 11 Dec 2010 13:27:14 +0000 Subject: [PATCH] - bugfix nested block tags in template inheritance child templates did not work correctly - bugfix {$smarty.current_dir} in child template did not point to dir of child template --- change_log.txt | 4 ++++ libs/sysplugins/smarty_internal_compile_block.php | 11 ++++++----- ...y_internal_compile_private_special_variable.php | 14 ++------------ 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/change_log.txt b/change_log.txt index a4e8aff8..130a5b14 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,8 @@ ===== SVN trunk ===== +11/12/2010 +- bugfix nested block tags in template inheritance child templates did not work correctly +- bugfix {$smarty.current_dir} in child template did not point to dir of child template + 06/12/2010 - bugfix getTemplateVars() should return 'null' instead dropping E_NOTICE on an unassigned variable diff --git a/libs/sysplugins/smarty_internal_compile_block.php b/libs/sysplugins/smarty_internal_compile_block.php index 7f622165..b1b64374 100644 --- a/libs/sysplugins/smarty_internal_compile_block.php +++ b/libs/sysplugins/smarty_internal_compile_block.php @@ -46,7 +46,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase { static function saveBlockData($block_content, $block_tag, $template, $filepath) { - $_rdl = preg_quote($template->smarty->right_delimiter); + $_rdl = preg_quote($template->smarty->right_delimiter); $_ldl = preg_quote($template->smarty->left_delimiter); if (0 == preg_match("!({$_ldl}block\s+)(name=)?(\w+|'.*'|\".*\")(\s*?)?((append|prepend|nocache)(=true)?)?(\s*{$_rdl})!", $block_tag, $_match)) { @@ -85,7 +85,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase { $template->block_data[$_name]['mode'] = 'replace'; } $template->block_data[$_name]['file'] = $filepath; - } + } } static function compileChildBlock ($compiler, $_name = null) @@ -100,6 +100,8 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase { break; } } + // flag that child is already compile by {$smarty.block.child} inclusion + $compiler->template->block_data[$_name]['compiled'] = true; } if ($_name == null) { $compiler->trigger_template_error('{$smarty.block.child} used out of context', $this->compiler->lex->taglineno); @@ -108,7 +110,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase { if (!isset($compiler->template->block_data[$_name])) { return ''; } - $_tpl = new Smarty_Internal_template ('eval:' . $compiler->template->block_data[$_name]['source'], $compiler->smarty, $compiler->template, $compiler->template->cache_id, + $_tpl = new Smarty_Internal_template ('eval:' . $compiler->template->block_data[$_name]['source'], $compiler->smarty, $compiler->template, $compiler->template->cache_id, $compiler->template->compile_id = null, $compiler->template->caching, $compiler->template->cache_lifetime); $_tpl->properties['nocache_hash'] = $compiler->template->properties['nocache_hash']; $_tpl->template_filepath = $compiler->template->block_data[$_name]['file']; @@ -141,7 +143,6 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase { } } unset($_tpl); - $compiler->template->block_data[$_name]['compiled'] = true; return $_output; } @@ -172,7 +173,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase { } else { $_output = $compiler->parser->current_buffer->to_smarty_php(); unset ($compiler->template->block_data[$_name]['compiled']); - } + } // reset flags $compiler->parser->current_buffer = $saved_data[1]; $compiler->nocache = $saved_data[2]; diff --git a/libs/sysplugins/smarty_internal_compile_private_special_variable.php b/libs/sysplugins/smarty_internal_compile_private_special_variable.php index 22fd9517..f9a8535c 100644 --- a/libs/sysplugins/smarty_internal_compile_private_special_variable.php +++ b/libs/sysplugins/smarty_internal_compile_private_special_variable.php @@ -56,21 +56,11 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C break; case 'template': - if ($compiler->smarty->inheritance) { - $ptr = $compiler->template->parent; - } else { - $ptr = $compiler->template; - } - $_template_name = $ptr->template_resource; + $_template_name = $compiler->template->template_resource; return "'$_template_name'"; case 'current_dir': - if ($compiler->smarty->inheritance) { - $ptr = $compiler->template->parent; - } else { - $ptr = $compiler->template; - } - $_template_dir_name = dirname($ptr->getTemplateFilepath()); + $_template_dir_name = dirname($compiler->template->getTemplateFilepath()); return "'$_template_dir_name'"; case 'version':