@@ -44,8 +44,9 @@ discard block |
||
| 44 | 44 | if(preg_match("/^([a-z]+)(?:\\((?P<vars>.*)\\))?(?:\\|(?P<chained>.+?))?$/", $s, $m)) { |
| 45 | 45 | $this->filter = $m[1]; |
| 46 | 46 | $this->vars = isset($m['vars']) && strlen($m['vars']) ? explode(',', $m['vars']) : []; |
| 47 | - foreach($this->vars as $k=>$v) |
|
| 48 | - $this->vars[$k] = str_replace(",",',',$v); |
|
| 47 | + foreach($this->vars as $k=>$v) { |
|
| 48 | + $this->vars[$k] = str_replace(",",',',$v); |
|
| 49 | + } |
|
| 49 | 50 | if(isset($m['chained']) && strlen($m['chained'])) { |
| 50 | 51 | $this->chained = new Filter($m['chained'],$what); |
| 51 | 52 | } |
@@ -58,31 +59,36 @@ discard block |
||
| 58 | 59 | throw new ParseError("Unknown Filter Type \"{$this->filter}\""); |
| 59 | 60 | } |
| 60 | 61 | $mapFilter = ['json'=>'json_encode']; |
| 61 | - if(isset($mapFilter[$this->filter])) |
|
| 62 | - $this->filter = $mapFilter[$this->filter]; |
|
| 62 | + if(isset($mapFilter[$this->filter])) { |
|
| 63 | + $this->filter = $mapFilter[$this->filter]; |
|
| 64 | + } |
|
| 63 | 65 | $this->what = $what; |
| 64 | 66 | } |
| 65 | 67 | |
| 66 | 68 | function toHTML($escape = false) { |
| 67 | - if($escape) |
|
| 68 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
| 69 | + if($escape) { |
|
| 70 | + return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
| 71 | + } |
|
| 69 | 72 | return "<?=" . $this->toPHP() . "?>"; |
| 70 | 73 | } |
| 71 | 74 | |
| 72 | 75 | function toPHPpre() { |
| 73 | 76 | $pre = ''; |
| 74 | - if($this->chained) |
|
| 75 | - $pre = $this->chained->toPHPpre(); |
|
| 77 | + if($this->chained) { |
|
| 78 | + $pre = $this->chained->toPHPpre(); |
|
| 79 | + } |
|
| 76 | 80 | return "$pre{$this->filter}("; |
| 77 | 81 | } |
| 78 | 82 | |
| 79 | 83 | function toPHPpost() { |
| 80 | 84 | $post = ''; |
| 81 | - if($this->chained) |
|
| 82 | - $post = $this->chained->toPHPpost(); |
|
| 85 | + if($this->chained) { |
|
| 86 | + $post = $this->chained->toPHPpost(); |
|
| 87 | + } |
|
| 83 | 88 | $o = ''; |
| 84 | - foreach($this->vars as $v) |
|
| 85 | - $o .= ','.$this->varToCode($v); |
|
| 89 | + foreach($this->vars as $v) { |
|
| 90 | + $o .= ','.$this->varToCode($v); |
|
| 91 | + } |
|
| 86 | 92 | return "$o)$post"; |
| 87 | 93 | } |
| 88 | 94 | |
@@ -97,8 +103,9 @@ discard block |
||
| 97 | 103 | static function itersplit($v, $sep = ",") { |
| 98 | 104 | $o = []; |
| 99 | 105 | foreach(explode($sep, $v) as $k=>$i) { |
| 100 | - if($i) |
|
| 101 | - $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k]; |
|
| 106 | + if($i) { |
|
| 107 | + $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k]; |
|
| 108 | + } |
|
| 102 | 109 | } |
| 103 | 110 | return new WrapArray($o); |
| 104 | 111 | } |