@@ -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 | } |
@@ -54,29 +55,33 @@ discard block |
||
54 | 55 | $this->filter = "Seufert\\Hamle\\Text\\Filter::{$this->filter}"; |
55 | 56 | } |
56 | 57 | $mapFilter = ['json'=>'json_encode']; |
57 | - if(isset($mapFilter[$this->filter])) |
|
58 | - $this->filter = $mapFilter[$this->filter]; |
|
58 | + if(isset($mapFilter[$this->filter])) { |
|
59 | + $this->filter = $mapFilter[$this->filter]; |
|
60 | + } |
|
59 | 61 | $this->what = $what; |
60 | 62 | } |
61 | 63 | |
62 | 64 | function toHTML($escape = false) { |
63 | - if($escape) |
|
64 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
65 | + if($escape) { |
|
66 | + return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
67 | + } |
|
65 | 68 | return "<?=" . $this->toPHP() . "?>"; |
66 | 69 | } |
67 | 70 | |
68 | 71 | function toPHP() { |
69 | 72 | $o = [$this->what->toPHPVar()] ; |
70 | - foreach($this->vars as $v) |
|
71 | - $o[] = $this->varToCode($v); |
|
73 | + foreach($this->vars as $v) { |
|
74 | + $o[] = $this->varToCode($v); |
|
75 | + } |
|
72 | 76 | return "{$this->filter}(" . implode(',',$o) . ")"; |
73 | 77 | } |
74 | 78 | |
75 | 79 | static function itersplit($v, $sep = ",") { |
76 | 80 | $o = []; |
77 | 81 | foreach(explode($sep, $v) as $k=>$i) { |
78 | - if($i) |
|
79 | - $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k]; |
|
82 | + if($i) { |
|
83 | + $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k]; |
|
84 | + } |
|
80 | 85 | } |
81 | 86 | return new WrapArray($o); |
82 | 87 | } |