@@ -38,39 +38,39 @@ |
||
38 | 38 | protected $what; |
39 | 39 | |
40 | 40 | function __construct($s, Text $what) { |
41 | - if(preg_match("/^([a-z]+)(\\((.*)\\))?$/",$s, $m)) { |
|
41 | + if (preg_match("/^([a-z]+)(\\((.*)\\))?$/", $s, $m)) { |
|
42 | 42 | $this->filter = $m[1]; |
43 | - $this->vars = isset($m[3])?explode(',',$m[3]):[]; |
|
43 | + $this->vars = isset($m[3]) ? explode(',', $m[3]) : []; |
|
44 | 44 | } else { |
45 | 45 | throw new ParseError("Unable to parse filter expression \"$s\""); |
46 | 46 | } |
47 | - if(!in_array($this->filter,['itersplit','round','strtoupper','strtolower','ucfirst'])) { |
|
47 | + if (!in_array($this->filter, ['itersplit', 'round', 'strtoupper', 'strtolower', 'ucfirst'])) { |
|
48 | 48 | throw new ParseError("Unknown Filter Type \"{$this->filter}\""); |
49 | 49 | } |
50 | - if($this->filter == "itersplit") { |
|
50 | + if ($this->filter == "itersplit") { |
|
51 | 51 | $this->filter = "Seufert\\Hamle\\Text\\Filter::iterSplit"; |
52 | 52 | } |
53 | 53 | $this->what = $what; |
54 | 54 | } |
55 | 55 | |
56 | 56 | function toHTML($escape = false) { |
57 | - if($escape) |
|
58 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
57 | + if ($escape) |
|
58 | + return "<?=htmlspecialchars(" . $this->toPHP() . ")?>"; |
|
59 | 59 | return "<?=" . $this->toPHP() . "?>"; |
60 | 60 | } |
61 | 61 | |
62 | 62 | function toPHP() { |
63 | - $o = [$this->what->toPHPVar()] ; |
|
64 | - foreach($this->vars as $v) |
|
63 | + $o = [$this->what->toPHPVar()]; |
|
64 | + foreach ($this->vars as $v) |
|
65 | 65 | $o[] = $this->varToCode($v); |
66 | - return "{$this->filter}(" . implode(',',$o) . ")"; |
|
66 | + return "{$this->filter}(" . implode(',', $o) . ")"; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | static function iterSplit($v, $sep = ",") { |
70 | 70 | $o = []; |
71 | - foreach(explode($sep, $v) as $k=>$i) { |
|
72 | - if($i) |
|
73 | - $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k]; |
|
71 | + foreach (explode($sep, $v) as $k=>$i) { |
|
72 | + if ($i) |
|
73 | + $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k, 'key'=>$k]; |
|
74 | 74 | } |
75 | 75 | return new WrapArray($o); |
76 | 76 | } |
@@ -54,23 +54,26 @@ |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | function toHTML($escape = false) { |
57 | - if($escape) |
|
58 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
57 | + if($escape) { |
|
58 | + return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
59 | + } |
|
59 | 60 | return "<?=" . $this->toPHP() . "?>"; |
60 | 61 | } |
61 | 62 | |
62 | 63 | function toPHP() { |
63 | 64 | $o = [$this->what->toPHPVar()] ; |
64 | - foreach($this->vars as $v) |
|
65 | - $o[] = $this->varToCode($v); |
|
65 | + foreach($this->vars as $v) { |
|
66 | + $o[] = $this->varToCode($v); |
|
67 | + } |
|
66 | 68 | return "{$this->filter}(" . implode(',',$o) . ")"; |
67 | 69 | } |
68 | 70 | |
69 | 71 | static function iterSplit($v, $sep = ",") { |
70 | 72 | $o = []; |
71 | 73 | foreach(explode($sep, $v) as $k=>$i) { |
72 | - if($i) |
|
73 | - $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k]; |
|
74 | + if($i) { |
|
75 | + $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k]; |
|
76 | + } |
|
74 | 77 | } |
75 | 78 | return new WrapArray($o); |
76 | 79 | } |