mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 11:24:27 +02:00
- bugfix for E_NOTICE change, array elements did not work as modifier parameter
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
25/10/2010
|
||||||
|
- bugfix for E_NOTICE change, array elements did not work as modifier parameter
|
||||||
|
|
||||||
20/10/2010
|
20/10/2010
|
||||||
- bugfix for the E_NOTICE change
|
- bugfix for the E_NOTICE change
|
||||||
|
|
||||||
|
@@ -30,20 +30,9 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
|||||||
$output = $_attr['value'];
|
$output = $_attr['value'];
|
||||||
// loop over list of modifiers
|
// loop over list of modifiers
|
||||||
foreach ($_attr['modifierlist'] as $single_modifier) {
|
foreach ($_attr['modifierlist'] as $single_modifier) {
|
||||||
preg_match_all('/(((\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|[^:"]*"[^"\\\\]*(?:\\\\.[^"\\\\]*)*")[^:]*)+|::?|[^:]+)/', $single_modifier, $mod_array);
|
$modifier = $single_modifier[0];
|
||||||
$modifier = $mod_array[0][0];
|
$single_modifier[0] = $output;
|
||||||
for ($i = 0, $count = count($mod_array[0]);$i < $count;$i++) {
|
$params = implode(',', $single_modifier);
|
||||||
if ($mod_array[0][$i] == ':') {
|
|
||||||
$mod_array[0][$i] = ',';
|
|
||||||
}
|
|
||||||
if ($mod_array[0][$i] == '::') {
|
|
||||||
$mod_array[0][$i-1] = $mod_array[0][$i-1] . $mod_array[0][$i] . $mod_array[0][$i + 1];
|
|
||||||
unset($mod_array[0][$i], $mod_array[0][$i + 1]);
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unset($mod_array[0][0]);
|
|
||||||
$params = $output . implode('', $mod_array[0]);
|
|
||||||
// check for registered modifier
|
// check for registered modifier
|
||||||
if (isset($compiler->smarty->registered_plugins['modifier'][$modifier])) {
|
if (isset($compiler->smarty->registered_plugins['modifier'][$modifier])) {
|
||||||
$function = $compiler->smarty->registered_plugins['modifier'][$modifier][0];
|
$function = $compiler->smarty->registered_plugins['modifier'][$modifier][0];
|
||||||
@@ -59,13 +48,7 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
|||||||
// check for plugin modifiercompiler
|
// check for plugin modifiercompiler
|
||||||
} else if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) {
|
} else if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) {
|
||||||
$plugin = 'smarty_modifiercompiler_' . $modifier;
|
$plugin = 'smarty_modifiercompiler_' . $modifier;
|
||||||
foreach($mod_array[0] as $key => $value) {
|
$output = $plugin($single_modifier, $compiler);
|
||||||
if ($value == ',') {
|
|
||||||
unset ($mod_array[0][$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$args = array_merge((array)$output, $mod_array[0]);
|
|
||||||
$output = $plugin($args, $compiler);
|
|
||||||
// check for plugin modifier
|
// check for plugin modifier
|
||||||
} else if ($function = $this->compiler->getPlugin($modifier, 'modifier')) {
|
} else if ($function = $this->compiler->getPlugin($modifier, 'modifier')) {
|
||||||
$output = "{$function}({$params})";
|
$output = "{$function}({$params})";
|
||||||
@@ -76,7 +59,7 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
|||||||
$output = "{$modifier}({$params})";
|
$output = "{$modifier}({$params})";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->compiler->trigger_template_error ("unknown modifier \"" . $modifier . "\"");
|
$this->compiler->trigger_template_error ("unknown modifier \"" . $modifier . "\"", $this->compiler->lex->taglineno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $output;
|
return $output;
|
||||||
|
@@ -23,44 +23,53 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
|
|||||||
public function compile($args, $compiler)
|
public function compile($args, $compiler)
|
||||||
{
|
{
|
||||||
$this->compiler = $compiler;
|
$this->compiler = $compiler;
|
||||||
|
$this->optional_attributes = array('assign');
|
||||||
$this->required_attributes = array('value');
|
$this->required_attributes = array('value');
|
||||||
$this->optional_attributes = array('assign', 'nocache', 'filter', 'nofilter', 'modifierlist');
|
$this->optional_attributes = array('assign', 'nocache', 'nofilter', 'modifierlist');
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->_get_attributes($args);
|
$_attr = $this->_get_attributes($args);
|
||||||
|
// nocache option
|
||||||
if (isset($_attr['nocache'])) {
|
if (isset($_attr['nocache'])) {
|
||||||
if ($_attr['nocache'] == 'true') {
|
if ($_attr['nocache'] == 'true') {
|
||||||
$this->compiler->tag_nocache = true;
|
$this->compiler->tag_nocache = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($_attr['filter'])) {
|
// filter handling
|
||||||
$_attr['filter'] = 'null';
|
|
||||||
}
|
|
||||||
if (isset($_attr['nofilter'])) {
|
if (isset($_attr['nofilter'])) {
|
||||||
if ($_attr['nofilter'] == 'true') {
|
$_filter = 'false';
|
||||||
$_attr['filter'] = 'false';
|
} else {
|
||||||
}
|
$_filter = 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// compiled output
|
||||||
if (isset($_attr['assign'])) {
|
if (isset($_attr['assign'])) {
|
||||||
// assign output to variable
|
// assign output to variable
|
||||||
$output = '<?php $_smarty_tpl->assign(' . $_attr['assign'] . ',' . $_attr['value'] . ');?>';
|
$output = "<?php \$_smarty_tpl->assign({$_attr['assign']},{$_attr['value']});?>";
|
||||||
} else {
|
} else {
|
||||||
// display value
|
// display value
|
||||||
if (isset($this->compiler->smarty->registered_filters['variable'])) {
|
if (isset($this->compiler->smarty->registered_filters['variable'])) {
|
||||||
$output = 'Smarty_Internal_Filter_Handler::runFilter(\'variable\', ' . $_attr['value'] . ',$_smarty_tpl->smarty, $_smarty_tpl, ' . $_attr['filter'] . ')';
|
$output = "Smarty_Internal_Filter_Handler::runFilter('variable', {$_attr['value']},\$_smarty_tpl->smarty, \$_smarty_tpl, {$_filter})";
|
||||||
} else {
|
} else {
|
||||||
$output = $_attr['value'];
|
$output = $_attr['value'];
|
||||||
}
|
}
|
||||||
if (!isset($_attr['nofilter']) && isset($this->compiler->smarty->default_modifiers)) {
|
if (!isset($_attr['nofilter']) && !empty($this->compiler->smarty->default_modifiers)) {
|
||||||
$output = $this->compiler->compileTag('private_modifier', array('modifierlist' => $this->compiler->smarty->default_modifiers, 'value' => $output));
|
$modifierlist = array();
|
||||||
|
foreach ($this->compiler->smarty->default_modifiers as $key => $single_default_modifier) {
|
||||||
|
preg_match_all('/(\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|:|[^:]+)/', $single_default_modifier, $mod_array);
|
||||||
|
for ($i = 0, $count = count($mod_array[0]);$i < $count;$i++) {
|
||||||
|
if ($mod_array[0][$i] != ':') {
|
||||||
|
$modifierlist[$key][] = $mod_array[0][$i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$output = $this->compiler->compileTag('private_modifier', array('modifierlist' => $modifierlist, 'value' => $output));
|
||||||
}
|
}
|
||||||
if (isset($_attr['modifierlist'])) {
|
if (!empty($_attr['modifierlist'])) {
|
||||||
$output = $this->compiler->compileTag('private_modifier', array('modifierlist' => $_attr['modifierlist'], 'value' => $output));
|
$output = $this->compiler->compileTag('private_modifier', array('modifierlist' => $_attr['modifierlist'], 'value' => $output));
|
||||||
}
|
}
|
||||||
$this->compiler->has_output = true;
|
$this->compiler->has_output = true;
|
||||||
$output = '<?php echo ' . $output . ';?>';
|
$output = "<?php echo {$output};?>";
|
||||||
}
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user