From 6b04b7d4aa393470cfff72871231e52523c349c7 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Tue, 18 Sep 2012 09:39:30 -0400 Subject: [PATCH] Add support for multidimentional array in assign & replaceVars routines --- include/class.variable.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/class.variable.php b/include/class.variable.php index 12b98bb41..1fbb338ca 100644 --- a/include/class.variable.php +++ b/include/class.variable.php @@ -53,7 +53,7 @@ class VariableReplacer { $this->objects[$var] = $val; } elseif($var && is_array($var)) { foreach($var as $k => $v) - $this->variables[$k] = $v; //NOT calling assign to force one dimentional array. + $this->assign($k, $v); } elseif($var) { $this->variables[$var] = $val; } @@ -90,12 +90,15 @@ class VariableReplacer { return $this->getVar($rv, $part); } - function replaceVars($text) { + function replaceVars($input) { - if(!($vars=$this->_parse($text))) - return $text; + if($input && is_array($input)) + return array_map(array($this, 'replaceVars'), $input); - return preg_replace($this->_delimit(array_keys($vars)), array_values($vars), $text); + if(!($vars=$this->_parse($input))) + return $input; + + return preg_replace($this->_delimit(array_keys($vars)), array_values($vars), $input); } function _resolveVar($var) { -- GitLab