diff --git a/NEWS b/NEWS index d3f704f2..87e53b73 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ + - added assign_by_ref() and append_by_ref() functions + (Monte) - changed default warning type for plugin errors from E_USER_WARNING to E_USER_ERROR (Monte) - added $all_extra, $hour_extra, $minute_extra, diff --git a/Smarty.class.php b/Smarty.class.php index b64c6ed1..8188e353 100644 --- a/Smarty.class.php +++ b/Smarty.class.php @@ -240,17 +240,27 @@ class Smarty $this->_extract = true; } - +/*======================================================================*\ + Function: assign_by_ref() + Purpose: assigns values to template variables by reference +\*======================================================================*/ + function assign_by_ref($tpl_var, &$value) + { + if ($tpl_var != '' && isset($value)) + $this->_tpl_vars[$tpl_var] = &$value; + $this->_extract = true; + } + /*======================================================================*\ Function: append - Purpose: appens values to template variables + Purpose: appends values to template variables \*======================================================================*/ function append($tpl_var, $value = NULL) { if (is_array($tpl_var)) { foreach ($tpl_var as $key => $val) { if ($key != '') { - if(!is_array($this->_tpl_vars[$key])) { + if(!@is_array($this->_tpl_vars[$key])) { settype($this->_tpl_vars[$key],'array'); } $this->_tpl_vars[$key][] = $val; @@ -258,7 +268,7 @@ class Smarty } } else { if ($tpl_var != '' && isset($value)) { - if(!is_array($this->_tpl_vars[$tpl_var])) { + if(!@is_array($this->_tpl_vars[$tpl_var])) { settype($this->_tpl_vars[$tpl_var],'array'); } $this->_tpl_vars[$tpl_var][] = $value; @@ -267,6 +277,21 @@ class Smarty $this->_extract = true; } +/*======================================================================*\ + Function: append_by_ref + Purpose: appends values to template variables by reference +\*======================================================================*/ + function append_by_ref($tpl_var, &$value) + { + if ($tpl_var != '' && isset($value)) { + if(!@is_array($this->_tpl_vars[$tpl_var])) { + settype($this->_tpl_vars[$tpl_var],'array'); + } + $this->_tpl_vars[$tpl_var][] = &$value; + } + $this->_extract = true; + } + /*======================================================================*\ Function: clear_assign() diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index b64c6ed1..8188e353 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -240,17 +240,27 @@ class Smarty $this->_extract = true; } - +/*======================================================================*\ + Function: assign_by_ref() + Purpose: assigns values to template variables by reference +\*======================================================================*/ + function assign_by_ref($tpl_var, &$value) + { + if ($tpl_var != '' && isset($value)) + $this->_tpl_vars[$tpl_var] = &$value; + $this->_extract = true; + } + /*======================================================================*\ Function: append - Purpose: appens values to template variables + Purpose: appends values to template variables \*======================================================================*/ function append($tpl_var, $value = NULL) { if (is_array($tpl_var)) { foreach ($tpl_var as $key => $val) { if ($key != '') { - if(!is_array($this->_tpl_vars[$key])) { + if(!@is_array($this->_tpl_vars[$key])) { settype($this->_tpl_vars[$key],'array'); } $this->_tpl_vars[$key][] = $val; @@ -258,7 +268,7 @@ class Smarty } } else { if ($tpl_var != '' && isset($value)) { - if(!is_array($this->_tpl_vars[$tpl_var])) { + if(!@is_array($this->_tpl_vars[$tpl_var])) { settype($this->_tpl_vars[$tpl_var],'array'); } $this->_tpl_vars[$tpl_var][] = $value; @@ -267,6 +277,21 @@ class Smarty $this->_extract = true; } +/*======================================================================*\ + Function: append_by_ref + Purpose: appends values to template variables by reference +\*======================================================================*/ + function append_by_ref($tpl_var, &$value) + { + if ($tpl_var != '' && isset($value)) { + if(!@is_array($this->_tpl_vars[$tpl_var])) { + settype($this->_tpl_vars[$tpl_var],'array'); + } + $this->_tpl_vars[$tpl_var][] = &$value; + } + $this->_extract = true; + } + /*======================================================================*\ Function: clear_assign()