diff --git a/change_log.txt b/change_log.txt index 96e935a4..61f236e4 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,6 +1,8 @@ ===== trunk ===== 09.01.2013 - bugfix compilation did fail when a prefilter did modify an {extends} tag (Forum Topic 23966) +- bugfix template inheritance could fail if nested {block} tags in childs did contain {$smarty.block.child} (Issue #127) +- bugfix template inheritance could fail if {block} tags in childs did have similar name as used plugins (Issue #128) 06.01.2013 - Allow '://' URL syntax in template names of stream resources (Issue #129) diff --git a/libs/sysplugins/smarty_internal_compile_block.php b/libs/sysplugins/smarty_internal_compile_block.php index 11a67998..f760e551 100644 --- a/libs/sysplugins/smarty_internal_compile_block.php +++ b/libs/sysplugins/smarty_internal_compile_block.php @@ -89,8 +89,8 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase { } else { $_name = trim($_match[3], '\'"'); if ($_match[8] != 'hide' || isset($template->block_data[$_name])) { // replace {$smarty.block.child} - // do we have {$smart.block.child} in nested {block} tags? - if (0 != preg_match_all("!({$_ldl}{$al}block\s+)(name=)?(\w+|'.*'|\".*\")([\s\S]*?)(hide)?(\s*{$_rdl})([\s\S]*?)({$_ldl}{$al}\\\$smarty\.block\.child\s*{$_rdl})([\s\S]*?{$_ldl}{$al}/block\s*{$_rdl})!", $block_content, $_match2)) { + // get nested block tags + if (0 != preg_match_all("!({$_ldl}{$al}block\s+)(name=)?(\w+|'.*'|\".*\")([\s\S]*?)(hide)?(\s*{$_rdl})([\s\S]*?)(.*)?({$_ldl}{$al}/block\s*{$_rdl})!", $block_content, $_match2)) { foreach ($_match2[3] as $key => $name) { // get it's replacement $_name2 = trim($name, '\'"'); @@ -101,12 +101,17 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase { $replacement = ''; } // replace {$smarty.block.child} tag - $search = array("!({$_ldl}{$al}block[\s\S]*?{$name}[\s\S]*?{$_rdl})([\s\S]*?)({$_ldl}{$al}\\\$smarty\.block\.child\s*{$_rdl})([\s\S]*?)({$_ldl}{$al}/block\s*{$_rdl})!", "/§§§child§§§/"); - $replace = array('\2§§§child§§§\4', $replacement); - $block_content = preg_replace($search, $replace, $block_content); + if (preg_match("!{$_ldl}{$al}\\\$smarty\.block\.child\s*{$_rdl}!",$_match2[7][$key])) { + $replacement = preg_replace("!({$_ldl}{$al}\\\$smarty\.block\.child\s*{$_rdl})!", $replacement, $_match2[7][$key]); + $block_content = preg_replace("!(({$_ldl}{$al}block)(.*)?{$name}(.*)?({$_rdl}[\s\S]*?{$_ldl}{$al}/block\s*{$_rdl}))!", $replacement, $block_content); + } + if (preg_match("!{$_ldl}{$al}\\\$smarty\.block\.child\s*{$_rdl}!",$_match2[8][$key])) { + $replacement = preg_replace("!{$_ldl}{$al}\\\$smarty\.block\.child\s*{$_rdl}!", $replacement, $_match2[8][$key]); + $block_content = preg_replace("!(({$_ldl}{$al}block)(.*)?{$name}(.*)?({$_rdl})(.*)?({$_ldl}{$al}/block\s*{$_rdl}))!", $replacement, $block_content); + } } else { // remove hidden blocks - $block_content = preg_replace("!({$_ldl}{$al}block[\s\S]*?{$name}[\s\S]*?{$_rdl}[\s\S]*?{$_ldl}{$al}/block\s*{$_rdl})!", '', $block_content); + $block_content = preg_replace("!(({$_ldl}{$al}block)(.*)?{$name}(.*)?({$_rdl}[\s\S]*?{$_ldl}{$al}/block\s*{$_rdl}))!", '', $block_content); } } }