mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
add support for $foo->$bar syntax
This commit is contained in:
1
NEWS
1
NEWS
@@ -1,3 +1,4 @@
|
|||||||
|
- support embedded variables in objects (Monte)
|
||||||
- fix bug with objects with no properties (M Mohr, Monte)
|
- fix bug with objects with no properties (M Mohr, Monte)
|
||||||
- support full dollar var syntax in quoted text (Monte)
|
- support full dollar var syntax in quoted text (Monte)
|
||||||
- fixed bug in $smarty.const.FOO introduced in 2.4.1 (M
|
- fixed bug in $smarty.const.FOO introduced in 2.4.1 (M
|
||||||
|
@@ -1495,7 +1495,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
|
|
||||||
$indexes = $match[0];
|
$indexes = $match[0];
|
||||||
$var_name = array_shift($indexes);
|
$var_name = array_shift($indexes);
|
||||||
|
|
||||||
/* Handle $smarty.* variable references as a special case. */
|
/* Handle $smarty.* variable references as a special case. */
|
||||||
if ($var_name == 'smarty') {
|
if ($var_name == 'smarty') {
|
||||||
/*
|
/*
|
||||||
@@ -1513,8 +1513,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
$output = "\$this->_tpl_vars['$var_name']";
|
$output = "\$this->_tpl_vars['$var_name']";
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($indexes as $index) {
|
foreach ($indexes as $index) {
|
||||||
|
|
||||||
if ($index{0} == '[') {
|
if ($index{0} == '[') {
|
||||||
$index = substr($index, 1, -1);
|
$index = substr($index, 1, -1);
|
||||||
if (is_numeric($index)) {
|
if (is_numeric($index)) {
|
||||||
@@ -1538,9 +1537,19 @@ class Smarty_Compiler extends Smarty {
|
|||||||
} elseif($this->security && substr($index,2,1) == '_') {
|
} elseif($this->security && substr($index,2,1) == '_') {
|
||||||
$this->_syntax_error('(secure) call to private object member is not allowed', E_USER_ERROR, __FILE__, __LINE__);
|
$this->_syntax_error('(secure) call to private object member is not allowed', E_USER_ERROR, __FILE__, __LINE__);
|
||||||
} else {
|
} else {
|
||||||
// parse each parameter to the object
|
if(preg_match('!((?:' . $this->_obj_ext_regexp . ')+)(' . $this->_obj_params_regexp . ')?!', $index, $match)) {
|
||||||
if(preg_match('!(?:' . $this->_obj_ext_regexp . ')+(?:(' . $this->_obj_params_regexp . '))?!', $index, $match)) {
|
if(!empty($match[2])) {
|
||||||
$index = str_replace($match[1], $this->_parse_parenth_args($match[1]), $index);
|
// parse object parameters
|
||||||
|
$index = str_replace($match[2], $this->_parse_parenth_args($match[2]), $index);
|
||||||
|
}
|
||||||
|
if(preg_match_all('!' . $this->_dvar_regexp . '!', $match[1], $_dvar_match)) {
|
||||||
|
// parse embedded variables
|
||||||
|
$_match_replace = $match[1];
|
||||||
|
foreach($_dvar_match[0] as $_curr_var) {
|
||||||
|
$_match_replace = str_replace($_curr_var, '{' . $this->_parse_var($_curr_var) . '}', $_match_replace);
|
||||||
|
}
|
||||||
|
$index = str_replace($match[1], $_match_replace, $index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$output .= $index;
|
$output .= $index;
|
||||||
}
|
}
|
||||||
|
@@ -1495,7 +1495,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
|
|
||||||
$indexes = $match[0];
|
$indexes = $match[0];
|
||||||
$var_name = array_shift($indexes);
|
$var_name = array_shift($indexes);
|
||||||
|
|
||||||
/* Handle $smarty.* variable references as a special case. */
|
/* Handle $smarty.* variable references as a special case. */
|
||||||
if ($var_name == 'smarty') {
|
if ($var_name == 'smarty') {
|
||||||
/*
|
/*
|
||||||
@@ -1513,8 +1513,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
$output = "\$this->_tpl_vars['$var_name']";
|
$output = "\$this->_tpl_vars['$var_name']";
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($indexes as $index) {
|
foreach ($indexes as $index) {
|
||||||
|
|
||||||
if ($index{0} == '[') {
|
if ($index{0} == '[') {
|
||||||
$index = substr($index, 1, -1);
|
$index = substr($index, 1, -1);
|
||||||
if (is_numeric($index)) {
|
if (is_numeric($index)) {
|
||||||
@@ -1538,9 +1537,19 @@ class Smarty_Compiler extends Smarty {
|
|||||||
} elseif($this->security && substr($index,2,1) == '_') {
|
} elseif($this->security && substr($index,2,1) == '_') {
|
||||||
$this->_syntax_error('(secure) call to private object member is not allowed', E_USER_ERROR, __FILE__, __LINE__);
|
$this->_syntax_error('(secure) call to private object member is not allowed', E_USER_ERROR, __FILE__, __LINE__);
|
||||||
} else {
|
} else {
|
||||||
// parse each parameter to the object
|
if(preg_match('!((?:' . $this->_obj_ext_regexp . ')+)(' . $this->_obj_params_regexp . ')?!', $index, $match)) {
|
||||||
if(preg_match('!(?:' . $this->_obj_ext_regexp . ')+(?:(' . $this->_obj_params_regexp . '))?!', $index, $match)) {
|
if(!empty($match[2])) {
|
||||||
$index = str_replace($match[1], $this->_parse_parenth_args($match[1]), $index);
|
// parse object parameters
|
||||||
|
$index = str_replace($match[2], $this->_parse_parenth_args($match[2]), $index);
|
||||||
|
}
|
||||||
|
if(preg_match_all('!' . $this->_dvar_regexp . '!', $match[1], $_dvar_match)) {
|
||||||
|
// parse embedded variables
|
||||||
|
$_match_replace = $match[1];
|
||||||
|
foreach($_dvar_match[0] as $_curr_var) {
|
||||||
|
$_match_replace = str_replace($_curr_var, '{' . $this->_parse_var($_curr_var) . '}', $_match_replace);
|
||||||
|
}
|
||||||
|
$index = str_replace($match[1], $_match_replace, $index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$output .= $index;
|
$output .= $index;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user