@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * PHPTAL templating engine |
|
4 | - * |
|
5 | - * PHP Version 5 |
|
6 | - * |
|
7 | - * @category HTML |
|
8 | - * @package PHPTAL |
|
9 | - * @author Laurent Bedubourg <[email protected]> |
|
10 | - * @author Kornel Lesiński <[email protected]> |
|
11 | - * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
12 | - * @version SVN: $Id$ |
|
13 | - * @link http://phptal.org/ |
|
14 | - */ |
|
3 | + * PHPTAL templating engine |
|
4 | + * |
|
5 | + * PHP Version 5 |
|
6 | + * |
|
7 | + * @category HTML |
|
8 | + * @package PHPTAL |
|
9 | + * @author Laurent Bedubourg <[email protected]> |
|
10 | + * @author Kornel Lesiński <[email protected]> |
|
11 | + * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
12 | + * @version SVN: $Id$ |
|
13 | + * @link http://phptal.org/ |
|
14 | + */ |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Wrong macro name in metal:use-macro |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * PHPTAL templating engine |
|
4 | - * |
|
5 | - * PHP Version 5 |
|
6 | - * |
|
7 | - * @category HTML |
|
8 | - * @package PHPTAL |
|
9 | - * @author Laurent Bedubourg <[email protected]> |
|
10 | - * @author Kornel Lesiński <[email protected]> |
|
11 | - * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
12 | - * @version SVN: $Id$ |
|
13 | - * @link http://phptal.org/ |
|
14 | - */ |
|
3 | + * PHPTAL templating engine |
|
4 | + * |
|
5 | + * PHP Version 5 |
|
6 | + * |
|
7 | + * @category HTML |
|
8 | + * @package PHPTAL |
|
9 | + * @author Laurent Bedubourg <[email protected]> |
|
10 | + * @author Kornel Lesiński <[email protected]> |
|
11 | + * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
12 | + * @version SVN: $Id$ |
|
13 | + * @link http://phptal.org/ |
|
14 | + */ |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * ${unknown:foo} found in template |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * PHPTAL templating engine |
|
4 | - * |
|
5 | - * PHP Version 5 |
|
6 | - * |
|
7 | - * @category HTML |
|
8 | - * @package PHPTAL |
|
9 | - * @author Laurent Bedubourg <[email protected]> |
|
10 | - * @author Kornel Lesiński <[email protected]> |
|
11 | - * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
12 | - * @version SVN: $Id$ |
|
13 | - * @link http://phptal.org/ |
|
14 | - */ |
|
3 | + * PHPTAL templating engine |
|
4 | + * |
|
5 | + * PHP Version 5 |
|
6 | + * |
|
7 | + * @category HTML |
|
8 | + * @package PHPTAL |
|
9 | + * @author Laurent Bedubourg <[email protected]> |
|
10 | + * @author Kornel Lesiński <[email protected]> |
|
11 | + * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
12 | + * @version SVN: $Id$ |
|
13 | + * @link http://phptal.org/ |
|
14 | + */ |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * @package PHPTAL |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * PHPTAL templating engine |
|
4 | - * |
|
5 | - * PHP Version 5 |
|
6 | - * |
|
7 | - * @category HTML |
|
8 | - * @package PHPTAL |
|
9 | - * @author Laurent Bedubourg <[email protected]> |
|
10 | - * @author Kornel Lesiński <[email protected]> |
|
11 | - * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
12 | - * @version SVN: $Id$ |
|
13 | - * @link http://phptal.org/ |
|
14 | - */ |
|
3 | + * PHPTAL templating engine |
|
4 | + * |
|
5 | + * PHP Version 5 |
|
6 | + * |
|
7 | + * @category HTML |
|
8 | + * @package PHPTAL |
|
9 | + * @author Laurent Bedubourg <[email protected]> |
|
10 | + * @author Kornel Lesiński <[email protected]> |
|
11 | + * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
12 | + * @version SVN: $Id$ |
|
13 | + * @link http://phptal.org/ |
|
14 | + */ |
|
15 | 15 | |
16 | 16 | |
17 | 17 | /** |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * PHPTAL templating engine |
|
4 | - * |
|
5 | - * PHP Version 5 |
|
6 | - * |
|
7 | - * @category HTML |
|
8 | - * @package PHPTAL |
|
9 | - * @author Laurent Bedubourg <[email protected]> |
|
10 | - * @author Kornel Lesiński <[email protected]> |
|
11 | - * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
12 | - * @version SVN: $Id$ |
|
13 | - * @link http://phptal.org/ |
|
14 | - */ |
|
3 | + * PHPTAL templating engine |
|
4 | + * |
|
5 | + * PHP Version 5 |
|
6 | + * |
|
7 | + * @category HTML |
|
8 | + * @package PHPTAL |
|
9 | + * @author Laurent Bedubourg <[email protected]> |
|
10 | + * @author Kornel Lesiński <[email protected]> |
|
11 | + * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
12 | + * @version SVN: $Id$ |
|
13 | + * @link http://phptal.org/ |
|
14 | + */ |
|
15 | 15 | |
16 | 16 | |
17 | 17 | /** |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * PHPTAL templating engine |
|
4 | - * |
|
5 | - * PHP Version 5 |
|
6 | - * |
|
7 | - * @category HTML |
|
8 | - * @package PHPTAL |
|
9 | - * @author Laurent Bedubourg <[email protected]> |
|
10 | - * @author Kornel Lesiński <[email protected]> |
|
11 | - * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
12 | - * @version SVN: $Id$ |
|
13 | - * @link http://phptal.org/ |
|
14 | - */ |
|
3 | + * PHPTAL templating engine |
|
4 | + * |
|
5 | + * PHP Version 5 |
|
6 | + * |
|
7 | + * @category HTML |
|
8 | + * @package PHPTAL |
|
9 | + * @author Laurent Bedubourg <[email protected]> |
|
10 | + * @author Kornel Lesiński <[email protected]> |
|
11 | + * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
12 | + * @version SVN: $Id$ |
|
13 | + * @link http://phptal.org/ |
|
14 | + */ |
|
15 | 15 | |
16 | 16 | |
17 | 17 | /** |
@@ -1,17 +1,17 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * PHPTAL templating engine |
|
4 | - * |
|
5 | - * PHP Version 5 |
|
6 | - * |
|
7 | - * @category HTML |
|
8 | - * @package PHPTAL |
|
9 | - * @author Laurent Bedubourg <[email protected]> |
|
10 | - * @author Kornel Lesiński <[email protected]> |
|
11 | - * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
12 | - * @version SVN: $Id$ |
|
13 | - * @link http://phptal.org/ |
|
14 | - */ |
|
3 | + * PHPTAL templating engine |
|
4 | + * |
|
5 | + * PHP Version 5 |
|
6 | + * |
|
7 | + * @category HTML |
|
8 | + * @package PHPTAL |
|
9 | + * @author Laurent Bedubourg <[email protected]> |
|
10 | + * @author Kornel Lesiński <[email protected]> |
|
11 | + * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
12 | + * @version SVN: $Id$ |
|
13 | + * @link http://phptal.org/ |
|
14 | + */ |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Tranform php: expressions into their php equivalent. |
@@ -37,20 +37,20 @@ discard block |
||
37 | 37 | class PHPTAL_Php_Transformer |
38 | 38 | { |
39 | 39 | const ST_WHITE = -1; // start of string or whitespace |
40 | - const ST_NONE = 0; // pass through (operators, parens, etc.) |
|
41 | - const ST_STR = 1; // 'foo' |
|
42 | - const ST_ESTR = 2; // "foo ${x} bar" |
|
43 | - const ST_VAR = 3; // abcd |
|
44 | - const ST_NUM = 4; // 123.02 |
|
45 | - const ST_EVAL = 5; // $somevar |
|
46 | - const ST_MEMBER = 6; // abcd.x |
|
47 | - const ST_STATIC = 7; // class::[$]static|const |
|
48 | - const ST_DEFINE = 8; // @MY_DEFINE |
|
40 | + const ST_NONE = 0; // pass through (operators, parens, etc.) |
|
41 | + const ST_STR = 1; // 'foo' |
|
42 | + const ST_ESTR = 2; // "foo ${x} bar" |
|
43 | + const ST_VAR = 3; // abcd |
|
44 | + const ST_NUM = 4; // 123.02 |
|
45 | + const ST_EVAL = 5; // $somevar |
|
46 | + const ST_MEMBER = 6; // abcd.x |
|
47 | + const ST_STATIC = 7; // class::[$]static|const |
|
48 | + const ST_DEFINE = 8; // @MY_DEFINE |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * transform PHPTAL's php-like syntax into real PHP |
52 | 52 | */ |
53 | - public static function transform($str, $prefix='$') |
|
53 | + public static function transform($str, $prefix = '$') |
|
54 | 54 | { |
55 | 55 | $len = strlen($str); |
56 | 56 | $state = self::ST_WHITE; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $result .= '->'; |
120 | 120 | $state = self::ST_MEMBER; |
121 | 121 | $mark = $i+2; |
122 | - $i+=2; |
|
122 | + $i += 2; |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | // @ is an access to some defined variable |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | // $xxx |
141 | 141 | case self::ST_EVAL: |
142 | 142 | if (!self::isVarNameChar($c)) { |
143 | - $result .= $prefix . substr($str, $mark, $i-$mark); |
|
143 | + $result .= $prefix.substr($str, $mark, $i-$mark); |
|
144 | 144 | $result .= '}'; |
145 | 145 | $state = self::ST_NONE; |
146 | 146 | } |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | // instring interpolation, search } and transform the |
178 | 178 | // interpollation to insert it into the string |
179 | 179 | elseif ($c === '$' && $i+1 < $len && $str[$i+1] === '{') { |
180 | - $result .= substr($str, $mark, $i-$mark) . '{'; |
|
180 | + $result .= substr($str, $mark, $i-$mark).'{'; |
|
181 | 181 | |
182 | 182 | $sub = 0; |
183 | - for ($j = $i; $j<$len; $j++) { |
|
183 | + for ($j = $i; $j < $len; $j++) { |
|
184 | 184 | if ($str[$j] === '{') { |
185 | 185 | $sub++; |
186 | 186 | } elseif ($str[$j] === '}' && (--$sub) == 0) { |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | } |
200 | 200 | // end of var, begin of member (method or var) |
201 | 201 | elseif ($c === '.') { |
202 | - $result .= $prefix . substr($str, $mark, $i-$mark); |
|
202 | + $result .= $prefix.substr($str, $mark, $i-$mark); |
|
203 | 203 | $result .= '->'; |
204 | 204 | $state = self::ST_MEMBER; |
205 | 205 | $mark = $i+1; |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | } |
220 | 220 | // array index, the var is done |
221 | 221 | elseif ($c === '[') { |
222 | - if ($str[$mark]==='_') { // superglobal? |
|
223 | - $result .= '$' . substr($str, $mark, $i-$mark+1); |
|
222 | + if ($str[$mark] === '_') { // superglobal? |
|
223 | + $result .= '$'.substr($str, $mark, $i-$mark+1); |
|
224 | 224 | } else { |
225 | - $result .= $prefix . substr($str, $mark, $i-$mark+1); |
|
225 | + $result .= $prefix.substr($str, $mark, $i-$mark+1); |
|
226 | 226 | } |
227 | 227 | $state = self::ST_NONE; |
228 | 228 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | } |
253 | 253 | // regular variable |
254 | 254 | else { |
255 | - $result .= $prefix . $var; |
|
255 | + $result .= $prefix.$var; |
|
256 | 256 | } |
257 | 257 | $i--; |
258 | 258 | $state = self::ST_NONE; |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | } |
266 | 266 | // eval mode ${foo} |
267 | 267 | elseif ($c === '$' && ($i >= $len-2 || $str[$i+1] !== '{')) { |
268 | - $result .= '{' . $prefix; |
|
268 | + $result .= '{'.$prefix; |
|
269 | 269 | $mark++; |
270 | 270 | $eval = true; |
271 | 271 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | // end of var member var, begin of new member |
277 | 277 | elseif ($c === '.') { |
278 | 278 | $result .= substr($str, $mark, $i-$mark); |
279 | - if ($eval) { $result .='}'; $eval = false; } |
|
279 | + if ($eval) { $result .= '}'; $eval = false; } |
|
280 | 280 | $result .= '->'; |
281 | 281 | $mark = $i+1; |
282 | 282 | $state = self::ST_MEMBER; |
@@ -284,24 +284,24 @@ discard block |
||
284 | 284 | // begin of static access |
285 | 285 | elseif ($c === ':') { |
286 | 286 | $result .= substr($str, $mark, $i-$mark+1); |
287 | - if ($eval) { $result .='}'; $eval = false; } |
|
287 | + if ($eval) { $result .= '}'; $eval = false; } |
|
288 | 288 | $state = self::ST_STATIC; |
289 | 289 | break; |
290 | 290 | } |
291 | 291 | // the member is a method or an array |
292 | 292 | elseif ($c === '(' || $c === '[') { |
293 | 293 | $result .= substr($str, $mark, $i-$mark+1); |
294 | - if ($eval) { $result .='}'; $eval = false; } |
|
294 | + if ($eval) { $result .= '}'; $eval = false; } |
|
295 | 295 | $state = self::ST_NONE; |
296 | 296 | } |
297 | 297 | // regular end of member, it is a var |
298 | 298 | else { |
299 | 299 | $var = substr($str, $mark, $i-$mark); |
300 | - if ($var !== '' && !preg_match('/^[a-z][a-z0-9_\x7f-\xff]*$/i',$var)) { |
|
300 | + if ($var !== '' && !preg_match('/^[a-z][a-z0-9_\x7f-\xff]*$/i', $var)) { |
|
301 | 301 | throw new PHPTAL_ParserException("Invalid field name '$var' in expression php:$str"); |
302 | 302 | } |
303 | 303 | $result .= $var; |
304 | - if ($eval) { $result .='}'; $eval = false; } |
|
304 | + if ($eval) { $result .= '}'; $eval = false; } |
|
305 | 305 | $state = self::ST_NONE; |
306 | 306 | $i--; |
307 | 307 | } |
@@ -63,8 +63,11 @@ discard block |
||
63 | 63 | |
64 | 64 | |
65 | 65 | for ($i = 0; $i <= $len; $i++) { |
66 | - if ($i == $len) $c = "\0"; |
|
67 | - else $c = $str[$i]; |
|
66 | + if ($i == $len) { |
|
67 | + $c = "\0"; |
|
68 | + } else { |
|
69 | + $c = $str[$i]; |
|
70 | + } |
|
68 | 71 | |
69 | 72 | switch ($state) { |
70 | 73 | |
@@ -85,8 +88,7 @@ discard block |
||
85 | 88 | $state = self::ST_EVAL; |
86 | 89 | $mark = $i+1; |
87 | 90 | $result .= $prefix.'{'; |
88 | - } |
|
89 | - elseif (self::isDigit($c)) |
|
91 | + } elseif (self::isDigit($c)) |
|
90 | 92 | { |
91 | 93 | $state = self::ST_NUM; |
92 | 94 | $mark = $i; |
@@ -126,8 +128,7 @@ discard block |
||
126 | 128 | elseif ($c === '@') { |
127 | 129 | $state = self::ST_DEFINE; |
128 | 130 | $mark = $i+1; |
129 | - } |
|
130 | - elseif (ctype_space($c)) { |
|
131 | + } elseif (ctype_space($c)) { |
|
131 | 132 | $state = self::ST_WHITE; |
132 | 133 | $result .= $c; |
133 | 134 | } |
@@ -377,7 +378,9 @@ discard block |
||
377 | 378 | $result = trim($result); |
378 | 379 | |
379 | 380 | // CodeWriter doesn't like expressions that look like blocks |
380 | - if ($result[strlen($result)-1] === '}') return '('.$result.')'; |
|
381 | + if ($result[strlen($result)-1] === '}') { |
|
382 | + return '('.$result.')'; |
|
383 | + } |
|
381 | 384 | |
382 | 385 | return $result; |
383 | 386 | } |
@@ -76,10 +76,11 @@ |
||
76 | 76 | |
77 | 77 | protected function doEchoAttribute(PHPTAL_Php_CodeWriter $codewriter, $code) |
78 | 78 | { |
79 | - if ($this->_echoType === self::ECHO_TEXT) |
|
80 | - $codewriter->doEcho($code); |
|
81 | - else |
|
82 | - $codewriter->doEchoRaw($code); |
|
79 | + if ($this->_echoType === self::ECHO_TEXT) { |
|
80 | + $codewriter->doEcho($code); |
|
81 | + } else { |
|
82 | + $codewriter->doEchoRaw($code); |
|
83 | + } |
|
83 | 84 | } |
84 | 85 | |
85 | 86 | protected function parseSetExpression($exp) |
@@ -80,7 +80,7 @@ |
||
80 | 80 | $code = $codewriter->evaluateExpression($expression); |
81 | 81 | |
82 | 82 | // instantiate controller using expression |
83 | - $codewriter->doSetVar( $this->var.'->'.$varName, 'new PHPTAL_RepeatController('.$code.')'."\n" ); |
|
83 | + $codewriter->doSetVar($this->var.'->'.$varName, 'new PHPTAL_RepeatController('.$code.')'."\n"); |
|
84 | 84 | |
85 | 85 | $codewriter->pushContext(); |
86 | 86 |