added assign_by_ref() and append_by_ref() functions

This commit is contained in:
mohrt
2002-08-02 18:17:40 +00:00
parent b0d260891f
commit cb83417158
3 changed files with 60 additions and 8 deletions

2
NEWS
View File

@@ -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,

View File

@@ -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()

View File

@@ -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()