@@ -41,8 +41,9 @@ discard block |
||
| 41 | 41 | if(preg_match("/^([a-z]+)(\\((.*)\\))?$/", $s, $m)) { |
| 42 | 42 | $this->filter = $m[1]; |
| 43 | 43 | $this->vars = isset($m[3]) ? explode(',', $m[3]) : []; |
| 44 | - foreach($this->vars as $k=>$v) |
|
| 45 | - $this->vars[$k] = str_replace(",",',',$v); |
|
| 44 | + foreach($this->vars as $k=>$v) { |
|
| 45 | + $this->vars[$k] = str_replace(",",',',$v); |
|
| 46 | + } |
|
| 46 | 47 | } else { |
| 47 | 48 | throw new ParseError("Unable to parse filter expression \"$s\""); |
| 48 | 49 | } |
@@ -57,23 +58,26 @@ discard block |
||
| 57 | 58 | } |
| 58 | 59 | |
| 59 | 60 | function toHTML($escape = false) { |
| 60 | - if($escape) |
|
| 61 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
| 61 | + if($escape) { |
|
| 62 | + return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
| 63 | + } |
|
| 62 | 64 | return "<?=" . $this->toPHP() . "?>"; |
| 63 | 65 | } |
| 64 | 66 | |
| 65 | 67 | function toPHP() { |
| 66 | 68 | $o = [$this->what->toPHPVar()] ; |
| 67 | - foreach($this->vars as $v) |
|
| 68 | - $o[] = $this->varToCode($v); |
|
| 69 | + foreach($this->vars as $v) { |
|
| 70 | + $o[] = $this->varToCode($v); |
|
| 71 | + } |
|
| 69 | 72 | return "{$this->filter}(" . implode(',',$o) . ")"; |
| 70 | 73 | } |
| 71 | 74 | |
| 72 | 75 | static function itersplit($v, $sep = ",") { |
| 73 | 76 | $o = []; |
| 74 | 77 | foreach(explode($sep, $v) as $k=>$i) { |
| 75 | - if($i) |
|
| 76 | - $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k]; |
|
| 78 | + if($i) { |
|
| 79 | + $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k]; |
|
| 80 | + } |
|
| 77 | 81 | } |
| 78 | 82 | return new WrapArray($o); |
| 79 | 83 | } |