back out "@" logic, apply only to default modifier special case

This commit is contained in:
mohrt
2003-03-15 20:47:29 +00:00
parent ab48cfa939
commit 76048d1ceb
2 changed files with 27 additions and 24 deletions

2
NEWS
View File

@@ -1,4 +1,4 @@
- append "@" to _run_mod_handler and template var echos to - append "@" to default modifier vars/args
supress possible warnings (Monte) supress possible warnings (Monte)
- fix problem with escaped double quotes (Monte) - fix problem with escaped double quotes (Monte)
- fix html_radios to not return an array (Monte) - fix html_radios to not return an array (Monte)

View File

@@ -391,10 +391,6 @@ class Smarty_Compiler extends Smarty {
if(isset($_tag_attrs['assign'])) { if(isset($_tag_attrs['assign'])) {
return "<?php \$this->assign('" . $this->_dequote($_tag_attrs['assign']) . "', $_return ); ?>\n"; return "<?php \$this->assign('" . $this->_dequote($_tag_attrs['assign']) . "', $_return ); ?>\n";
} else { } else {
// prepend '@' if eching a variable
if(substr($_return, 0, 1) == '$') {
$_return = '@' . $_return;
}
return "<?php echo $_return; ?>\n"; return "<?php echo $_return; ?>\n";
} }
} }
@@ -1615,38 +1611,45 @@ class Smarty_Compiler extends Smarty {
*/ */
function _parse_modifiers(&$output, $modifier_string) function _parse_modifiers(&$output, $modifier_string)
{ {
preg_match_all('!\|(@?\w+)((?>:(?:'. $this->_qstr_regexp . '|[^|]+))*)!', '|' . $modifier_string, $match); preg_match_all('!\|(@?\w+)((?>:(?:'. $this->_qstr_regexp . '|[^|]+))*)!', '|' . $modifier_string, $_match);
list(, $modifiers, $modifier_arg_strings) = $match; list(, $_modifiers, $modifier_arg_strings) = $_match;
for ($i = 0, $for_max = count($modifiers); $i < $for_max; $i++) { for ($_i = 0, $_for_max = count($_modifiers); $_i < $_for_max; $_i++) {
$modifier_name = $modifiers[$i]; $_modifier_name = $_modifiers[$_i];
if($modifier_name == 'smarty') { if($_modifier_name == 'smarty') {
// skip smarty modifier // skip smarty modifier
continue; continue;
} }
preg_match_all('!:(' . $this->_qstr_regexp . '|[^:]+)!', $modifier_arg_strings[$i], $match); preg_match_all('!:(' . $this->_qstr_regexp . '|[^:]+)!', $modifier_arg_strings[$_i], $_match);
$modifier_args = $match[1]; $_modifier_args = $_match[1];
if ($modifier_name{0} == '@') { if ($_modifier_name{0} == '@') {
$map_array = 'false'; $_map_array = 'false';
$modifier_name = substr($modifier_name, 1); $_modifier_name = substr($_modifier_name, 1);
} else { } else {
$map_array = 'true'; $_map_array = 'true';
} }
$this->_add_plugin('modifier', $modifier_name); $this->_add_plugin('modifier', $_modifier_name);
$this->_parse_vars_props($_modifier_args);
$this->_parse_vars_props($modifier_args); if($_modifier_name == 'default') {
// supress notifications of default modifier vars and args
if (count($modifier_args) > 0) if($output{0} == '$') {
$modifier_args = ', '.implode(', ', $modifier_args); $output = '@' . $output;
}
if($_modifier_args[0]{0} == '$') {
$_modifier_args[0] = '@' . $_modifier_args[0];
}
}
if (count($_modifier_args) > 0)
$_modifier_args = ', '.implode(', ', $_modifier_args);
else else
$modifier_args = ''; $_modifier_args = '';
$output = "\$this->_run_mod_handler('$_modifier_name', $_map_array, $output$_modifier_args)";
$output = "@\$this->_run_mod_handler('$modifier_name', $map_array, $output$modifier_args)";
} }
} }