mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 03:14:27 +02:00
- added $smarty->_tag_stack for tracing block tag hierarchy
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
09/02/2010
|
||||||
|
- added $smarty->_tag_stack for tracing block tag hierarchy
|
||||||
|
|
||||||
08/02/2010
|
08/02/2010
|
||||||
- bugfix use template fullpath at <20>smarty->cache->clear(...), $smarty->clear_cache(....)
|
- bugfix use template fullpath at <20>smarty->cache->clear(...), $smarty->clear_cache(....)
|
||||||
- bugfix of cache filename on extended templates when force_compile=true
|
- bugfix of cache filename on extended templates when force_compile=true
|
||||||
|
@@ -222,6 +222,8 @@ class Smarty extends Smarty_Internal_Data {
|
|||||||
public $smarty = null;
|
public $smarty = null;
|
||||||
// block data at template inheritance
|
// block data at template inheritance
|
||||||
public $block_data = array();
|
public $block_data = array();
|
||||||
|
// block tag hierarchy
|
||||||
|
public $_tag_stack = array();
|
||||||
// generate deprecated function call notices?
|
// generate deprecated function call notices?
|
||||||
public $deprecation_notices = true;
|
public $deprecation_notices = true;
|
||||||
|
|
||||||
|
@@ -45,9 +45,9 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
|
|||||||
$this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache;
|
$this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache;
|
||||||
// compile code
|
// compile code
|
||||||
if (is_array($function)) {
|
if (is_array($function)) {
|
||||||
$output = '<?php $_block_repeat=true; call_user_func_array(array(\'' . $function[0] . '\',\'' . $function[1] . '\'),(array(' . $_params . ', null, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl));while ($_block_repeat) { ob_start();?>';
|
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; call_user_func_array(array('{$function[0]}','{$function[1]}'),(array({$_params}, null, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl));while (\$_block_repeat) { ob_start();?>";
|
||||||
} else {
|
} else {
|
||||||
$output = '<?php $_block_repeat=true; ' . $function . '(' . $_params . ', null, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl);while ($_block_repeat) { ob_start();?>';
|
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; {$function}({$_params}, null, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl);while (\$_block_repeat) { ob_start();?>";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// must endblock be nocache?
|
// must endblock be nocache?
|
||||||
@@ -60,10 +60,9 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
|
|||||||
$this->compiler->has_output = true;
|
$this->compiler->has_output = true;
|
||||||
// compile code
|
// compile code
|
||||||
if (is_array($function)) {
|
if (is_array($function)) {
|
||||||
var_dump('error');
|
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false; echo call_user_func_array(array('{$function[0]}','{$function[1]}'),(array({$_params}, \$_block_content, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl)); } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
|
||||||
$output = '<?php $_block_content = ob_get_clean(); $_block_repeat=false; echo call_user_func_array(array(\'' . $function[0] . '\',\'' . $function[1] . '\'),(array(' . $_params . ', $_block_content, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl)); }?>';
|
|
||||||
} else {
|
} else {
|
||||||
$output = '<?php $_block_content = ob_get_clean(); $_block_repeat=false; echo ' . $function . '(' . $_params . ', $_block_content, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl); }?>';
|
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false; echo {$function}({$_params}, \$_block_content, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl); } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $output."\n";
|
return $output."\n";
|
||||||
|
@@ -43,14 +43,15 @@ class Smarty_Internal_Compile_Private_Object_Block_Function extends Smarty_Inter
|
|||||||
|
|
||||||
$this->_open_tag($tag . '->' . $methode, $_params);
|
$this->_open_tag($tag . '->' . $methode, $_params);
|
||||||
// compile code
|
// compile code
|
||||||
$output = '<?php $_block_repeat=true; $_smarty_tpl->smarty->registered_objects[\'' . $tag . '\'][0]->' . $methode . '(' . $_params . ', null, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl);while ($_block_repeat) { ob_start();?>';
|
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}->{$methode}', {$_params}); \$_block_repeat=true; \$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$methode}({$_params}, null, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl);while (\$_block_repeat) { ob_start();?>";
|
||||||
} else {
|
} else {
|
||||||
|
$base_tag = substr($tag, 0, -5);
|
||||||
// closing tag of block plugin
|
// closing tag of block plugin
|
||||||
$_params = $this->_close_tag(substr($tag, 0, -5) . '->' . $methode);
|
$_params = $this->_close_tag($base_tag . '->' . $methode);
|
||||||
// This tag does create output
|
// This tag does create output
|
||||||
$this->compiler->has_output = true;
|
$this->compiler->has_output = true;
|
||||||
// compile code
|
// compile code
|
||||||
$output = '<?php $_block_content = ob_get_contents(); ob_end_clean(); $_block_repeat=false; echo $_smarty_tpl->smarty->registered_objects[\'' . substr($tag, 0, -5) . '\'][0]->' . $methode . '(' . $_params . ', $_block_content, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl); }?>';
|
$output = "<?php \$_block_content = ob_get_contents(); ob_end_clean(); \$_block_repeat=false; echo \$_smarty_tpl->smarty->registered_objects['{$base_tag}'][0]->{$methode}({$_params}, \$_block_content, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl); } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
|
||||||
}
|
}
|
||||||
return $output."\n";
|
return $output."\n";
|
||||||
}
|
}
|
||||||
|
@@ -46,11 +46,11 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C
|
|||||||
$function = $compiler->smarty->registered_plugins['block'][$tag][0];
|
$function = $compiler->smarty->registered_plugins['block'][$tag][0];
|
||||||
// compile code
|
// compile code
|
||||||
if (!is_array($function)) {
|
if (!is_array($function)) {
|
||||||
$output = '<?php $_block_repeat=true; ' . $function . '(' . $_params . ', null, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl);while ($_block_repeat) { ob_start();?>';
|
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; {$function}({$_params}, null, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl);while (\$_block_repeat) { ob_start();?>";
|
||||||
} else if (is_object($function[0])) {
|
} else if (is_object($function[0])) {
|
||||||
$output = '<?php $_block_repeat=true; call_user_func_array($_smarty_tpl->smarty->registered_plugins[\'block\'][\'' . $tag . '\'][0],array(' . $_params . ', null, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl));while ($_block_repeat) { ob_start();?>';
|
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; call_user_func_array(\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0],array({$_params}, null, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl));while (\$_block_repeat) { ob_start();?>";
|
||||||
} else {
|
} else {
|
||||||
$output = '<?php $_block_repeat=true; call_user_func_array(array(\'' . $function[0] . '\',\'' . $function[1] . '\'),array(' . $_params . ', null, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl));while ($_block_repeat) { ob_start();?>';
|
$output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; call_user_func_array(array({$function[0]}','{$function[1]}'),array({$_params}, null, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl));while (\$_block_repeat) { ob_start();?>";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// must endblock be nocache?
|
// must endblock be nocache?
|
||||||
@@ -65,11 +65,11 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C
|
|||||||
$function = $compiler->smarty->registered_plugins['block'][$base_tag][0];
|
$function = $compiler->smarty->registered_plugins['block'][$base_tag][0];
|
||||||
// compile code
|
// compile code
|
||||||
if (!is_array($function)) {
|
if (!is_array($function)) {
|
||||||
$output = '<?php $_block_content = ob_get_clean(); $_block_repeat=false; echo ' . $function . '(' . $_params . ', $_block_content, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl); }?>';
|
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false; echo {$function}({$_params}, \$_block_content, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl); } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
|
||||||
} else if (is_object($function[0])) {
|
} else if (is_object($function[0])) {
|
||||||
$output = '<?php $_block_content = ob_get_clean(); $_block_repeat=false; echo call_user_func_array($_smarty_tpl->smarty->registered_plugins[\'block\'][\'' . $base_tag . '\'][0],array(' . $_params . ', $_block_content, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl)); }?>';
|
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false; echo call_user_func_array(\$_smarty_tpl->smarty->registered_plugins['block']['{$base_tag}'][0],array({$_params}, \$_block_content, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl)); } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
|
||||||
} else {
|
} else {
|
||||||
$output = '<?php $_block_content = ob_get_clean(); $_block_repeat=false; echo call_user_func_array(array(\'' . $function[0] . '\',\'' . $function[1] . '\'),array(' . $_params . ', $_block_content, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl)); }?>';
|
$output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false; echo call_user_func_array(array('{$function[0]}','{$function[1]}'),array({$_params}, \$_block_content, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl)); } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $output."\n";
|
return $output."\n";
|
||||||
|
@@ -21,7 +21,7 @@ class Smarty_Internal_TemplateCompilerBase {
|
|||||||
// tag stack
|
// tag stack
|
||||||
public $_tag_stack = array();
|
public $_tag_stack = array();
|
||||||
// current template
|
// current template
|
||||||
public $template = null;
|
public $template = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize compiler
|
* Initialize compiler
|
||||||
@@ -175,6 +175,9 @@ class Smarty_Internal_TemplateCompilerBase {
|
|||||||
foreach ($this->smarty->plugin_search_order as $plugin_type) {
|
foreach ($this->smarty->plugin_search_order as $plugin_type) {
|
||||||
if ($plugin_type == 'compiler' && $this->smarty->loadPlugin('smarty_compiler_' . $tag)) {
|
if ($plugin_type == 'compiler' && $this->smarty->loadPlugin('smarty_compiler_' . $tag)) {
|
||||||
$plugin = 'smarty_compiler_' . $tag;
|
$plugin = 'smarty_compiler_' . $tag;
|
||||||
|
if (is_callable($plugin)) {
|
||||||
|
return call_user_func_array($plugin, array($args, $this->smarty));
|
||||||
|
}
|
||||||
if (class_exists($plugin, false)) {
|
if (class_exists($plugin, false)) {
|
||||||
$plugin = array(new $plugin, 'compile');
|
$plugin = array(new $plugin, 'compile');
|
||||||
}
|
}
|
||||||
@@ -212,6 +215,9 @@ class Smarty_Internal_TemplateCompilerBase {
|
|||||||
}
|
}
|
||||||
if ($this->smarty->loadPlugin('smarty_compiler_' . $tag)) {
|
if ($this->smarty->loadPlugin('smarty_compiler_' . $tag)) {
|
||||||
$plugin = 'smarty_compiler_' . $tag;
|
$plugin = 'smarty_compiler_' . $tag;
|
||||||
|
if (is_callable($plugin)) {
|
||||||
|
return call_user_func_array($plugin, array($args, $this->smarty));
|
||||||
|
}
|
||||||
if (class_exists($plugin, false)) {
|
if (class_exists($plugin, false)) {
|
||||||
$plugin = array(new $plugin, 'compile');
|
$plugin = array(new $plugin, 'compile');
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user