mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 19:34:27 +02:00
- bugfix {block.. hide} did not work as nested child (Forum Topic 22216)
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
===== trunk =====
|
===== trunk =====
|
||||||
|
30.06.2012
|
||||||
|
- bugfix {block.. hide} did not work as nested child (Forum Topic 22216)
|
||||||
|
|
||||||
25.06.2012
|
25.06.2012
|
||||||
- bugfix the default plugin handler did not allow static class methods for modifier (issue 85)
|
- bugfix the default plugin handler did not allow static class methods for modifier (issue 85)
|
||||||
|
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Block
|
* Smarty Internal Plugin Compile Block
|
||||||
*
|
*
|
||||||
@@ -24,6 +25,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
|||||||
* @see Smarty_Internal_CompileBase
|
* @see Smarty_Internal_CompileBase
|
||||||
*/
|
*/
|
||||||
public $required_attributes = array('name');
|
public $required_attributes = array('name');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute definition: Overwrites base class.
|
* Attribute definition: Overwrites base class.
|
||||||
*
|
*
|
||||||
@@ -31,6 +33,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
|||||||
* @see Smarty_Internal_CompileBase
|
* @see Smarty_Internal_CompileBase
|
||||||
*/
|
*/
|
||||||
public $shorttag_order = array('name', 'hide');
|
public $shorttag_order = array('name', 'hide');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attribute definition: Overwrites base class.
|
* Attribute definition: Overwrites base class.
|
||||||
*
|
*
|
||||||
@@ -46,8 +49,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
|||||||
* @param object $compiler compiler object
|
* @param object $compiler compiler object
|
||||||
* @return boolean true
|
* @return boolean true
|
||||||
*/
|
*/
|
||||||
public function compile($args, $compiler)
|
public function compile($args, $compiler) {
|
||||||
{
|
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
$save = array($_attr, $compiler->parser->current_buffer, $compiler->nocache, $compiler->smarty->merge_compiled_includes, $compiler->merged_templates, $compiler->smarty->merged_templates_func, $compiler->template->properties, $compiler->template->has_nocache_code);
|
$save = array($_attr, $compiler->parser->current_buffer, $compiler->nocache, $compiler->smarty->merge_compiled_includes, $compiler->merged_templates, $compiler->smarty->merged_templates_func, $compiler->template->properties, $compiler->template->has_nocache_code);
|
||||||
@@ -73,8 +75,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
|||||||
* @param object $template template object
|
* @param object $template template object
|
||||||
* @param string $filepath filepath of template source
|
* @param string $filepath filepath of template source
|
||||||
*/
|
*/
|
||||||
public static function saveBlockData($block_content, $block_tag, $template, $filepath)
|
public 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);
|
$_ldl = preg_quote($template->smarty->left_delimiter);
|
||||||
if ($template->smarty->auto_literal) {
|
if ($template->smarty->auto_literal) {
|
||||||
@@ -89,10 +90,11 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
|||||||
$_name = trim($_match[3], '\'"');
|
$_name = trim($_match[3], '\'"');
|
||||||
if ($_match[8] != 'hide' || isset($template->block_data[$_name])) { // replace {$smarty.block.child}
|
if ($_match[8] != 'hide' || isset($template->block_data[$_name])) { // replace {$smarty.block.child}
|
||||||
// do we have {$smart.block.child} in nested {block} tags?
|
// do we have {$smart.block.child} in nested {block} tags?
|
||||||
if (0 != preg_match_all("!({$_ldl}{$al}block\s+)(name=)?(\w+|'.*'|\".*\")([\s\S]*?{$_rdl})([\s\S]*?)({$_ldl}{$al}\\\$smarty\.block\.child{$_rdl})([\s\S]*?{$_ldl}{$al}/block{$_rdl})!", $block_content, $_match2)) {
|
if (0 != preg_match_all("!({$_ldl}{$al}block\s+)(name=)?(\w+|'.*'|\".*\")([\s\S]*?)(hide)?(\s*{$_rdl})([\s\S]*?)({$_ldl}{$al}\\\$smarty\.block\.child{$_rdl})([\s\S]*?{$_ldl}{$al}/block{$_rdl})!", $block_content, $_match2)) {
|
||||||
foreach($_match2[3] as $name) {
|
foreach ($_match2[3] as $key => $name) {
|
||||||
// get it's replacement
|
// get it's replacement
|
||||||
$_name2 = trim($name, '\'"');
|
$_name2 = trim($name, '\'"');
|
||||||
|
if ($_match2[5][$key] != 'hide' || isset($template->block_data[$_name2])) {
|
||||||
if (isset($template->block_data[$_name2])) {
|
if (isset($template->block_data[$_name2])) {
|
||||||
$replacement = $template->block_data[$_name2]['source'];
|
$replacement = $template->block_data[$_name2]['source'];
|
||||||
} else {
|
} else {
|
||||||
@@ -102,6 +104,10 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
|||||||
$search = array("%({$_ldl}{$al}block[\s\S]*?{$name}[\s\S]*?{$_rdl})([\s\S]*?)({$_ldl}{$al}\\\$smarty\.block\.child{$_rdl})([\s\S]*?)({$_ldl}{$al}/block{$_rdl})%", "/<2F><><EFBFBD>child<6C><64><EFBFBD>/");
|
$search = array("%({$_ldl}{$al}block[\s\S]*?{$name}[\s\S]*?{$_rdl})([\s\S]*?)({$_ldl}{$al}\\\$smarty\.block\.child{$_rdl})([\s\S]*?)({$_ldl}{$al}/block{$_rdl})%", "/<2F><><EFBFBD>child<6C><64><EFBFBD>/");
|
||||||
$replace = array('\2<><32><EFBFBD>child<6C><64><EFBFBD>\4', $replacement);
|
$replace = array('\2<><32><EFBFBD>child<6C><64><EFBFBD>\4', $replacement);
|
||||||
$block_content = preg_replace($search, $replace, $block_content);
|
$block_content = preg_replace($search, $replace, $block_content);
|
||||||
|
} else {
|
||||||
|
// remove hidden blocks
|
||||||
|
$block_content = preg_replace("%({$_ldl}{$al}block[\s\S]*?{$name}[\s\S]*?{$_rdl}[\s\S]*?{$_ldl}{$al}/block{$_rdl})%", '', $block_content);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// do we have not nested {$smart.block.child}
|
// do we have not nested {$smart.block.child}
|
||||||
@@ -146,8 +152,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
|
|||||||
* @param string $_name optional name of child block
|
* @param string $_name optional name of child block
|
||||||
* @return string compiled code of schild block
|
* @return string compiled code of schild block
|
||||||
*/
|
*/
|
||||||
public static function compileChildBlock($compiler, $_name = null)
|
public static function compileChildBlock($compiler, $_name = null) {
|
||||||
{
|
|
||||||
$_output = '';
|
$_output = '';
|
||||||
// if called by {$smarty.block.child} we must search the name of enclosing {block}
|
// if called by {$smarty.block.child} we must search the name of enclosing {block}
|
||||||
if ($_name == null) {
|
if ($_name == null) {
|
||||||
@@ -231,8 +236,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase {
|
|||||||
* @param object $compiler compiler object
|
* @param object $compiler compiler object
|
||||||
* @return string compiled code
|
* @return string compiled code
|
||||||
*/
|
*/
|
||||||
public function compile($args, $compiler)
|
public function compile($args, $compiler) {
|
||||||
{
|
|
||||||
$compiler->has_code = true;
|
$compiler->has_code = true;
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
|
Reference in New Issue
Block a user