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)
|
||||
- support full dollar var syntax in quoted text (Monte)
|
||||
- fixed bug in $smarty.const.FOO introduced in 2.4.1 (M
|
||||
|
@@ -1514,7 +1514,6 @@ class Smarty_Compiler extends Smarty {
|
||||
}
|
||||
|
||||
foreach ($indexes as $index) {
|
||||
|
||||
if ($index{0} == '[') {
|
||||
$index = substr($index, 1, -1);
|
||||
if (is_numeric($index)) {
|
||||
@@ -1538,9 +1537,19 @@ class Smarty_Compiler extends Smarty {
|
||||
} elseif($this->security && substr($index,2,1) == '_') {
|
||||
$this->_syntax_error('(secure) call to private object member is not allowed', E_USER_ERROR, __FILE__, __LINE__);
|
||||
} else {
|
||||
// parse each parameter to the object
|
||||
if(preg_match('!(?:' . $this->_obj_ext_regexp . ')+(?:(' . $this->_obj_params_regexp . '))?!', $index, $match)) {
|
||||
$index = str_replace($match[1], $this->_parse_parenth_args($match[1]), $index);
|
||||
if(preg_match('!((?:' . $this->_obj_ext_regexp . ')+)(' . $this->_obj_params_regexp . ')?!', $index, $match)) {
|
||||
if(!empty($match[2])) {
|
||||
// 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;
|
||||
}
|
||||
|
@@ -1514,7 +1514,6 @@ class Smarty_Compiler extends Smarty {
|
||||
}
|
||||
|
||||
foreach ($indexes as $index) {
|
||||
|
||||
if ($index{0} == '[') {
|
||||
$index = substr($index, 1, -1);
|
||||
if (is_numeric($index)) {
|
||||
@@ -1538,9 +1537,19 @@ class Smarty_Compiler extends Smarty {
|
||||
} elseif($this->security && substr($index,2,1) == '_') {
|
||||
$this->_syntax_error('(secure) call to private object member is not allowed', E_USER_ERROR, __FILE__, __LINE__);
|
||||
} else {
|
||||
// parse each parameter to the object
|
||||
if(preg_match('!(?:' . $this->_obj_ext_regexp . ')+(?:(' . $this->_obj_params_regexp . '))?!', $index, $match)) {
|
||||
$index = str_replace($match[1], $this->_parse_parenth_args($match[1]), $index);
|
||||
if(preg_match('!((?:' . $this->_obj_ext_regexp . ')+)(' . $this->_obj_params_regexp . ')?!', $index, $match)) {
|
||||
if(!empty($match[2])) {
|
||||
// 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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user