mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 03:14:27 +02:00
back out third parameter, extend functionality of append
This commit is contained in:
@@ -578,10 +578,11 @@ class Smarty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($tpl_var != '')
|
if ($tpl_var != '') {
|
||||||
$this->_tpl_vars[$tpl_var] = $value;
|
$this->_tpl_vars[$tpl_var] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* assigns values to template variables by reference
|
* assigns values to template variables by reference
|
||||||
@@ -600,20 +601,20 @@ class Smarty
|
|||||||
*
|
*
|
||||||
* @param array|string $tpl_var the template variable name(s)
|
* @param array|string $tpl_var the template variable name(s)
|
||||||
* @param mixed $value the value to append
|
* @param mixed $value the value to append
|
||||||
* @param mixed $key the key of value to append
|
|
||||||
*/
|
*/
|
||||||
function append($tpl_var, $value = null, $key=null)
|
function append($tpl_var, $value = null)
|
||||||
{
|
{
|
||||||
if (is_array($tpl_var)) {
|
if (is_array($tpl_var)) {
|
||||||
foreach ($tpl_var as $name=>$val) {
|
foreach ($tpl_var as $key => $val) {
|
||||||
if ($var_name != '') {
|
if ($key != '') {
|
||||||
if(!@is_array($this->_tpl_vars[$name])) {
|
if(!@is_array($this->_tpl_vars[$key])) {
|
||||||
settype($this->_tpl_vars[$name],'array');
|
settype($this->_tpl_vars[$key],'array');
|
||||||
|
}
|
||||||
|
if(@is_array($val)) {
|
||||||
|
$this->_tpl_vars[$key] = array_merge($this->_tpl_vars[$key],$val);
|
||||||
|
} else {
|
||||||
|
$this->_tpl_vars[$key][] = $val;
|
||||||
}
|
}
|
||||||
if (isset($key))
|
|
||||||
$this->_tpl_vars[$name][$key] = $val;
|
|
||||||
else
|
|
||||||
$this->_tpl_vars[$name][] = $val;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -621,30 +622,27 @@ class Smarty
|
|||||||
if(!@is_array($this->_tpl_vars[$tpl_var])) {
|
if(!@is_array($this->_tpl_vars[$tpl_var])) {
|
||||||
settype($this->_tpl_vars[$tpl_var],'array');
|
settype($this->_tpl_vars[$tpl_var],'array');
|
||||||
}
|
}
|
||||||
if (isset($key))
|
if(@is_array($value)) {
|
||||||
$this->_tpl_vars[$tpl_var][$key] = $value;
|
$this->_tpl_vars[$tpl_var] = array_merge($this->_tpl_vars[$tpl_var],$value);
|
||||||
else
|
} else {
|
||||||
$this->_tpl_vars[$tpl_var][] = $value;
|
$this->_tpl_vars[$tpl_var][] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* appends values to template variables by reference
|
* appends values to template variables by reference
|
||||||
*
|
*
|
||||||
* @param string $tpl_var the template variable name
|
* @param string $tpl_var the template variable name
|
||||||
* @param mixed $value the referenced value to append
|
* @param mixed $value the referenced value to append
|
||||||
* @param mixed $key the key of value to append
|
|
||||||
*/
|
*/
|
||||||
function append_by_ref($tpl_var, &$value, $key=null)
|
function append_by_ref($tpl_var, &$value)
|
||||||
{
|
{
|
||||||
if ($tpl_var != '' && isset($value)) {
|
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');
|
settype($this->_tpl_vars[$tpl_var],'array');
|
||||||
}
|
}
|
||||||
if (isset($key))
|
|
||||||
$this->_tpl_vars[$tpl_var][$key] = &$value;
|
|
||||||
else
|
|
||||||
$this->_tpl_vars[$tpl_var][] = &$value;
|
$this->_tpl_vars[$tpl_var][] = &$value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -578,10 +578,11 @@ class Smarty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($tpl_var != '')
|
if ($tpl_var != '') {
|
||||||
$this->_tpl_vars[$tpl_var] = $value;
|
$this->_tpl_vars[$tpl_var] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* assigns values to template variables by reference
|
* assigns values to template variables by reference
|
||||||
@@ -600,20 +601,20 @@ class Smarty
|
|||||||
*
|
*
|
||||||
* @param array|string $tpl_var the template variable name(s)
|
* @param array|string $tpl_var the template variable name(s)
|
||||||
* @param mixed $value the value to append
|
* @param mixed $value the value to append
|
||||||
* @param mixed $key the key of value to append
|
|
||||||
*/
|
*/
|
||||||
function append($tpl_var, $value = null, $key=null)
|
function append($tpl_var, $value = null)
|
||||||
{
|
{
|
||||||
if (is_array($tpl_var)) {
|
if (is_array($tpl_var)) {
|
||||||
foreach ($tpl_var as $name=>$val) {
|
foreach ($tpl_var as $key => $val) {
|
||||||
if ($var_name != '') {
|
if ($key != '') {
|
||||||
if(!@is_array($this->_tpl_vars[$name])) {
|
if(!@is_array($this->_tpl_vars[$key])) {
|
||||||
settype($this->_tpl_vars[$name],'array');
|
settype($this->_tpl_vars[$key],'array');
|
||||||
|
}
|
||||||
|
if(@is_array($val)) {
|
||||||
|
$this->_tpl_vars[$key] = array_merge($this->_tpl_vars[$key],$val);
|
||||||
|
} else {
|
||||||
|
$this->_tpl_vars[$key][] = $val;
|
||||||
}
|
}
|
||||||
if (isset($key))
|
|
||||||
$this->_tpl_vars[$name][$key] = $val;
|
|
||||||
else
|
|
||||||
$this->_tpl_vars[$name][] = $val;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -621,30 +622,27 @@ class Smarty
|
|||||||
if(!@is_array($this->_tpl_vars[$tpl_var])) {
|
if(!@is_array($this->_tpl_vars[$tpl_var])) {
|
||||||
settype($this->_tpl_vars[$tpl_var],'array');
|
settype($this->_tpl_vars[$tpl_var],'array');
|
||||||
}
|
}
|
||||||
if (isset($key))
|
if(@is_array($value)) {
|
||||||
$this->_tpl_vars[$tpl_var][$key] = $value;
|
$this->_tpl_vars[$tpl_var] = array_merge($this->_tpl_vars[$tpl_var],$value);
|
||||||
else
|
} else {
|
||||||
$this->_tpl_vars[$tpl_var][] = $value;
|
$this->_tpl_vars[$tpl_var][] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* appends values to template variables by reference
|
* appends values to template variables by reference
|
||||||
*
|
*
|
||||||
* @param string $tpl_var the template variable name
|
* @param string $tpl_var the template variable name
|
||||||
* @param mixed $value the referenced value to append
|
* @param mixed $value the referenced value to append
|
||||||
* @param mixed $key the key of value to append
|
|
||||||
*/
|
*/
|
||||||
function append_by_ref($tpl_var, &$value, $key=null)
|
function append_by_ref($tpl_var, &$value)
|
||||||
{
|
{
|
||||||
if ($tpl_var != '' && isset($value)) {
|
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');
|
settype($this->_tpl_vars[$tpl_var],'array');
|
||||||
}
|
}
|
||||||
if (isset($key))
|
|
||||||
$this->_tpl_vars[$tpl_var][$key] = &$value;
|
|
||||||
else
|
|
||||||
$this->_tpl_vars[$tpl_var][] = &$value;
|
$this->_tpl_vars[$tpl_var][] = &$value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user