@@ -34,9 +34,9 @@ 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 | 42 | if (!$s[0]) throw new ParseError("Unable to parse Complex Expression"); |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | function toHTML($escape = false) { |
54 | - if($escape) |
|
55 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
54 | + if ($escape) |
|
55 | + return "<?=htmlspecialchars(" . $this->toPHP() . ")?>"; |
|
56 | 56 | return "<?=" . $this->toPHP() . "?>"; |
57 | 57 | } |
58 | 58 | function toPHP() { |
59 | - return $this->filter?$this->filter->toPHP():$this->toPHPVar(); |
|
59 | + return $this->filter ? $this->filter->toPHP() : $this->toPHPVar(); |
|
60 | 60 | } |
61 | 61 | function toPHPVar() { |
62 | 62 | if ($this->sel) { |
@@ -39,20 +39,24 @@ discard block |
||
39 | 39 | $s = substr($s,0,$pos); |
40 | 40 | } |
41 | 41 | $s = explode("->", $s); |
42 | - if (!$s[0]) throw new ParseError("Unable to parse Complex Expression"); |
|
43 | - if ($s[0][1] == "(") |
|
44 | - $this->func = new Text\Func($s[0]); |
|
45 | - elseif ($s[0][1] == "[") |
|
46 | - $this->func = new Text\Scope($s[0]); |
|
47 | - else |
|
48 | - $this->func = new SimpleVar($s[0]); |
|
42 | + if (!$s[0]) { |
|
43 | + throw new ParseError("Unable to parse Complex Expression"); |
|
44 | + } |
|
45 | + if ($s[0][1] == "(") { |
|
46 | + $this->func = new Text\Func($s[0]); |
|
47 | + } elseif ($s[0][1] == "[") { |
|
48 | + $this->func = new Text\Scope($s[0]); |
|
49 | + } else { |
|
50 | + $this->func = new SimpleVar($s[0]); |
|
51 | + } |
|
49 | 52 | array_shift($s); |
50 | 53 | $this->sel = $s; |
51 | 54 | } |
52 | 55 | |
53 | 56 | function toHTML($escape = false) { |
54 | - if($escape) |
|
55 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
57 | + if($escape) { |
|
58 | + return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
59 | + } |
|
56 | 60 | return "<?=" . $this->toPHP() . "?>"; |
57 | 61 | } |
58 | 62 | function toPHP() { |
@@ -61,11 +65,13 @@ discard block |
||
61 | 65 | function toPHPVar() { |
62 | 66 | if ($this->sel) { |
63 | 67 | $sel = array(); |
64 | - foreach ($this->sel as $s) |
|
65 | - $sel[] = "hamleGet('$s')"; |
|
68 | + foreach ($this->sel as $s) { |
|
69 | + $sel[] = "hamleGet('$s')"; |
|
70 | + } |
|
66 | 71 | return $this->func->toPHP() . "->" . implode('->', $sel); |
67 | - } else |
|
68 | - return $this->func->toPHP(); |
|
72 | + } else { |
|
73 | + return $this->func->toPHP(); |
|
74 | + } |
|
69 | 75 | } |
70 | 76 | |
71 | 77 | } |
72 | 78 | \ No newline at end of file |
@@ -13,6 +13,9 @@ |
||
13 | 13 | protected $s; |
14 | 14 | protected $type; |
15 | 15 | |
16 | + /** |
|
17 | + * @param string $s |
|
18 | + */ |
|
16 | 19 | function __construct($s, $type = self::TOKEN_HTML) { |
17 | 20 | $this->s = str_replace('\\$', "$", $s); |
18 | 21 | $this->type = $type; |
@@ -34,16 +34,18 @@ |
||
34 | 34 | function __construct($s) { |
35 | 35 | $m = array(); |
36 | 36 | //var_dump($s); |
37 | - if (!preg_match('/\$\[(-?[0-9]+|[a-zA-Z][a-zA-Z0-9]+)\]/', $s, $m)) |
|
38 | - throw new ParseError("Unable to match scope ($s)"); |
|
37 | + if (!preg_match('/\$\[(-?[0-9]+|[a-zA-Z][a-zA-Z0-9]+)\]/', $s, $m)) { |
|
38 | + throw new ParseError("Unable to match scope ($s)"); |
|
39 | + } |
|
39 | 40 | $this->scope = $m[1]; |
40 | 41 | } |
41 | 42 | |
42 | 43 | function toPHP() { |
43 | - if (is_numeric($this->scope)) |
|
44 | - return "Hamle\\Scope::get(" . Text::varToCode($this->scope) . ")"; |
|
45 | - else |
|
46 | - return "Hamle\\Scope::getName(" . Text::varToCode($this->scope) . ")"; |
|
44 | + if (is_numeric($this->scope)) { |
|
45 | + return "Hamle\\Scope::get(" . Text::varToCode($this->scope) . ")"; |
|
46 | + } else { |
|
47 | + return "Hamle\\Scope::getName(" . Text::varToCode($this->scope) . ")"; |
|
48 | + } |
|
47 | 49 | } |
48 | 50 | |
49 | 51 | function toHTML($escape = false) { |
@@ -33,22 +33,22 @@ |
||
33 | 33 | protected $filter; |
34 | 34 | |
35 | 35 | function __construct($s) { |
36 | - if(FALSE !== $pos = strpos($s,'|')) { |
|
37 | - $this->var = substr($s,1,$pos-1); |
|
38 | - $this->filter = new Filter(substr($s, $pos+1), $this); |
|
36 | + if (FALSE !== $pos = strpos($s, '|')) { |
|
37 | + $this->var = substr($s, 1, $pos - 1); |
|
38 | + $this->filter = new Filter(substr($s, $pos + 1), $this); |
|
39 | 39 | } else { |
40 | 40 | $this->var = substr($s, 1); |
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
44 | 44 | function toHTML($escape = false) { |
45 | - if($escape) |
|
46 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
45 | + if ($escape) |
|
46 | + return "<?=htmlspecialchars(" . $this->toPHP() . ")?>"; |
|
47 | 47 | return "<?=" . $this->toPHP() . "?>"; |
48 | 48 | } |
49 | 49 | |
50 | 50 | function toPHP() { |
51 | - return $this->filter?$this->filter->toPHP():$this->toPHPVar(); |
|
51 | + return $this->filter ? $this->filter->toPHP() : $this->toPHPVar(); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | function toPHPVar() { |
@@ -42,8 +42,9 @@ |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | function toHTML($escape = false) { |
45 | - if($escape) |
|
46 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
45 | + if($escape) { |
|
46 | + return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
47 | + } |
|
47 | 48 | return "<?=" . $this->toPHP() . "?>"; |
48 | 49 | } |
49 | 50 |
@@ -50,15 +50,17 @@ |
||
50 | 50 | } |
51 | 51 | |
52 | 52 | function toHTML($escape = false) { |
53 | - if($escape) |
|
54 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
53 | + if($escape) { |
|
54 | + return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
55 | + } |
|
55 | 56 | return "<?=" . $this->toPHP() . "?>"; |
56 | 57 | } |
57 | 58 | |
58 | 59 | function toPHP() { |
59 | 60 | $o = [$this->what->toPHPVar()] ; |
60 | - foreach($this->vars as $v) |
|
61 | - $o[] = $this->varToCode($v); |
|
61 | + foreach($this->vars as $v) { |
|
62 | + $o[] = $this->varToCode($v); |
|
63 | + } |
|
62 | 64 | return "{$this->filter}(" . implode(',',$o) . ")"; |
63 | 65 | } |
64 | 66 | } |
65 | 67 | \ No newline at end of file |
@@ -13,6 +13,9 @@ |
||
13 | 13 | protected $s; |
14 | 14 | protected $type; |
15 | 15 | |
16 | + /** |
|
17 | + * @param string $s |
|
18 | + */ |
|
16 | 19 | function __construct($s, $type = self::TOKEN_HTML) { |
17 | 20 | $this->s = str_replace('\\$', "$", $s); |
18 | 21 | $this->type = $type; |
@@ -37,28 +37,28 @@ |
||
37 | 37 | protected $what; |
38 | 38 | |
39 | 39 | function __construct($s, Text $what) { |
40 | - if(preg_match("/^([a-z]+)(\\((.*)\\))?$/",$s, $m)) { |
|
40 | + if (preg_match("/^([a-z]+)(\\((.*)\\))?$/", $s, $m)) { |
|
41 | 41 | $this->filter = $m[1]; |
42 | - $this->vars = isset($m[3])?explode(',',$m[3]):[]; |
|
42 | + $this->vars = isset($m[3]) ? explode(',', $m[3]) : []; |
|
43 | 43 | } else { |
44 | 44 | throw new ParseError("Unable to parse filter expression \"$s\""); |
45 | 45 | } |
46 | - if(!in_array($this->filter,['round','strtoupper','strtolower','ucfirst'])) { |
|
46 | + if (!in_array($this->filter, ['round', 'strtoupper', 'strtolower', 'ucfirst'])) { |
|
47 | 47 | throw new ParseError("Unknown Filter Type \"{$this->filter}\""); |
48 | 48 | } |
49 | 49 | $this->what = $what; |
50 | 50 | } |
51 | 51 | |
52 | 52 | function toHTML($escape = false) { |
53 | - if($escape) |
|
54 | - return "<?=htmlspecialchars(" .$this->toPHP() . ")?>"; |
|
53 | + if ($escape) |
|
54 | + return "<?=htmlspecialchars(" . $this->toPHP() . ")?>"; |
|
55 | 55 | return "<?=" . $this->toPHP() . "?>"; |
56 | 56 | } |
57 | 57 | |
58 | 58 | function toPHP() { |
59 | - $o = [$this->what->toPHPVar()] ; |
|
60 | - foreach($this->vars as $v) |
|
59 | + $o = [$this->what->toPHPVar()]; |
|
60 | + foreach ($this->vars as $v) |
|
61 | 61 | $o[] = $this->varToCode($v); |
62 | - return "{$this->filter}(" . implode(',',$o) . ")"; |
|
62 | + return "{$this->filter}(" . implode(',', $o) . ")"; |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | \ No newline at end of file |
@@ -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,20 +49,20 @@ 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 | - return $p1." == ".$p2; |
|
58 | + return $p1 . " == " . $p2; |
|
59 | 59 | case "notequals": |
60 | 60 | case "notequal": |
61 | - return $p1." != ".$p2; |
|
61 | + return $p1 . " != " . $p2; |
|
62 | 62 | case "less": |
63 | - return $p1." < ".$p2; |
|
63 | + return $p1 . " < " . $p2; |
|
64 | 64 | case "greater": |
65 | - return $p1." > ".$p2; |
|
65 | + return $p1 . " > " . $p2; |
|
66 | 66 | case "has": |
67 | 67 | return "in_array($p2, $p1)"; |
68 | 68 | case "starts": |
@@ -39,8 +39,9 @@ discard block |
||
39 | 39 | $this->param1 = new Text($m[1],Text::TOKEN_HTML); |
40 | 40 | $this->param2 = new Text($m[3],Text::TOKEN_HTML); |
41 | 41 | $this->operator = $m[2]; |
42 | - } else |
|
43 | - $this->param1 = new Text($s,Text::TOKEN_HTML); |
|
42 | + } else { |
|
43 | + $this->param1 = new Text($s,Text::TOKEN_HTML); |
|
44 | + } |
|
44 | 45 | } |
45 | 46 | |
46 | 47 | // function __construct(String $p1, String $p2, $operator) { |
@@ -49,7 +50,9 @@ discard block |
||
49 | 50 | // $this->operator = $operator; |
50 | 51 | // } |
51 | 52 | function toPHP() { |
52 | - if(!$this->param2) return $this->param1->toPHP(); |
|
53 | + if(!$this->param2) { |
|
54 | + return $this->param1->toPHP(); |
|
55 | + } |
|
53 | 56 | $p1 = $this->param1->toPHP(); |
54 | 57 | $p2 = $this->param2->toPHP(); |
55 | 58 | switch($this->operator) { |
@@ -13,6 +13,9 @@ |
||
13 | 13 | protected $s; |
14 | 14 | protected $type; |
15 | 15 | |
16 | + /** |
|
17 | + * @param string $s |
|
18 | + */ |
|
16 | 19 | function __construct($s, $type = self::TOKEN_HTML) { |
17 | 20 | $this->s = str_replace('\\$', "$", $s); |
18 | 21 | $this->type = $type; |
@@ -31,7 +31,8 @@ |
||
31 | 31 | function __construct($s) { |
32 | 32 | $s = explode("->", $s, 2); |
33 | 33 | $this->key = $s[0]; |
34 | - if (count($s) > 1) |
|
35 | - $this->sel = $s[1]; |
|
34 | + if (count($s) > 1) { |
|
35 | + $this->sel = $s[1]; |
|
36 | + } |
|
36 | 37 | } |
37 | 38 | } |
38 | 39 | \ No newline at end of file |
@@ -76,9 +76,10 @@ discard block |
||
76 | 76 | } |
77 | 77 | array_shift($path); |
78 | 78 | } |
79 | - foreach ($this->tags as $tag) |
|
80 | - if ($found = $tag->find($path)) |
|
81 | - $list = array_merge($list, $found); |
|
79 | + foreach ($this->tags as $tag) { |
|
80 | + if ($found = $tag->find($path)) |
|
81 | + $list = array_merge($list, $found); |
|
82 | + } |
|
82 | 83 | return $list; |
83 | 84 | } |
84 | 85 | |
@@ -90,7 +91,9 @@ discard block |
||
90 | 91 | */ |
91 | 92 | function replace($path, Tag $newTag) { |
92 | 93 | if ($this->compare($path[0])) { |
93 | - if (count($path) == 1) return $newTag; |
|
94 | + if (count($path) == 1) { |
|
95 | + return $newTag; |
|
96 | + } |
|
94 | 97 | array_shift($path); |
95 | 98 | } |
96 | 99 | foreach ($this->tags as $k => $tag) { |
@@ -103,21 +106,25 @@ discard block |
||
103 | 106 | } |
104 | 107 | |
105 | 108 | function addSnipContent($contentTag, &$tagArray = array(), $key = 0) { |
106 | - foreach ($this->tags as $k => $tag) |
|
107 | - $tag->addSnipContent($contentTag, $this->tags, $k); |
|
109 | + foreach ($this->tags as $k => $tag) { |
|
110 | + $tag->addSnipContent($contentTag, $this->tags, $k); |
|
111 | + } |
|
108 | 112 | } |
109 | 113 | |
110 | 114 | function compare($tic) { |
111 | - if (isset($tic['type']) && $this->type != $tic['type']) |
|
112 | - return false; |
|
115 | + if (isset($tic['type']) && $this->type != $tic['type']) { |
|
116 | + return false; |
|
117 | + } |
|
113 | 118 | if (isset($tic['id']) && |
114 | 119 | !(isset($this->opt['id']) && $tic['id'] == $this->opt['id']) |
115 | - ) |
|
116 | - return false; |
|
120 | + ) { |
|
121 | + return false; |
|
122 | + } |
|
117 | 123 | if (isset($tic['class']) && !(isset($this->opt['class']) |
118 | 124 | && !array_diff($tic['class'], $this->opt['class'])) |
119 | - ) |
|
120 | - return false; |
|
125 | + ) { |
|
126 | + return false; |
|
127 | + } |
|
121 | 128 | return true; |
122 | 129 | } |
123 | 130 | |
@@ -127,10 +134,11 @@ discard block |
||
127 | 134 | * @param string $mode Mode to add child [append|prepend] |
128 | 135 | */ |
129 | 136 | function addChild(Tag $tag, $mode = "append") { |
130 | - if ($mode == "prepend") |
|
131 | - array_unshift($this->tags, $tag); |
|
132 | - else |
|
133 | - $this->tags[] = $tag; |
|
137 | + if ($mode == "prepend") { |
|
138 | + array_unshift($this->tags, $tag); |
|
139 | + } else { |
|
140 | + $this->tags[] = $tag; |
|
141 | + } |
|
134 | 142 | } |
135 | 143 | |
136 | 144 | /** |
@@ -145,9 +153,12 @@ discard block |
||
145 | 153 | $ind = $doIndent ? str_pad("", $indent, " ") : ""; |
146 | 154 | $oneliner = ((count($this->content) > 1 || $this->tags) ? false : true); |
147 | 155 | $out = $ind . $this->renderStTag() . ($oneliner ? "" : "\n"); |
148 | - if ($this->content) $out .= $this->renderContent($ind, $oneliner); |
|
149 | - foreach ($this->tags as $tag) |
|
150 | - $out .= $tag->render($indent + self::INDENT_SIZE); |
|
156 | + if ($this->content) { |
|
157 | + $out .= $this->renderContent($ind, $oneliner); |
|
158 | + } |
|
159 | + foreach ($this->tags as $tag) { |
|
160 | + $out .= $tag->render($indent + self::INDENT_SIZE); |
|
161 | + } |
|
151 | 162 | $out .= ($oneliner ? "" : $ind) . $this->renderEnTag() . "\n"; |
152 | 163 | return $out; |
153 | 164 | } |
@@ -161,8 +172,9 @@ discard block |
||
161 | 172 | */ |
162 | 173 | function renderContent($pad = "", $oneliner = false) { |
163 | 174 | $out = ""; |
164 | - foreach ($this->content as $c) |
|
165 | - $out .= ($oneliner ? "" : $pad) . $c . ($oneliner ? "" : "\n"); |
|
175 | + foreach ($this->content as $c) { |
|
176 | + $out .= ($oneliner ? "" : $pad) . $c . ($oneliner ? "" : "\n"); |
|
177 | + } |
|
166 | 178 | return $out; |
167 | 179 | } |
168 | 180 |
@@ -36,14 +36,18 @@ |
||
36 | 36 | function getInputAttDynamic(&$atts, &$type, &$content) { |
37 | 37 | parent::getInputAttDynamic($atts, $type, $content); |
38 | 38 | $atts['value'] = "ON"; |
39 | - if ($this->getValue()) |
|
40 | - $atts['checked'] = "checked"; |
|
39 | + if ($this->getValue()) { |
|
40 | + $atts['checked'] = "checked"; |
|
41 | + } |
|
41 | 42 | } |
42 | 43 | |
43 | 44 | function getValue() { |
44 | - if (!is_null($this->setValue)) return $this->setValue; |
|
45 | - if (isset($_REQUEST[$this->form . "__submit"])) |
|
46 | - return isset($_REQUEST[$this->form . "_" . $this->name]); |
|
45 | + if (!is_null($this->setValue)) { |
|
46 | + return $this->setValue; |
|
47 | + } |
|
48 | + if (isset($_REQUEST[$this->form . "__submit"])) { |
|
49 | + return isset($_REQUEST[$this->form . "_" . $this->name]); |
|
50 | + } |
|
47 | 51 | return $this->opt['default']; |
48 | 52 | } |
49 | 53 | } |
50 | 54 | \ No newline at end of file |
@@ -35,8 +35,9 @@ |
||
35 | 35 | } |
36 | 36 | |
37 | 37 | function hamleGet($key) { |
38 | - if (!isset($this->data[$this->pos][$key])) |
|
39 | - return "Missing Key [$key]"; |
|
38 | + if (!isset($this->data[$this->pos][$key])) { |
|
39 | + return "Missing Key [$key]"; |
|
40 | + } |
|
40 | 41 | return $this->data[$this->pos][$key]; |
41 | 42 | } |
42 | 43 |