aboutsummaryrefslogtreecommitdiff
path: root/h-source/Library/Helper/List.php
diff options
context:
space:
mode:
authorAntonio Gallo <tonicucoz@gmail.com>2013-10-14 16:06:56 +0000
committerAntonio Gallo <tonicucoz@gmail.com>2013-10-14 16:06:56 +0000
commita93461b231fb94f3a6a9df09a30557732201ddcc (patch)
treef278951ee7746da2a618ec57043c57fafe779c1d /h-source/Library/Helper/List.php
parent6fa0219202ce4ccc5c4592e66031bb0f7f8be2b0 (diff)
added new EasyGiant Library
Diffstat (limited to 'h-source/Library/Helper/List.php')
-rwxr-xr-xh-source/Library/Helper/List.php45
1 files changed, 25 insertions, 20 deletions
diff --git a/h-source/Library/Helper/List.php b/h-source/Library/Helper/List.php
index ba59643..7f8fb77 100755
--- a/h-source/Library/Helper/List.php
+++ b/h-source/Library/Helper/List.php
@@ -172,47 +172,48 @@ class Helper_List extends Helper_Html {
public function replaceFields($string,$rowArray) {
$this->__rowArray = $rowArray; //used by the replaceField method
- $string = preg_replace_callback('/(\;)(.*?)(\;)/', 'Helper_List::replaceField' ,$string);
+ $string = preg_replace_callback('/(\;)(.*?)(\;)/', array($this, 'replaceField') ,$string);
return $string;
}
+ //get : or . as char used to separate table and field
+ public function getChar($string)
+ {
+ return strstr($string,':') ? ':' : '.';
+ }
+
//replace a single string wrapped by ; with its correspondent value taken by the $recordArray associative array (a row of the select query)
public function replaceField($match)
{
$string = $match[2];
- if (strstr($string,':') or strstr($string,'.')) {
- if (strstr($string,':'))
- {
- $char = ':';
- }
- else
- {
- $char = '.';
- }
- //check if a function has been indicated
- if (strstr($string,'|'))
+ //check if a function has been indicated
+ if (strstr($string,'|'))
+ {
+ //get the function
+ $firstArray = explode('|',$string);
+ if (strstr($firstArray[1],':') or strstr($firstArray[1],'.'))
{
- //get the function
- $firstArray = explode('|',$string);
$func = $firstArray[0];
//replace the fields
+ $char = $this->getChar($firstArray[1]);
$temp = explode($char,$firstArray[1]);
$string = $this->__rowArray[$temp[0]][$temp[1]];
- if (!function_exists($func)) {
- throw new Exception('Error in <b>'.__METHOD__.'</b>: function <b>'.$func.'</b> does not exists..');
- }
- //apply the function
- $string = call_user_func($func,$string);
+ $string = callFunction($func,$string,__METHOD__);
}
- else
+ }
+ else
+ {
+ if (strstr($string,':') or strstr($string,'.'))
{
+ $char = $this->getChar($string);
$temp = explode($char,$string);
$string = $this->__rowArray[$temp[0]][$temp[1]];
}
}
+
return $string;
}
@@ -477,6 +478,10 @@ class Helper_List extends Helper_Html {
$viewStatus = Url::createUrl(array_values($this->viewArgs));
if (strcmp($value,Params::$nullQueryValue) === 0) $value = '';
}
+ else
+ {
+ $viewStatus = $this->viewStatus;
+ }
$this->viewArgs[$viewArgsName] = $temp;
$action = Url::getRoot($this->url).$viewStatus;