@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | |
36 | 36 | function __construct($s, $mode = self::TOKEN_CONTROL) { |
37 | 37 | $m = array(); |
38 | - if(preg_match('/^(.*) '.self::REGEX_COMP_OPER.' (.*)$/', $s, $m)) { |
|
39 | - $this->param1 = new Text($m[1],Text::TOKEN_HTML); |
|
40 | - $this->param2 = new Text($m[3],Text::TOKEN_HTML); |
|
38 | + if (preg_match('/^(.*) '.self::REGEX_COMP_OPER.' (.*)$/', $s, $m)) { |
|
39 | + $this->param1 = new Text($m[1], Text::TOKEN_HTML); |
|
40 | + $this->param2 = new Text($m[3], Text::TOKEN_HTML); |
|
41 | 41 | $this->operator = $m[2]; |
42 | 42 | } else |
43 | - $this->param1 = new Text($s,Text::TOKEN_HTML); |
|
43 | + $this->param1 = new Text($s, Text::TOKEN_HTML); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | // function __construct(String $p1, String $p2, $operator) { |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | // $this->operator = $operator; |
50 | 50 | // } |
51 | 51 | function toPHP() { |
52 | - if(!$this->param2) return $this->param1->toPHP(); |
|
52 | + if (!$this->param2) return $this->param1->toPHP(); |
|
53 | 53 | $p1 = $this->param1->toPHP(); |
54 | 54 | $p2 = $this->param2->toPHP(); |
55 | - switch($this->operator) { |
|
55 | + switch ($this->operator) { |
|
56 | 56 | case "equals": |
57 | 57 | case "equal": |
58 | 58 | return $p1." == ".$p2; |
@@ -35,10 +35,10 @@ |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | function toPHP() { |
38 | - return '$form->getField(' . Text::varToCode($this->var) . ')->getValue()'; |
|
38 | + return '$form->getField('.Text::varToCode($this->var).')->getValue()'; |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | function toHTML($escape = false) { |
42 | - return '<?=' . $this->toPHP() . '?>'; |
|
42 | + return '<?='.$this->toPHP().'?>'; |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | \ No newline at end of file |
@@ -34,12 +34,12 @@ discard block |
||
34 | 34 | protected $filter; |
35 | 35 | |
36 | 36 | function __construct($s) { |
37 | - if(FALSE !== $pos = strpos($s,'|')) { |
|
38 | - $this->filter = new Filter(substr($s, $pos+1), $this); |
|
39 | - $s = substr($s,0,$pos); |
|
37 | + if (FALSE !== $pos = strpos($s, '|')) { |
|
38 | + $this->filter = new Filter(substr($s, $pos + 1), $this); |
|
39 | + $s = substr($s, 0, $pos); |
|
40 | 40 | } |
41 | 41 | $s = explode("->", $s); |
42 | - if(count($s) == 1) $s = explode("-!",$s[0]); |
|
42 | + if (count($s) == 1) $s = explode("-!", $s[0]); |
|
43 | 43 | if (!$s[0]) throw new ParseError("Unable to parse Complex Expression"); |
44 | 44 | if ($s[0][1] == "(") |
45 | 45 | $this->func = new Text\Func($s[0]); |
@@ -52,19 +52,19 @@ discard block |
||
52 | 52 | } |
53 | 53 | |
54 | 54 | function toHTML($escape = false) { |
55 | - if($escape) |
|
56 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
57 | - return "<?=" . $this->toPHP() . "?>"; |
|
55 | + if ($escape) |
|
56 | + return "<?=htmlspecialchars(".$this->toPHP().")?>"; |
|
57 | + return "<?=".$this->toPHP()."?>"; |
|
58 | 58 | } |
59 | 59 | function toPHP() { |
60 | - return $this->filter?$this->filter->toPHP():$this->toPHPVar(); |
|
60 | + return $this->filter ? $this->filter->toPHP() : $this->toPHPVar(); |
|
61 | 61 | } |
62 | 62 | function toPHPVar() { |
63 | 63 | if ($this->sel) { |
64 | 64 | $sel = array(); |
65 | 65 | foreach ($this->sel as $s) |
66 | 66 | $sel[] = "hamleGet('$s')"; |
67 | - return $this->func->toPHP() . "->" . implode('->', $sel); |
|
67 | + return $this->func->toPHP()."->".implode('->', $sel); |
|
68 | 68 | } else |
69 | 69 | return $this->func->toPHP(); |
70 | 70 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | function __construct($s) { |
40 | 40 | $m = array(); |
41 | - if (!preg_match('/^ +([><]) +('.self::REGEX_FUNCSEL . '+)(.*)$/', $s, $m)) |
|
41 | + if (!preg_match('/^ +([><]) +('.self::REGEX_FUNCSEL.'+)(.*)$/', $s, $m)) |
|
42 | 42 | throw new ParseError("Unable to read \$ sub func in '$s'"); |
43 | 43 | if ($m[1] == "<") $this->dir = Hamle\Hamle::REL_PARENT; |
44 | 44 | elseif ($m[1] == ">") $this->dir = Hamle\Hamle::REL_CHILD; |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | * @return string |
57 | 57 | */ |
58 | 58 | function toPHP() { |
59 | - $limit = Hamle\Text::varToCode($this->sortlimit['sort']) . "," . |
|
60 | - $this->sortlimit['limit'] . "," . $this->sortlimit['offset'] . "," . |
|
59 | + $limit = Hamle\Text::varToCode($this->sortlimit['sort']).",". |
|
60 | + $this->sortlimit['limit'].",".$this->sortlimit['offset'].",". |
|
61 | 61 | $this->grouptype['grouptype']; |
62 | - $sub = $this->sub ? "->" . $this->sub->toPHP() : ""; |
|
63 | - return "hamleRel(" . $this->dir . "," . |
|
64 | - Hamle\Text::varToCode($this->filt['tag']) . ",$limit)$sub"; |
|
62 | + $sub = $this->sub ? "->".$this->sub->toPHP() : ""; |
|
63 | + return "hamleRel(".$this->dir.",". |
|
64 | + Hamle\Text::varToCode($this->filt['tag']).",$limit)$sub"; |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | \ No newline at end of file |
@@ -41,9 +41,9 @@ |
||
41 | 41 | |
42 | 42 | function toPHP() { |
43 | 43 | if (is_numeric($this->scope)) |
44 | - return "Hamle\\Scope::get(" . Text::varToCode($this->scope) . ")"; |
|
44 | + return "Hamle\\Scope::get(".Text::varToCode($this->scope).")"; |
|
45 | 45 | else |
46 | - return "Hamle\\Scope::getName(" . Text::varToCode($this->scope) . ")"; |
|
46 | + return "Hamle\\Scope::getName(".Text::varToCode($this->scope).")"; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | function toHTML($escape = false) { |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | $i = self::indentLevel($indent); |
158 | 158 | unset($m[0]); |
159 | 159 | switch (strlen($code) ? $code[0] : ($textcode ? $textcode : "")) { |
160 | - case "|": //Control Tag |
|
160 | + case "|" : //Control Tag |
|
161 | 161 | if ($code == "|snippet") |
162 | 162 | $hTag = new Tag\Snippet($text); |
163 | 163 | elseif ($code == "|form") |
@@ -192,10 +192,10 @@ discard block |
||
192 | 192 | break; |
193 | 193 | default: |
194 | 194 | $attr = array(); |
195 | - if(isset($params[0]) && $params[0] == "[") { |
|
195 | + if (isset($params[0]) && $params[0] == "[") { |
|
196 | 196 | $param = substr($params, 1, strlen($params) - 2); |
197 | - $param = str_replace('+','%2B', $param); |
|
198 | - $param = str_replace('\\&','%26', $param); |
|
197 | + $param = str_replace('+', '%2B', $param); |
|
198 | + $param = str_replace('\\&', '%26', $param); |
|
199 | 199 | // parse_str($param, $attr); |
200 | 200 | $attr = $this->parseQueryString($param); |
201 | 201 | } |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | if ($s[0] == ".") $class[] = substr($s, 1); |
207 | 207 | if ($s[0] == "!") $ref = substr($s, 1); |
208 | 208 | } |
209 | - if($ref) |
|
209 | + if ($ref) |
|
210 | 210 | $hTag = new Tag\DynHtml($tag, $class, $attr, $id, $ref); |
211 | 211 | else |
212 | 212 | $hTag = new Tag\Html($tag, $class, $attr, $id); |
@@ -219,16 +219,16 @@ discard block |
||
219 | 219 | else |
220 | 220 | $this->root[] = $hTag; |
221 | 221 | } else |
222 | - throw new ParseError("Unable to parse line {$this->lineNo}\n\"$line\"/" . preg_last_error()); |
|
222 | + throw new ParseError("Unable to parse line {$this->lineNo}\n\"$line\"/".preg_last_error()); |
|
223 | 223 | $this->lineNo++; |
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | 227 | function parseQueryString($qs) { |
228 | 228 | $out = []; |
229 | - foreach(explode('&',$qs) as $s) { |
|
230 | - $kv = explode('=',$s,2); |
|
231 | - $out[urldecode($kv[0])] = isset($kv[1])?urldecode($kv[1]):null; |
|
229 | + foreach (explode('&', $qs) as $s) { |
|
230 | + $kv = explode('=', $s, 2); |
|
231 | + $out[urldecode($kv[0])] = isset($kv[1]) ? urldecode($kv[1]) : null; |
|
232 | 232 | } |
233 | 233 | return $out; |
234 | 234 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | $m = array(); |
247 | 247 | while ($this->lineNo + 1 < $this->lineCount && |
248 | 248 | (!trim($this->lines[$this->lineNo + 1]) || |
249 | - preg_match('/^(\s){' . $indent . '}((\s)+[^\s].*)$/', |
|
249 | + preg_match('/^(\s){'.$indent.'}((\s)+[^\s].*)$/', |
|
250 | 250 | $this->lines[$this->lineNo + 1], $m))) { |
251 | 251 | if (trim($this->lines[$this->lineNo + 1])) |
252 | 252 | $out[] = $m[2]; |
@@ -38,55 +38,55 @@ |
||
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 | 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 | } else { |
47 | 47 | throw new ParseError("Unable to parse filter expression \"$s\""); |
48 | 48 | } |
49 | - if(!in_array($this->filter, ['itersplit', 'newlinebr', 'round', |
|
50 | - 'strtoupper', 'strtolower', 'ucfirst','replace', 'json'])) { |
|
49 | + if (!in_array($this->filter, ['itersplit', 'newlinebr', 'round', |
|
50 | + 'strtoupper', 'strtolower', 'ucfirst', 'replace', 'json'])) { |
|
51 | 51 | throw new ParseError("Unknown Filter Type \"{$this->filter}\""); |
52 | 52 | } |
53 | - if(in_array($this->filter,['itersplit','newlinebr', 'replace'])) { |
|
53 | + if (in_array($this->filter, ['itersplit', 'newlinebr', 'replace'])) { |
|
54 | 54 | $this->filter = "Seufert\\Hamle\\Text\\Filter::{$this->filter}"; |
55 | 55 | } |
56 | 56 | $mapFilter = ['json'=>'json_encode']; |
57 | - if(isset($mapFilter[$this->filter])) |
|
57 | + if (isset($mapFilter[$this->filter])) |
|
58 | 58 | $this->filter = $mapFilter[$this->filter]; |
59 | 59 | $this->what = $what; |
60 | 60 | } |
61 | 61 | |
62 | 62 | function toHTML($escape = false) { |
63 | - if($escape) |
|
64 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
65 | - return "<?=" . $this->toPHP() . "?>"; |
|
63 | + if ($escape) |
|
64 | + return "<?=htmlspecialchars(".$this->toPHP().")?>"; |
|
65 | + return "<?=".$this->toPHP()."?>"; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | function toPHP() { |
69 | - $o = [$this->what->toPHPVar()] ; |
|
70 | - foreach($this->vars as $v) |
|
69 | + $o = [$this->what->toPHPVar()]; |
|
70 | + foreach ($this->vars as $v) |
|
71 | 71 | $o[] = $this->varToCode($v); |
72 | - return "{$this->filter}(" . implode(',',$o) . ")"; |
|
72 | + return "{$this->filter}(".implode(',', $o).")"; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | static function itersplit($v, $sep = ",") { |
76 | 76 | $o = []; |
77 | - foreach(explode($sep, $v) as $k=>$i) { |
|
78 | - if($i) |
|
79 | - $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k,'key'=>$k]; |
|
77 | + foreach (explode($sep, $v) as $k=>$i) { |
|
78 | + if ($i) |
|
79 | + $o[] = ['v'=>trim($i), 'value'=>trim($i), 'k'=>$k, 'key'=>$k]; |
|
80 | 80 | } |
81 | 81 | return new WrapArray($o); |
82 | 82 | } |
83 | 83 | |
84 | 84 | static function newlinebr($v) { |
85 | - return str_replace("\n","<br />\n",$v); |
|
85 | + return str_replace("\n", "<br />\n", $v); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | static function replace($v, $src, $dst) { |
89 | - return str_replace($src,$dst,$v); |
|
89 | + return str_replace($src, $dst, $v); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | } |
93 | 93 | \ No newline at end of file |
@@ -67,7 +67,7 @@ |
||
67 | 67 | self::$namedScopes[$name]->rewind(); |
68 | 68 | return self::$namedScopes[$name]; |
69 | 69 | } else |
70 | - if(self::$returnZeroOnNoScope) |
|
70 | + if (self::$returnZeroOnNoScope) |
|
71 | 71 | return new Model\Zero(); |
72 | 72 | throw new RunTime("Unable to find scope ($name)"); |
73 | 73 | } |
@@ -42,6 +42,6 @@ |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | function isClicked() { |
45 | - return isset($_REQUEST[$this->form . "_" . $this->name]); |
|
45 | + return isset($_REQUEST[$this->form."_".$this->name]); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | \ No newline at end of file |