@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $i = self::indentLevel($indent); |
157 | 157 | unset($m[0]); |
158 | 158 | switch (strlen($code) ? $code[0] : ($textcode ? $textcode : "")) { |
159 | - case "|": //Control Tag |
|
159 | + case "|" : //Control Tag |
|
160 | 160 | if ($code == "|snippet") |
161 | 161 | $hTag = new Tag\Snippet($text); |
162 | 162 | elseif ($code == "|form") |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | break; |
197 | 197 | default: |
198 | 198 | $attr = array(); |
199 | - if(isset($params[0]) && $params[0] == "[") { |
|
199 | + if (isset($params[0]) && $params[0] == "[") { |
|
200 | 200 | $param = substr($params, 1, -1); |
201 | 201 | $param = str_replace(['+', '\\&'], ['%2B', '%26'], $param); |
202 | 202 | // parse_str($param, $attr); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | if ($s[0] == ".") $class[] = substr($s, 1); |
210 | 210 | if ($s[0] == "!") $ref = substr($s, 1); |
211 | 211 | } |
212 | - if($ref) |
|
212 | + if ($ref) |
|
213 | 213 | $hTag = new Tag\DynHtml($tag, $class, $attr, $id, $ref); |
214 | 214 | else |
215 | 215 | $hTag = new Tag\Html($tag, $class, $attr, $id); |
@@ -222,16 +222,16 @@ discard block |
||
222 | 222 | else |
223 | 223 | $this->root[] = $hTag; |
224 | 224 | } else |
225 | - throw new ParseError("Unable to parse line {$this->lineNo}\n\"$line\"/" . preg_last_error()); |
|
225 | + throw new ParseError("Unable to parse line {$this->lineNo}\n\"$line\"/".preg_last_error()); |
|
226 | 226 | $this->lineNo++; |
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
230 | 230 | function parseQueryString($qs) { |
231 | 231 | $out = []; |
232 | - foreach(explode('&',$qs) as $s) { |
|
233 | - $kv = explode('=',$s,2); |
|
234 | - $out[urldecode($kv[0])] = isset($kv[1])?urldecode($kv[1]):null; |
|
232 | + foreach (explode('&', $qs) as $s) { |
|
233 | + $kv = explode('=', $s, 2); |
|
234 | + $out[urldecode($kv[0])] = isset($kv[1]) ?urldecode($kv[1]) : null; |
|
235 | 235 | } |
236 | 236 | return $out; |
237 | 237 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $m = array(); |
250 | 250 | while ($this->lineNo + 1 < $this->lineCount && |
251 | 251 | (!trim($this->lines[$this->lineNo + 1]) || |
252 | - preg_match('/^(\s){' . $indent . '}((\s)+[^\s].*)$/', |
|
252 | + preg_match('/^(\s){'.$indent.'}((\s)+[^\s].*)$/', |
|
253 | 253 | $this->lines[$this->lineNo + 1], $m))) { |
254 | 254 | if (trim($this->lines[$this->lineNo + 1])) |
255 | 255 | $out[] = $m[2]; |
@@ -46,23 +46,23 @@ discard block |
||
46 | 46 | static $filterResolver = null; |
47 | 47 | |
48 | 48 | function __construct($s, Text $what) { |
49 | - if(preg_match("/^([a-z_]+)(?:\\((?P<vars>.*)\\))?(?:\\|(?P<chained>.+?))?$/", $s, $m)) { |
|
49 | + if (preg_match("/^([a-z_]+)(?:\\((?P<vars>.*)\\))?(?:\\|(?P<chained>.+?))?$/", $s, $m)) { |
|
50 | 50 | $this->filter = $m[1]; |
51 | 51 | $this->vars = isset($m['vars']) && strlen($m['vars']) ? explode(',', $m['vars']) : []; |
52 | - foreach($this->vars as $k=>$v) |
|
53 | - $this->vars[$k] = str_replace(",",',',$v); |
|
54 | - if(isset($m['chained']) && strlen($m['chained'])) { |
|
55 | - $this->chained = new Filter($m['chained'],$what); |
|
52 | + foreach ($this->vars as $k=>$v) |
|
53 | + $this->vars[$k] = str_replace(",", ',', $v); |
|
54 | + if (isset($m['chained']) && strlen($m['chained'])) { |
|
55 | + $this->chained = new Filter($m['chained'], $what); |
|
56 | 56 | } |
57 | 57 | } else { |
58 | 58 | throw new ParseError("Unable to parse filter expression \"$s\""); |
59 | 59 | } |
60 | - if(method_exists(Filter::class, $this->filter)) { |
|
60 | + if (method_exists(Filter::class, $this->filter)) { |
|
61 | 61 | $this->filter = Filter::class.'::'.$this->filter; |
62 | - } elseif(in_array($this->filter, ['round', 'strtoupper', 'strtolower', 'ucfirst'])) { |
|
63 | - } elseif($this->filter === 'json') { |
|
62 | + } elseif (in_array($this->filter, ['round', 'strtoupper', 'strtolower', 'ucfirst'])) { |
|
63 | + } elseif ($this->filter === 'json') { |
|
64 | 64 | $this->filter = 'json_encode'; |
65 | - } elseif(self::$filterResolver && $filter = (self::$filterResolver)($this->filter)) { |
|
65 | + } elseif (self::$filterResolver && $filter = (self::$filterResolver)($this->filter)) { |
|
66 | 66 | $this->filter = $filter; |
67 | 67 | } else { |
68 | 68 | throw new ParseError("Unknown Filter Type \"{$this->filter}\""); |
@@ -71,24 +71,24 @@ discard block |
||
71 | 71 | } |
72 | 72 | |
73 | 73 | function toHTML($escape = false) { |
74 | - if($escape) |
|
75 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
76 | - return "<?=" . $this->toPHP() . "?>"; |
|
74 | + if ($escape) |
|
75 | + return "<?=htmlspecialchars(".$this->toPHP().")?>"; |
|
76 | + return "<?=".$this->toPHP()."?>"; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | function toPHPpre() { |
80 | 80 | $pre = ''; |
81 | - if($this->chained) |
|
81 | + if ($this->chained) |
|
82 | 82 | $pre = $this->chained->toPHPpre(); |
83 | 83 | return "$pre{$this->filter}("; |
84 | 84 | } |
85 | 85 | |
86 | 86 | function toPHPpost() { |
87 | 87 | $post = ''; |
88 | - if($this->chained) |
|
88 | + if ($this->chained) |
|
89 | 89 | $post = $this->chained->toPHPpost(); |
90 | 90 | $o = ''; |
91 | - foreach($this->vars as $v) |
|
91 | + foreach ($this->vars as $v) |
|
92 | 92 | $o .= ','.$this->varToCode($v); |
93 | 93 | return "$o)$post"; |
94 | 94 | } |
@@ -103,24 +103,24 @@ discard block |
||
103 | 103 | |
104 | 104 | static function itersplit($v, $sep = ",") { |
105 | 105 | $o = []; |
106 | - foreach(explode($sep, $v) as $k=>$i) { |
|
107 | - if($i) |
|
108 | - $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k]; |
|
106 | + foreach (explode($sep, $v) as $k=>$i) { |
|
107 | + if ($i) |
|
108 | + $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k, 'key'=>$k]; |
|
109 | 109 | } |
110 | 110 | return new WrapArray($o); |
111 | 111 | } |
112 | 112 | |
113 | 113 | static function newlinebr($v) { |
114 | - return str_replace("\n","<br />\n",$v); |
|
114 | + return str_replace("\n", "<br />\n", $v); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | static function replace($v, $src, $dst) { |
118 | - return str_replace($src,$dst,$v); |
|
118 | + return str_replace($src, $dst, $v); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | static function ascents($v) { |
122 | - $v = str_replace(['$',' ',','],'', $v); |
|
123 | - return (int) round($v * 100,0); |
|
122 | + $v = str_replace(['$', ' ', ','], '', $v); |
|
123 | + return (int) round($v * 100, 0); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | } |