mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
- changed execution order. A variable filter does now run before modifiers on output of variables
- bugfix use always { and } as delimiter for debug.tpl
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
23/07/2010
|
||||
- changed execution order. A variable filter does now run before modifiers on output of variables
|
||||
- bugfix use always { and } as delimiter for debug.tpl
|
||||
|
||||
|
||||
22/07/2010
|
||||
- bugfix in templateExists() methode
|
||||
|
||||
|
@@ -23,32 +23,40 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
||||
{
|
||||
$this->compiler = $compiler;
|
||||
$this->smarty = $this->compiler->smarty;
|
||||
$this->required_attributes = array('modifier', 'params');
|
||||
$this->required_attributes = array('value', 'modifierlist');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
// check for registered modifier
|
||||
if (isset($compiler->smarty->registered_plugins['modifier'][$_attr['modifier']])) {
|
||||
$function = $compiler->smarty->registered_plugins['modifier'][$_attr['modifier']][0];
|
||||
if (!is_array($function)) {
|
||||
$output = "{$function}({$_attr['params']})";
|
||||
} else {
|
||||
if (is_object($function[0])) {
|
||||
$output = '$_smarty_tpl->smarty->registered_plugins[\'modifier\'][\'' . $_attr['modifier'] . '\'][0][0]->' . $function[1] . '(' . $_attr['params'] . ')';
|
||||
$_attr = $this->_get_attributes($args);
|
||||
$output = $_attr['value'];
|
||||
// loop over list of modifiers
|
||||
foreach ($_attr['modifierlist'] as $single_modifier) {
|
||||
$mod_array = explode (':', $single_modifier);
|
||||
$modifier = $mod_array[0];
|
||||
$mod_array[0] = $output;
|
||||
$params = implode(", ", $mod_array);
|
||||
// check for registered modifier
|
||||
if (isset($compiler->smarty->registered_plugins['modifier'][$modifier])) {
|
||||
$function = $compiler->smarty->registered_plugins['modifier'][$modifier][0];
|
||||
if (!is_array($function)) {
|
||||
$output = "{$function}({$params})";
|
||||
} else {
|
||||
$output = $function[0] . '::' . $function[1] . '(' . $_attr['params'] . ')';
|
||||
if (is_object($function[0])) {
|
||||
$output = '$_smarty_tpl->smarty->registered_plugins[\'modifier\'][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';
|
||||
} else {
|
||||
$output = $function[0] . '::' . $function[1] . '(' . $params . ')';
|
||||
}
|
||||
}
|
||||
// check for plugin modifier
|
||||
} else if ($function = $this->compiler->getPlugin($modifier, 'modifier')) {
|
||||
$output = "{$function}({$params})";
|
||||
// check if trusted PHP function
|
||||
} else if (is_callable($modifier)) {
|
||||
// check if modifier allowed
|
||||
if (!$this->compiler->template->security || $this->smarty->security_handler->isTrustedModifier($modifier, $this->compiler)) {
|
||||
$output = "{$modifier}({$params})";
|
||||
}
|
||||
} else {
|
||||
$this->compiler->trigger_template_error ("unknown modifier \"" . $modifier . "\"");
|
||||
}
|
||||
// check for plugin modifier
|
||||
} else if ($function = $this->compiler->getPlugin($_attr['modifier'], 'modifier')) {
|
||||
$output = "{$function}({$_attr['params']})";
|
||||
// check if trusted PHP function
|
||||
} else if (is_callable($_attr['modifier'])) {
|
||||
// check if modifier allowed
|
||||
if (!$this->compiler->template->security || $this->smarty->security_handler->isTrustedModifier($_attr['modifier'], $this->compiler)) {
|
||||
$output = "{$_attr['modifier']}({$_attr['params']})";
|
||||
}
|
||||
} else {
|
||||
$this->compiler->trigger_template_error ("unknown modifier \"" . $_attr['modifier'] . "\"");
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
||||
{
|
||||
$this->compiler = $compiler;
|
||||
$this->required_attributes = array('value');
|
||||
$this->optional_attributes = array('assign', 'nocache', 'filter', 'nofilter');
|
||||
$this->optional_attributes = array('assign', 'nocache', 'filter', 'nofilter', 'modifierlist');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
|
||||
@@ -54,12 +54,10 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
||||
$output = $_attr['value'];
|
||||
}
|
||||
if (!isset($_attr['nofilter']) && isset($this->compiler->smarty->default_modifiers)) {
|
||||
foreach ($this->compiler->smarty->default_modifiers as $default_modifier) {
|
||||
$mod_array = explode (':', $default_modifier);
|
||||
$modifier = $mod_array[0];
|
||||
$mod_array[0] = $output;
|
||||
$output = $this->compiler->compileTag('private_modifier', array('modifier' => $modifier, 'params' => implode(", ", $mod_array)));
|
||||
}
|
||||
$output = $this->compiler->compileTag('private_modifier', array('modifierlist' => $this->compiler->smarty->default_modifiers, 'value' => $output));
|
||||
}
|
||||
if (isset($_attr['modifierlist'])) {
|
||||
$output = $this->compiler->compileTag('private_modifier', array('modifierlist' => $_attr['modifierlist'], 'value' => $output));
|
||||
}
|
||||
$output = '<?php echo ' . $output . ';?>';
|
||||
}
|
||||
|
@@ -1,24 +1,24 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Debug
|
||||
*
|
||||
* Class to collect data for the Smarty Debugging Consol
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Debug
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
* Smarty Internal Plugin Debug
|
||||
*
|
||||
* Class to collect data for the Smarty Debugging Consol
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Debug
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
/**
|
||||
* Smarty Internal Plugin Debug Class
|
||||
*/
|
||||
* Smarty Internal Plugin Debug Class
|
||||
*/
|
||||
class Smarty_Internal_Debug extends Smarty_Internal_Data {
|
||||
// template data
|
||||
static $template_data = array();
|
||||
|
||||
/**
|
||||
* Start logging of compile time
|
||||
*/
|
||||
* Start logging of compile time
|
||||
*/
|
||||
public static function start_compile($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
@@ -26,8 +26,8 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data {
|
||||
}
|
||||
|
||||
/**
|
||||
* End logging of compile time
|
||||
*/
|
||||
* End logging of compile time
|
||||
*/
|
||||
public static function end_compile($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
@@ -35,8 +35,8 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data {
|
||||
}
|
||||
|
||||
/**
|
||||
* Start logging of render time
|
||||
*/
|
||||
* Start logging of render time
|
||||
*/
|
||||
public static function start_render($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
@@ -44,8 +44,8 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data {
|
||||
}
|
||||
|
||||
/**
|
||||
* End logging of compile time
|
||||
*/
|
||||
* End logging of compile time
|
||||
*/
|
||||
public static function end_render($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
@@ -53,8 +53,8 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data {
|
||||
}
|
||||
|
||||
/**
|
||||
* Start logging of cache time
|
||||
*/
|
||||
* Start logging of cache time
|
||||
*/
|
||||
public static function start_cache($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
@@ -62,16 +62,16 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data {
|
||||
}
|
||||
|
||||
/**
|
||||
* End logging of cache time
|
||||
*/
|
||||
* End logging of cache time
|
||||
*/
|
||||
public static function end_cache($template)
|
||||
{
|
||||
$key = self::get_key($template);
|
||||
self::$template_data[$key]['cache_time'] += microtime(true) - self::$template_data[$key]['start_time'];
|
||||
}
|
||||
/**
|
||||
* Opens a window for the Smarty Debugging Consol and display the data
|
||||
*/
|
||||
* Opens a window for the Smarty Debugging Consol and display the data
|
||||
*/
|
||||
public static function display_debug($smarty)
|
||||
{
|
||||
// prepare information of assigned variables
|
||||
@@ -79,6 +79,10 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data {
|
||||
ksort($_assigned_vars);
|
||||
$_config_vars = $smarty->config_vars;
|
||||
ksort($_config_vars);
|
||||
$ldelim = $smarty->left_delimiter;
|
||||
$rdelim = $smarty->right_delimiter;
|
||||
$smarty->left_delimiter = '{';
|
||||
$smarty->right_delimiter = '}';
|
||||
$_template = new Smarty_Template ($smarty->debug_tpl, $smarty);
|
||||
$_template->caching = false;
|
||||
$_template->force_compile = false;
|
||||
@@ -90,13 +94,15 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data {
|
||||
$_template->assign('config_vars', $_config_vars);
|
||||
$_template->assign('execution_time', microtime(true) - $smarty->start_time);
|
||||
echo $smarty->fetch($_template);
|
||||
$smarty->left_delimiter = $ldelim;
|
||||
$smarty->right_delimiter = $rdelim;
|
||||
}
|
||||
|
||||
/**
|
||||
* get_key
|
||||
*/
|
||||
* get_key
|
||||
*/
|
||||
static function get_key($template)
|
||||
{
|
||||
{
|
||||
// calculate Uid if not already done
|
||||
if ($template->templateUid == '') {
|
||||
$template->getTemplateFilepath();
|
||||
@@ -112,7 +118,6 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data {
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user