mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
support appending key=>val pairs
This commit is contained in:
1
NEWS
1
NEWS
@@ -1,3 +1,4 @@
|
|||||||
|
- add support for appending key=>value vars (messju, Monte)
|
||||||
- change embedded variable logic to only recognize $foo and
|
- change embedded variable logic to only recognize $foo and
|
||||||
$foo[0][bar] syntax (Monte)
|
$foo[0][bar] syntax (Monte)
|
||||||
- allow null as function attribute value
|
- allow null as function attribute value
|
||||||
|
@@ -600,16 +600,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)
|
function append($tpl_var, $value = null, $key=null)
|
||||||
{
|
{
|
||||||
if (is_array($tpl_var)) {
|
if (is_array($tpl_var)) {
|
||||||
foreach ($tpl_var as $key => $val) {
|
foreach ($tpl_var as $name=>$val) {
|
||||||
if ($key != '') {
|
if ($var_name != '') {
|
||||||
if(!@is_array($this->_tpl_vars[$key])) {
|
if(!@is_array($this->_tpl_vars[$name])) {
|
||||||
settype($this->_tpl_vars[$key],'array');
|
settype($this->_tpl_vars[$name],'array');
|
||||||
}
|
}
|
||||||
$this->_tpl_vars[$key][] = $val;
|
if (isset($key))
|
||||||
|
$this->_tpl_vars[$name][$key] = $val;
|
||||||
|
else
|
||||||
|
$this->_tpl_vars[$name][] = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -617,7 +621,10 @@ 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');
|
||||||
}
|
}
|
||||||
$this->_tpl_vars[$tpl_var][] = $value;
|
if (isset($key))
|
||||||
|
$this->_tpl_vars[$tpl_var][$key] = $value;
|
||||||
|
else
|
||||||
|
$this->_tpl_vars[$tpl_var][] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -627,14 +634,18 @@ class Smarty
|
|||||||
*
|
*
|
||||||
* @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)
|
function append_by_ref($tpl_var, &$value, $key=null)
|
||||||
{
|
{
|
||||||
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');
|
||||||
}
|
}
|
||||||
$this->_tpl_vars[$tpl_var][] = &$value;
|
if (isset($key))
|
||||||
|
$this->_tpl_vars[$tpl_var][$key] = &$value;
|
||||||
|
else
|
||||||
|
$this->_tpl_vars[$tpl_var][] = &$value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -600,16 +600,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)
|
function append($tpl_var, $value = null, $key=null)
|
||||||
{
|
{
|
||||||
if (is_array($tpl_var)) {
|
if (is_array($tpl_var)) {
|
||||||
foreach ($tpl_var as $key => $val) {
|
foreach ($tpl_var as $name=>$val) {
|
||||||
if ($key != '') {
|
if ($var_name != '') {
|
||||||
if(!@is_array($this->_tpl_vars[$key])) {
|
if(!@is_array($this->_tpl_vars[$name])) {
|
||||||
settype($this->_tpl_vars[$key],'array');
|
settype($this->_tpl_vars[$name],'array');
|
||||||
}
|
}
|
||||||
$this->_tpl_vars[$key][] = $val;
|
if (isset($key))
|
||||||
|
$this->_tpl_vars[$name][$key] = $val;
|
||||||
|
else
|
||||||
|
$this->_tpl_vars[$name][] = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -617,7 +621,10 @@ 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');
|
||||||
}
|
}
|
||||||
$this->_tpl_vars[$tpl_var][] = $value;
|
if (isset($key))
|
||||||
|
$this->_tpl_vars[$tpl_var][$key] = $value;
|
||||||
|
else
|
||||||
|
$this->_tpl_vars[$tpl_var][] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -627,14 +634,18 @@ class Smarty
|
|||||||
*
|
*
|
||||||
* @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)
|
function append_by_ref($tpl_var, &$value, $key=null)
|
||||||
{
|
{
|
||||||
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');
|
||||||
}
|
}
|
||||||
$this->_tpl_vars[$tpl_var][] = &$value;
|
if (isset($key))
|
||||||
|
$this->_tpl_vars[$tpl_var][$key] = &$value;
|
||||||
|
else
|
||||||
|
$this->_tpl_vars[$tpl_var][] = &$value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user