fix default modifier to work with config vars

This commit is contained in:
mohrt
2002-07-17 21:56:41 +00:00
parent 36e160bb39
commit f07ea419e7
2 changed files with 16 additions and 8 deletions

View File

@@ -1108,13 +1108,11 @@ class Smarty_Compiler extends Smarty {
$parts = explode('|', substr($var_expr, 1), 2); $parts = explode('|', substr($var_expr, 1), 2);
$var_ref = $parts[0]; $var_ref = $parts[0];
$modifiers = isset($parts[1]) ? $parts[1] : ''; $modifiers = isset($parts[1]) ? $parts[1] : '';
if(!empty($this->default_modifiers) && !strstr($modifiers,'smarty:nodefaults')) { if(!empty($this->default_modifiers) && !strstr($modifiers,'smarty:nodefaults')) {
$_default_mod_string = implode('|',(array)$this->default_modifiers); $_default_mod_string = implode('|',(array)$this->default_modifiers);
$modifiers = empty($modifiers) ? $_default_mod_string : $_default_mod_string . '|' . $modifiers; $modifiers = empty($modifiers) ? $_default_mod_string : $_default_mod_string . '|' . $modifiers;
} }
$modifiers = str_replace(array('smarty:nodefaults','||'),array('','|'),$modifiers);
preg_match_all('!\[(?:\$\w+|\w+(\.\w+)?)\]|(->|\.)\$?\w+|^\w+!', $var_ref, $match); preg_match_all('!\[(?:\$\w+|\w+(\.\w+)?)\]|(->|\.)\$?\w+|^\w+!', $var_ref, $match);
$indexes = $match[0]; $indexes = $match[0];
@@ -1220,6 +1218,12 @@ class Smarty_Compiler extends Smarty {
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') {
// skip smarty modifier
continue;
}
preg_match_all('!:(' . $qstr_regexp . '|[^:]+)!', $modifier_arg_strings[$i], $match); preg_match_all('!:(' . $qstr_regexp . '|[^:]+)!', $modifier_arg_strings[$i], $match);
$modifier_args = $match[1]; $modifier_args = $match[1];
@@ -1229,7 +1233,7 @@ class Smarty_Compiler extends Smarty {
} 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);

View File

@@ -1108,13 +1108,11 @@ class Smarty_Compiler extends Smarty {
$parts = explode('|', substr($var_expr, 1), 2); $parts = explode('|', substr($var_expr, 1), 2);
$var_ref = $parts[0]; $var_ref = $parts[0];
$modifiers = isset($parts[1]) ? $parts[1] : ''; $modifiers = isset($parts[1]) ? $parts[1] : '';
if(!empty($this->default_modifiers) && !strstr($modifiers,'smarty:nodefaults')) { if(!empty($this->default_modifiers) && !strstr($modifiers,'smarty:nodefaults')) {
$_default_mod_string = implode('|',(array)$this->default_modifiers); $_default_mod_string = implode('|',(array)$this->default_modifiers);
$modifiers = empty($modifiers) ? $_default_mod_string : $_default_mod_string . '|' . $modifiers; $modifiers = empty($modifiers) ? $_default_mod_string : $_default_mod_string . '|' . $modifiers;
} }
$modifiers = str_replace(array('smarty:nodefaults','||'),array('','|'),$modifiers);
preg_match_all('!\[(?:\$\w+|\w+(\.\w+)?)\]|(->|\.)\$?\w+|^\w+!', $var_ref, $match); preg_match_all('!\[(?:\$\w+|\w+(\.\w+)?)\]|(->|\.)\$?\w+|^\w+!', $var_ref, $match);
$indexes = $match[0]; $indexes = $match[0];
@@ -1220,6 +1218,12 @@ class Smarty_Compiler extends Smarty {
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') {
// skip smarty modifier
continue;
}
preg_match_all('!:(' . $qstr_regexp . '|[^:]+)!', $modifier_arg_strings[$i], $match); preg_match_all('!:(' . $qstr_regexp . '|[^:]+)!', $modifier_arg_strings[$i], $match);
$modifier_args = $match[1]; $modifier_args = $match[1];
@@ -1229,7 +1233,7 @@ class Smarty_Compiler extends Smarty {
} 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);