Total Complexity | 1162 |
Total Lines | 5063 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Complex classes like SSTemplateParser often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use SSTemplateParser, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
55 | class SSTemplateParser extends Parser implements TemplateParser |
||
56 | { |
||
57 | |||
58 | /** |
||
59 | * @var bool - Set true by SSTemplateParser::compileString if the template should include comments intended |
||
60 | * for debugging (template source, included files, etc) |
||
61 | */ |
||
62 | protected $includeDebuggingComments = false; |
||
63 | |||
64 | /** |
||
65 | * Stores the user-supplied closed block extension rules in the form: |
||
66 | * [ |
||
67 | * 'name' => function (&$res) {} |
||
68 | * ] |
||
69 | * See SSTemplateParser::ClosedBlock_Handle_Loop for an example of what the callable should look like |
||
70 | * @var array |
||
71 | */ |
||
72 | protected $closedBlocks = []; |
||
73 | |||
74 | /** |
||
75 | * Stores the user-supplied open block extension rules in the form: |
||
76 | * [ |
||
77 | * 'name' => function (&$res) {} |
||
78 | * ] |
||
79 | * See SSTemplateParser::OpenBlock_Handle_Base_tag for an example of what the callable should look like |
||
80 | * @var array |
||
81 | */ |
||
82 | protected $openBlocks = []; |
||
83 | |||
84 | /** |
||
85 | * Allow the injection of new closed & open block callables |
||
86 | * @param array $closedBlocks |
||
87 | * @param array $openBlocks |
||
88 | */ |
||
89 | public function __construct($closedBlocks = [], $openBlocks = []) |
||
90 | { |
||
91 | parent::__construct(null); |
||
92 | $this->setClosedBlocks($closedBlocks); |
||
93 | $this->setOpenBlocks($openBlocks); |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * Override the function that constructs the result arrays to also prepare a 'php' item in the array |
||
98 | */ |
||
99 | function construct($matchrule, $name, $arguments = null) |
||
|
|||
100 | { |
||
101 | $res = parent::construct($matchrule, $name, $arguments); |
||
102 | if (!isset($res['php'])) { |
||
103 | $res['php'] = ''; |
||
104 | } |
||
105 | return $res; |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * Set the closed blocks that the template parser should use |
||
110 | * |
||
111 | * This method will delete any existing closed blocks, please use addClosedBlock if you don't |
||
112 | * want to overwrite |
||
113 | * @param array $closedBlocks |
||
114 | * @throws InvalidArgumentException |
||
115 | */ |
||
116 | public function setClosedBlocks($closedBlocks) |
||
117 | { |
||
118 | $this->closedBlocks = []; |
||
119 | foreach ((array) $closedBlocks as $name => $callable) { |
||
120 | $this->addClosedBlock($name, $callable); |
||
121 | } |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * Set the open blocks that the template parser should use |
||
126 | * |
||
127 | * This method will delete any existing open blocks, please use addOpenBlock if you don't |
||
128 | * want to overwrite |
||
129 | * @param array $openBlocks |
||
130 | * @throws InvalidArgumentException |
||
131 | */ |
||
132 | public function setOpenBlocks($openBlocks) |
||
133 | { |
||
134 | $this->openBlocks = []; |
||
135 | foreach ((array) $openBlocks as $name => $callable) { |
||
136 | $this->addOpenBlock($name, $callable); |
||
137 | } |
||
138 | } |
||
139 | |||
140 | /** |
||
141 | * Add a closed block callable to allow <% name %><% end_name %> syntax |
||
142 | * @param string $name The name of the token to be used in the syntax <% name %><% end_name %> |
||
143 | * @param callable $callable The function that modifies the generation of template code |
||
144 | * @throws InvalidArgumentException |
||
145 | */ |
||
146 | public function addClosedBlock($name, $callable) |
||
147 | { |
||
148 | $this->validateExtensionBlock($name, $callable, 'Closed block'); |
||
149 | $this->closedBlocks[$name] = $callable; |
||
150 | } |
||
151 | |||
152 | /** |
||
153 | * Add a closed block callable to allow <% name %> syntax |
||
154 | * @param string $name The name of the token to be used in the syntax <% name %> |
||
155 | * @param callable $callable The function that modifies the generation of template code |
||
156 | * @throws InvalidArgumentException |
||
157 | */ |
||
158 | public function addOpenBlock($name, $callable) |
||
162 | } |
||
163 | |||
164 | /** |
||
165 | * Ensures that the arguments to addOpenBlock and addClosedBlock are valid |
||
166 | * @param $name |
||
167 | * @param $callable |
||
168 | * @param $type |
||
169 | * @throws InvalidArgumentException |
||
170 | */ |
||
171 | protected function validateExtensionBlock($name, $callable, $type) |
||
186 | ) |
||
187 | ); |
||
188 | } |
||
189 | } |
||
190 | |||
191 | /* Template: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock | |
||
192 | OpenBlock | MalformedBlock | MalformedBracketInjection | Injection | Text)+ */ |
||
193 | protected $match_Template_typestack = array('Template'); |
||
194 | function match_Template ($stack = array()) { |
||
195 | $matchrule = "Template"; $result = $this->construct($matchrule, $matchrule, null); |
||
196 | $count = 0; |
||
197 | while (true) { |
||
198 | $res_54 = $result; |
||
199 | $pos_54 = $this->pos; |
||
200 | $_53 = NULL; |
||
201 | do { |
||
202 | $_51 = NULL; |
||
203 | do { |
||
204 | $res_0 = $result; |
||
205 | $pos_0 = $this->pos; |
||
206 | $matcher = 'match_'.'Comment'; $key = $matcher; $pos = $this->pos; |
||
207 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
208 | if ($subres !== FALSE) { |
||
209 | $this->store( $result, $subres ); |
||
210 | $_51 = TRUE; break; |
||
211 | } |
||
212 | $result = $res_0; |
||
213 | $this->pos = $pos_0; |
||
214 | $_49 = NULL; |
||
215 | do { |
||
216 | $res_2 = $result; |
||
217 | $pos_2 = $this->pos; |
||
218 | $matcher = 'match_'.'Translate'; $key = $matcher; $pos = $this->pos; |
||
219 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
220 | if ($subres !== FALSE) { |
||
221 | $this->store( $result, $subres ); |
||
222 | $_49 = TRUE; break; |
||
223 | } |
||
224 | $result = $res_2; |
||
225 | $this->pos = $pos_2; |
||
226 | $_47 = NULL; |
||
227 | do { |
||
228 | $res_4 = $result; |
||
229 | $pos_4 = $this->pos; |
||
230 | $matcher = 'match_'.'If'; $key = $matcher; $pos = $this->pos; |
||
231 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
232 | if ($subres !== FALSE) { |
||
233 | $this->store( $result, $subres ); |
||
234 | $_47 = TRUE; break; |
||
235 | } |
||
236 | $result = $res_4; |
||
237 | $this->pos = $pos_4; |
||
238 | $_45 = NULL; |
||
239 | do { |
||
240 | $res_6 = $result; |
||
241 | $pos_6 = $this->pos; |
||
242 | $matcher = 'match_'.'Require'; $key = $matcher; $pos = $this->pos; |
||
243 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
244 | if ($subres !== FALSE) { |
||
245 | $this->store( $result, $subres ); |
||
246 | $_45 = TRUE; break; |
||
247 | } |
||
248 | $result = $res_6; |
||
249 | $this->pos = $pos_6; |
||
250 | $_43 = NULL; |
||
251 | do { |
||
252 | $res_8 = $result; |
||
253 | $pos_8 = $this->pos; |
||
254 | $matcher = 'match_'.'CacheBlock'; $key = $matcher; $pos = $this->pos; |
||
255 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
256 | if ($subres !== FALSE) { |
||
257 | $this->store( $result, $subres ); |
||
258 | $_43 = TRUE; break; |
||
259 | } |
||
260 | $result = $res_8; |
||
261 | $this->pos = $pos_8; |
||
262 | $_41 = NULL; |
||
263 | do { |
||
264 | $res_10 = $result; |
||
265 | $pos_10 = $this->pos; |
||
266 | $matcher = 'match_'.'UncachedBlock'; $key = $matcher; $pos = $this->pos; |
||
267 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
268 | if ($subres !== FALSE) { |
||
269 | $this->store( $result, $subres ); |
||
270 | $_41 = TRUE; break; |
||
271 | } |
||
272 | $result = $res_10; |
||
273 | $this->pos = $pos_10; |
||
274 | $_39 = NULL; |
||
275 | do { |
||
276 | $res_12 = $result; |
||
277 | $pos_12 = $this->pos; |
||
278 | $matcher = 'match_'.'OldI18NTag'; $key = $matcher; $pos = $this->pos; |
||
279 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
280 | if ($subres !== FALSE) { |
||
281 | $this->store( $result, $subres ); |
||
282 | $_39 = TRUE; break; |
||
283 | } |
||
284 | $result = $res_12; |
||
285 | $this->pos = $pos_12; |
||
286 | $_37 = NULL; |
||
287 | do { |
||
288 | $res_14 = $result; |
||
289 | $pos_14 = $this->pos; |
||
290 | $matcher = 'match_'.'Include'; $key = $matcher; $pos = $this->pos; |
||
291 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
292 | if ($subres !== FALSE) { |
||
293 | $this->store( $result, $subres ); |
||
294 | $_37 = TRUE; break; |
||
295 | } |
||
296 | $result = $res_14; |
||
297 | $this->pos = $pos_14; |
||
298 | $_35 = NULL; |
||
299 | do { |
||
300 | $res_16 = $result; |
||
301 | $pos_16 = $this->pos; |
||
302 | $matcher = 'match_'.'ClosedBlock'; $key = $matcher; $pos = $this->pos; |
||
303 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
304 | if ($subres !== FALSE) { |
||
305 | $this->store( $result, $subres ); |
||
306 | $_35 = TRUE; break; |
||
307 | } |
||
308 | $result = $res_16; |
||
309 | $this->pos = $pos_16; |
||
310 | $_33 = NULL; |
||
311 | do { |
||
312 | $res_18 = $result; |
||
313 | $pos_18 = $this->pos; |
||
314 | $matcher = 'match_'.'OpenBlock'; $key = $matcher; $pos = $this->pos; |
||
315 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
316 | if ($subres !== FALSE) { |
||
317 | $this->store( $result, $subres ); |
||
318 | $_33 = TRUE; break; |
||
319 | } |
||
320 | $result = $res_18; |
||
321 | $this->pos = $pos_18; |
||
322 | $_31 = NULL; |
||
323 | do { |
||
324 | $res_20 = $result; |
||
325 | $pos_20 = $this->pos; |
||
326 | $matcher = 'match_'.'MalformedBlock'; $key = $matcher; $pos = $this->pos; |
||
327 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
328 | if ($subres !== FALSE) { |
||
329 | $this->store( $result, $subres ); |
||
330 | $_31 = TRUE; break; |
||
331 | } |
||
332 | $result = $res_20; |
||
333 | $this->pos = $pos_20; |
||
334 | $_29 = NULL; |
||
335 | do { |
||
336 | $res_22 = $result; |
||
337 | $pos_22 = $this->pos; |
||
338 | $matcher = 'match_'.'MalformedBracketInjection'; $key = $matcher; $pos = $this->pos; |
||
339 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
340 | if ($subres !== FALSE) { |
||
341 | $this->store( $result, $subres ); |
||
342 | $_29 = TRUE; break; |
||
343 | } |
||
344 | $result = $res_22; |
||
345 | $this->pos = $pos_22; |
||
346 | $_27 = NULL; |
||
347 | do { |
||
348 | $res_24 = $result; |
||
349 | $pos_24 = $this->pos; |
||
350 | $matcher = 'match_'.'Injection'; $key = $matcher; $pos = $this->pos; |
||
351 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
352 | if ($subres !== FALSE) { |
||
353 | $this->store( $result, $subres ); |
||
354 | $_27 = TRUE; break; |
||
355 | } |
||
356 | $result = $res_24; |
||
357 | $this->pos = $pos_24; |
||
358 | $matcher = 'match_'.'Text'; $key = $matcher; $pos = $this->pos; |
||
359 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
360 | if ($subres !== FALSE) { |
||
361 | $this->store( $result, $subres ); |
||
362 | $_27 = TRUE; break; |
||
363 | } |
||
364 | $result = $res_24; |
||
365 | $this->pos = $pos_24; |
||
366 | $_27 = FALSE; break; |
||
367 | } |
||
368 | while(0); |
||
369 | if( $_27 === TRUE ) { $_29 = TRUE; break; } |
||
370 | $result = $res_22; |
||
371 | $this->pos = $pos_22; |
||
372 | $_29 = FALSE; break; |
||
373 | } |
||
374 | while(0); |
||
375 | if( $_29 === TRUE ) { $_31 = TRUE; break; } |
||
376 | $result = $res_20; |
||
377 | $this->pos = $pos_20; |
||
378 | $_31 = FALSE; break; |
||
379 | } |
||
380 | while(0); |
||
381 | if( $_31 === TRUE ) { $_33 = TRUE; break; } |
||
382 | $result = $res_18; |
||
383 | $this->pos = $pos_18; |
||
384 | $_33 = FALSE; break; |
||
385 | } |
||
386 | while(0); |
||
387 | if( $_33 === TRUE ) { $_35 = TRUE; break; } |
||
388 | $result = $res_16; |
||
389 | $this->pos = $pos_16; |
||
390 | $_35 = FALSE; break; |
||
391 | } |
||
392 | while(0); |
||
393 | if( $_35 === TRUE ) { $_37 = TRUE; break; } |
||
394 | $result = $res_14; |
||
395 | $this->pos = $pos_14; |
||
396 | $_37 = FALSE; break; |
||
397 | } |
||
398 | while(0); |
||
399 | if( $_37 === TRUE ) { $_39 = TRUE; break; } |
||
400 | $result = $res_12; |
||
401 | $this->pos = $pos_12; |
||
402 | $_39 = FALSE; break; |
||
403 | } |
||
404 | while(0); |
||
405 | if( $_39 === TRUE ) { $_41 = TRUE; break; } |
||
406 | $result = $res_10; |
||
407 | $this->pos = $pos_10; |
||
408 | $_41 = FALSE; break; |
||
409 | } |
||
410 | while(0); |
||
411 | if( $_41 === TRUE ) { $_43 = TRUE; break; } |
||
412 | $result = $res_8; |
||
413 | $this->pos = $pos_8; |
||
414 | $_43 = FALSE; break; |
||
415 | } |
||
416 | while(0); |
||
417 | if( $_43 === TRUE ) { $_45 = TRUE; break; } |
||
418 | $result = $res_6; |
||
419 | $this->pos = $pos_6; |
||
420 | $_45 = FALSE; break; |
||
421 | } |
||
422 | while(0); |
||
423 | if( $_45 === TRUE ) { $_47 = TRUE; break; } |
||
424 | $result = $res_4; |
||
425 | $this->pos = $pos_4; |
||
426 | $_47 = FALSE; break; |
||
427 | } |
||
428 | while(0); |
||
429 | if( $_47 === TRUE ) { $_49 = TRUE; break; } |
||
430 | $result = $res_2; |
||
431 | $this->pos = $pos_2; |
||
432 | $_49 = FALSE; break; |
||
433 | } |
||
434 | while(0); |
||
435 | if( $_49 === TRUE ) { $_51 = TRUE; break; } |
||
436 | $result = $res_0; |
||
437 | $this->pos = $pos_0; |
||
438 | $_51 = FALSE; break; |
||
439 | } |
||
440 | while(0); |
||
441 | if( $_51 === FALSE) { $_53 = FALSE; break; } |
||
442 | $_53 = TRUE; break; |
||
443 | } |
||
444 | while(0); |
||
445 | if( $_53 === FALSE) { |
||
446 | $result = $res_54; |
||
447 | $this->pos = $pos_54; |
||
448 | unset( $res_54 ); |
||
449 | unset( $pos_54 ); |
||
450 | break; |
||
451 | } |
||
452 | $count += 1; |
||
453 | } |
||
454 | if ($count > 0) { return $this->finalise($result); } |
||
455 | else { return FALSE; } |
||
456 | } |
||
457 | |||
458 | |||
459 | |||
460 | function Template_STR(&$res, $sub) |
||
461 | { |
||
462 | $res['php'] .= $sub['php'] . PHP_EOL ; |
||
463 | } |
||
464 | |||
465 | /* Word: / [A-Za-z_] [A-Za-z0-9_]* / */ |
||
466 | protected $match_Word_typestack = array('Word'); |
||
467 | function match_Word ($stack = array()) { |
||
474 | } |
||
475 | |||
476 | |||
477 | /* NamespacedWord: / [A-Za-z_\/\\] [A-Za-z0-9_\/\\]* / */ |
||
478 | protected $match_NamespacedWord_typestack = array('NamespacedWord'); |
||
479 | function match_NamespacedWord ($stack = array()) { |
||
480 | $matchrule = "NamespacedWord"; $result = $this->construct($matchrule, $matchrule, null); |
||
481 | if (( $subres = $this->rx( '/ [A-Za-z_\/\\\\] [A-Za-z0-9_\/\\\\]* /' ) ) !== FALSE) { |
||
482 | $result["text"] .= $subres; |
||
483 | return $this->finalise($result); |
||
484 | } |
||
485 | else { return FALSE; } |
||
486 | } |
||
487 | |||
488 | |||
489 | /* Number: / [0-9]+ / */ |
||
490 | protected $match_Number_typestack = array('Number'); |
||
491 | function match_Number ($stack = array()) { |
||
492 | $matchrule = "Number"; $result = $this->construct($matchrule, $matchrule, null); |
||
493 | if (( $subres = $this->rx( '/ [0-9]+ /' ) ) !== FALSE) { |
||
494 | $result["text"] .= $subres; |
||
495 | return $this->finalise($result); |
||
496 | } |
||
497 | else { return FALSE; } |
||
498 | } |
||
499 | |||
500 | |||
501 | /* Value: / [A-Za-z0-9_]+ / */ |
||
502 | protected $match_Value_typestack = array('Value'); |
||
503 | function match_Value ($stack = array()) { |
||
504 | $matchrule = "Value"; $result = $this->construct($matchrule, $matchrule, null); |
||
505 | if (( $subres = $this->rx( '/ [A-Za-z0-9_]+ /' ) ) !== FALSE) { |
||
506 | $result["text"] .= $subres; |
||
507 | return $this->finalise($result); |
||
508 | } |
||
509 | else { return FALSE; } |
||
510 | } |
||
511 | |||
512 | |||
513 | /* CallArguments: :Argument ( < "," < :Argument )* */ |
||
514 | protected $match_CallArguments_typestack = array('CallArguments'); |
||
515 | function match_CallArguments ($stack = array()) { |
||
516 | $matchrule = "CallArguments"; $result = $this->construct($matchrule, $matchrule, null); |
||
517 | $_66 = NULL; |
||
518 | do { |
||
519 | $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
||
520 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
521 | if ($subres !== FALSE) { |
||
522 | $this->store( $result, $subres, "Argument" ); |
||
523 | } |
||
524 | else { $_66 = FALSE; break; } |
||
525 | while (true) { |
||
526 | $res_65 = $result; |
||
527 | $pos_65 = $this->pos; |
||
528 | $_64 = NULL; |
||
529 | do { |
||
530 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
531 | if (substr($this->string,$this->pos,1) == ',') { |
||
532 | $this->pos += 1; |
||
533 | $result["text"] .= ','; |
||
534 | } |
||
535 | else { $_64 = FALSE; break; } |
||
536 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
537 | $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
||
538 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
539 | if ($subres !== FALSE) { |
||
540 | $this->store( $result, $subres, "Argument" ); |
||
541 | } |
||
542 | else { $_64 = FALSE; break; } |
||
543 | $_64 = TRUE; break; |
||
544 | } |
||
545 | while(0); |
||
546 | if( $_64 === FALSE) { |
||
547 | $result = $res_65; |
||
548 | $this->pos = $pos_65; |
||
549 | unset( $res_65 ); |
||
550 | unset( $pos_65 ); |
||
551 | break; |
||
552 | } |
||
553 | } |
||
554 | $_66 = TRUE; break; |
||
555 | } |
||
556 | while(0); |
||
557 | if( $_66 === TRUE ) { return $this->finalise($result); } |
||
558 | if( $_66 === FALSE) { return FALSE; } |
||
559 | } |
||
560 | |||
561 | |||
562 | |||
563 | |||
564 | /** |
||
565 | * Values are bare words in templates, but strings in PHP. We rely on PHP's type conversion to back-convert |
||
566 | * strings to numbers when needed. |
||
567 | */ |
||
568 | function CallArguments_Argument(&$res, $sub) |
||
569 | { |
||
570 | if (!empty($res['php'])) { |
||
571 | $res['php'] .= ', '; |
||
572 | } |
||
573 | |||
574 | $res['php'] .= ($sub['ArgumentMode'] == 'default') ? $sub['string_php'] : |
||
575 | str_replace('$$FINAL', 'XML_val', $sub['php']); |
||
576 | } |
||
577 | |||
578 | /* Call: Method:Word ( "(" < :CallArguments? > ")" )? */ |
||
579 | protected $match_Call_typestack = array('Call'); |
||
580 | function match_Call ($stack = array()) { |
||
581 | $matchrule = "Call"; $result = $this->construct($matchrule, $matchrule, null); |
||
582 | $_76 = NULL; |
||
583 | do { |
||
584 | $matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
||
585 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
586 | if ($subres !== FALSE) { |
||
587 | $this->store( $result, $subres, "Method" ); |
||
588 | } |
||
589 | else { $_76 = FALSE; break; } |
||
590 | $res_75 = $result; |
||
591 | $pos_75 = $this->pos; |
||
592 | $_74 = NULL; |
||
593 | do { |
||
594 | if (substr($this->string,$this->pos,1) == '(') { |
||
595 | $this->pos += 1; |
||
596 | $result["text"] .= '('; |
||
597 | } |
||
598 | else { $_74 = FALSE; break; } |
||
599 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
600 | $res_71 = $result; |
||
601 | $pos_71 = $this->pos; |
||
602 | $matcher = 'match_'.'CallArguments'; $key = $matcher; $pos = $this->pos; |
||
603 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
604 | if ($subres !== FALSE) { |
||
605 | $this->store( $result, $subres, "CallArguments" ); |
||
606 | } |
||
607 | else { |
||
608 | $result = $res_71; |
||
609 | $this->pos = $pos_71; |
||
610 | unset( $res_71 ); |
||
611 | unset( $pos_71 ); |
||
612 | } |
||
613 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
614 | if (substr($this->string,$this->pos,1) == ')') { |
||
615 | $this->pos += 1; |
||
616 | $result["text"] .= ')'; |
||
617 | } |
||
618 | else { $_74 = FALSE; break; } |
||
619 | $_74 = TRUE; break; |
||
620 | } |
||
621 | while(0); |
||
622 | if( $_74 === FALSE) { |
||
623 | $result = $res_75; |
||
624 | $this->pos = $pos_75; |
||
625 | unset( $res_75 ); |
||
626 | unset( $pos_75 ); |
||
627 | } |
||
628 | $_76 = TRUE; break; |
||
629 | } |
||
630 | while(0); |
||
631 | if( $_76 === TRUE ) { return $this->finalise($result); } |
||
632 | if( $_76 === FALSE) { return FALSE; } |
||
633 | } |
||
634 | |||
635 | |||
636 | /* LookupStep: :Call &"." */ |
||
637 | protected $match_LookupStep_typestack = array('LookupStep'); |
||
638 | function match_LookupStep ($stack = array()) { |
||
639 | $matchrule = "LookupStep"; $result = $this->construct($matchrule, $matchrule, null); |
||
640 | $_80 = NULL; |
||
641 | do { |
||
642 | $matcher = 'match_'.'Call'; $key = $matcher; $pos = $this->pos; |
||
643 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
644 | if ($subres !== FALSE) { |
||
645 | $this->store( $result, $subres, "Call" ); |
||
646 | } |
||
647 | else { $_80 = FALSE; break; } |
||
648 | $res_79 = $result; |
||
649 | $pos_79 = $this->pos; |
||
650 | if (substr($this->string,$this->pos,1) == '.') { |
||
651 | $this->pos += 1; |
||
652 | $result["text"] .= '.'; |
||
653 | $result = $res_79; |
||
654 | $this->pos = $pos_79; |
||
655 | } |
||
656 | else { |
||
657 | $result = $res_79; |
||
658 | $this->pos = $pos_79; |
||
659 | $_80 = FALSE; break; |
||
660 | } |
||
661 | $_80 = TRUE; break; |
||
662 | } |
||
663 | while(0); |
||
664 | if( $_80 === TRUE ) { return $this->finalise($result); } |
||
665 | if( $_80 === FALSE) { return FALSE; } |
||
666 | } |
||
667 | |||
668 | |||
669 | /* LastLookupStep: :Call */ |
||
670 | protected $match_LastLookupStep_typestack = array('LastLookupStep'); |
||
671 | function match_LastLookupStep ($stack = array()) { |
||
672 | $matchrule = "LastLookupStep"; $result = $this->construct($matchrule, $matchrule, null); |
||
673 | $matcher = 'match_'.'Call'; $key = $matcher; $pos = $this->pos; |
||
674 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
675 | if ($subres !== FALSE) { |
||
676 | $this->store( $result, $subres, "Call" ); |
||
677 | return $this->finalise($result); |
||
678 | } |
||
679 | else { return FALSE; } |
||
680 | } |
||
681 | |||
682 | |||
683 | /* Lookup: LookupStep ("." LookupStep)* "." LastLookupStep | LastLookupStep */ |
||
684 | protected $match_Lookup_typestack = array('Lookup'); |
||
685 | function match_Lookup ($stack = array()) { |
||
686 | $matchrule = "Lookup"; $result = $this->construct($matchrule, $matchrule, null); |
||
687 | $_94 = NULL; |
||
688 | do { |
||
689 | $res_83 = $result; |
||
690 | $pos_83 = $this->pos; |
||
691 | $_91 = NULL; |
||
692 | do { |
||
693 | $matcher = 'match_'.'LookupStep'; $key = $matcher; $pos = $this->pos; |
||
694 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
695 | if ($subres !== FALSE) { |
||
696 | $this->store( $result, $subres ); |
||
697 | } |
||
698 | else { $_91 = FALSE; break; } |
||
699 | while (true) { |
||
700 | $res_88 = $result; |
||
701 | $pos_88 = $this->pos; |
||
702 | $_87 = NULL; |
||
703 | do { |
||
704 | if (substr($this->string,$this->pos,1) == '.') { |
||
705 | $this->pos += 1; |
||
706 | $result["text"] .= '.'; |
||
707 | } |
||
708 | else { $_87 = FALSE; break; } |
||
709 | $matcher = 'match_'.'LookupStep'; $key = $matcher; $pos = $this->pos; |
||
710 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
711 | if ($subres !== FALSE) { |
||
712 | $this->store( $result, $subres ); |
||
713 | } |
||
714 | else { $_87 = FALSE; break; } |
||
715 | $_87 = TRUE; break; |
||
716 | } |
||
717 | while(0); |
||
718 | if( $_87 === FALSE) { |
||
719 | $result = $res_88; |
||
720 | $this->pos = $pos_88; |
||
721 | unset( $res_88 ); |
||
722 | unset( $pos_88 ); |
||
723 | break; |
||
724 | } |
||
725 | } |
||
726 | if (substr($this->string,$this->pos,1) == '.') { |
||
727 | $this->pos += 1; |
||
728 | $result["text"] .= '.'; |
||
729 | } |
||
730 | else { $_91 = FALSE; break; } |
||
731 | $matcher = 'match_'.'LastLookupStep'; $key = $matcher; $pos = $this->pos; |
||
732 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
733 | if ($subres !== FALSE) { |
||
734 | $this->store( $result, $subres ); |
||
735 | } |
||
736 | else { $_91 = FALSE; break; } |
||
737 | $_91 = TRUE; break; |
||
738 | } |
||
739 | while(0); |
||
740 | if( $_91 === TRUE ) { $_94 = TRUE; break; } |
||
741 | $result = $res_83; |
||
742 | $this->pos = $pos_83; |
||
743 | $matcher = 'match_'.'LastLookupStep'; $key = $matcher; $pos = $this->pos; |
||
744 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
745 | if ($subres !== FALSE) { |
||
746 | $this->store( $result, $subres ); |
||
747 | $_94 = TRUE; break; |
||
748 | } |
||
749 | $result = $res_83; |
||
750 | $this->pos = $pos_83; |
||
751 | $_94 = FALSE; break; |
||
752 | } |
||
753 | while(0); |
||
754 | if( $_94 === TRUE ) { return $this->finalise($result); } |
||
755 | if( $_94 === FALSE) { return FALSE; } |
||
756 | } |
||
757 | |||
758 | |||
759 | |||
760 | |||
761 | function Lookup__construct(&$res) |
||
762 | { |
||
763 | $res['php'] = '$scope->locally()'; |
||
764 | $res['LookupSteps'] = []; |
||
765 | } |
||
766 | |||
767 | /** |
||
768 | * The basic generated PHP of LookupStep and LastLookupStep is the same, except that LookupStep calls 'obj' to |
||
769 | * get the next ViewableData in the sequence, and LastLookupStep calls different methods (XML_val, hasValue, obj) |
||
770 | * depending on the context the lookup is used in. |
||
771 | */ |
||
772 | function Lookup_AddLookupStep(&$res, $sub, $method) |
||
773 | { |
||
774 | $res['LookupSteps'][] = $sub; |
||
775 | |||
776 | $property = $sub['Call']['Method']['text']; |
||
777 | |||
778 | if (isset($sub['Call']['CallArguments']) && $arguments = $sub['Call']['CallArguments']['php']) { |
||
779 | $res['php'] .= "->$method('$property', [$arguments], true)"; |
||
780 | } else { |
||
781 | $res['php'] .= "->$method('$property', null, true)"; |
||
782 | } |
||
783 | } |
||
784 | |||
785 | function Lookup_LookupStep(&$res, $sub) |
||
786 | { |
||
787 | $this->Lookup_AddLookupStep($res, $sub, 'obj'); |
||
788 | } |
||
789 | |||
790 | function Lookup_LastLookupStep(&$res, $sub) |
||
791 | { |
||
792 | $this->Lookup_AddLookupStep($res, $sub, '$$FINAL'); |
||
793 | } |
||
794 | |||
795 | |||
796 | /* Translate: "<%t" < Entity < (Default:QuotedString)? < (!("is" "=") < "is" < Context:QuotedString)? < |
||
797 | (InjectionVariables)? > "%>" */ |
||
798 | protected $match_Translate_typestack = array('Translate'); |
||
799 | function match_Translate ($stack = array()) { |
||
800 | $matchrule = "Translate"; $result = $this->construct($matchrule, $matchrule, null); |
||
801 | $_120 = NULL; |
||
802 | do { |
||
803 | if (( $subres = $this->literal( '<%t' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
804 | else { $_120 = FALSE; break; } |
||
805 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
806 | $matcher = 'match_'.'Entity'; $key = $matcher; $pos = $this->pos; |
||
807 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
808 | if ($subres !== FALSE) { |
||
809 | $this->store( $result, $subres ); |
||
810 | } |
||
811 | else { $_120 = FALSE; break; } |
||
812 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
813 | $res_102 = $result; |
||
814 | $pos_102 = $this->pos; |
||
815 | $_101 = NULL; |
||
816 | do { |
||
817 | $matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos; |
||
818 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
819 | if ($subres !== FALSE) { |
||
820 | $this->store( $result, $subres, "Default" ); |
||
821 | } |
||
822 | else { $_101 = FALSE; break; } |
||
823 | $_101 = TRUE; break; |
||
824 | } |
||
825 | while(0); |
||
826 | if( $_101 === FALSE) { |
||
827 | $result = $res_102; |
||
828 | $this->pos = $pos_102; |
||
829 | unset( $res_102 ); |
||
830 | unset( $pos_102 ); |
||
831 | } |
||
832 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
833 | $res_113 = $result; |
||
834 | $pos_113 = $this->pos; |
||
835 | $_112 = NULL; |
||
836 | do { |
||
837 | $res_107 = $result; |
||
838 | $pos_107 = $this->pos; |
||
839 | $_106 = NULL; |
||
840 | do { |
||
841 | if (( $subres = $this->literal( 'is' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
842 | else { $_106 = FALSE; break; } |
||
843 | if (substr($this->string,$this->pos,1) == '=') { |
||
844 | $this->pos += 1; |
||
845 | $result["text"] .= '='; |
||
846 | } |
||
847 | else { $_106 = FALSE; break; } |
||
848 | $_106 = TRUE; break; |
||
849 | } |
||
850 | while(0); |
||
851 | if( $_106 === TRUE ) { |
||
852 | $result = $res_107; |
||
853 | $this->pos = $pos_107; |
||
854 | $_112 = FALSE; break; |
||
855 | } |
||
856 | if( $_106 === FALSE) { |
||
857 | $result = $res_107; |
||
858 | $this->pos = $pos_107; |
||
859 | } |
||
860 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
861 | if (( $subres = $this->literal( 'is' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
862 | else { $_112 = FALSE; break; } |
||
863 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
864 | $matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos; |
||
865 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
866 | if ($subres !== FALSE) { |
||
867 | $this->store( $result, $subres, "Context" ); |
||
868 | } |
||
869 | else { $_112 = FALSE; break; } |
||
870 | $_112 = TRUE; break; |
||
871 | } |
||
872 | while(0); |
||
873 | if( $_112 === FALSE) { |
||
874 | $result = $res_113; |
||
875 | $this->pos = $pos_113; |
||
876 | unset( $res_113 ); |
||
877 | unset( $pos_113 ); |
||
878 | } |
||
879 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
880 | $res_117 = $result; |
||
881 | $pos_117 = $this->pos; |
||
882 | $_116 = NULL; |
||
883 | do { |
||
884 | $matcher = 'match_'.'InjectionVariables'; $key = $matcher; $pos = $this->pos; |
||
885 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
886 | if ($subres !== FALSE) { |
||
887 | $this->store( $result, $subres ); |
||
888 | } |
||
889 | else { $_116 = FALSE; break; } |
||
890 | $_116 = TRUE; break; |
||
891 | } |
||
892 | while(0); |
||
893 | if( $_116 === FALSE) { |
||
894 | $result = $res_117; |
||
895 | $this->pos = $pos_117; |
||
896 | unset( $res_117 ); |
||
897 | unset( $pos_117 ); |
||
898 | } |
||
899 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
900 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
901 | else { $_120 = FALSE; break; } |
||
902 | $_120 = TRUE; break; |
||
903 | } |
||
904 | while(0); |
||
905 | if( $_120 === TRUE ) { return $this->finalise($result); } |
||
906 | if( $_120 === FALSE) { return FALSE; } |
||
907 | } |
||
908 | |||
909 | |||
910 | /* InjectionVariables: (< InjectionName:Word "=" Argument)+ */ |
||
911 | protected $match_InjectionVariables_typestack = array('InjectionVariables'); |
||
912 | function match_InjectionVariables ($stack = array()) { |
||
913 | $matchrule = "InjectionVariables"; $result = $this->construct($matchrule, $matchrule, null); |
||
914 | $count = 0; |
||
915 | while (true) { |
||
916 | $res_127 = $result; |
||
917 | $pos_127 = $this->pos; |
||
918 | $_126 = NULL; |
||
919 | do { |
||
920 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
921 | $matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
||
922 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
923 | if ($subres !== FALSE) { |
||
924 | $this->store( $result, $subres, "InjectionName" ); |
||
925 | } |
||
926 | else { $_126 = FALSE; break; } |
||
927 | if (substr($this->string,$this->pos,1) == '=') { |
||
928 | $this->pos += 1; |
||
929 | $result["text"] .= '='; |
||
930 | } |
||
931 | else { $_126 = FALSE; break; } |
||
932 | $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
||
933 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
934 | if ($subres !== FALSE) { |
||
935 | $this->store( $result, $subres ); |
||
936 | } |
||
937 | else { $_126 = FALSE; break; } |
||
938 | $_126 = TRUE; break; |
||
939 | } |
||
940 | while(0); |
||
941 | if( $_126 === FALSE) { |
||
942 | $result = $res_127; |
||
943 | $this->pos = $pos_127; |
||
944 | unset( $res_127 ); |
||
945 | unset( $pos_127 ); |
||
946 | break; |
||
947 | } |
||
948 | $count += 1; |
||
949 | } |
||
950 | if ($count > 0) { return $this->finalise($result); } |
||
951 | else { return FALSE; } |
||
952 | } |
||
953 | |||
954 | |||
955 | /* Entity: / [A-Za-z_\\] [\w\.\\]* / */ |
||
956 | protected $match_Entity_typestack = array('Entity'); |
||
957 | function match_Entity ($stack = array()) { |
||
958 | $matchrule = "Entity"; $result = $this->construct($matchrule, $matchrule, null); |
||
959 | if (( $subres = $this->rx( '/ [A-Za-z_\\\\] [\w\.\\\\]* /' ) ) !== FALSE) { |
||
960 | $result["text"] .= $subres; |
||
961 | return $this->finalise($result); |
||
962 | } |
||
963 | else { return FALSE; } |
||
964 | } |
||
965 | |||
966 | |||
967 | |||
968 | |||
969 | function Translate__construct(&$res) |
||
970 | { |
||
971 | $res['php'] = '$val .= _t('; |
||
972 | } |
||
973 | |||
974 | function Translate_Entity(&$res, $sub) |
||
975 | { |
||
976 | $res['php'] .= "'$sub[text]'"; |
||
977 | } |
||
978 | |||
979 | function Translate_Default(&$res, $sub) |
||
980 | { |
||
981 | $res['php'] .= ",$sub[text]"; |
||
982 | } |
||
983 | |||
984 | function Translate_Context(&$res, $sub) |
||
985 | { |
||
986 | $res['php'] .= ",$sub[text]"; |
||
987 | } |
||
988 | |||
989 | function Translate_InjectionVariables(&$res, $sub) |
||
990 | { |
||
991 | $res['php'] .= ",$sub[php]"; |
||
992 | } |
||
993 | |||
994 | function Translate__finalise(&$res) |
||
995 | { |
||
996 | $res['php'] .= ');'; |
||
997 | } |
||
998 | |||
999 | function InjectionVariables__construct(&$res) |
||
1000 | { |
||
1001 | $res['php'] = "["; |
||
1002 | } |
||
1003 | |||
1004 | function InjectionVariables_InjectionName(&$res, $sub) |
||
1005 | { |
||
1006 | $res['php'] .= "'$sub[text]'=>"; |
||
1007 | } |
||
1008 | |||
1009 | function InjectionVariables_Argument(&$res, $sub) |
||
1010 | { |
||
1011 | $res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']) . ','; |
||
1012 | } |
||
1013 | |||
1014 | function InjectionVariables__finalise(&$res) |
||
1015 | { |
||
1016 | if (substr($res['php'], -1) == ',') { |
||
1017 | $res['php'] = substr($res['php'], 0, -1); //remove last comma in the array |
||
1018 | } |
||
1019 | $res['php'] .= ']'; |
||
1020 | } |
||
1021 | |||
1022 | /* MalformedBracketInjection: "{$" :Lookup !( "}" ) */ |
||
1023 | protected $match_MalformedBracketInjection_typestack = array('MalformedBracketInjection'); |
||
1024 | function match_MalformedBracketInjection ($stack = array()) { |
||
1025 | $matchrule = "MalformedBracketInjection"; $result = $this->construct($matchrule, $matchrule, null); |
||
1026 | $_134 = NULL; |
||
1027 | do { |
||
1028 | if (( $subres = $this->literal( '{$' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1029 | else { $_134 = FALSE; break; } |
||
1030 | $matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos; |
||
1031 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1032 | if ($subres !== FALSE) { |
||
1033 | $this->store( $result, $subres, "Lookup" ); |
||
1034 | } |
||
1035 | else { $_134 = FALSE; break; } |
||
1036 | $res_133 = $result; |
||
1037 | $pos_133 = $this->pos; |
||
1038 | $_132 = NULL; |
||
1039 | do { |
||
1040 | if (substr($this->string,$this->pos,1) == '}') { |
||
1041 | $this->pos += 1; |
||
1042 | $result["text"] .= '}'; |
||
1043 | } |
||
1044 | else { $_132 = FALSE; break; } |
||
1045 | $_132 = TRUE; break; |
||
1046 | } |
||
1047 | while(0); |
||
1048 | if( $_132 === TRUE ) { |
||
1049 | $result = $res_133; |
||
1050 | $this->pos = $pos_133; |
||
1051 | $_134 = FALSE; break; |
||
1052 | } |
||
1053 | if( $_132 === FALSE) { |
||
1054 | $result = $res_133; |
||
1055 | $this->pos = $pos_133; |
||
1056 | } |
||
1057 | $_134 = TRUE; break; |
||
1058 | } |
||
1059 | while(0); |
||
1060 | if( $_134 === TRUE ) { return $this->finalise($result); } |
||
1061 | if( $_134 === FALSE) { return FALSE; } |
||
1062 | } |
||
1063 | |||
1064 | |||
1065 | |||
1066 | function MalformedBracketInjection__finalise(&$res) |
||
1067 | { |
||
1068 | $lookup = $res['text']; |
||
1069 | throw new SSTemplateParseException("Malformed bracket injection $lookup. Perhaps you have forgotten the " . |
||
1070 | "closing bracket (})?", $this); |
||
1071 | } |
||
1072 | |||
1073 | /* SimpleInjection: '$' :Lookup */ |
||
1074 | protected $match_SimpleInjection_typestack = array('SimpleInjection'); |
||
1075 | function match_SimpleInjection ($stack = array()) { |
||
1076 | $matchrule = "SimpleInjection"; $result = $this->construct($matchrule, $matchrule, null); |
||
1077 | $_138 = NULL; |
||
1078 | do { |
||
1079 | if (substr($this->string,$this->pos,1) == '$') { |
||
1080 | $this->pos += 1; |
||
1081 | $result["text"] .= '$'; |
||
1082 | } |
||
1083 | else { $_138 = FALSE; break; } |
||
1084 | $matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos; |
||
1085 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1086 | if ($subres !== FALSE) { |
||
1087 | $this->store( $result, $subres, "Lookup" ); |
||
1088 | } |
||
1089 | else { $_138 = FALSE; break; } |
||
1090 | $_138 = TRUE; break; |
||
1091 | } |
||
1092 | while(0); |
||
1093 | if( $_138 === TRUE ) { return $this->finalise($result); } |
||
1094 | if( $_138 === FALSE) { return FALSE; } |
||
1095 | } |
||
1096 | |||
1097 | |||
1098 | /* BracketInjection: '{$' :Lookup "}" */ |
||
1099 | protected $match_BracketInjection_typestack = array('BracketInjection'); |
||
1100 | function match_BracketInjection ($stack = array()) { |
||
1101 | $matchrule = "BracketInjection"; $result = $this->construct($matchrule, $matchrule, null); |
||
1102 | $_143 = NULL; |
||
1103 | do { |
||
1104 | if (( $subres = $this->literal( '{$' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1105 | else { $_143 = FALSE; break; } |
||
1106 | $matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos; |
||
1107 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1108 | if ($subres !== FALSE) { |
||
1109 | $this->store( $result, $subres, "Lookup" ); |
||
1110 | } |
||
1111 | else { $_143 = FALSE; break; } |
||
1112 | if (substr($this->string,$this->pos,1) == '}') { |
||
1113 | $this->pos += 1; |
||
1114 | $result["text"] .= '}'; |
||
1115 | } |
||
1116 | else { $_143 = FALSE; break; } |
||
1117 | $_143 = TRUE; break; |
||
1118 | } |
||
1119 | while(0); |
||
1120 | if( $_143 === TRUE ) { return $this->finalise($result); } |
||
1121 | if( $_143 === FALSE) { return FALSE; } |
||
1122 | } |
||
1123 | |||
1124 | |||
1125 | /* Injection: BracketInjection | SimpleInjection */ |
||
1126 | protected $match_Injection_typestack = array('Injection'); |
||
1127 | function match_Injection ($stack = array()) { |
||
1128 | $matchrule = "Injection"; $result = $this->construct($matchrule, $matchrule, null); |
||
1129 | $_148 = NULL; |
||
1130 | do { |
||
1131 | $res_145 = $result; |
||
1132 | $pos_145 = $this->pos; |
||
1133 | $matcher = 'match_'.'BracketInjection'; $key = $matcher; $pos = $this->pos; |
||
1134 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1135 | if ($subres !== FALSE) { |
||
1136 | $this->store( $result, $subres ); |
||
1137 | $_148 = TRUE; break; |
||
1138 | } |
||
1139 | $result = $res_145; |
||
1140 | $this->pos = $pos_145; |
||
1141 | $matcher = 'match_'.'SimpleInjection'; $key = $matcher; $pos = $this->pos; |
||
1142 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1143 | if ($subres !== FALSE) { |
||
1144 | $this->store( $result, $subres ); |
||
1145 | $_148 = TRUE; break; |
||
1146 | } |
||
1147 | $result = $res_145; |
||
1148 | $this->pos = $pos_145; |
||
1149 | $_148 = FALSE; break; |
||
1150 | } |
||
1151 | while(0); |
||
1152 | if( $_148 === TRUE ) { return $this->finalise($result); } |
||
1153 | if( $_148 === FALSE) { return FALSE; } |
||
1154 | } |
||
1155 | |||
1156 | |||
1157 | |||
1158 | function Injection_STR(&$res, $sub) |
||
1159 | { |
||
1160 | $res['php'] = '$val .= '. str_replace('$$FINAL', 'XML_val', $sub['Lookup']['php']) . ';'; |
||
1161 | } |
||
1162 | |||
1163 | /* DollarMarkedLookup: SimpleInjection */ |
||
1164 | protected $match_DollarMarkedLookup_typestack = array('DollarMarkedLookup'); |
||
1165 | function match_DollarMarkedLookup ($stack = array()) { |
||
1166 | $matchrule = "DollarMarkedLookup"; $result = $this->construct($matchrule, $matchrule, null); |
||
1167 | $matcher = 'match_'.'SimpleInjection'; $key = $matcher; $pos = $this->pos; |
||
1168 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1169 | if ($subres !== FALSE) { |
||
1170 | $this->store( $result, $subres ); |
||
1171 | return $this->finalise($result); |
||
1172 | } |
||
1173 | else { return FALSE; } |
||
1174 | } |
||
1175 | |||
1176 | |||
1177 | |||
1178 | function DollarMarkedLookup_STR(&$res, $sub) |
||
1179 | { |
||
1180 | $res['Lookup'] = $sub['Lookup']; |
||
1181 | } |
||
1182 | |||
1183 | /* QuotedString: q:/['"]/ String:/ (\\\\ | \\. | [^$q\\])* / '$q' */ |
||
1184 | protected $match_QuotedString_typestack = array('QuotedString'); |
||
1185 | function match_QuotedString ($stack = array()) { |
||
1186 | $matchrule = "QuotedString"; $result = $this->construct($matchrule, $matchrule, null); |
||
1187 | $_154 = NULL; |
||
1188 | do { |
||
1189 | $stack[] = $result; $result = $this->construct( $matchrule, "q" ); |
||
1190 | if (( $subres = $this->rx( '/[\'"]/' ) ) !== FALSE) { |
||
1191 | $result["text"] .= $subres; |
||
1192 | $subres = $result; $result = array_pop($stack); |
||
1193 | $this->store( $result, $subres, 'q' ); |
||
1194 | } |
||
1195 | else { |
||
1196 | $result = array_pop($stack); |
||
1197 | $_154 = FALSE; break; |
||
1198 | } |
||
1199 | $stack[] = $result; $result = $this->construct( $matchrule, "String" ); |
||
1200 | if (( $subres = $this->rx( '/ (\\\\\\\\ | \\\\. | [^'.$this->expression($result, $stack, 'q').'\\\\])* /' ) ) !== FALSE) { |
||
1201 | $result["text"] .= $subres; |
||
1202 | $subres = $result; $result = array_pop($stack); |
||
1203 | $this->store( $result, $subres, 'String' ); |
||
1204 | } |
||
1205 | else { |
||
1206 | $result = array_pop($stack); |
||
1207 | $_154 = FALSE; break; |
||
1208 | } |
||
1209 | if (( $subres = $this->literal( ''.$this->expression($result, $stack, 'q').'' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1210 | else { $_154 = FALSE; break; } |
||
1211 | $_154 = TRUE; break; |
||
1212 | } |
||
1213 | while(0); |
||
1214 | if( $_154 === TRUE ) { return $this->finalise($result); } |
||
1215 | if( $_154 === FALSE) { return FALSE; } |
||
1216 | } |
||
1217 | |||
1218 | |||
1219 | /* FreeString: /[^,)%!=><|&]+/ */ |
||
1220 | protected $match_FreeString_typestack = array('FreeString'); |
||
1221 | function match_FreeString ($stack = array()) { |
||
1222 | $matchrule = "FreeString"; $result = $this->construct($matchrule, $matchrule, null); |
||
1223 | if (( $subres = $this->rx( '/[^,)%!=><|&]+/' ) ) !== FALSE) { |
||
1224 | $result["text"] .= $subres; |
||
1225 | return $this->finalise($result); |
||
1226 | } |
||
1227 | else { return FALSE; } |
||
1228 | } |
||
1229 | |||
1230 | |||
1231 | /* Argument: |
||
1232 | :DollarMarkedLookup | |
||
1233 | :QuotedString | |
||
1234 | :Lookup !(< FreeString)| |
||
1235 | :FreeString */ |
||
1236 | protected $match_Argument_typestack = array('Argument'); |
||
1237 | function match_Argument ($stack = array()) { |
||
1238 | $matchrule = "Argument"; $result = $this->construct($matchrule, $matchrule, null); |
||
1239 | $_174 = NULL; |
||
1240 | do { |
||
1241 | $res_157 = $result; |
||
1242 | $pos_157 = $this->pos; |
||
1243 | $matcher = 'match_'.'DollarMarkedLookup'; $key = $matcher; $pos = $this->pos; |
||
1244 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1245 | if ($subres !== FALSE) { |
||
1246 | $this->store( $result, $subres, "DollarMarkedLookup" ); |
||
1247 | $_174 = TRUE; break; |
||
1248 | } |
||
1249 | $result = $res_157; |
||
1250 | $this->pos = $pos_157; |
||
1251 | $_172 = NULL; |
||
1252 | do { |
||
1253 | $res_159 = $result; |
||
1254 | $pos_159 = $this->pos; |
||
1255 | $matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos; |
||
1256 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1257 | if ($subres !== FALSE) { |
||
1258 | $this->store( $result, $subres, "QuotedString" ); |
||
1259 | $_172 = TRUE; break; |
||
1260 | } |
||
1261 | $result = $res_159; |
||
1262 | $this->pos = $pos_159; |
||
1263 | $_170 = NULL; |
||
1264 | do { |
||
1265 | $res_161 = $result; |
||
1266 | $pos_161 = $this->pos; |
||
1267 | $_167 = NULL; |
||
1268 | do { |
||
1269 | $matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos; |
||
1270 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1271 | if ($subres !== FALSE) { |
||
1272 | $this->store( $result, $subres, "Lookup" ); |
||
1273 | } |
||
1274 | else { $_167 = FALSE; break; } |
||
1275 | $res_166 = $result; |
||
1276 | $pos_166 = $this->pos; |
||
1277 | $_165 = NULL; |
||
1278 | do { |
||
1279 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1280 | $matcher = 'match_'.'FreeString'; $key = $matcher; $pos = $this->pos; |
||
1281 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1282 | if ($subres !== FALSE) { |
||
1283 | $this->store( $result, $subres ); |
||
1284 | } |
||
1285 | else { $_165 = FALSE; break; } |
||
1286 | $_165 = TRUE; break; |
||
1287 | } |
||
1288 | while(0); |
||
1289 | if( $_165 === TRUE ) { |
||
1290 | $result = $res_166; |
||
1291 | $this->pos = $pos_166; |
||
1292 | $_167 = FALSE; break; |
||
1293 | } |
||
1294 | if( $_165 === FALSE) { |
||
1295 | $result = $res_166; |
||
1296 | $this->pos = $pos_166; |
||
1297 | } |
||
1298 | $_167 = TRUE; break; |
||
1299 | } |
||
1300 | while(0); |
||
1301 | if( $_167 === TRUE ) { $_170 = TRUE; break; } |
||
1302 | $result = $res_161; |
||
1303 | $this->pos = $pos_161; |
||
1304 | $matcher = 'match_'.'FreeString'; $key = $matcher; $pos = $this->pos; |
||
1305 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1306 | if ($subres !== FALSE) { |
||
1307 | $this->store( $result, $subres, "FreeString" ); |
||
1308 | $_170 = TRUE; break; |
||
1309 | } |
||
1310 | $result = $res_161; |
||
1311 | $this->pos = $pos_161; |
||
1312 | $_170 = FALSE; break; |
||
1313 | } |
||
1314 | while(0); |
||
1315 | if( $_170 === TRUE ) { $_172 = TRUE; break; } |
||
1316 | $result = $res_159; |
||
1317 | $this->pos = $pos_159; |
||
1318 | $_172 = FALSE; break; |
||
1319 | } |
||
1320 | while(0); |
||
1321 | if( $_172 === TRUE ) { $_174 = TRUE; break; } |
||
1322 | $result = $res_157; |
||
1323 | $this->pos = $pos_157; |
||
1324 | $_174 = FALSE; break; |
||
1325 | } |
||
1326 | while(0); |
||
1327 | if( $_174 === TRUE ) { return $this->finalise($result); } |
||
1328 | if( $_174 === FALSE) { return FALSE; } |
||
1329 | } |
||
1330 | |||
1331 | |||
1332 | |||
1333 | |||
1334 | /** |
||
1335 | * If we get a bare value, we don't know enough to determine exactly what php would be the translation, because |
||
1336 | * we don't know if the position of use indicates a lookup or a string argument. |
||
1337 | * |
||
1338 | * Instead, we record 'ArgumentMode' as a member of this matches results node, which can be: |
||
1339 | * - lookup if this argument was unambiguously a lookup (marked as such) |
||
1340 | * - string is this argument was unambiguously a string (marked as such, or impossible to parse as lookup) |
||
1341 | * - default if this argument needs to be handled as per 2.4 |
||
1342 | * |
||
1343 | * In the case of 'default', there is no php member of the results node, but instead 'lookup_php', which |
||
1344 | * should be used by the parent if the context indicates a lookup, and 'string_php' which should be used |
||
1345 | * if the context indicates a string |
||
1346 | */ |
||
1347 | |||
1348 | function Argument_DollarMarkedLookup(&$res, $sub) |
||
1349 | { |
||
1350 | $res['ArgumentMode'] = 'lookup'; |
||
1351 | $res['php'] = $sub['Lookup']['php']; |
||
1352 | } |
||
1353 | |||
1354 | function Argument_QuotedString(&$res, $sub) |
||
1355 | { |
||
1356 | $res['ArgumentMode'] = 'string'; |
||
1357 | $res['php'] = "'" . str_replace("'", "\\'", $sub['String']['text']) . "'"; |
||
1358 | } |
||
1359 | |||
1360 | function Argument_Lookup(&$res, $sub) |
||
1361 | { |
||
1362 | if (count($sub['LookupSteps']) == 1 && !isset($sub['LookupSteps'][0]['Call']['Arguments'])) { |
||
1363 | $res['ArgumentMode'] = 'default'; |
||
1364 | $res['lookup_php'] = $sub['php']; |
||
1365 | $res['string_php'] = "'".$sub['LookupSteps'][0]['Call']['Method']['text']."'"; |
||
1366 | } else { |
||
1367 | $res['ArgumentMode'] = 'lookup'; |
||
1368 | $res['php'] = $sub['php']; |
||
1369 | } |
||
1370 | } |
||
1371 | |||
1372 | function Argument_FreeString(&$res, $sub) |
||
1373 | { |
||
1374 | $res['ArgumentMode'] = 'string'; |
||
1375 | $res['php'] = "'" . str_replace("'", "\\'", trim($sub['text'])) . "'"; |
||
1376 | } |
||
1377 | |||
1378 | /* ComparisonOperator: "!=" | "==" | ">=" | ">" | "<=" | "<" | "=" */ |
||
1379 | protected $match_ComparisonOperator_typestack = array('ComparisonOperator'); |
||
1380 | function match_ComparisonOperator ($stack = array()) { |
||
1381 | $matchrule = "ComparisonOperator"; $result = $this->construct($matchrule, $matchrule, null); |
||
1382 | $_199 = NULL; |
||
1383 | do { |
||
1384 | $res_176 = $result; |
||
1385 | $pos_176 = $this->pos; |
||
1386 | if (( $subres = $this->literal( '!=' ) ) !== FALSE) { |
||
1387 | $result["text"] .= $subres; |
||
1388 | $_199 = TRUE; break; |
||
1389 | } |
||
1390 | $result = $res_176; |
||
1391 | $this->pos = $pos_176; |
||
1392 | $_197 = NULL; |
||
1393 | do { |
||
1394 | $res_178 = $result; |
||
1395 | $pos_178 = $this->pos; |
||
1396 | if (( $subres = $this->literal( '==' ) ) !== FALSE) { |
||
1397 | $result["text"] .= $subres; |
||
1398 | $_197 = TRUE; break; |
||
1399 | } |
||
1400 | $result = $res_178; |
||
1401 | $this->pos = $pos_178; |
||
1402 | $_195 = NULL; |
||
1403 | do { |
||
1404 | $res_180 = $result; |
||
1405 | $pos_180 = $this->pos; |
||
1406 | if (( $subres = $this->literal( '>=' ) ) !== FALSE) { |
||
1407 | $result["text"] .= $subres; |
||
1408 | $_195 = TRUE; break; |
||
1409 | } |
||
1410 | $result = $res_180; |
||
1411 | $this->pos = $pos_180; |
||
1412 | $_193 = NULL; |
||
1413 | do { |
||
1414 | $res_182 = $result; |
||
1415 | $pos_182 = $this->pos; |
||
1416 | if (substr($this->string,$this->pos,1) == '>') { |
||
1417 | $this->pos += 1; |
||
1418 | $result["text"] .= '>'; |
||
1419 | $_193 = TRUE; break; |
||
1420 | } |
||
1421 | $result = $res_182; |
||
1422 | $this->pos = $pos_182; |
||
1423 | $_191 = NULL; |
||
1424 | do { |
||
1425 | $res_184 = $result; |
||
1426 | $pos_184 = $this->pos; |
||
1427 | if (( $subres = $this->literal( '<=' ) ) !== FALSE) { |
||
1428 | $result["text"] .= $subres; |
||
1429 | $_191 = TRUE; break; |
||
1430 | } |
||
1431 | $result = $res_184; |
||
1432 | $this->pos = $pos_184; |
||
1433 | $_189 = NULL; |
||
1434 | do { |
||
1435 | $res_186 = $result; |
||
1436 | $pos_186 = $this->pos; |
||
1437 | if (substr($this->string,$this->pos,1) == '<') { |
||
1438 | $this->pos += 1; |
||
1439 | $result["text"] .= '<'; |
||
1440 | $_189 = TRUE; break; |
||
1441 | } |
||
1442 | $result = $res_186; |
||
1443 | $this->pos = $pos_186; |
||
1444 | if (substr($this->string,$this->pos,1) == '=') { |
||
1445 | $this->pos += 1; |
||
1446 | $result["text"] .= '='; |
||
1447 | $_189 = TRUE; break; |
||
1448 | } |
||
1449 | $result = $res_186; |
||
1450 | $this->pos = $pos_186; |
||
1451 | $_189 = FALSE; break; |
||
1452 | } |
||
1453 | while(0); |
||
1454 | if( $_189 === TRUE ) { $_191 = TRUE; break; } |
||
1455 | $result = $res_184; |
||
1456 | $this->pos = $pos_184; |
||
1457 | $_191 = FALSE; break; |
||
1458 | } |
||
1459 | while(0); |
||
1460 | if( $_191 === TRUE ) { $_193 = TRUE; break; } |
||
1461 | $result = $res_182; |
||
1462 | $this->pos = $pos_182; |
||
1463 | $_193 = FALSE; break; |
||
1464 | } |
||
1465 | while(0); |
||
1466 | if( $_193 === TRUE ) { $_195 = TRUE; break; } |
||
1467 | $result = $res_180; |
||
1468 | $this->pos = $pos_180; |
||
1469 | $_195 = FALSE; break; |
||
1470 | } |
||
1471 | while(0); |
||
1472 | if( $_195 === TRUE ) { $_197 = TRUE; break; } |
||
1473 | $result = $res_178; |
||
1474 | $this->pos = $pos_178; |
||
1475 | $_197 = FALSE; break; |
||
1476 | } |
||
1477 | while(0); |
||
1478 | if( $_197 === TRUE ) { $_199 = TRUE; break; } |
||
1479 | $result = $res_176; |
||
1480 | $this->pos = $pos_176; |
||
1481 | $_199 = FALSE; break; |
||
1482 | } |
||
1483 | while(0); |
||
1484 | if( $_199 === TRUE ) { return $this->finalise($result); } |
||
1485 | if( $_199 === FALSE) { return FALSE; } |
||
1486 | } |
||
1487 | |||
1488 | |||
1489 | /* Comparison: Argument < ComparisonOperator > Argument */ |
||
1490 | protected $match_Comparison_typestack = array('Comparison'); |
||
1491 | function match_Comparison ($stack = array()) { |
||
1492 | $matchrule = "Comparison"; $result = $this->construct($matchrule, $matchrule, null); |
||
1493 | $_206 = NULL; |
||
1494 | do { |
||
1495 | $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
||
1496 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1497 | if ($subres !== FALSE) { |
||
1498 | $this->store( $result, $subres ); |
||
1499 | } |
||
1500 | else { $_206 = FALSE; break; } |
||
1501 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1502 | $matcher = 'match_'.'ComparisonOperator'; $key = $matcher; $pos = $this->pos; |
||
1503 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1504 | if ($subres !== FALSE) { |
||
1505 | $this->store( $result, $subres ); |
||
1506 | } |
||
1507 | else { $_206 = FALSE; break; } |
||
1508 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1509 | $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
||
1510 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1511 | if ($subres !== FALSE) { |
||
1512 | $this->store( $result, $subres ); |
||
1513 | } |
||
1514 | else { $_206 = FALSE; break; } |
||
1515 | $_206 = TRUE; break; |
||
1516 | } |
||
1517 | while(0); |
||
1518 | if( $_206 === TRUE ) { return $this->finalise($result); } |
||
1519 | if( $_206 === FALSE) { return FALSE; } |
||
1520 | } |
||
1521 | |||
1522 | |||
1523 | |||
1524 | function Comparison_Argument(&$res, $sub) |
||
1525 | { |
||
1526 | if ($sub['ArgumentMode'] == 'default') { |
||
1527 | if (!empty($res['php'])) { |
||
1528 | $res['php'] .= $sub['string_php']; |
||
1529 | } else { |
||
1530 | $res['php'] = str_replace('$$FINAL', 'XML_val', $sub['lookup_php']); |
||
1531 | } |
||
1532 | } else { |
||
1533 | $res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']); |
||
1534 | } |
||
1535 | } |
||
1536 | |||
1537 | function Comparison_ComparisonOperator(&$res, $sub) |
||
1538 | { |
||
1539 | $res['php'] .= ($sub['text'] == '=' ? '==' : $sub['text']); |
||
1540 | } |
||
1541 | |||
1542 | /* PresenceCheck: (Not:'not' <)? Argument */ |
||
1543 | protected $match_PresenceCheck_typestack = array('PresenceCheck'); |
||
1544 | function match_PresenceCheck ($stack = array()) { |
||
1545 | $matchrule = "PresenceCheck"; $result = $this->construct($matchrule, $matchrule, null); |
||
1546 | $_213 = NULL; |
||
1547 | do { |
||
1548 | $res_211 = $result; |
||
1549 | $pos_211 = $this->pos; |
||
1550 | $_210 = NULL; |
||
1551 | do { |
||
1552 | $stack[] = $result; $result = $this->construct( $matchrule, "Not" ); |
||
1553 | if (( $subres = $this->literal( 'not' ) ) !== FALSE) { |
||
1554 | $result["text"] .= $subres; |
||
1555 | $subres = $result; $result = array_pop($stack); |
||
1556 | $this->store( $result, $subres, 'Not' ); |
||
1557 | } |
||
1558 | else { |
||
1559 | $result = array_pop($stack); |
||
1560 | $_210 = FALSE; break; |
||
1561 | } |
||
1562 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1563 | $_210 = TRUE; break; |
||
1564 | } |
||
1565 | while(0); |
||
1566 | if( $_210 === FALSE) { |
||
1567 | $result = $res_211; |
||
1568 | $this->pos = $pos_211; |
||
1569 | unset( $res_211 ); |
||
1570 | unset( $pos_211 ); |
||
1571 | } |
||
1572 | $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
||
1573 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1574 | if ($subres !== FALSE) { |
||
1575 | $this->store( $result, $subres ); |
||
1576 | } |
||
1577 | else { $_213 = FALSE; break; } |
||
1578 | $_213 = TRUE; break; |
||
1579 | } |
||
1580 | while(0); |
||
1581 | if( $_213 === TRUE ) { return $this->finalise($result); } |
||
1582 | if( $_213 === FALSE) { return FALSE; } |
||
1583 | } |
||
1584 | |||
1585 | |||
1586 | |||
1587 | function PresenceCheck_Not(&$res, $sub) |
||
1588 | { |
||
1589 | $res['php'] = '!'; |
||
1590 | } |
||
1591 | |||
1592 | function PresenceCheck_Argument(&$res, $sub) |
||
1593 | { |
||
1594 | if ($sub['ArgumentMode'] == 'string') { |
||
1595 | $res['php'] .= '((bool)'.$sub['php'].')'; |
||
1596 | } else { |
||
1597 | $php = ($sub['ArgumentMode'] == 'default' ? $sub['lookup_php'] : $sub['php']); |
||
1598 | // TODO: kinda hacky - maybe we need a way to pass state down the parse chain so |
||
1599 | // Lookup_LastLookupStep and Argument_BareWord can produce hasValue instead of XML_val |
||
1600 | $res['php'] .= str_replace('$$FINAL', 'hasValue', $php); |
||
1601 | } |
||
1602 | } |
||
1603 | |||
1604 | /* IfArgumentPortion: Comparison | PresenceCheck */ |
||
1605 | protected $match_IfArgumentPortion_typestack = array('IfArgumentPortion'); |
||
1606 | function match_IfArgumentPortion ($stack = array()) { |
||
1607 | $matchrule = "IfArgumentPortion"; $result = $this->construct($matchrule, $matchrule, null); |
||
1608 | $_218 = NULL; |
||
1609 | do { |
||
1610 | $res_215 = $result; |
||
1611 | $pos_215 = $this->pos; |
||
1612 | $matcher = 'match_'.'Comparison'; $key = $matcher; $pos = $this->pos; |
||
1613 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1614 | if ($subres !== FALSE) { |
||
1615 | $this->store( $result, $subres ); |
||
1616 | $_218 = TRUE; break; |
||
1617 | } |
||
1618 | $result = $res_215; |
||
1619 | $this->pos = $pos_215; |
||
1620 | $matcher = 'match_'.'PresenceCheck'; $key = $matcher; $pos = $this->pos; |
||
1621 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1622 | if ($subres !== FALSE) { |
||
1623 | $this->store( $result, $subres ); |
||
1624 | $_218 = TRUE; break; |
||
1625 | } |
||
1626 | $result = $res_215; |
||
1627 | $this->pos = $pos_215; |
||
1628 | $_218 = FALSE; break; |
||
1629 | } |
||
1630 | while(0); |
||
1631 | if( $_218 === TRUE ) { return $this->finalise($result); } |
||
1632 | if( $_218 === FALSE) { return FALSE; } |
||
1633 | } |
||
1634 | |||
1635 | |||
1636 | |||
1637 | function IfArgumentPortion_STR(&$res, $sub) |
||
1638 | { |
||
1639 | $res['php'] = $sub['php']; |
||
1640 | } |
||
1641 | |||
1642 | /* BooleanOperator: "||" | "&&" */ |
||
1643 | protected $match_BooleanOperator_typestack = array('BooleanOperator'); |
||
1644 | function match_BooleanOperator ($stack = array()) { |
||
1645 | $matchrule = "BooleanOperator"; $result = $this->construct($matchrule, $matchrule, null); |
||
1646 | $_223 = NULL; |
||
1647 | do { |
||
1648 | $res_220 = $result; |
||
1649 | $pos_220 = $this->pos; |
||
1650 | if (( $subres = $this->literal( '||' ) ) !== FALSE) { |
||
1651 | $result["text"] .= $subres; |
||
1652 | $_223 = TRUE; break; |
||
1653 | } |
||
1654 | $result = $res_220; |
||
1655 | $this->pos = $pos_220; |
||
1656 | if (( $subres = $this->literal( '&&' ) ) !== FALSE) { |
||
1657 | $result["text"] .= $subres; |
||
1658 | $_223 = TRUE; break; |
||
1659 | } |
||
1660 | $result = $res_220; |
||
1661 | $this->pos = $pos_220; |
||
1662 | $_223 = FALSE; break; |
||
1663 | } |
||
1664 | while(0); |
||
1665 | if( $_223 === TRUE ) { return $this->finalise($result); } |
||
1666 | if( $_223 === FALSE) { return FALSE; } |
||
1667 | } |
||
1668 | |||
1669 | |||
1670 | /* IfArgument: :IfArgumentPortion ( < :BooleanOperator < :IfArgumentPortion )* */ |
||
1671 | protected $match_IfArgument_typestack = array('IfArgument'); |
||
1672 | function match_IfArgument ($stack = array()) { |
||
1673 | $matchrule = "IfArgument"; $result = $this->construct($matchrule, $matchrule, null); |
||
1674 | $_232 = NULL; |
||
1675 | do { |
||
1676 | $matcher = 'match_'.'IfArgumentPortion'; $key = $matcher; $pos = $this->pos; |
||
1677 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1678 | if ($subres !== FALSE) { |
||
1679 | $this->store( $result, $subres, "IfArgumentPortion" ); |
||
1680 | } |
||
1681 | else { $_232 = FALSE; break; } |
||
1682 | while (true) { |
||
1683 | $res_231 = $result; |
||
1684 | $pos_231 = $this->pos; |
||
1685 | $_230 = NULL; |
||
1686 | do { |
||
1687 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1688 | $matcher = 'match_'.'BooleanOperator'; $key = $matcher; $pos = $this->pos; |
||
1689 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1690 | if ($subres !== FALSE) { |
||
1691 | $this->store( $result, $subres, "BooleanOperator" ); |
||
1692 | } |
||
1693 | else { $_230 = FALSE; break; } |
||
1694 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1695 | $matcher = 'match_'.'IfArgumentPortion'; $key = $matcher; $pos = $this->pos; |
||
1696 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1697 | if ($subres !== FALSE) { |
||
1698 | $this->store( $result, $subres, "IfArgumentPortion" ); |
||
1699 | } |
||
1700 | else { $_230 = FALSE; break; } |
||
1701 | $_230 = TRUE; break; |
||
1702 | } |
||
1703 | while(0); |
||
1704 | if( $_230 === FALSE) { |
||
1705 | $result = $res_231; |
||
1706 | $this->pos = $pos_231; |
||
1707 | unset( $res_231 ); |
||
1708 | unset( $pos_231 ); |
||
1709 | break; |
||
1710 | } |
||
1711 | } |
||
1712 | $_232 = TRUE; break; |
||
1713 | } |
||
1714 | while(0); |
||
1715 | if( $_232 === TRUE ) { return $this->finalise($result); } |
||
1716 | if( $_232 === FALSE) { return FALSE; } |
||
1717 | } |
||
1718 | |||
1719 | |||
1720 | |||
1721 | function IfArgument_IfArgumentPortion(&$res, $sub) |
||
1722 | { |
||
1723 | $res['php'] .= $sub['php']; |
||
1724 | } |
||
1725 | |||
1726 | function IfArgument_BooleanOperator(&$res, $sub) |
||
1727 | { |
||
1728 | $res['php'] .= $sub['text']; |
||
1729 | } |
||
1730 | |||
1731 | /* IfPart: '<%' < 'if' [ :IfArgument > '%>' Template:$TemplateMatcher? */ |
||
1732 | protected $match_IfPart_typestack = array('IfPart'); |
||
1733 | function match_IfPart ($stack = array()) { |
||
1734 | $matchrule = "IfPart"; $result = $this->construct($matchrule, $matchrule, null); |
||
1735 | $_242 = NULL; |
||
1736 | do { |
||
1737 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1738 | else { $_242 = FALSE; break; } |
||
1739 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1740 | if (( $subres = $this->literal( 'if' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1741 | else { $_242 = FALSE; break; } |
||
1742 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1743 | else { $_242 = FALSE; break; } |
||
1744 | $matcher = 'match_'.'IfArgument'; $key = $matcher; $pos = $this->pos; |
||
1745 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1746 | if ($subres !== FALSE) { |
||
1747 | $this->store( $result, $subres, "IfArgument" ); |
||
1748 | } |
||
1749 | else { $_242 = FALSE; break; } |
||
1750 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1751 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1752 | else { $_242 = FALSE; break; } |
||
1753 | $res_241 = $result; |
||
1754 | $pos_241 = $this->pos; |
||
1755 | $matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $key = $matcher; $pos = $this->pos; |
||
1756 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1757 | if ($subres !== FALSE) { |
||
1758 | $this->store( $result, $subres, "Template" ); |
||
1759 | } |
||
1760 | else { |
||
1761 | $result = $res_241; |
||
1762 | $this->pos = $pos_241; |
||
1763 | unset( $res_241 ); |
||
1764 | unset( $pos_241 ); |
||
1765 | } |
||
1766 | $_242 = TRUE; break; |
||
1767 | } |
||
1768 | while(0); |
||
1769 | if( $_242 === TRUE ) { return $this->finalise($result); } |
||
1770 | if( $_242 === FALSE) { return FALSE; } |
||
1771 | } |
||
1772 | |||
1773 | |||
1774 | /* ElseIfPart: '<%' < 'else_if' [ :IfArgument > '%>' Template:$TemplateMatcher? */ |
||
1775 | protected $match_ElseIfPart_typestack = array('ElseIfPart'); |
||
1776 | function match_ElseIfPart ($stack = array()) { |
||
1777 | $matchrule = "ElseIfPart"; $result = $this->construct($matchrule, $matchrule, null); |
||
1778 | $_252 = NULL; |
||
1779 | do { |
||
1780 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1781 | else { $_252 = FALSE; break; } |
||
1782 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1783 | if (( $subres = $this->literal( 'else_if' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1784 | else { $_252 = FALSE; break; } |
||
1785 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1786 | else { $_252 = FALSE; break; } |
||
1787 | $matcher = 'match_'.'IfArgument'; $key = $matcher; $pos = $this->pos; |
||
1788 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1789 | if ($subres !== FALSE) { |
||
1790 | $this->store( $result, $subres, "IfArgument" ); |
||
1791 | } |
||
1792 | else { $_252 = FALSE; break; } |
||
1793 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1794 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1795 | else { $_252 = FALSE; break; } |
||
1796 | $res_251 = $result; |
||
1797 | $pos_251 = $this->pos; |
||
1798 | $matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $key = $matcher; $pos = $this->pos; |
||
1799 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1800 | if ($subres !== FALSE) { |
||
1801 | $this->store( $result, $subres, "Template" ); |
||
1802 | } |
||
1803 | else { |
||
1804 | $result = $res_251; |
||
1805 | $this->pos = $pos_251; |
||
1806 | unset( $res_251 ); |
||
1807 | unset( $pos_251 ); |
||
1808 | } |
||
1809 | $_252 = TRUE; break; |
||
1810 | } |
||
1811 | while(0); |
||
1812 | if( $_252 === TRUE ) { return $this->finalise($result); } |
||
1813 | if( $_252 === FALSE) { return FALSE; } |
||
1814 | } |
||
1815 | |||
1816 | |||
1817 | /* ElsePart: '<%' < 'else' > '%>' Template:$TemplateMatcher? */ |
||
1818 | protected $match_ElsePart_typestack = array('ElsePart'); |
||
1819 | function match_ElsePart ($stack = array()) { |
||
1820 | $matchrule = "ElsePart"; $result = $this->construct($matchrule, $matchrule, null); |
||
1821 | $_260 = NULL; |
||
1822 | do { |
||
1823 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1824 | else { $_260 = FALSE; break; } |
||
1825 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1826 | if (( $subres = $this->literal( 'else' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1827 | else { $_260 = FALSE; break; } |
||
1828 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1829 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1830 | else { $_260 = FALSE; break; } |
||
1831 | $res_259 = $result; |
||
1832 | $pos_259 = $this->pos; |
||
1833 | $matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $key = $matcher; $pos = $this->pos; |
||
1834 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1835 | if ($subres !== FALSE) { |
||
1836 | $this->store( $result, $subres, "Template" ); |
||
1837 | } |
||
1838 | else { |
||
1839 | $result = $res_259; |
||
1840 | $this->pos = $pos_259; |
||
1841 | unset( $res_259 ); |
||
1842 | unset( $pos_259 ); |
||
1843 | } |
||
1844 | $_260 = TRUE; break; |
||
1845 | } |
||
1846 | while(0); |
||
1847 | if( $_260 === TRUE ) { return $this->finalise($result); } |
||
1848 | if( $_260 === FALSE) { return FALSE; } |
||
1849 | } |
||
1850 | |||
1851 | |||
1852 | /* If: IfPart ElseIfPart* ElsePart? '<%' < 'end_if' > '%>' */ |
||
1853 | protected $match_If_typestack = array('If'); |
||
1854 | function match_If ($stack = array()) { |
||
1855 | $matchrule = "If"; $result = $this->construct($matchrule, $matchrule, null); |
||
1856 | $_270 = NULL; |
||
1857 | do { |
||
1858 | $matcher = 'match_'.'IfPart'; $key = $matcher; $pos = $this->pos; |
||
1859 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1860 | if ($subres !== FALSE) { |
||
1861 | $this->store( $result, $subres ); |
||
1862 | } |
||
1863 | else { $_270 = FALSE; break; } |
||
1864 | while (true) { |
||
1865 | $res_263 = $result; |
||
1866 | $pos_263 = $this->pos; |
||
1867 | $matcher = 'match_'.'ElseIfPart'; $key = $matcher; $pos = $this->pos; |
||
1868 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1869 | if ($subres !== FALSE) { |
||
1870 | $this->store( $result, $subres ); |
||
1871 | } |
||
1872 | else { |
||
1873 | $result = $res_263; |
||
1874 | $this->pos = $pos_263; |
||
1875 | unset( $res_263 ); |
||
1876 | unset( $pos_263 ); |
||
1877 | break; |
||
1878 | } |
||
1879 | } |
||
1880 | $res_264 = $result; |
||
1881 | $pos_264 = $this->pos; |
||
1882 | $matcher = 'match_'.'ElsePart'; $key = $matcher; $pos = $this->pos; |
||
1883 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1884 | if ($subres !== FALSE) { |
||
1885 | $this->store( $result, $subres ); |
||
1886 | } |
||
1887 | else { |
||
1888 | $result = $res_264; |
||
1889 | $this->pos = $pos_264; |
||
1890 | unset( $res_264 ); |
||
1891 | unset( $pos_264 ); |
||
1892 | } |
||
1893 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1894 | else { $_270 = FALSE; break; } |
||
1895 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1896 | if (( $subres = $this->literal( 'end_if' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1897 | else { $_270 = FALSE; break; } |
||
1898 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1899 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1900 | else { $_270 = FALSE; break; } |
||
1901 | $_270 = TRUE; break; |
||
1902 | } |
||
1903 | while(0); |
||
1904 | if( $_270 === TRUE ) { return $this->finalise($result); } |
||
1905 | if( $_270 === FALSE) { return FALSE; } |
||
1906 | } |
||
1907 | |||
1908 | |||
1909 | |||
1910 | function If_IfPart(&$res, $sub) |
||
1911 | { |
||
1912 | $res['php'] = |
||
1913 | 'if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL . |
||
1914 | (isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL . |
||
1915 | '}'; |
||
1916 | } |
||
1917 | |||
1918 | function If_ElseIfPart(&$res, $sub) |
||
1919 | { |
||
1920 | $res['php'] .= |
||
1921 | 'else if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL . |
||
1922 | (isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL . |
||
1923 | '}'; |
||
1924 | } |
||
1925 | |||
1926 | function If_ElsePart(&$res, $sub) |
||
1927 | { |
||
1928 | $res['php'] .= |
||
1929 | 'else { ' . PHP_EOL . |
||
1930 | (isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL . |
||
1931 | '}'; |
||
1932 | } |
||
1933 | |||
1934 | /* Require: '<%' < 'require' [ Call:(Method:Word "(" < :CallArguments > ")") > '%>' */ |
||
1935 | protected $match_Require_typestack = array('Require'); |
||
1936 | function match_Require ($stack = array()) { |
||
1993 | } |
||
1994 | |||
1995 | |||
1996 | |||
1997 | function Require_Call(&$res, $sub) |
||
1998 | { |
||
1999 | $requirements = '\\SilverStripe\\View\\Requirements'; |
||
2000 | $res['php'] = "{$requirements}::".$sub['Method']['text'].'('.$sub['CallArguments']['php'].');'; |
||
2001 | } |
||
2002 | |||
2003 | |||
2004 | /* CacheBlockArgument: |
||
2005 | !( "if " | "unless " ) |
||
2006 | ( |
||
2007 | :DollarMarkedLookup | |
||
2008 | :QuotedString | |
||
2009 | :Lookup |
||
2010 | ) */ |
||
2011 | protected $match_CacheBlockArgument_typestack = array('CacheBlockArgument'); |
||
2012 | function match_CacheBlockArgument ($stack = array()) { |
||
2013 | $matchrule = "CacheBlockArgument"; $result = $this->construct($matchrule, $matchrule, null); |
||
2014 | $_306 = NULL; |
||
2015 | do { |
||
2016 | $res_294 = $result; |
||
2017 | $pos_294 = $this->pos; |
||
2018 | $_293 = NULL; |
||
2019 | do { |
||
2020 | $_291 = NULL; |
||
2021 | do { |
||
2022 | $res_288 = $result; |
||
2023 | $pos_288 = $this->pos; |
||
2024 | if (( $subres = $this->literal( 'if ' ) ) !== FALSE) { |
||
2025 | $result["text"] .= $subres; |
||
2026 | $_291 = TRUE; break; |
||
2027 | } |
||
2028 | $result = $res_288; |
||
2029 | $this->pos = $pos_288; |
||
2030 | if (( $subres = $this->literal( 'unless ' ) ) !== FALSE) { |
||
2031 | $result["text"] .= $subres; |
||
2032 | $_291 = TRUE; break; |
||
2033 | } |
||
2034 | $result = $res_288; |
||
2035 | $this->pos = $pos_288; |
||
2036 | $_291 = FALSE; break; |
||
2037 | } |
||
2038 | while(0); |
||
2039 | if( $_291 === FALSE) { $_293 = FALSE; break; } |
||
2040 | $_293 = TRUE; break; |
||
2041 | } |
||
2042 | while(0); |
||
2043 | if( $_293 === TRUE ) { |
||
2044 | $result = $res_294; |
||
2045 | $this->pos = $pos_294; |
||
2046 | $_306 = FALSE; break; |
||
2047 | } |
||
2048 | if( $_293 === FALSE) { |
||
2049 | $result = $res_294; |
||
2050 | $this->pos = $pos_294; |
||
2051 | } |
||
2052 | $_304 = NULL; |
||
2053 | do { |
||
2054 | $_302 = NULL; |
||
2055 | do { |
||
2056 | $res_295 = $result; |
||
2057 | $pos_295 = $this->pos; |
||
2058 | $matcher = 'match_'.'DollarMarkedLookup'; $key = $matcher; $pos = $this->pos; |
||
2059 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2060 | if ($subres !== FALSE) { |
||
2061 | $this->store( $result, $subres, "DollarMarkedLookup" ); |
||
2062 | $_302 = TRUE; break; |
||
2063 | } |
||
2064 | $result = $res_295; |
||
2065 | $this->pos = $pos_295; |
||
2066 | $_300 = NULL; |
||
2067 | do { |
||
2068 | $res_297 = $result; |
||
2069 | $pos_297 = $this->pos; |
||
2070 | $matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos; |
||
2071 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2072 | if ($subres !== FALSE) { |
||
2073 | $this->store( $result, $subres, "QuotedString" ); |
||
2074 | $_300 = TRUE; break; |
||
2075 | } |
||
2076 | $result = $res_297; |
||
2077 | $this->pos = $pos_297; |
||
2078 | $matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos; |
||
2079 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2080 | if ($subres !== FALSE) { |
||
2081 | $this->store( $result, $subres, "Lookup" ); |
||
2082 | $_300 = TRUE; break; |
||
2083 | } |
||
2084 | $result = $res_297; |
||
2085 | $this->pos = $pos_297; |
||
2086 | $_300 = FALSE; break; |
||
2087 | } |
||
2088 | while(0); |
||
2089 | if( $_300 === TRUE ) { $_302 = TRUE; break; } |
||
2090 | $result = $res_295; |
||
2091 | $this->pos = $pos_295; |
||
2092 | $_302 = FALSE; break; |
||
2093 | } |
||
2094 | while(0); |
||
2095 | if( $_302 === FALSE) { $_304 = FALSE; break; } |
||
2096 | $_304 = TRUE; break; |
||
2097 | } |
||
2098 | while(0); |
||
2099 | if( $_304 === FALSE) { $_306 = FALSE; break; } |
||
2100 | $_306 = TRUE; break; |
||
2101 | } |
||
2102 | while(0); |
||
2103 | if( $_306 === TRUE ) { return $this->finalise($result); } |
||
2104 | if( $_306 === FALSE) { return FALSE; } |
||
2105 | } |
||
2106 | |||
2107 | |||
2108 | |||
2109 | function CacheBlockArgument_DollarMarkedLookup(&$res, $sub) |
||
2110 | { |
||
2111 | $res['php'] = $sub['Lookup']['php']; |
||
2112 | } |
||
2113 | |||
2114 | function CacheBlockArgument_QuotedString(&$res, $sub) |
||
2115 | { |
||
2116 | $res['php'] = "'" . str_replace("'", "\\'", $sub['String']['text']) . "'"; |
||
2117 | } |
||
2118 | |||
2119 | function CacheBlockArgument_Lookup(&$res, $sub) |
||
2120 | { |
||
2121 | $res['php'] = $sub['php']; |
||
2122 | } |
||
2123 | |||
2124 | /* CacheBlockArguments: CacheBlockArgument ( < "," < CacheBlockArgument )* */ |
||
2125 | protected $match_CacheBlockArguments_typestack = array('CacheBlockArguments'); |
||
2126 | function match_CacheBlockArguments ($stack = array()) { |
||
2127 | $matchrule = "CacheBlockArguments"; $result = $this->construct($matchrule, $matchrule, null); |
||
2128 | $_315 = NULL; |
||
2129 | do { |
||
2130 | $matcher = 'match_'.'CacheBlockArgument'; $key = $matcher; $pos = $this->pos; |
||
2131 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2132 | if ($subres !== FALSE) { |
||
2133 | $this->store( $result, $subres ); |
||
2134 | } |
||
2135 | else { $_315 = FALSE; break; } |
||
2136 | while (true) { |
||
2137 | $res_314 = $result; |
||
2138 | $pos_314 = $this->pos; |
||
2139 | $_313 = NULL; |
||
2140 | do { |
||
2141 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2142 | if (substr($this->string,$this->pos,1) == ',') { |
||
2143 | $this->pos += 1; |
||
2144 | $result["text"] .= ','; |
||
2145 | } |
||
2146 | else { $_313 = FALSE; break; } |
||
2147 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2148 | $matcher = 'match_'.'CacheBlockArgument'; $key = $matcher; $pos = $this->pos; |
||
2149 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2150 | if ($subres !== FALSE) { |
||
2151 | $this->store( $result, $subres ); |
||
2152 | } |
||
2153 | else { $_313 = FALSE; break; } |
||
2154 | $_313 = TRUE; break; |
||
2155 | } |
||
2156 | while(0); |
||
2157 | if( $_313 === FALSE) { |
||
2158 | $result = $res_314; |
||
2159 | $this->pos = $pos_314; |
||
2160 | unset( $res_314 ); |
||
2161 | unset( $pos_314 ); |
||
2162 | break; |
||
2163 | } |
||
2164 | } |
||
2165 | $_315 = TRUE; break; |
||
2166 | } |
||
2167 | while(0); |
||
2168 | if( $_315 === TRUE ) { return $this->finalise($result); } |
||
2169 | if( $_315 === FALSE) { return FALSE; } |
||
2170 | } |
||
2171 | |||
2172 | |||
2173 | |||
2174 | function CacheBlockArguments_CacheBlockArgument(&$res, $sub) |
||
2175 | { |
||
2176 | if (!empty($res['php'])) { |
||
2177 | $res['php'] .= ".'_'."; |
||
2178 | } else { |
||
2179 | $res['php'] = ''; |
||
2180 | } |
||
2181 | |||
2182 | $res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']); |
||
2183 | } |
||
2184 | |||
2185 | /* CacheBlockTemplate: (Comment | Translate | If | Require | OldI18NTag | Include | ClosedBlock | |
||
2186 | OpenBlock | MalformedBlock | MalformedBracketInjection | Injection | Text)+ */ |
||
2187 | protected $match_CacheBlockTemplate_typestack = array('CacheBlockTemplate','Template'); |
||
2188 | function match_CacheBlockTemplate ($stack = array()) { |
||
2189 | $matchrule = "CacheBlockTemplate"; $result = $this->construct($matchrule, $matchrule, array('TemplateMatcher' => 'CacheRestrictedTemplate')); |
||
2190 | $count = 0; |
||
2191 | while (true) { |
||
2192 | $res_363 = $result; |
||
2193 | $pos_363 = $this->pos; |
||
2194 | $_362 = NULL; |
||
2195 | do { |
||
2196 | $_360 = NULL; |
||
2197 | do { |
||
2198 | $res_317 = $result; |
||
2199 | $pos_317 = $this->pos; |
||
2200 | $matcher = 'match_'.'Comment'; $key = $matcher; $pos = $this->pos; |
||
2201 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2202 | if ($subres !== FALSE) { |
||
2203 | $this->store( $result, $subres ); |
||
2204 | $_360 = TRUE; break; |
||
2205 | } |
||
2206 | $result = $res_317; |
||
2207 | $this->pos = $pos_317; |
||
2208 | $_358 = NULL; |
||
2209 | do { |
||
2210 | $res_319 = $result; |
||
2211 | $pos_319 = $this->pos; |
||
2212 | $matcher = 'match_'.'Translate'; $key = $matcher; $pos = $this->pos; |
||
2213 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2214 | if ($subres !== FALSE) { |
||
2215 | $this->store( $result, $subres ); |
||
2216 | $_358 = TRUE; break; |
||
2217 | } |
||
2218 | $result = $res_319; |
||
2219 | $this->pos = $pos_319; |
||
2220 | $_356 = NULL; |
||
2221 | do { |
||
2222 | $res_321 = $result; |
||
2223 | $pos_321 = $this->pos; |
||
2224 | $matcher = 'match_'.'If'; $key = $matcher; $pos = $this->pos; |
||
2225 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2226 | if ($subres !== FALSE) { |
||
2227 | $this->store( $result, $subres ); |
||
2228 | $_356 = TRUE; break; |
||
2229 | } |
||
2230 | $result = $res_321; |
||
2231 | $this->pos = $pos_321; |
||
2232 | $_354 = NULL; |
||
2233 | do { |
||
2234 | $res_323 = $result; |
||
2235 | $pos_323 = $this->pos; |
||
2236 | $matcher = 'match_'.'Require'; $key = $matcher; $pos = $this->pos; |
||
2237 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2238 | if ($subres !== FALSE) { |
||
2239 | $this->store( $result, $subres ); |
||
2240 | $_354 = TRUE; break; |
||
2241 | } |
||
2242 | $result = $res_323; |
||
2243 | $this->pos = $pos_323; |
||
2244 | $_352 = NULL; |
||
2245 | do { |
||
2246 | $res_325 = $result; |
||
2247 | $pos_325 = $this->pos; |
||
2248 | $matcher = 'match_'.'OldI18NTag'; $key = $matcher; $pos = $this->pos; |
||
2249 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2250 | if ($subres !== FALSE) { |
||
2251 | $this->store( $result, $subres ); |
||
2252 | $_352 = TRUE; break; |
||
2253 | } |
||
2254 | $result = $res_325; |
||
2255 | $this->pos = $pos_325; |
||
2256 | $_350 = NULL; |
||
2257 | do { |
||
2258 | $res_327 = $result; |
||
2259 | $pos_327 = $this->pos; |
||
2260 | $matcher = 'match_'.'Include'; $key = $matcher; $pos = $this->pos; |
||
2261 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2262 | if ($subres !== FALSE) { |
||
2263 | $this->store( $result, $subres ); |
||
2264 | $_350 = TRUE; break; |
||
2265 | } |
||
2266 | $result = $res_327; |
||
2267 | $this->pos = $pos_327; |
||
2268 | $_348 = NULL; |
||
2269 | do { |
||
2270 | $res_329 = $result; |
||
2271 | $pos_329 = $this->pos; |
||
2272 | $matcher = 'match_'.'ClosedBlock'; $key = $matcher; $pos = $this->pos; |
||
2273 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2274 | if ($subres !== FALSE) { |
||
2275 | $this->store( $result, $subres ); |
||
2276 | $_348 = TRUE; break; |
||
2277 | } |
||
2278 | $result = $res_329; |
||
2279 | $this->pos = $pos_329; |
||
2280 | $_346 = NULL; |
||
2281 | do { |
||
2282 | $res_331 = $result; |
||
2283 | $pos_331 = $this->pos; |
||
2284 | $matcher = 'match_'.'OpenBlock'; $key = $matcher; $pos = $this->pos; |
||
2285 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2286 | if ($subres !== FALSE) { |
||
2287 | $this->store( $result, $subres ); |
||
2288 | $_346 = TRUE; break; |
||
2289 | } |
||
2290 | $result = $res_331; |
||
2291 | $this->pos = $pos_331; |
||
2292 | $_344 = NULL; |
||
2293 | do { |
||
2294 | $res_333 = $result; |
||
2295 | $pos_333 = $this->pos; |
||
2296 | $matcher = 'match_'.'MalformedBlock'; $key = $matcher; $pos = $this->pos; |
||
2297 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2298 | if ($subres !== FALSE) { |
||
2299 | $this->store( $result, $subres ); |
||
2300 | $_344 = TRUE; break; |
||
2301 | } |
||
2302 | $result = $res_333; |
||
2303 | $this->pos = $pos_333; |
||
2304 | $_342 = NULL; |
||
2305 | do { |
||
2306 | $res_335 = $result; |
||
2307 | $pos_335 = $this->pos; |
||
2308 | $matcher = 'match_'.'MalformedBracketInjection'; $key = $matcher; $pos = $this->pos; |
||
2309 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2310 | if ($subres !== FALSE) { |
||
2311 | $this->store( $result, $subres ); |
||
2312 | $_342 = TRUE; break; |
||
2313 | } |
||
2314 | $result = $res_335; |
||
2315 | $this->pos = $pos_335; |
||
2316 | $_340 = NULL; |
||
2317 | do { |
||
2318 | $res_337 = $result; |
||
2319 | $pos_337 = $this->pos; |
||
2320 | $matcher = 'match_'.'Injection'; $key = $matcher; $pos = $this->pos; |
||
2321 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2322 | if ($subres !== FALSE) { |
||
2323 | $this->store( $result, $subres ); |
||
2324 | $_340 = TRUE; break; |
||
2325 | } |
||
2326 | $result = $res_337; |
||
2327 | $this->pos = $pos_337; |
||
2328 | $matcher = 'match_'.'Text'; $key = $matcher; $pos = $this->pos; |
||
2329 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2330 | if ($subres !== FALSE) { |
||
2331 | $this->store( $result, $subres ); |
||
2332 | $_340 = TRUE; break; |
||
2333 | } |
||
2334 | $result = $res_337; |
||
2335 | $this->pos = $pos_337; |
||
2336 | $_340 = FALSE; break; |
||
2337 | } |
||
2338 | while(0); |
||
2339 | if( $_340 === TRUE ) { $_342 = TRUE; break; } |
||
2340 | $result = $res_335; |
||
2341 | $this->pos = $pos_335; |
||
2342 | $_342 = FALSE; break; |
||
2343 | } |
||
2344 | while(0); |
||
2345 | if( $_342 === TRUE ) { $_344 = TRUE; break; } |
||
2346 | $result = $res_333; |
||
2347 | $this->pos = $pos_333; |
||
2348 | $_344 = FALSE; break; |
||
2349 | } |
||
2350 | while(0); |
||
2351 | if( $_344 === TRUE ) { $_346 = TRUE; break; } |
||
2352 | $result = $res_331; |
||
2353 | $this->pos = $pos_331; |
||
2354 | $_346 = FALSE; break; |
||
2355 | } |
||
2356 | while(0); |
||
2357 | if( $_346 === TRUE ) { $_348 = TRUE; break; } |
||
2358 | $result = $res_329; |
||
2359 | $this->pos = $pos_329; |
||
2360 | $_348 = FALSE; break; |
||
2361 | } |
||
2362 | while(0); |
||
2363 | if( $_348 === TRUE ) { $_350 = TRUE; break; } |
||
2364 | $result = $res_327; |
||
2365 | $this->pos = $pos_327; |
||
2366 | $_350 = FALSE; break; |
||
2367 | } |
||
2368 | while(0); |
||
2369 | if( $_350 === TRUE ) { $_352 = TRUE; break; } |
||
2370 | $result = $res_325; |
||
2371 | $this->pos = $pos_325; |
||
2372 | $_352 = FALSE; break; |
||
2373 | } |
||
2374 | while(0); |
||
2375 | if( $_352 === TRUE ) { $_354 = TRUE; break; } |
||
2376 | $result = $res_323; |
||
2377 | $this->pos = $pos_323; |
||
2378 | $_354 = FALSE; break; |
||
2379 | } |
||
2380 | while(0); |
||
2381 | if( $_354 === TRUE ) { $_356 = TRUE; break; } |
||
2382 | $result = $res_321; |
||
2383 | $this->pos = $pos_321; |
||
2384 | $_356 = FALSE; break; |
||
2385 | } |
||
2386 | while(0); |
||
2387 | if( $_356 === TRUE ) { $_358 = TRUE; break; } |
||
2388 | $result = $res_319; |
||
2389 | $this->pos = $pos_319; |
||
2390 | $_358 = FALSE; break; |
||
2391 | } |
||
2392 | while(0); |
||
2393 | if( $_358 === TRUE ) { $_360 = TRUE; break; } |
||
2394 | $result = $res_317; |
||
2395 | $this->pos = $pos_317; |
||
2396 | $_360 = FALSE; break; |
||
2397 | } |
||
2398 | while(0); |
||
2399 | if( $_360 === FALSE) { $_362 = FALSE; break; } |
||
2400 | $_362 = TRUE; break; |
||
2401 | } |
||
2402 | while(0); |
||
2403 | if( $_362 === FALSE) { |
||
2404 | $result = $res_363; |
||
2405 | $this->pos = $pos_363; |
||
2406 | unset( $res_363 ); |
||
2407 | unset( $pos_363 ); |
||
2408 | break; |
||
2409 | } |
||
2410 | $count += 1; |
||
2411 | } |
||
2412 | if ($count > 0) { return $this->finalise($result); } |
||
2413 | else { return FALSE; } |
||
2414 | } |
||
2415 | |||
2416 | |||
2417 | |||
2418 | |||
2419 | /* UncachedBlock: |
||
2420 | '<%' < "uncached" < CacheBlockArguments? ( < Conditional:("if"|"unless") > Condition:IfArgument )? > '%>' |
||
2421 | Template:$TemplateMatcher? |
||
2422 | '<%' < 'end_' ("uncached"|"cached"|"cacheblock") > '%>' */ |
||
2423 | protected $match_UncachedBlock_typestack = array('UncachedBlock'); |
||
2424 | function match_UncachedBlock ($stack = array()) { |
||
2425 | $matchrule = "UncachedBlock"; $result = $this->construct($matchrule, $matchrule, null); |
||
2426 | $_400 = NULL; |
||
2427 | do { |
||
2428 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2429 | else { $_400 = FALSE; break; } |
||
2430 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2431 | if (( $subres = $this->literal( 'uncached' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2432 | else { $_400 = FALSE; break; } |
||
2433 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2434 | $res_368 = $result; |
||
2435 | $pos_368 = $this->pos; |
||
2436 | $matcher = 'match_'.'CacheBlockArguments'; $key = $matcher; $pos = $this->pos; |
||
2437 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2438 | if ($subres !== FALSE) { |
||
2439 | $this->store( $result, $subres ); |
||
2440 | } |
||
2441 | else { |
||
2442 | $result = $res_368; |
||
2443 | $this->pos = $pos_368; |
||
2444 | unset( $res_368 ); |
||
2445 | unset( $pos_368 ); |
||
2446 | } |
||
2447 | $res_380 = $result; |
||
2448 | $pos_380 = $this->pos; |
||
2449 | $_379 = NULL; |
||
2450 | do { |
||
2451 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2452 | $stack[] = $result; $result = $this->construct( $matchrule, "Conditional" ); |
||
2453 | $_375 = NULL; |
||
2454 | do { |
||
2455 | $_373 = NULL; |
||
2456 | do { |
||
2457 | $res_370 = $result; |
||
2458 | $pos_370 = $this->pos; |
||
2459 | if (( $subres = $this->literal( 'if' ) ) !== FALSE) { |
||
2460 | $result["text"] .= $subres; |
||
2461 | $_373 = TRUE; break; |
||
2462 | } |
||
2463 | $result = $res_370; |
||
2464 | $this->pos = $pos_370; |
||
2465 | if (( $subres = $this->literal( 'unless' ) ) !== FALSE) { |
||
2466 | $result["text"] .= $subres; |
||
2467 | $_373 = TRUE; break; |
||
2468 | } |
||
2469 | $result = $res_370; |
||
2470 | $this->pos = $pos_370; |
||
2471 | $_373 = FALSE; break; |
||
2472 | } |
||
2473 | while(0); |
||
2474 | if( $_373 === FALSE) { $_375 = FALSE; break; } |
||
2475 | $_375 = TRUE; break; |
||
2476 | } |
||
2477 | while(0); |
||
2478 | if( $_375 === TRUE ) { |
||
2479 | $subres = $result; $result = array_pop($stack); |
||
2480 | $this->store( $result, $subres, 'Conditional' ); |
||
2481 | } |
||
2482 | if( $_375 === FALSE) { |
||
2483 | $result = array_pop($stack); |
||
2484 | $_379 = FALSE; break; |
||
2485 | } |
||
2486 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2487 | $matcher = 'match_'.'IfArgument'; $key = $matcher; $pos = $this->pos; |
||
2488 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2489 | if ($subres !== FALSE) { |
||
2490 | $this->store( $result, $subres, "Condition" ); |
||
2491 | } |
||
2492 | else { $_379 = FALSE; break; } |
||
2493 | $_379 = TRUE; break; |
||
2494 | } |
||
2495 | while(0); |
||
2496 | if( $_379 === FALSE) { |
||
2497 | $result = $res_380; |
||
2498 | $this->pos = $pos_380; |
||
2499 | unset( $res_380 ); |
||
2500 | unset( $pos_380 ); |
||
2501 | } |
||
2502 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2503 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2504 | else { $_400 = FALSE; break; } |
||
2505 | $res_383 = $result; |
||
2506 | $pos_383 = $this->pos; |
||
2507 | $matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $key = $matcher; $pos = $this->pos; |
||
2508 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2509 | if ($subres !== FALSE) { |
||
2510 | $this->store( $result, $subres, "Template" ); |
||
2511 | } |
||
2512 | else { |
||
2513 | $result = $res_383; |
||
2514 | $this->pos = $pos_383; |
||
2515 | unset( $res_383 ); |
||
2516 | unset( $pos_383 ); |
||
2517 | } |
||
2518 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2519 | else { $_400 = FALSE; break; } |
||
2520 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2521 | if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2522 | else { $_400 = FALSE; break; } |
||
2523 | $_396 = NULL; |
||
2524 | do { |
||
2525 | $_394 = NULL; |
||
2526 | do { |
||
2527 | $res_387 = $result; |
||
2528 | $pos_387 = $this->pos; |
||
2529 | if (( $subres = $this->literal( 'uncached' ) ) !== FALSE) { |
||
2530 | $result["text"] .= $subres; |
||
2531 | $_394 = TRUE; break; |
||
2532 | } |
||
2533 | $result = $res_387; |
||
2534 | $this->pos = $pos_387; |
||
2535 | $_392 = NULL; |
||
2536 | do { |
||
2537 | $res_389 = $result; |
||
2538 | $pos_389 = $this->pos; |
||
2539 | if (( $subres = $this->literal( 'cached' ) ) !== FALSE) { |
||
2540 | $result["text"] .= $subres; |
||
2541 | $_392 = TRUE; break; |
||
2542 | } |
||
2543 | $result = $res_389; |
||
2544 | $this->pos = $pos_389; |
||
2545 | if (( $subres = $this->literal( 'cacheblock' ) ) !== FALSE) { |
||
2546 | $result["text"] .= $subres; |
||
2547 | $_392 = TRUE; break; |
||
2548 | } |
||
2549 | $result = $res_389; |
||
2550 | $this->pos = $pos_389; |
||
2551 | $_392 = FALSE; break; |
||
2552 | } |
||
2553 | while(0); |
||
2554 | if( $_392 === TRUE ) { $_394 = TRUE; break; } |
||
2555 | $result = $res_387; |
||
2556 | $this->pos = $pos_387; |
||
2557 | $_394 = FALSE; break; |
||
2558 | } |
||
2559 | while(0); |
||
2560 | if( $_394 === FALSE) { $_396 = FALSE; break; } |
||
2561 | $_396 = TRUE; break; |
||
2562 | } |
||
2563 | while(0); |
||
2564 | if( $_396 === FALSE) { $_400 = FALSE; break; } |
||
2565 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2566 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2567 | else { $_400 = FALSE; break; } |
||
2568 | $_400 = TRUE; break; |
||
2569 | } |
||
2570 | while(0); |
||
2571 | if( $_400 === TRUE ) { return $this->finalise($result); } |
||
2572 | if( $_400 === FALSE) { return FALSE; } |
||
2573 | } |
||
2574 | |||
2575 | |||
2576 | |||
2577 | function UncachedBlock_Template(&$res, $sub) |
||
2578 | { |
||
2579 | $res['php'] = $sub['php']; |
||
2580 | } |
||
2581 | |||
2582 | /* CacheRestrictedTemplate: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock | |
||
2583 | OpenBlock | MalformedBlock | MalformedBracketInjection | Injection | Text)+ */ |
||
2584 | protected $match_CacheRestrictedTemplate_typestack = array('CacheRestrictedTemplate','Template'); |
||
2585 | function match_CacheRestrictedTemplate ($stack = array()) { |
||
2586 | $matchrule = "CacheRestrictedTemplate"; $result = $this->construct($matchrule, $matchrule, null); |
||
2587 | $count = 0; |
||
2588 | while (true) { |
||
2589 | $res_456 = $result; |
||
2590 | $pos_456 = $this->pos; |
||
2591 | $_455 = NULL; |
||
2592 | do { |
||
2593 | $_453 = NULL; |
||
2594 | do { |
||
2595 | $res_402 = $result; |
||
2596 | $pos_402 = $this->pos; |
||
2597 | $matcher = 'match_'.'Comment'; $key = $matcher; $pos = $this->pos; |
||
2598 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2599 | if ($subres !== FALSE) { |
||
2600 | $this->store( $result, $subres ); |
||
2601 | $_453 = TRUE; break; |
||
2602 | } |
||
2603 | $result = $res_402; |
||
2604 | $this->pos = $pos_402; |
||
2605 | $_451 = NULL; |
||
2606 | do { |
||
2607 | $res_404 = $result; |
||
2608 | $pos_404 = $this->pos; |
||
2609 | $matcher = 'match_'.'Translate'; $key = $matcher; $pos = $this->pos; |
||
2610 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2611 | if ($subres !== FALSE) { |
||
2612 | $this->store( $result, $subres ); |
||
2613 | $_451 = TRUE; break; |
||
2614 | } |
||
2615 | $result = $res_404; |
||
2616 | $this->pos = $pos_404; |
||
2617 | $_449 = NULL; |
||
2618 | do { |
||
2619 | $res_406 = $result; |
||
2620 | $pos_406 = $this->pos; |
||
2621 | $matcher = 'match_'.'If'; $key = $matcher; $pos = $this->pos; |
||
2622 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2623 | if ($subres !== FALSE) { |
||
2624 | $this->store( $result, $subres ); |
||
2625 | $_449 = TRUE; break; |
||
2626 | } |
||
2627 | $result = $res_406; |
||
2628 | $this->pos = $pos_406; |
||
2629 | $_447 = NULL; |
||
2630 | do { |
||
2631 | $res_408 = $result; |
||
2632 | $pos_408 = $this->pos; |
||
2633 | $matcher = 'match_'.'Require'; $key = $matcher; $pos = $this->pos; |
||
2634 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2635 | if ($subres !== FALSE) { |
||
2636 | $this->store( $result, $subres ); |
||
2637 | $_447 = TRUE; break; |
||
2638 | } |
||
2639 | $result = $res_408; |
||
2640 | $this->pos = $pos_408; |
||
2641 | $_445 = NULL; |
||
2642 | do { |
||
2643 | $res_410 = $result; |
||
2644 | $pos_410 = $this->pos; |
||
2645 | $matcher = 'match_'.'CacheBlock'; $key = $matcher; $pos = $this->pos; |
||
2646 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2647 | if ($subres !== FALSE) { |
||
2648 | $this->store( $result, $subres ); |
||
2649 | $_445 = TRUE; break; |
||
2650 | } |
||
2651 | $result = $res_410; |
||
2652 | $this->pos = $pos_410; |
||
2653 | $_443 = NULL; |
||
2654 | do { |
||
2655 | $res_412 = $result; |
||
2656 | $pos_412 = $this->pos; |
||
2657 | $matcher = 'match_'.'UncachedBlock'; $key = $matcher; $pos = $this->pos; |
||
2658 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2659 | if ($subres !== FALSE) { |
||
2660 | $this->store( $result, $subres ); |
||
2661 | $_443 = TRUE; break; |
||
2662 | } |
||
2663 | $result = $res_412; |
||
2664 | $this->pos = $pos_412; |
||
2665 | $_441 = NULL; |
||
2666 | do { |
||
2667 | $res_414 = $result; |
||
2668 | $pos_414 = $this->pos; |
||
2669 | $matcher = 'match_'.'OldI18NTag'; $key = $matcher; $pos = $this->pos; |
||
2670 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2671 | if ($subres !== FALSE) { |
||
2672 | $this->store( $result, $subres ); |
||
2673 | $_441 = TRUE; break; |
||
2674 | } |
||
2675 | $result = $res_414; |
||
2676 | $this->pos = $pos_414; |
||
2677 | $_439 = NULL; |
||
2678 | do { |
||
2679 | $res_416 = $result; |
||
2680 | $pos_416 = $this->pos; |
||
2681 | $matcher = 'match_'.'Include'; $key = $matcher; $pos = $this->pos; |
||
2682 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2683 | if ($subres !== FALSE) { |
||
2684 | $this->store( $result, $subres ); |
||
2685 | $_439 = TRUE; break; |
||
2686 | } |
||
2687 | $result = $res_416; |
||
2688 | $this->pos = $pos_416; |
||
2689 | $_437 = NULL; |
||
2690 | do { |
||
2691 | $res_418 = $result; |
||
2692 | $pos_418 = $this->pos; |
||
2693 | $matcher = 'match_'.'ClosedBlock'; $key = $matcher; $pos = $this->pos; |
||
2694 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2695 | if ($subres !== FALSE) { |
||
2696 | $this->store( $result, $subres ); |
||
2697 | $_437 = TRUE; break; |
||
2698 | } |
||
2699 | $result = $res_418; |
||
2700 | $this->pos = $pos_418; |
||
2701 | $_435 = NULL; |
||
2702 | do { |
||
2703 | $res_420 = $result; |
||
2704 | $pos_420 = $this->pos; |
||
2705 | $matcher = 'match_'.'OpenBlock'; $key = $matcher; $pos = $this->pos; |
||
2706 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2707 | if ($subres !== FALSE) { |
||
2708 | $this->store( $result, $subres ); |
||
2709 | $_435 = TRUE; break; |
||
2710 | } |
||
2711 | $result = $res_420; |
||
2712 | $this->pos = $pos_420; |
||
2713 | $_433 = NULL; |
||
2714 | do { |
||
2715 | $res_422 = $result; |
||
2716 | $pos_422 = $this->pos; |
||
2717 | $matcher = 'match_'.'MalformedBlock'; $key = $matcher; $pos = $this->pos; |
||
2718 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2719 | if ($subres !== FALSE) { |
||
2720 | $this->store( $result, $subres ); |
||
2721 | $_433 = TRUE; break; |
||
2722 | } |
||
2723 | $result = $res_422; |
||
2724 | $this->pos = $pos_422; |
||
2725 | $_431 = NULL; |
||
2726 | do { |
||
2727 | $res_424 = $result; |
||
2728 | $pos_424 = $this->pos; |
||
2729 | $matcher = 'match_'.'MalformedBracketInjection'; $key = $matcher; $pos = $this->pos; |
||
2730 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2731 | if ($subres !== FALSE) { |
||
2732 | $this->store( $result, $subres ); |
||
2733 | $_431 = TRUE; break; |
||
2734 | } |
||
2735 | $result = $res_424; |
||
2736 | $this->pos = $pos_424; |
||
2737 | $_429 = NULL; |
||
2738 | do { |
||
2739 | $res_426 = $result; |
||
2740 | $pos_426 = $this->pos; |
||
2741 | $matcher = 'match_'.'Injection'; $key = $matcher; $pos = $this->pos; |
||
2742 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2743 | if ($subres !== FALSE) { |
||
2744 | $this->store( $result, $subres ); |
||
2745 | $_429 = TRUE; break; |
||
2746 | } |
||
2747 | $result = $res_426; |
||
2748 | $this->pos = $pos_426; |
||
2749 | $matcher = 'match_'.'Text'; $key = $matcher; $pos = $this->pos; |
||
2750 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2751 | if ($subres !== FALSE) { |
||
2752 | $this->store( $result, $subres ); |
||
2753 | $_429 = TRUE; break; |
||
2754 | } |
||
2755 | $result = $res_426; |
||
2756 | $this->pos = $pos_426; |
||
2757 | $_429 = FALSE; break; |
||
2758 | } |
||
2759 | while(0); |
||
2760 | if( $_429 === TRUE ) { |
||
2761 | $_431 = TRUE; break; |
||
2762 | } |
||
2763 | $result = $res_424; |
||
2764 | $this->pos = $pos_424; |
||
2765 | $_431 = FALSE; break; |
||
2766 | } |
||
2767 | while(0); |
||
2768 | if( $_431 === TRUE ) { $_433 = TRUE; break; } |
||
2769 | $result = $res_422; |
||
2770 | $this->pos = $pos_422; |
||
2771 | $_433 = FALSE; break; |
||
2772 | } |
||
2773 | while(0); |
||
2774 | if( $_433 === TRUE ) { $_435 = TRUE; break; } |
||
2775 | $result = $res_420; |
||
2776 | $this->pos = $pos_420; |
||
2777 | $_435 = FALSE; break; |
||
2778 | } |
||
2779 | while(0); |
||
2780 | if( $_435 === TRUE ) { $_437 = TRUE; break; } |
||
2781 | $result = $res_418; |
||
2782 | $this->pos = $pos_418; |
||
2783 | $_437 = FALSE; break; |
||
2784 | } |
||
2785 | while(0); |
||
2786 | if( $_437 === TRUE ) { $_439 = TRUE; break; } |
||
2787 | $result = $res_416; |
||
2788 | $this->pos = $pos_416; |
||
2789 | $_439 = FALSE; break; |
||
2790 | } |
||
2791 | while(0); |
||
2792 | if( $_439 === TRUE ) { $_441 = TRUE; break; } |
||
2793 | $result = $res_414; |
||
2794 | $this->pos = $pos_414; |
||
2795 | $_441 = FALSE; break; |
||
2796 | } |
||
2797 | while(0); |
||
2798 | if( $_441 === TRUE ) { $_443 = TRUE; break; } |
||
2799 | $result = $res_412; |
||
2800 | $this->pos = $pos_412; |
||
2801 | $_443 = FALSE; break; |
||
2802 | } |
||
2803 | while(0); |
||
2804 | if( $_443 === TRUE ) { $_445 = TRUE; break; } |
||
2805 | $result = $res_410; |
||
2806 | $this->pos = $pos_410; |
||
2807 | $_445 = FALSE; break; |
||
2808 | } |
||
2809 | while(0); |
||
2810 | if( $_445 === TRUE ) { $_447 = TRUE; break; } |
||
2811 | $result = $res_408; |
||
2812 | $this->pos = $pos_408; |
||
2813 | $_447 = FALSE; break; |
||
2814 | } |
||
2815 | while(0); |
||
2816 | if( $_447 === TRUE ) { $_449 = TRUE; break; } |
||
2817 | $result = $res_406; |
||
2818 | $this->pos = $pos_406; |
||
2819 | $_449 = FALSE; break; |
||
2820 | } |
||
2821 | while(0); |
||
2822 | if( $_449 === TRUE ) { $_451 = TRUE; break; } |
||
2823 | $result = $res_404; |
||
2824 | $this->pos = $pos_404; |
||
2825 | $_451 = FALSE; break; |
||
2826 | } |
||
2827 | while(0); |
||
2828 | if( $_451 === TRUE ) { $_453 = TRUE; break; } |
||
2829 | $result = $res_402; |
||
2830 | $this->pos = $pos_402; |
||
2831 | $_453 = FALSE; break; |
||
2832 | } |
||
2833 | while(0); |
||
2834 | if( $_453 === FALSE) { $_455 = FALSE; break; } |
||
2835 | $_455 = TRUE; break; |
||
2836 | } |
||
2837 | while(0); |
||
2838 | if( $_455 === FALSE) { |
||
2839 | $result = $res_456; |
||
2840 | $this->pos = $pos_456; |
||
2841 | unset( $res_456 ); |
||
2842 | unset( $pos_456 ); |
||
2843 | break; |
||
2844 | } |
||
2845 | $count += 1; |
||
2846 | } |
||
2847 | if ($count > 0) { return $this->finalise($result); } |
||
2848 | else { return FALSE; } |
||
2849 | } |
||
2850 | |||
2851 | |||
2852 | |||
2853 | function CacheRestrictedTemplate_CacheBlock(&$res, $sub) |
||
2854 | { |
||
2855 | throw new SSTemplateParseException('You cant have cache blocks nested within with, loop or control blocks ' . |
||
2856 | 'that are within cache blocks', $this); |
||
2857 | } |
||
2858 | |||
2859 | function CacheRestrictedTemplate_UncachedBlock(&$res, $sub) |
||
2860 | { |
||
2861 | throw new SSTemplateParseException('You cant have uncache blocks nested within with, loop or control blocks ' . |
||
2862 | 'that are within cache blocks', $this); |
||
2863 | } |
||
2864 | |||
2865 | /* CacheBlock: |
||
2866 | '<%' < CacheTag:("cached"|"cacheblock") < (CacheBlockArguments)? ( < Conditional:("if"|"unless") > |
||
2867 | Condition:IfArgument )? > '%>' |
||
2868 | (CacheBlock | UncachedBlock | CacheBlockTemplate)* |
||
2869 | '<%' < 'end_' ("cached"|"uncached"|"cacheblock") > '%>' */ |
||
2870 | protected $match_CacheBlock_typestack = array('CacheBlock'); |
||
2871 | function match_CacheBlock ($stack = array()) { |
||
2872 | $matchrule = "CacheBlock"; $result = $this->construct($matchrule, $matchrule, null); |
||
2873 | $_511 = NULL; |
||
2874 | do { |
||
2875 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2876 | else { $_511 = FALSE; break; } |
||
2877 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2878 | $stack[] = $result; $result = $this->construct( $matchrule, "CacheTag" ); |
||
2879 | $_464 = NULL; |
||
2880 | do { |
||
2881 | $_462 = NULL; |
||
2882 | do { |
||
2883 | $res_459 = $result; |
||
2884 | $pos_459 = $this->pos; |
||
2885 | if (( $subres = $this->literal( 'cached' ) ) !== FALSE) { |
||
2886 | $result["text"] .= $subres; |
||
2887 | $_462 = TRUE; break; |
||
2888 | } |
||
2889 | $result = $res_459; |
||
2890 | $this->pos = $pos_459; |
||
2891 | if (( $subres = $this->literal( 'cacheblock' ) ) !== FALSE) { |
||
2892 | $result["text"] .= $subres; |
||
2893 | $_462 = TRUE; break; |
||
2894 | } |
||
2895 | $result = $res_459; |
||
2896 | $this->pos = $pos_459; |
||
2897 | $_462 = FALSE; break; |
||
2898 | } |
||
2899 | while(0); |
||
2900 | if( $_462 === FALSE) { $_464 = FALSE; break; } |
||
2901 | $_464 = TRUE; break; |
||
2902 | } |
||
2903 | while(0); |
||
2904 | if( $_464 === TRUE ) { |
||
2905 | $subres = $result; $result = array_pop($stack); |
||
2906 | $this->store( $result, $subres, 'CacheTag' ); |
||
2907 | } |
||
2908 | if( $_464 === FALSE) { |
||
2909 | $result = array_pop($stack); |
||
2910 | $_511 = FALSE; break; |
||
2911 | } |
||
2912 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2913 | $res_469 = $result; |
||
2914 | $pos_469 = $this->pos; |
||
2915 | $_468 = NULL; |
||
2916 | do { |
||
2917 | $matcher = 'match_'.'CacheBlockArguments'; $key = $matcher; $pos = $this->pos; |
||
2918 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2919 | if ($subres !== FALSE) { |
||
2920 | $this->store( $result, $subres ); |
||
2921 | } |
||
2922 | else { $_468 = FALSE; break; } |
||
2923 | $_468 = TRUE; break; |
||
2924 | } |
||
2925 | while(0); |
||
2926 | if( $_468 === FALSE) { |
||
2927 | $result = $res_469; |
||
2928 | $this->pos = $pos_469; |
||
2929 | unset( $res_469 ); |
||
2930 | unset( $pos_469 ); |
||
2931 | } |
||
2932 | $res_481 = $result; |
||
2933 | $pos_481 = $this->pos; |
||
2934 | $_480 = NULL; |
||
2935 | do { |
||
2936 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2937 | $stack[] = $result; $result = $this->construct( $matchrule, "Conditional" ); |
||
2938 | $_476 = NULL; |
||
2939 | do { |
||
2940 | $_474 = NULL; |
||
2941 | do { |
||
2942 | $res_471 = $result; |
||
2943 | $pos_471 = $this->pos; |
||
2944 | if (( $subres = $this->literal( 'if' ) ) !== FALSE) { |
||
2945 | $result["text"] .= $subres; |
||
2946 | $_474 = TRUE; break; |
||
2947 | } |
||
2948 | $result = $res_471; |
||
2949 | $this->pos = $pos_471; |
||
2950 | if (( $subres = $this->literal( 'unless' ) ) !== FALSE) { |
||
2951 | $result["text"] .= $subres; |
||
2952 | $_474 = TRUE; break; |
||
2953 | } |
||
2954 | $result = $res_471; |
||
2955 | $this->pos = $pos_471; |
||
2956 | $_474 = FALSE; break; |
||
2957 | } |
||
2958 | while(0); |
||
2959 | if( $_474 === FALSE) { $_476 = FALSE; break; } |
||
2960 | $_476 = TRUE; break; |
||
2961 | } |
||
2962 | while(0); |
||
2963 | if( $_476 === TRUE ) { |
||
2964 | $subres = $result; $result = array_pop($stack); |
||
2965 | $this->store( $result, $subres, 'Conditional' ); |
||
2966 | } |
||
2967 | if( $_476 === FALSE) { |
||
2968 | $result = array_pop($stack); |
||
2969 | $_480 = FALSE; break; |
||
2970 | } |
||
2971 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2972 | $matcher = 'match_'.'IfArgument'; $key = $matcher; $pos = $this->pos; |
||
2973 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2974 | if ($subres !== FALSE) { |
||
2975 | $this->store( $result, $subres, "Condition" ); |
||
2976 | } |
||
2977 | else { $_480 = FALSE; break; } |
||
2978 | $_480 = TRUE; break; |
||
2979 | } |
||
2980 | while(0); |
||
2981 | if( $_480 === FALSE) { |
||
2982 | $result = $res_481; |
||
2983 | $this->pos = $pos_481; |
||
2984 | unset( $res_481 ); |
||
2985 | unset( $pos_481 ); |
||
2986 | } |
||
2987 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2988 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2989 | else { $_511 = FALSE; break; } |
||
2990 | while (true) { |
||
2991 | $res_494 = $result; |
||
2992 | $pos_494 = $this->pos; |
||
2993 | $_493 = NULL; |
||
2994 | do { |
||
2995 | $_491 = NULL; |
||
2996 | do { |
||
2997 | $res_484 = $result; |
||
2998 | $pos_484 = $this->pos; |
||
2999 | $matcher = 'match_'.'CacheBlock'; $key = $matcher; $pos = $this->pos; |
||
3000 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3001 | if ($subres !== FALSE) { |
||
3002 | $this->store( $result, $subres ); |
||
3003 | $_491 = TRUE; break; |
||
3004 | } |
||
3005 | $result = $res_484; |
||
3006 | $this->pos = $pos_484; |
||
3007 | $_489 = NULL; |
||
3008 | do { |
||
3009 | $res_486 = $result; |
||
3010 | $pos_486 = $this->pos; |
||
3011 | $matcher = 'match_'.'UncachedBlock'; $key = $matcher; $pos = $this->pos; |
||
3012 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3013 | if ($subres !== FALSE) { |
||
3014 | $this->store( $result, $subres ); |
||
3015 | $_489 = TRUE; break; |
||
3016 | } |
||
3017 | $result = $res_486; |
||
3018 | $this->pos = $pos_486; |
||
3019 | $matcher = 'match_'.'CacheBlockTemplate'; $key = $matcher; $pos = $this->pos; |
||
3020 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3021 | if ($subres !== FALSE) { |
||
3022 | $this->store( $result, $subres ); |
||
3023 | $_489 = TRUE; break; |
||
3024 | } |
||
3025 | $result = $res_486; |
||
3026 | $this->pos = $pos_486; |
||
3027 | $_489 = FALSE; break; |
||
3028 | } |
||
3029 | while(0); |
||
3030 | if( $_489 === TRUE ) { $_491 = TRUE; break; } |
||
3031 | $result = $res_484; |
||
3032 | $this->pos = $pos_484; |
||
3033 | $_491 = FALSE; break; |
||
3034 | } |
||
3035 | while(0); |
||
3036 | if( $_491 === FALSE) { $_493 = FALSE; break; } |
||
3037 | $_493 = TRUE; break; |
||
3038 | } |
||
3039 | while(0); |
||
3040 | if( $_493 === FALSE) { |
||
3041 | $result = $res_494; |
||
3042 | $this->pos = $pos_494; |
||
3043 | unset( $res_494 ); |
||
3044 | unset( $pos_494 ); |
||
3045 | break; |
||
3046 | } |
||
3047 | } |
||
3048 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3049 | else { $_511 = FALSE; break; } |
||
3050 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3051 | if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3052 | else { $_511 = FALSE; break; } |
||
3053 | $_507 = NULL; |
||
3054 | do { |
||
3055 | $_505 = NULL; |
||
3056 | do { |
||
3057 | $res_498 = $result; |
||
3058 | $pos_498 = $this->pos; |
||
3059 | if (( $subres = $this->literal( 'cached' ) ) !== FALSE) { |
||
3060 | $result["text"] .= $subres; |
||
3061 | $_505 = TRUE; break; |
||
3062 | } |
||
3063 | $result = $res_498; |
||
3064 | $this->pos = $pos_498; |
||
3065 | $_503 = NULL; |
||
3066 | do { |
||
3067 | $res_500 = $result; |
||
3068 | $pos_500 = $this->pos; |
||
3069 | if (( $subres = $this->literal( 'uncached' ) ) !== FALSE) { |
||
3070 | $result["text"] .= $subres; |
||
3071 | $_503 = TRUE; break; |
||
3072 | } |
||
3073 | $result = $res_500; |
||
3074 | $this->pos = $pos_500; |
||
3075 | if (( $subres = $this->literal( 'cacheblock' ) ) !== FALSE) { |
||
3076 | $result["text"] .= $subres; |
||
3077 | $_503 = TRUE; break; |
||
3078 | } |
||
3079 | $result = $res_500; |
||
3080 | $this->pos = $pos_500; |
||
3081 | $_503 = FALSE; break; |
||
3082 | } |
||
3083 | while(0); |
||
3084 | if( $_503 === TRUE ) { $_505 = TRUE; break; } |
||
3085 | $result = $res_498; |
||
3086 | $this->pos = $pos_498; |
||
3087 | $_505 = FALSE; break; |
||
3088 | } |
||
3089 | while(0); |
||
3090 | if( $_505 === FALSE) { $_507 = FALSE; break; } |
||
3091 | $_507 = TRUE; break; |
||
3092 | } |
||
3093 | while(0); |
||
3094 | if( $_507 === FALSE) { $_511 = FALSE; break; } |
||
3095 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3096 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3097 | else { $_511 = FALSE; break; } |
||
3098 | $_511 = TRUE; break; |
||
3099 | } |
||
3100 | while(0); |
||
3101 | if( $_511 === TRUE ) { return $this->finalise($result); } |
||
3102 | if( $_511 === FALSE) { return FALSE; } |
||
3103 | } |
||
3104 | |||
3105 | |||
3106 | |||
3107 | function CacheBlock__construct(&$res) |
||
3108 | { |
||
3109 | $res['subblocks'] = 0; |
||
3110 | } |
||
3111 | |||
3112 | function CacheBlock_CacheBlockArguments(&$res, $sub) |
||
3115 | } |
||
3116 | |||
3117 | function CacheBlock_Condition(&$res, $sub) |
||
3118 | { |
||
3119 | $res['condition'] = ($res['Conditional']['text'] == 'if' ? '(' : '!(') . $sub['php'] . ') && '; |
||
3120 | } |
||
3121 | |||
3122 | function CacheBlock_CacheBlock(&$res, $sub) |
||
3123 | { |
||
3124 | $res['php'] .= $sub['php']; |
||
3125 | } |
||
3126 | |||
3127 | function CacheBlock_UncachedBlock(&$res, $sub) |
||
3128 | { |
||
3129 | $res['php'] .= $sub['php']; |
||
3130 | } |
||
3131 | |||
3132 | function CacheBlock_CacheBlockTemplate(&$res, $sub) |
||
3133 | { |
||
3134 | // Get the block counter |
||
3135 | $block = ++$res['subblocks']; |
||
3136 | // Build the key for this block from the global key (evaluated in a closure within the template), |
||
3137 | // the passed cache key, the block index, and the sha hash of the template. |
||
3138 | $res['php'] .= '$keyExpression = function() use ($scope, $cache) {' . PHP_EOL; |
||
3139 | $res['php'] .= '$val = \'\';' . PHP_EOL; |
||
3140 | if ($globalKey = SSViewer::config()->get('global_key')) { |
||
3141 | // Embed the code necessary to evaluate the globalKey directly into the template, |
||
3142 | // so that SSTemplateParser only needs to be called during template regeneration. |
||
3143 | // Warning: If the global key is changed, it's necessary to flush the template cache. |
||
3144 | $parser = Injector::inst()->get(__CLASS__, false); |
||
3145 | $result = $parser->compileString($globalKey, '', false, false); |
||
3146 | if (!$result) { |
||
3147 | throw new SSTemplateParseException('Unexpected problem parsing template', $parser); |
||
3148 | } |
||
3149 | $res['php'] .= $result . PHP_EOL; |
||
3150 | } |
||
3151 | $res['php'] .= 'return $val;' . PHP_EOL; |
||
3152 | $res['php'] .= '};' . PHP_EOL; |
||
3153 | $key = 'sha1($keyExpression())' // Global key |
||
3154 | . '.\'_' . sha1($sub['php']) // sha of template |
||
3155 | . (isset($res['key']) && $res['key'] ? "_'.sha1(".$res['key'].")" : "'") // Passed key |
||
3156 | . ".'_$block'"; // block index |
||
3157 | // Get any condition |
||
3158 | $condition = isset($res['condition']) ? $res['condition'] : ''; |
||
3159 | |||
3160 | $res['php'] .= 'if ('.$condition.'($partial = $cache->get('.$key.'))) $val .= $partial;' . PHP_EOL; |
||
3161 | $res['php'] .= 'else { $oldval = $val; $val = "";' . PHP_EOL; |
||
3162 | $res['php'] .= $sub['php'] . PHP_EOL; |
||
3163 | $res['php'] .= $condition . ' $cache->set('.$key.', $val); $val = $oldval . $val;' . PHP_EOL; |
||
3164 | $res['php'] .= '}'; |
||
3165 | } |
||
3166 | |||
3167 | /* OldTPart: "_t" N "(" N QuotedString (N "," N CallArguments)? N ")" N (";")? */ |
||
3168 | protected $match_OldTPart_typestack = array('OldTPart'); |
||
3169 | function match_OldTPart ($stack = array()) { |
||
3170 | $matchrule = "OldTPart"; $result = $this->construct($matchrule, $matchrule, null); |
||
3171 | $_530 = NULL; |
||
3172 | do { |
||
3173 | if (( $subres = $this->literal( '_t' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3174 | else { $_530 = FALSE; break; } |
||
3175 | $matcher = 'match_'.'N'; $key = $matcher; $pos = $this->pos; |
||
3176 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3177 | if ($subres !== FALSE) { |
||
3178 | $this->store( $result, $subres ); |
||
3179 | } |
||
3180 | else { $_530 = FALSE; break; } |
||
3181 | if (substr($this->string,$this->pos,1) == '(') { |
||
3182 | $this->pos += 1; |
||
3183 | $result["text"] .= '('; |
||
3184 | } |
||
3185 | else { $_530 = FALSE; break; } |
||
3186 | $matcher = 'match_'.'N'; $key = $matcher; $pos = $this->pos; |
||
3187 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3188 | if ($subres !== FALSE) { |
||
3189 | $this->store( $result, $subres ); |
||
3190 | } |
||
3191 | else { $_530 = FALSE; break; } |
||
3192 | $matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos; |
||
3193 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3194 | if ($subres !== FALSE) { |
||
3195 | $this->store( $result, $subres ); |
||
3196 | } |
||
3197 | else { $_530 = FALSE; break; } |
||
3198 | $res_523 = $result; |
||
3199 | $pos_523 = $this->pos; |
||
3200 | $_522 = NULL; |
||
3201 | do { |
||
3202 | $matcher = 'match_'.'N'; $key = $matcher; $pos = $this->pos; |
||
3203 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3204 | if ($subres !== FALSE) { |
||
3205 | $this->store( $result, $subres ); |
||
3206 | } |
||
3207 | else { $_522 = FALSE; break; } |
||
3208 | if (substr($this->string,$this->pos,1) == ',') { |
||
3209 | $this->pos += 1; |
||
3210 | $result["text"] .= ','; |
||
3211 | } |
||
3212 | else { $_522 = FALSE; break; } |
||
3213 | $matcher = 'match_'.'N'; $key = $matcher; $pos = $this->pos; |
||
3214 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3215 | if ($subres !== FALSE) { |
||
3216 | $this->store( $result, $subres ); |
||
3217 | } |
||
3218 | else { $_522 = FALSE; break; } |
||
3219 | $matcher = 'match_'.'CallArguments'; $key = $matcher; $pos = $this->pos; |
||
3220 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3221 | if ($subres !== FALSE) { |
||
3222 | $this->store( $result, $subres ); |
||
3223 | } |
||
3224 | else { $_522 = FALSE; break; } |
||
3225 | $_522 = TRUE; break; |
||
3226 | } |
||
3227 | while(0); |
||
3228 | if( $_522 === FALSE) { |
||
3229 | $result = $res_523; |
||
3230 | $this->pos = $pos_523; |
||
3231 | unset( $res_523 ); |
||
3232 | unset( $pos_523 ); |
||
3233 | } |
||
3234 | $matcher = 'match_'.'N'; $key = $matcher; $pos = $this->pos; |
||
3235 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3236 | if ($subres !== FALSE) { |
||
3237 | $this->store( $result, $subres ); |
||
3238 | } |
||
3239 | else { $_530 = FALSE; break; } |
||
3240 | if (substr($this->string,$this->pos,1) == ')') { |
||
3241 | $this->pos += 1; |
||
3242 | $result["text"] .= ')'; |
||
3243 | } |
||
3244 | else { $_530 = FALSE; break; } |
||
3245 | $matcher = 'match_'.'N'; $key = $matcher; $pos = $this->pos; |
||
3246 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3247 | if ($subres !== FALSE) { |
||
3248 | $this->store( $result, $subres ); |
||
3249 | } |
||
3250 | else { $_530 = FALSE; break; } |
||
3251 | $res_529 = $result; |
||
3252 | $pos_529 = $this->pos; |
||
3253 | $_528 = NULL; |
||
3254 | do { |
||
3255 | if (substr($this->string,$this->pos,1) == ';') { |
||
3256 | $this->pos += 1; |
||
3257 | $result["text"] .= ';'; |
||
3258 | } |
||
3259 | else { $_528 = FALSE; break; } |
||
3260 | $_528 = TRUE; break; |
||
3261 | } |
||
3262 | while(0); |
||
3263 | if( $_528 === FALSE) { |
||
3264 | $result = $res_529; |
||
3265 | $this->pos = $pos_529; |
||
3266 | unset( $res_529 ); |
||
3267 | unset( $pos_529 ); |
||
3268 | } |
||
3269 | $_530 = TRUE; break; |
||
3270 | } |
||
3271 | while(0); |
||
3272 | if( $_530 === TRUE ) { return $this->finalise($result); } |
||
3273 | if( $_530 === FALSE) { return FALSE; } |
||
3274 | } |
||
3275 | |||
3276 | |||
3277 | /* N: / [\s\n]* / */ |
||
3278 | protected $match_N_typestack = array('N'); |
||
3279 | function match_N ($stack = array()) { |
||
3280 | $matchrule = "N"; $result = $this->construct($matchrule, $matchrule, null); |
||
3281 | if (( $subres = $this->rx( '/ [\s\n]* /' ) ) !== FALSE) { |
||
3282 | $result["text"] .= $subres; |
||
3283 | return $this->finalise($result); |
||
3284 | } |
||
3285 | else { return FALSE; } |
||
3286 | } |
||
3287 | |||
3288 | |||
3289 | |||
3290 | function OldTPart__construct(&$res) |
||
3291 | { |
||
3292 | $res['php'] = "_t("; |
||
3293 | } |
||
3294 | |||
3295 | function OldTPart_QuotedString(&$res, $sub) |
||
3296 | { |
||
3297 | $entity = $sub['String']['text']; |
||
3298 | if (strpos($entity, '.') === false) { |
||
3299 | $res['php'] .= "\$scope->XML_val('I18NNamespace').'.$entity'"; |
||
3300 | } else { |
||
3301 | $res['php'] .= "'$entity'"; |
||
3302 | } |
||
3303 | } |
||
3304 | |||
3305 | function OldTPart_CallArguments(&$res, $sub) |
||
3306 | { |
||
3307 | $res['php'] .= ',' . $sub['php']; |
||
3308 | } |
||
3309 | |||
3310 | function OldTPart__finalise(&$res) |
||
3311 | { |
||
3312 | $res['php'] .= ')'; |
||
3313 | } |
||
3314 | |||
3315 | /* OldTTag: "<%" < OldTPart > "%>" */ |
||
3316 | protected $match_OldTTag_typestack = array('OldTTag'); |
||
3317 | function match_OldTTag ($stack = array()) { |
||
3318 | $matchrule = "OldTTag"; $result = $this->construct($matchrule, $matchrule, null); |
||
3319 | $_538 = NULL; |
||
3320 | do { |
||
3321 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3322 | else { $_538 = FALSE; break; } |
||
3323 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3324 | $matcher = 'match_'.'OldTPart'; $key = $matcher; $pos = $this->pos; |
||
3325 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3326 | if ($subres !== FALSE) { |
||
3327 | $this->store( $result, $subres ); |
||
3328 | } |
||
3329 | else { $_538 = FALSE; break; } |
||
3330 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3331 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3332 | else { $_538 = FALSE; break; } |
||
3333 | $_538 = TRUE; break; |
||
3334 | } |
||
3335 | while(0); |
||
3336 | if( $_538 === TRUE ) { return $this->finalise($result); } |
||
3337 | if( $_538 === FALSE) { return FALSE; } |
||
3338 | } |
||
3339 | |||
3340 | |||
3341 | |||
3342 | function OldTTag_OldTPart(&$res, $sub) |
||
3343 | { |
||
3344 | $res['php'] = $sub['php']; |
||
3345 | } |
||
3346 | |||
3347 | /* OldSprintfTag: "<%" < "sprintf" < "(" < OldTPart < "," < CallArguments > ")" > "%>" */ |
||
3348 | protected $match_OldSprintfTag_typestack = array('OldSprintfTag'); |
||
3349 | function match_OldSprintfTag ($stack = array()) { |
||
3350 | $matchrule = "OldSprintfTag"; $result = $this->construct($matchrule, $matchrule, null); |
||
3351 | $_555 = NULL; |
||
3352 | do { |
||
3353 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3354 | else { $_555 = FALSE; break; } |
||
3355 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3356 | if (( $subres = $this->literal( 'sprintf' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3357 | else { $_555 = FALSE; break; } |
||
3358 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3359 | if (substr($this->string,$this->pos,1) == '(') { |
||
3360 | $this->pos += 1; |
||
3361 | $result["text"] .= '('; |
||
3362 | } |
||
3363 | else { $_555 = FALSE; break; } |
||
3364 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3365 | $matcher = 'match_'.'OldTPart'; $key = $matcher; $pos = $this->pos; |
||
3366 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3367 | if ($subres !== FALSE) { |
||
3368 | $this->store( $result, $subres ); |
||
3369 | } |
||
3370 | else { $_555 = FALSE; break; } |
||
3371 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3372 | if (substr($this->string,$this->pos,1) == ',') { |
||
3373 | $this->pos += 1; |
||
3374 | $result["text"] .= ','; |
||
3375 | } |
||
3376 | else { $_555 = FALSE; break; } |
||
3377 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3378 | $matcher = 'match_'.'CallArguments'; $key = $matcher; $pos = $this->pos; |
||
3379 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3380 | if ($subres !== FALSE) { |
||
3381 | $this->store( $result, $subres ); |
||
3382 | } |
||
3383 | else { $_555 = FALSE; break; } |
||
3384 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3385 | if (substr($this->string,$this->pos,1) == ')') { |
||
3386 | $this->pos += 1; |
||
3387 | $result["text"] .= ')'; |
||
3388 | } |
||
3389 | else { $_555 = FALSE; break; } |
||
3390 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3391 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3392 | else { $_555 = FALSE; break; } |
||
3393 | $_555 = TRUE; break; |
||
3394 | } |
||
3395 | while(0); |
||
3396 | if( $_555 === TRUE ) { return $this->finalise($result); } |
||
3397 | if( $_555 === FALSE) { return FALSE; } |
||
3398 | } |
||
3399 | |||
3400 | |||
3401 | |||
3402 | function OldSprintfTag__construct(&$res) |
||
3403 | { |
||
3404 | $res['php'] = "sprintf("; |
||
3405 | } |
||
3406 | |||
3407 | function OldSprintfTag_OldTPart(&$res, $sub) |
||
3408 | { |
||
3409 | $res['php'] .= $sub['php']; |
||
3410 | } |
||
3411 | |||
3412 | function OldSprintfTag_CallArguments(&$res, $sub) |
||
3413 | { |
||
3414 | $res['php'] .= ',' . $sub['php'] . ')'; |
||
3415 | } |
||
3416 | |||
3417 | /* OldI18NTag: OldSprintfTag | OldTTag */ |
||
3418 | protected $match_OldI18NTag_typestack = array('OldI18NTag'); |
||
3419 | function match_OldI18NTag ($stack = array()) { |
||
3420 | $matchrule = "OldI18NTag"; $result = $this->construct($matchrule, $matchrule, null); |
||
3421 | $_560 = NULL; |
||
3422 | do { |
||
3423 | $res_557 = $result; |
||
3424 | $pos_557 = $this->pos; |
||
3425 | $matcher = 'match_'.'OldSprintfTag'; $key = $matcher; $pos = $this->pos; |
||
3426 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3427 | if ($subres !== FALSE) { |
||
3428 | $this->store( $result, $subres ); |
||
3429 | $_560 = TRUE; break; |
||
3430 | } |
||
3431 | $result = $res_557; |
||
3432 | $this->pos = $pos_557; |
||
3433 | $matcher = 'match_'.'OldTTag'; $key = $matcher; $pos = $this->pos; |
||
3434 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3435 | if ($subres !== FALSE) { |
||
3436 | $this->store( $result, $subres ); |
||
3437 | $_560 = TRUE; break; |
||
3438 | } |
||
3439 | $result = $res_557; |
||
3440 | $this->pos = $pos_557; |
||
3441 | $_560 = FALSE; break; |
||
3442 | } |
||
3443 | while(0); |
||
3444 | if( $_560 === TRUE ) { return $this->finalise($result); } |
||
3445 | if( $_560 === FALSE) { return FALSE; } |
||
3446 | } |
||
3447 | |||
3448 | |||
3449 | |||
3450 | function OldI18NTag_STR(&$res, $sub) |
||
3451 | { |
||
3452 | $res['php'] = '$val .= ' . $sub['php'] . ';'; |
||
3453 | } |
||
3454 | |||
3455 | /* NamedArgument: Name:Word "=" Value:Argument */ |
||
3456 | protected $match_NamedArgument_typestack = array('NamedArgument'); |
||
3457 | function match_NamedArgument ($stack = array()) { |
||
3458 | $matchrule = "NamedArgument"; $result = $this->construct($matchrule, $matchrule, null); |
||
3459 | $_565 = NULL; |
||
3460 | do { |
||
3461 | $matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
||
3462 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3463 | if ($subres !== FALSE) { |
||
3464 | $this->store( $result, $subres, "Name" ); |
||
3465 | } |
||
3466 | else { $_565 = FALSE; break; } |
||
3467 | if (substr($this->string,$this->pos,1) == '=') { |
||
3468 | $this->pos += 1; |
||
3469 | $result["text"] .= '='; |
||
3470 | } |
||
3471 | else { $_565 = FALSE; break; } |
||
3472 | $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
||
3473 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3474 | if ($subres !== FALSE) { |
||
3475 | $this->store( $result, $subres, "Value" ); |
||
3476 | } |
||
3477 | else { $_565 = FALSE; break; } |
||
3478 | $_565 = TRUE; break; |
||
3479 | } |
||
3480 | while(0); |
||
3481 | if( $_565 === TRUE ) { return $this->finalise($result); } |
||
3482 | if( $_565 === FALSE) { return FALSE; } |
||
3483 | } |
||
3484 | |||
3485 | |||
3486 | |||
3487 | function NamedArgument_Name(&$res, $sub) |
||
3488 | { |
||
3489 | $res['php'] = "'" . $sub['text'] . "' => "; |
||
3490 | } |
||
3491 | |||
3492 | function NamedArgument_Value(&$res, $sub) |
||
3493 | { |
||
3494 | switch ($sub['ArgumentMode']) { |
||
3495 | case 'string': |
||
3496 | $res['php'] .= $sub['php']; |
||
3497 | break; |
||
3498 | |||
3499 | case 'default': |
||
3500 | $res['php'] .= $sub['string_php']; |
||
3501 | break; |
||
3502 | |||
3503 | default: |
||
3504 | $res['php'] .= str_replace('$$FINAL', 'obj', $sub['php']) . '->self()'; |
||
3505 | break; |
||
3506 | } |
||
3507 | } |
||
3508 | |||
3509 | /* Include: "<%" < "include" < Template:NamespacedWord < (NamedArgument ( < "," < NamedArgument )*)? > "%>" */ |
||
3510 | protected $match_Include_typestack = array('Include'); |
||
3511 | function match_Include ($stack = array()) { |
||
3512 | $matchrule = "Include"; $result = $this->construct($matchrule, $matchrule, null); |
||
3513 | $_584 = NULL; |
||
3514 | do { |
||
3515 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3516 | else { $_584 = FALSE; break; } |
||
3517 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3518 | if (( $subres = $this->literal( 'include' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3519 | else { $_584 = FALSE; break; } |
||
3520 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3521 | $matcher = 'match_'.'NamespacedWord'; $key = $matcher; $pos = $this->pos; |
||
3522 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3523 | if ($subres !== FALSE) { |
||
3524 | $this->store( $result, $subres, "Template" ); |
||
3525 | } |
||
3526 | else { $_584 = FALSE; break; } |
||
3527 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3528 | $res_581 = $result; |
||
3529 | $pos_581 = $this->pos; |
||
3530 | $_580 = NULL; |
||
3531 | do { |
||
3532 | $matcher = 'match_'.'NamedArgument'; $key = $matcher; $pos = $this->pos; |
||
3533 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3534 | if ($subres !== FALSE) { |
||
3535 | $this->store( $result, $subres ); |
||
3536 | } |
||
3537 | else { $_580 = FALSE; break; } |
||
3538 | while (true) { |
||
3539 | $res_579 = $result; |
||
3540 | $pos_579 = $this->pos; |
||
3541 | $_578 = NULL; |
||
3542 | do { |
||
3543 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3544 | if (substr($this->string,$this->pos,1) == ',') { |
||
3545 | $this->pos += 1; |
||
3546 | $result["text"] .= ','; |
||
3547 | } |
||
3548 | else { $_578 = FALSE; break; } |
||
3549 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3550 | $matcher = 'match_'.'NamedArgument'; $key = $matcher; $pos = $this->pos; |
||
3551 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3552 | if ($subres !== FALSE) { |
||
3553 | $this->store( $result, $subres ); |
||
3554 | } |
||
3555 | else { $_578 = FALSE; break; } |
||
3556 | $_578 = TRUE; break; |
||
3557 | } |
||
3558 | while(0); |
||
3559 | if( $_578 === FALSE) { |
||
3560 | $result = $res_579; |
||
3561 | $this->pos = $pos_579; |
||
3562 | unset( $res_579 ); |
||
3563 | unset( $pos_579 ); |
||
3564 | break; |
||
3565 | } |
||
3566 | } |
||
3567 | $_580 = TRUE; break; |
||
3568 | } |
||
3569 | while(0); |
||
3570 | if( $_580 === FALSE) { |
||
3571 | $result = $res_581; |
||
3572 | $this->pos = $pos_581; |
||
3573 | unset( $res_581 ); |
||
3574 | unset( $pos_581 ); |
||
3575 | } |
||
3576 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3577 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3578 | else { $_584 = FALSE; break; } |
||
3579 | $_584 = TRUE; break; |
||
3580 | } |
||
3581 | while(0); |
||
3582 | if( $_584 === TRUE ) { return $this->finalise($result); } |
||
3583 | if( $_584 === FALSE) { return FALSE; } |
||
3584 | } |
||
3585 | |||
3586 | |||
3587 | |||
3588 | function Include__construct(&$res) |
||
3589 | { |
||
3590 | $res['arguments'] = []; |
||
3591 | } |
||
3592 | |||
3593 | function Include_Template(&$res, $sub) |
||
3594 | { |
||
3595 | $res['template'] = "'" . $sub['text'] . "'"; |
||
3596 | } |
||
3597 | |||
3598 | function Include_NamedArgument(&$res, $sub) |
||
3599 | { |
||
3600 | $res['arguments'][] = $sub['php']; |
||
3601 | } |
||
3602 | |||
3603 | function Include__finalise(&$res) |
||
3604 | { |
||
3605 | $template = $res['template']; |
||
3606 | $arguments = $res['arguments']; |
||
3607 | |||
3608 | // Note: 'type' here is important to disable subTemplates in SSViewer::getSubtemplateFor() |
||
3609 | $res['php'] = '$val .= \\SilverStripe\\View\\SSViewer::execute_template([["type" => "Includes", '.$template.'], '.$template.'], $scope->getItem(), [' . |
||
3610 | implode(',', $arguments)."], \$scope, true);\n"; |
||
3611 | |||
3612 | if ($this->includeDebuggingComments) { // Add include filename comments on dev sites |
||
3613 | $res['php'] = |
||
3614 | '$val .= \'<!-- include '.addslashes($template).' -->\';'. "\n". |
||
3615 | $res['php']. |
||
3616 | '$val .= \'<!-- end include '.addslashes($template).' -->\';'. "\n"; |
||
3617 | } |
||
3618 | } |
||
3619 | |||
3620 | /* BlockArguments: :Argument ( < "," < :Argument)* */ |
||
3621 | protected $match_BlockArguments_typestack = array('BlockArguments'); |
||
3622 | function match_BlockArguments ($stack = array()) { |
||
3623 | $matchrule = "BlockArguments"; $result = $this->construct($matchrule, $matchrule, null); |
||
3624 | $_593 = NULL; |
||
3625 | do { |
||
3626 | $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
||
3627 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3628 | if ($subres !== FALSE) { |
||
3629 | $this->store( $result, $subres, "Argument" ); |
||
3630 | } |
||
3631 | else { $_593 = FALSE; break; } |
||
3632 | while (true) { |
||
3633 | $res_592 = $result; |
||
3634 | $pos_592 = $this->pos; |
||
3635 | $_591 = NULL; |
||
3636 | do { |
||
3637 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3638 | if (substr($this->string,$this->pos,1) == ',') { |
||
3639 | $this->pos += 1; |
||
3640 | $result["text"] .= ','; |
||
3641 | } |
||
3642 | else { $_591 = FALSE; break; } |
||
3643 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3644 | $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
||
3645 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3646 | if ($subres !== FALSE) { |
||
3647 | $this->store( $result, $subres, "Argument" ); |
||
3648 | } |
||
3649 | else { $_591 = FALSE; break; } |
||
3650 | $_591 = TRUE; break; |
||
3651 | } |
||
3652 | while(0); |
||
3653 | if( $_591 === FALSE) { |
||
3654 | $result = $res_592; |
||
3655 | $this->pos = $pos_592; |
||
3656 | unset( $res_592 ); |
||
3657 | unset( $pos_592 ); |
||
3658 | break; |
||
3659 | } |
||
3660 | } |
||
3661 | $_593 = TRUE; break; |
||
3662 | } |
||
3663 | while(0); |
||
3664 | if( $_593 === TRUE ) { return $this->finalise($result); } |
||
3665 | if( $_593 === FALSE) { return FALSE; } |
||
3666 | } |
||
3667 | |||
3668 | |||
3669 | /* NotBlockTag: "end_" | (("if" | "else_if" | "else" | "require" | "cached" | "uncached" | "cacheblock" | "include")]) */ |
||
3670 | protected $match_NotBlockTag_typestack = array('NotBlockTag'); |
||
3671 | function match_NotBlockTag ($stack = array()) { |
||
3672 | $matchrule = "NotBlockTag"; $result = $this->construct($matchrule, $matchrule, null); |
||
3673 | $_631 = NULL; |
||
3674 | do { |
||
3675 | $res_595 = $result; |
||
3676 | $pos_595 = $this->pos; |
||
3677 | if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { |
||
3678 | $result["text"] .= $subres; |
||
3679 | $_631 = TRUE; break; |
||
3680 | } |
||
3681 | $result = $res_595; |
||
3682 | $this->pos = $pos_595; |
||
3683 | $_629 = NULL; |
||
3684 | do { |
||
3685 | $_626 = NULL; |
||
3686 | do { |
||
3687 | $_624 = NULL; |
||
3688 | do { |
||
3689 | $res_597 = $result; |
||
3690 | $pos_597 = $this->pos; |
||
3691 | if (( $subres = $this->literal( 'if' ) ) !== FALSE) { |
||
3692 | $result["text"] .= $subres; |
||
3693 | $_624 = TRUE; break; |
||
3694 | } |
||
3695 | $result = $res_597; |
||
3696 | $this->pos = $pos_597; |
||
3697 | $_622 = NULL; |
||
3698 | do { |
||
3699 | $res_599 = $result; |
||
3700 | $pos_599 = $this->pos; |
||
3701 | if (( $subres = $this->literal( 'else_if' ) ) !== FALSE) { |
||
3702 | $result["text"] .= $subres; |
||
3703 | $_622 = TRUE; break; |
||
3704 | } |
||
3705 | $result = $res_599; |
||
3706 | $this->pos = $pos_599; |
||
3707 | $_620 = NULL; |
||
3708 | do { |
||
3709 | $res_601 = $result; |
||
3710 | $pos_601 = $this->pos; |
||
3711 | if (( $subres = $this->literal( 'else' ) ) !== FALSE) { |
||
3712 | $result["text"] .= $subres; |
||
3713 | $_620 = TRUE; break; |
||
3714 | } |
||
3715 | $result = $res_601; |
||
3716 | $this->pos = $pos_601; |
||
3717 | $_618 = NULL; |
||
3718 | do { |
||
3719 | $res_603 = $result; |
||
3720 | $pos_603 = $this->pos; |
||
3721 | if (( $subres = $this->literal( 'require' ) ) !== FALSE) { |
||
3722 | $result["text"] .= $subres; |
||
3723 | $_618 = TRUE; break; |
||
3724 | } |
||
3725 | $result = $res_603; |
||
3726 | $this->pos = $pos_603; |
||
3727 | $_616 = NULL; |
||
3728 | do { |
||
3729 | $res_605 = $result; |
||
3730 | $pos_605 = $this->pos; |
||
3731 | if (( $subres = $this->literal( 'cached' ) ) !== FALSE) { |
||
3732 | $result["text"] .= $subres; |
||
3733 | $_616 = TRUE; break; |
||
3734 | } |
||
3735 | $result = $res_605; |
||
3736 | $this->pos = $pos_605; |
||
3737 | $_614 = NULL; |
||
3738 | do { |
||
3739 | $res_607 = $result; |
||
3740 | $pos_607 = $this->pos; |
||
3741 | if (( $subres = $this->literal( 'uncached' ) ) !== FALSE) { |
||
3742 | $result["text"] .= $subres; |
||
3743 | $_614 = TRUE; break; |
||
3744 | } |
||
3745 | $result = $res_607; |
||
3746 | $this->pos = $pos_607; |
||
3747 | $_612 = NULL; |
||
3748 | do { |
||
3749 | $res_609 = $result; |
||
3750 | $pos_609 = $this->pos; |
||
3751 | if (( $subres = $this->literal( 'cacheblock' ) ) !== FALSE) { |
||
3752 | $result["text"] .= $subres; |
||
3753 | $_612 = TRUE; break; |
||
3754 | } |
||
3755 | $result = $res_609; |
||
3756 | $this->pos = $pos_609; |
||
3757 | if (( $subres = $this->literal( 'include' ) ) !== FALSE) { |
||
3758 | $result["text"] .= $subres; |
||
3759 | $_612 = TRUE; break; |
||
3760 | } |
||
3761 | $result = $res_609; |
||
3762 | $this->pos = $pos_609; |
||
3763 | $_612 = FALSE; break; |
||
3764 | } |
||
3765 | while(0); |
||
3766 | if( $_612 === TRUE ) { $_614 = TRUE; break; } |
||
3767 | $result = $res_607; |
||
3768 | $this->pos = $pos_607; |
||
3769 | $_614 = FALSE; break; |
||
3770 | } |
||
3771 | while(0); |
||
3772 | if( $_614 === TRUE ) { $_616 = TRUE; break; } |
||
3773 | $result = $res_605; |
||
3774 | $this->pos = $pos_605; |
||
3775 | $_616 = FALSE; break; |
||
3776 | } |
||
3777 | while(0); |
||
3778 | if( $_616 === TRUE ) { $_618 = TRUE; break; } |
||
3779 | $result = $res_603; |
||
3780 | $this->pos = $pos_603; |
||
3781 | $_618 = FALSE; break; |
||
3782 | } |
||
3783 | while(0); |
||
3784 | if( $_618 === TRUE ) { $_620 = TRUE; break; } |
||
3785 | $result = $res_601; |
||
3786 | $this->pos = $pos_601; |
||
3787 | $_620 = FALSE; break; |
||
3788 | } |
||
3789 | while(0); |
||
3790 | if( $_620 === TRUE ) { $_622 = TRUE; break; } |
||
3791 | $result = $res_599; |
||
3792 | $this->pos = $pos_599; |
||
3793 | $_622 = FALSE; break; |
||
3794 | } |
||
3795 | while(0); |
||
3796 | if( $_622 === TRUE ) { $_624 = TRUE; break; } |
||
3797 | $result = $res_597; |
||
3798 | $this->pos = $pos_597; |
||
3799 | $_624 = FALSE; break; |
||
3800 | } |
||
3801 | while(0); |
||
3802 | if( $_624 === FALSE) { $_626 = FALSE; break; } |
||
3803 | $_626 = TRUE; break; |
||
3804 | } |
||
3805 | while(0); |
||
3806 | if( $_626 === FALSE) { $_629 = FALSE; break; } |
||
3807 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3808 | else { $_629 = FALSE; break; } |
||
3809 | $_629 = TRUE; break; |
||
3810 | } |
||
3811 | while(0); |
||
3812 | if( $_629 === TRUE ) { $_631 = TRUE; break; } |
||
3813 | $result = $res_595; |
||
3814 | $this->pos = $pos_595; |
||
3815 | $_631 = FALSE; break; |
||
3816 | } |
||
3817 | while(0); |
||
3818 | if( $_631 === TRUE ) { return $this->finalise($result); } |
||
3819 | if( $_631 === FALSE) { return FALSE; } |
||
3820 | } |
||
3821 | |||
3822 | |||
3823 | /* ClosedBlock: '<%' < !NotBlockTag BlockName:Word ( [ :BlockArguments ] )? > Zap:'%>' Template:$TemplateMatcher? |
||
3824 | '<%' < 'end_' '$BlockName' > '%>' */ |
||
3825 | protected $match_ClosedBlock_typestack = array('ClosedBlock'); |
||
3826 | function match_ClosedBlock ($stack = array()) { |
||
3827 | $matchrule = "ClosedBlock"; $result = $this->construct($matchrule, $matchrule, null); |
||
3828 | $_651 = NULL; |
||
3829 | do { |
||
3830 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3831 | else { $_651 = FALSE; break; } |
||
3832 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3833 | $res_635 = $result; |
||
3834 | $pos_635 = $this->pos; |
||
3835 | $matcher = 'match_'.'NotBlockTag'; $key = $matcher; $pos = $this->pos; |
||
3836 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3837 | if ($subres !== FALSE) { |
||
3838 | $this->store( $result, $subres ); |
||
3839 | $result = $res_635; |
||
3840 | $this->pos = $pos_635; |
||
3841 | $_651 = FALSE; break; |
||
3842 | } |
||
3843 | else { |
||
3844 | $result = $res_635; |
||
3845 | $this->pos = $pos_635; |
||
3846 | } |
||
3847 | $matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
||
3848 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3849 | if ($subres !== FALSE) { |
||
3850 | $this->store( $result, $subres, "BlockName" ); |
||
3851 | } |
||
3852 | else { $_651 = FALSE; break; } |
||
3853 | $res_641 = $result; |
||
3854 | $pos_641 = $this->pos; |
||
3855 | $_640 = NULL; |
||
3856 | do { |
||
3857 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3858 | else { $_640 = FALSE; break; } |
||
3859 | $matcher = 'match_'.'BlockArguments'; $key = $matcher; $pos = $this->pos; |
||
3860 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3861 | if ($subres !== FALSE) { |
||
3862 | $this->store( $result, $subres, "BlockArguments" ); |
||
3863 | } |
||
3864 | else { $_640 = FALSE; break; } |
||
3865 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3866 | else { $_640 = FALSE; break; } |
||
3867 | $_640 = TRUE; break; |
||
3868 | } |
||
3869 | while(0); |
||
3870 | if( $_640 === FALSE) { |
||
3871 | $result = $res_641; |
||
3872 | $this->pos = $pos_641; |
||
3873 | unset( $res_641 ); |
||
3874 | unset( $pos_641 ); |
||
3875 | } |
||
3876 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3877 | $stack[] = $result; $result = $this->construct( $matchrule, "Zap" ); |
||
3878 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { |
||
3879 | $result["text"] .= $subres; |
||
3880 | $subres = $result; $result = array_pop($stack); |
||
3881 | $this->store( $result, $subres, 'Zap' ); |
||
3882 | } |
||
3883 | else { |
||
3884 | $result = array_pop($stack); |
||
3885 | $_651 = FALSE; break; |
||
3886 | } |
||
3887 | $res_644 = $result; |
||
3888 | $pos_644 = $this->pos; |
||
3889 | $matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $key = $matcher; $pos = $this->pos; |
||
3890 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3891 | if ($subres !== FALSE) { |
||
3892 | $this->store( $result, $subres, "Template" ); |
||
3893 | } |
||
3894 | else { |
||
3895 | $result = $res_644; |
||
3896 | $this->pos = $pos_644; |
||
3897 | unset( $res_644 ); |
||
3898 | unset( $pos_644 ); |
||
3899 | } |
||
3900 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3901 | else { $_651 = FALSE; break; } |
||
3902 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3903 | if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3904 | else { $_651 = FALSE; break; } |
||
3905 | if (( $subres = $this->literal( ''.$this->expression($result, $stack, 'BlockName').'' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3906 | else { $_651 = FALSE; break; } |
||
3907 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3908 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3909 | else { $_651 = FALSE; break; } |
||
3910 | $_651 = TRUE; break; |
||
3911 | } |
||
3912 | while(0); |
||
3913 | if( $_651 === TRUE ) { return $this->finalise($result); } |
||
3914 | if( $_651 === FALSE) { return FALSE; } |
||
3915 | } |
||
3916 | |||
3917 | |||
3918 | |||
3919 | |||
3920 | /** |
||
3921 | * As mentioned in the parser comment, block handling is kept fairly generic for extensibility. The match rule |
||
3922 | * builds up two important elements in the match result array: |
||
3923 | * 'ArgumentCount' - how many arguments were passed in the opening tag |
||
3924 | * 'Arguments' an array of the Argument match rule result arrays |
||
3925 | * |
||
3926 | * Once a block has successfully been matched against, it will then look for the actual handler, which should |
||
3927 | * be on this class (either defined or extended on) as ClosedBlock_Handler_Name(&$res), where Name is the |
||
3928 | * tag name, first letter captialized (i.e Control, Loop, With, etc). |
||
3929 | * |
||
3930 | * This function will be called with the match rule result array as it's first argument. It should return |
||
3931 | * the php result of this block as it's return value, or throw an error if incorrect arguments were passed. |
||
3932 | */ |
||
3933 | |||
3934 | function ClosedBlock__construct(&$res) |
||
3935 | { |
||
3936 | $res['ArgumentCount'] = 0; |
||
3937 | } |
||
3938 | |||
3939 | function ClosedBlock_BlockArguments(&$res, $sub) |
||
3940 | { |
||
3941 | if (isset($sub['Argument']['ArgumentMode'])) { |
||
3942 | $res['Arguments'] = [$sub['Argument']]; |
||
3943 | $res['ArgumentCount'] = 1; |
||
3944 | } else { |
||
3945 | $res['Arguments'] = $sub['Argument']; |
||
3946 | $res['ArgumentCount'] = count($res['Arguments']); |
||
3947 | } |
||
3948 | } |
||
3949 | |||
3950 | function ClosedBlock__finalise(&$res) |
||
3951 | { |
||
3952 | $blockname = $res['BlockName']['text']; |
||
3953 | |||
3954 | $method = 'ClosedBlock_Handle_'.$blockname; |
||
3955 | if (method_exists($this, $method)) { |
||
3956 | $res['php'] = $this->$method($res); |
||
3957 | } elseif (isset($this->closedBlocks[$blockname])) { |
||
3958 | $res['php'] = call_user_func($this->closedBlocks[$blockname], $res); |
||
3959 | } else { |
||
3960 | throw new SSTemplateParseException('Unknown closed block "'.$blockname.'" encountered. Perhaps you are ' . |
||
3961 | 'not supposed to close this block, or have mis-spelled it?', $this); |
||
3962 | } |
||
3963 | } |
||
3964 | |||
3965 | /** |
||
3966 | * This is an example of a block handler function. This one handles the loop tag. |
||
3967 | */ |
||
3968 | function ClosedBlock_Handle_Loop(&$res) |
||
3994 | } |
||
3995 | |||
3996 | /** |
||
3997 | * The closed block handler for with blocks |
||
3998 | */ |
||
3999 | function ClosedBlock_Handle_With(&$res) |
||
4000 | { |
||
4001 | if ($res['ArgumentCount'] != 1) { |
||
4002 | throw new SSTemplateParseException('Either no or too many arguments in with block. Must be one ' . |
||
4003 | 'argument only.', $this); |
||
4004 | } |
||
4005 | |||
4006 | $arg = $res['Arguments'][0]; |
||
4007 | if ($arg['ArgumentMode'] == 'string') { |
||
4008 | throw new SSTemplateParseException('Control block cant take string as argument.', $this); |
||
4009 | } |
||
4010 | |||
4011 | $on = str_replace('$$FINAL', 'obj', ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']); |
||
4012 | return |
||
4013 | $on . '; $scope->pushScope();' . PHP_EOL . |
||
4014 | $res['Template']['php'] . PHP_EOL . |
||
4015 | '; $scope->popScope(); '; |
||
4016 | } |
||
4017 | |||
4018 | /* OpenBlock: '<%' < !NotBlockTag BlockName:Word ( [ :BlockArguments ] )? > '%>' */ |
||
4019 | protected $match_OpenBlock_typestack = array('OpenBlock'); |
||
4020 | function match_OpenBlock ($stack = array()) { |
||
4021 | $matchrule = "OpenBlock"; $result = $this->construct($matchrule, $matchrule, null); |
||
4022 | $_664 = NULL; |
||
4023 | do { |
||
4024 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4025 | else { $_664 = FALSE; break; } |
||
4026 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4027 | $res_655 = $result; |
||
4028 | $pos_655 = $this->pos; |
||
4029 | $matcher = 'match_'.'NotBlockTag'; $key = $matcher; $pos = $this->pos; |
||
4030 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4031 | if ($subres !== FALSE) { |
||
4032 | $this->store( $result, $subres ); |
||
4033 | $result = $res_655; |
||
4034 | $this->pos = $pos_655; |
||
4035 | $_664 = FALSE; break; |
||
4036 | } |
||
4037 | else { |
||
4038 | $result = $res_655; |
||
4039 | $this->pos = $pos_655; |
||
4040 | } |
||
4041 | $matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
||
4042 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4043 | if ($subres !== FALSE) { |
||
4044 | $this->store( $result, $subres, "BlockName" ); |
||
4045 | } |
||
4046 | else { $_664 = FALSE; break; } |
||
4047 | $res_661 = $result; |
||
4048 | $pos_661 = $this->pos; |
||
4049 | $_660 = NULL; |
||
4050 | do { |
||
4051 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4052 | else { $_660 = FALSE; break; } |
||
4053 | $matcher = 'match_'.'BlockArguments'; $key = $matcher; $pos = $this->pos; |
||
4054 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4055 | if ($subres !== FALSE) { |
||
4056 | $this->store( $result, $subres, "BlockArguments" ); |
||
4057 | } |
||
4058 | else { $_660 = FALSE; break; } |
||
4059 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4060 | else { $_660 = FALSE; break; } |
||
4061 | $_660 = TRUE; break; |
||
4062 | } |
||
4063 | while(0); |
||
4064 | if( $_660 === FALSE) { |
||
4065 | $result = $res_661; |
||
4066 | $this->pos = $pos_661; |
||
4067 | unset( $res_661 ); |
||
4068 | unset( $pos_661 ); |
||
4069 | } |
||
4070 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4071 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4072 | else { $_664 = FALSE; break; } |
||
4073 | $_664 = TRUE; break; |
||
4074 | } |
||
4075 | while(0); |
||
4076 | if( $_664 === TRUE ) { return $this->finalise($result); } |
||
4077 | if( $_664 === FALSE) { return FALSE; } |
||
4078 | } |
||
4079 | |||
4080 | |||
4081 | |||
4082 | function OpenBlock__construct(&$res) |
||
4083 | { |
||
4084 | $res['ArgumentCount'] = 0; |
||
4085 | } |
||
4086 | |||
4087 | function OpenBlock_BlockArguments(&$res, $sub) |
||
4088 | { |
||
4089 | if (isset($sub['Argument']['ArgumentMode'])) { |
||
4090 | $res['Arguments'] = [$sub['Argument']]; |
||
4091 | $res['ArgumentCount'] = 1; |
||
4092 | } else { |
||
4093 | $res['Arguments'] = $sub['Argument']; |
||
4094 | $res['ArgumentCount'] = count($res['Arguments']); |
||
4095 | } |
||
4096 | } |
||
4097 | |||
4098 | function OpenBlock__finalise(&$res) |
||
4099 | { |
||
4100 | $blockname = $res['BlockName']['text']; |
||
4101 | |||
4102 | $method = 'OpenBlock_Handle_'.$blockname; |
||
4103 | if (method_exists($this, $method)) { |
||
4104 | $res['php'] = $this->$method($res); |
||
4105 | } elseif (isset($this->openBlocks[$blockname])) { |
||
4106 | $res['php'] = call_user_func($this->openBlocks[$blockname], $res); |
||
4107 | } else { |
||
4108 | throw new SSTemplateParseException('Unknown open block "'.$blockname.'" encountered. Perhaps you missed ' . |
||
4109 | ' the closing tag or have mis-spelled it?', $this); |
||
4110 | } |
||
4111 | } |
||
4112 | |||
4113 | /** |
||
4114 | * This is an open block handler, for the <% debug %> utility tag |
||
4115 | */ |
||
4116 | function OpenBlock_Handle_Debug(&$res) |
||
4117 | { |
||
4118 | if ($res['ArgumentCount'] == 0) { |
||
4119 | return '$scope->debug();'; |
||
4120 | } elseif ($res['ArgumentCount'] == 1) { |
||
4121 | $arg = $res['Arguments'][0]; |
||
4122 | |||
4123 | if ($arg['ArgumentMode'] == 'string') { |
||
4124 | return 'Debug::show('.$arg['php'].');'; |
||
4125 | } |
||
4126 | |||
4127 | $php = ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']; |
||
4128 | return '$val .= Debug::show('.str_replace('FINALGET!', 'cachedCall', $php).');'; |
||
4129 | } else { |
||
4130 | throw new SSTemplateParseException('Debug takes 0 or 1 argument only.', $this); |
||
4131 | } |
||
4132 | } |
||
4133 | |||
4134 | /** |
||
4135 | * This is an open block handler, for the <% base_tag %> tag |
||
4136 | */ |
||
4137 | function OpenBlock_Handle_Base_tag(&$res) |
||
4138 | { |
||
4139 | if ($res['ArgumentCount'] != 0) { |
||
4140 | throw new SSTemplateParseException('Base_tag takes no arguments', $this); |
||
4141 | } |
||
4142 | return '$val .= \\SilverStripe\\View\\SSViewer::get_base_tag($val);'; |
||
4143 | } |
||
4144 | |||
4145 | /** |
||
4146 | * This is an open block handler, for the <% current_page %> tag |
||
4147 | */ |
||
4148 | function OpenBlock_Handle_Current_page(&$res) |
||
4154 | } |
||
4155 | |||
4156 | /* MismatchedEndBlock: '<%' < 'end_' :Word > '%>' */ |
||
4157 | protected $match_MismatchedEndBlock_typestack = array('MismatchedEndBlock'); |
||
4158 | function match_MismatchedEndBlock ($stack = array()) { |
||
4159 | $matchrule = "MismatchedEndBlock"; $result = $this->construct($matchrule, $matchrule, null); |
||
4160 | $_672 = NULL; |
||
4161 | do { |
||
4162 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4163 | else { $_672 = FALSE; break; } |
||
4164 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4165 | if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4166 | else { $_672 = FALSE; break; } |
||
4167 | $matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
||
4168 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4169 | if ($subres !== FALSE) { |
||
4170 | $this->store( $result, $subres, "Word" ); |
||
4171 | } |
||
4172 | else { $_672 = FALSE; break; } |
||
4173 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4174 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4175 | else { $_672 = FALSE; break; } |
||
4176 | $_672 = TRUE; break; |
||
4177 | } |
||
4178 | while(0); |
||
4179 | if( $_672 === TRUE ) { return $this->finalise($result); } |
||
4180 | if( $_672 === FALSE) { return FALSE; } |
||
4181 | } |
||
4182 | |||
4183 | |||
4184 | |||
4185 | function MismatchedEndBlock__finalise(&$res) |
||
4186 | { |
||
4187 | $blockname = $res['Word']['text']; |
||
4188 | throw new SSTemplateParseException('Unexpected close tag end_' . $blockname . |
||
4189 | ' encountered. Perhaps you have mis-nested blocks, or have mis-spelled a tag?', $this); |
||
4190 | } |
||
4191 | |||
4192 | /* MalformedOpenTag: '<%' < !NotBlockTag Tag:Word !( ( [ :BlockArguments ] )? > '%>' ) */ |
||
4193 | protected $match_MalformedOpenTag_typestack = array('MalformedOpenTag'); |
||
4194 | function match_MalformedOpenTag ($stack = array()) { |
||
4195 | $matchrule = "MalformedOpenTag"; $result = $this->construct($matchrule, $matchrule, null); |
||
4196 | $_687 = NULL; |
||
4197 | do { |
||
4198 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4199 | else { $_687 = FALSE; break; } |
||
4200 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4201 | $res_676 = $result; |
||
4202 | $pos_676 = $this->pos; |
||
4203 | $matcher = 'match_'.'NotBlockTag'; $key = $matcher; $pos = $this->pos; |
||
4204 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4205 | if ($subres !== FALSE) { |
||
4206 | $this->store( $result, $subres ); |
||
4207 | $result = $res_676; |
||
4208 | $this->pos = $pos_676; |
||
4209 | $_687 = FALSE; break; |
||
4210 | } |
||
4211 | else { |
||
4212 | $result = $res_676; |
||
4213 | $this->pos = $pos_676; |
||
4214 | } |
||
4215 | $matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
||
4216 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4217 | if ($subres !== FALSE) { |
||
4218 | $this->store( $result, $subres, "Tag" ); |
||
4219 | } |
||
4220 | else { $_687 = FALSE; break; } |
||
4221 | $res_686 = $result; |
||
4222 | $pos_686 = $this->pos; |
||
4223 | $_685 = NULL; |
||
4224 | do { |
||
4225 | $res_682 = $result; |
||
4226 | $pos_682 = $this->pos; |
||
4227 | $_681 = NULL; |
||
4228 | do { |
||
4229 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4230 | else { $_681 = FALSE; break; } |
||
4231 | $matcher = 'match_'.'BlockArguments'; $key = $matcher; $pos = $this->pos; |
||
4232 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4233 | if ($subres !== FALSE) { |
||
4234 | $this->store( $result, $subres, "BlockArguments" ); |
||
4235 | } |
||
4236 | else { $_681 = FALSE; break; } |
||
4237 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4238 | else { $_681 = FALSE; break; } |
||
4239 | $_681 = TRUE; break; |
||
4240 | } |
||
4241 | while(0); |
||
4242 | if( $_681 === FALSE) { |
||
4243 | $result = $res_682; |
||
4244 | $this->pos = $pos_682; |
||
4245 | unset( $res_682 ); |
||
4246 | unset( $pos_682 ); |
||
4247 | } |
||
4248 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4249 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4250 | else { $_685 = FALSE; break; } |
||
4251 | $_685 = TRUE; break; |
||
4252 | } |
||
4253 | while(0); |
||
4254 | if( $_685 === TRUE ) { |
||
4255 | $result = $res_686; |
||
4256 | $this->pos = $pos_686; |
||
4257 | $_687 = FALSE; break; |
||
4258 | } |
||
4259 | if( $_685 === FALSE) { |
||
4260 | $result = $res_686; |
||
4261 | $this->pos = $pos_686; |
||
4262 | } |
||
4263 | $_687 = TRUE; break; |
||
4264 | } |
||
4265 | while(0); |
||
4266 | if( $_687 === TRUE ) { return $this->finalise($result); } |
||
4267 | if( $_687 === FALSE) { return FALSE; } |
||
4268 | } |
||
4269 | |||
4270 | |||
4271 | |||
4272 | function MalformedOpenTag__finalise(&$res) |
||
4273 | { |
||
4274 | $tag = $res['Tag']['text']; |
||
4275 | throw new SSTemplateParseException("Malformed opening block tag $tag. Perhaps you have tried to use operators?", $this); |
||
4276 | } |
||
4277 | |||
4278 | /* MalformedCloseTag: '<%' < Tag:('end_' :Word ) !( > '%>' ) */ |
||
4279 | protected $match_MalformedCloseTag_typestack = array('MalformedCloseTag'); |
||
4280 | function match_MalformedCloseTag ($stack = array()) { |
||
4281 | $matchrule = "MalformedCloseTag"; $result = $this->construct($matchrule, $matchrule, null); |
||
4282 | $_699 = NULL; |
||
4283 | do { |
||
4284 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4285 | else { $_699 = FALSE; break; } |
||
4286 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4287 | $stack[] = $result; $result = $this->construct( $matchrule, "Tag" ); |
||
4288 | $_693 = NULL; |
||
4289 | do { |
||
4290 | if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4291 | else { $_693 = FALSE; break; } |
||
4292 | $matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
||
4293 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4294 | if ($subres !== FALSE) { |
||
4295 | $this->store( $result, $subres, "Word" ); |
||
4296 | } |
||
4297 | else { $_693 = FALSE; break; } |
||
4298 | $_693 = TRUE; break; |
||
4299 | } |
||
4300 | while(0); |
||
4301 | if( $_693 === TRUE ) { |
||
4302 | $subres = $result; $result = array_pop($stack); |
||
4303 | $this->store( $result, $subres, 'Tag' ); |
||
4304 | } |
||
4305 | if( $_693 === FALSE) { |
||
4306 | $result = array_pop($stack); |
||
4307 | $_699 = FALSE; break; |
||
4308 | } |
||
4309 | $res_698 = $result; |
||
4310 | $pos_698 = $this->pos; |
||
4311 | $_697 = NULL; |
||
4312 | do { |
||
4313 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4314 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4315 | else { $_697 = FALSE; break; } |
||
4316 | $_697 = TRUE; break; |
||
4317 | } |
||
4318 | while(0); |
||
4319 | if( $_697 === TRUE ) { |
||
4320 | $result = $res_698; |
||
4321 | $this->pos = $pos_698; |
||
4322 | $_699 = FALSE; break; |
||
4323 | } |
||
4324 | if( $_697 === FALSE) { |
||
4325 | $result = $res_698; |
||
4326 | $this->pos = $pos_698; |
||
4327 | } |
||
4328 | $_699 = TRUE; break; |
||
4329 | } |
||
4330 | while(0); |
||
4331 | if( $_699 === TRUE ) { return $this->finalise($result); } |
||
4332 | if( $_699 === FALSE) { return FALSE; } |
||
4333 | } |
||
4334 | |||
4335 | |||
4336 | |||
4337 | function MalformedCloseTag__finalise(&$res) |
||
4342 | } |
||
4343 | |||
4344 | /* MalformedBlock: MalformedOpenTag | MalformedCloseTag */ |
||
4345 | protected $match_MalformedBlock_typestack = array('MalformedBlock'); |
||
4346 | function match_MalformedBlock ($stack = array()) { |
||
4347 | $matchrule = "MalformedBlock"; $result = $this->construct($matchrule, $matchrule, null); |
||
4348 | $_704 = NULL; |
||
4349 | do { |
||
4350 | $res_701 = $result; |
||
4351 | $pos_701 = $this->pos; |
||
4352 | $matcher = 'match_'.'MalformedOpenTag'; $key = $matcher; $pos = $this->pos; |
||
4353 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4354 | if ($subres !== FALSE) { |
||
4355 | $this->store( $result, $subres ); |
||
4356 | $_704 = TRUE; break; |
||
4357 | } |
||
4358 | $result = $res_701; |
||
4359 | $this->pos = $pos_701; |
||
4360 | $matcher = 'match_'.'MalformedCloseTag'; $key = $matcher; $pos = $this->pos; |
||
4361 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4362 | if ($subres !== FALSE) { |
||
4363 | $this->store( $result, $subres ); |
||
4364 | $_704 = TRUE; break; |
||
4365 | } |
||
4366 | $result = $res_701; |
||
4367 | $this->pos = $pos_701; |
||
4368 | $_704 = FALSE; break; |
||
4369 | } |
||
4370 | while(0); |
||
4371 | if( $_704 === TRUE ) { return $this->finalise($result); } |
||
4372 | if( $_704 === FALSE) { return FALSE; } |
||
4373 | } |
||
4374 | |||
4375 | |||
4376 | |||
4377 | |||
4378 | /* CommentWithContent: '<%--' ( !"--%>" /(?s)./ )+ '--%>' */ |
||
4379 | protected $match_CommentWithContent_typestack = array('CommentWithContent'); |
||
4380 | function match_CommentWithContent ($stack = array()) { |
||
4381 | $matchrule = "CommentWithContent"; $result = $this->construct($matchrule, $matchrule, null); |
||
4382 | $_712 = NULL; |
||
4383 | do { |
||
4384 | if (( $subres = $this->literal( '<%--' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4385 | else { $_712 = FALSE; break; } |
||
4386 | $count = 0; |
||
4387 | while (true) { |
||
4388 | $res_710 = $result; |
||
4389 | $pos_710 = $this->pos; |
||
4390 | $_709 = NULL; |
||
4391 | do { |
||
4392 | $res_707 = $result; |
||
4393 | $pos_707 = $this->pos; |
||
4394 | if (( $subres = $this->literal( '--%>' ) ) !== FALSE) { |
||
4395 | $result["text"] .= $subres; |
||
4396 | $result = $res_707; |
||
4397 | $this->pos = $pos_707; |
||
4398 | $_709 = FALSE; break; |
||
4399 | } |
||
4400 | else { |
||
4401 | $result = $res_707; |
||
4402 | $this->pos = $pos_707; |
||
4403 | } |
||
4404 | if (( $subres = $this->rx( '/(?s)./' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4405 | else { $_709 = FALSE; break; } |
||
4406 | $_709 = TRUE; break; |
||
4407 | } |
||
4408 | while(0); |
||
4409 | if( $_709 === FALSE) { |
||
4410 | $result = $res_710; |
||
4411 | $this->pos = $pos_710; |
||
4412 | unset( $res_710 ); |
||
4413 | unset( $pos_710 ); |
||
4414 | break; |
||
4415 | } |
||
4416 | $count += 1; |
||
4417 | } |
||
4418 | if ($count > 0) { } |
||
4419 | else { $_712 = FALSE; break; } |
||
4420 | if (( $subres = $this->literal( '--%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4421 | else { $_712 = FALSE; break; } |
||
4422 | $_712 = TRUE; break; |
||
4423 | } |
||
4424 | while(0); |
||
4425 | if( $_712 === TRUE ) { return $this->finalise($result); } |
||
4426 | if( $_712 === FALSE) { return FALSE; } |
||
4427 | } |
||
4428 | |||
4429 | |||
4430 | /* EmptyComment: '<%----%>' */ |
||
4431 | protected $match_EmptyComment_typestack = array('EmptyComment'); |
||
4432 | function match_EmptyComment ($stack = array()) { |
||
4433 | $matchrule = "EmptyComment"; $result = $this->construct($matchrule, $matchrule, null); |
||
4434 | if (( $subres = $this->literal( '<%----%>' ) ) !== FALSE) { |
||
4435 | $result["text"] .= $subres; |
||
4436 | return $this->finalise($result); |
||
4437 | } |
||
4438 | else { return FALSE; } |
||
4439 | } |
||
4440 | |||
4441 | |||
4442 | /* Comment: :EmptyComment | :CommentWithContent */ |
||
4443 | protected $match_Comment_typestack = array('Comment'); |
||
4444 | function match_Comment ($stack = array()) { |
||
4471 | } |
||
4472 | |||
4473 | |||
4474 | |||
4475 | function Comment__construct(&$res) |
||
4476 | { |
||
4477 | $res['php'] = ''; |
||
4478 | } |
||
4479 | |||
4480 | /* TopTemplate: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock | |
||
4481 | OpenBlock | MalformedBlock | MismatchedEndBlock | MalformedBracketInjection | Injection | Text)+ */ |
||
4482 | protected $match_TopTemplate_typestack = array('TopTemplate','Template'); |
||
4483 | function match_TopTemplate ($stack = array()) { |
||
4484 | $matchrule = "TopTemplate"; $result = $this->construct($matchrule, $matchrule, array('TemplateMatcher' => 'Template')); |
||
4485 | $count = 0; |
||
4486 | while (true) { |
||
4487 | $res_778 = $result; |
||
4488 | $pos_778 = $this->pos; |
||
4489 | $_777 = NULL; |
||
4490 | do { |
||
4491 | $_775 = NULL; |
||
4492 | do { |
||
4493 | $res_720 = $result; |
||
4494 | $pos_720 = $this->pos; |
||
4495 | $matcher = 'match_'.'Comment'; $key = $matcher; $pos = $this->pos; |
||
4496 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4497 | if ($subres !== FALSE) { |
||
4498 | $this->store( $result, $subres ); |
||
4499 | $_775 = TRUE; break; |
||
4500 | } |
||
4501 | $result = $res_720; |
||
4502 | $this->pos = $pos_720; |
||
4503 | $_773 = NULL; |
||
4504 | do { |
||
4505 | $res_722 = $result; |
||
4506 | $pos_722 = $this->pos; |
||
4507 | $matcher = 'match_'.'Translate'; $key = $matcher; $pos = $this->pos; |
||
4508 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4509 | if ($subres !== FALSE) { |
||
4510 | $this->store( $result, $subres ); |
||
4511 | $_773 = TRUE; break; |
||
4512 | } |
||
4513 | $result = $res_722; |
||
4514 | $this->pos = $pos_722; |
||
4515 | $_771 = NULL; |
||
4516 | do { |
||
4517 | $res_724 = $result; |
||
4518 | $pos_724 = $this->pos; |
||
4519 | $matcher = 'match_'.'If'; $key = $matcher; $pos = $this->pos; |
||
4520 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4521 | if ($subres !== FALSE) { |
||
4522 | $this->store( $result, $subres ); |
||
4523 | $_771 = TRUE; break; |
||
4524 | } |
||
4525 | $result = $res_724; |
||
4526 | $this->pos = $pos_724; |
||
4527 | $_769 = NULL; |
||
4528 | do { |
||
4529 | $res_726 = $result; |
||
4530 | $pos_726 = $this->pos; |
||
4531 | $matcher = 'match_'.'Require'; $key = $matcher; $pos = $this->pos; |
||
4532 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4533 | if ($subres !== FALSE) { |
||
4534 | $this->store( $result, $subres ); |
||
4535 | $_769 = TRUE; break; |
||
4536 | } |
||
4537 | $result = $res_726; |
||
4538 | $this->pos = $pos_726; |
||
4539 | $_767 = NULL; |
||
4540 | do { |
||
4541 | $res_728 = $result; |
||
4542 | $pos_728 = $this->pos; |
||
4543 | $matcher = 'match_'.'CacheBlock'; $key = $matcher; $pos = $this->pos; |
||
4544 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4545 | if ($subres !== FALSE) { |
||
4546 | $this->store( $result, $subres ); |
||
4547 | $_767 = TRUE; break; |
||
4548 | } |
||
4549 | $result = $res_728; |
||
4550 | $this->pos = $pos_728; |
||
4551 | $_765 = NULL; |
||
4552 | do { |
||
4553 | $res_730 = $result; |
||
4554 | $pos_730 = $this->pos; |
||
4555 | $matcher = 'match_'.'UncachedBlock'; $key = $matcher; $pos = $this->pos; |
||
4556 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4557 | if ($subres !== FALSE) { |
||
4558 | $this->store( $result, $subres ); |
||
4559 | $_765 = TRUE; break; |
||
4560 | } |
||
4561 | $result = $res_730; |
||
4562 | $this->pos = $pos_730; |
||
4563 | $_763 = NULL; |
||
4564 | do { |
||
4565 | $res_732 = $result; |
||
4566 | $pos_732 = $this->pos; |
||
4567 | $matcher = 'match_'.'OldI18NTag'; $key = $matcher; $pos = $this->pos; |
||
4568 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4569 | if ($subres !== FALSE) { |
||
4570 | $this->store( $result, $subres ); |
||
4571 | $_763 = TRUE; break; |
||
4572 | } |
||
4573 | $result = $res_732; |
||
4574 | $this->pos = $pos_732; |
||
4575 | $_761 = NULL; |
||
4576 | do { |
||
4577 | $res_734 = $result; |
||
4578 | $pos_734 = $this->pos; |
||
4579 | $matcher = 'match_'.'Include'; $key = $matcher; $pos = $this->pos; |
||
4580 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4581 | if ($subres !== FALSE) { |
||
4582 | $this->store( $result, $subres ); |
||
4583 | $_761 = TRUE; break; |
||
4584 | } |
||
4585 | $result = $res_734; |
||
4586 | $this->pos = $pos_734; |
||
4587 | $_759 = NULL; |
||
4588 | do { |
||
4589 | $res_736 = $result; |
||
4590 | $pos_736 = $this->pos; |
||
4591 | $matcher = 'match_'.'ClosedBlock'; $key = $matcher; $pos = $this->pos; |
||
4592 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4593 | if ($subres !== FALSE) { |
||
4594 | $this->store( $result, $subres ); |
||
4595 | $_759 = TRUE; break; |
||
4596 | } |
||
4597 | $result = $res_736; |
||
4598 | $this->pos = $pos_736; |
||
4599 | $_757 = NULL; |
||
4600 | do { |
||
4601 | $res_738 = $result; |
||
4602 | $pos_738 = $this->pos; |
||
4603 | $matcher = 'match_'.'OpenBlock'; $key = $matcher; $pos = $this->pos; |
||
4604 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4605 | if ($subres !== FALSE) { |
||
4606 | $this->store( $result, $subres ); |
||
4607 | $_757 = TRUE; break; |
||
4608 | } |
||
4609 | $result = $res_738; |
||
4610 | $this->pos = $pos_738; |
||
4611 | $_755 = NULL; |
||
4612 | do { |
||
4613 | $res_740 = $result; |
||
4614 | $pos_740 = $this->pos; |
||
4615 | $matcher = 'match_'.'MalformedBlock'; $key = $matcher; $pos = $this->pos; |
||
4616 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4617 | if ($subres !== FALSE) { |
||
4618 | $this->store( $result, $subres ); |
||
4619 | $_755 = TRUE; break; |
||
4620 | } |
||
4621 | $result = $res_740; |
||
4622 | $this->pos = $pos_740; |
||
4623 | $_753 = NULL; |
||
4624 | do { |
||
4625 | $res_742 = $result; |
||
4626 | $pos_742 = $this->pos; |
||
4627 | $matcher = 'match_'.'MismatchedEndBlock'; $key = $matcher; $pos = $this->pos; |
||
4628 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4629 | if ($subres !== FALSE) { |
||
4630 | $this->store( $result, $subres ); |
||
4631 | $_753 = TRUE; break; |
||
4632 | } |
||
4633 | $result = $res_742; |
||
4634 | $this->pos = $pos_742; |
||
4635 | $_751 = NULL; |
||
4636 | do { |
||
4637 | $res_744 = $result; |
||
4638 | $pos_744 = $this->pos; |
||
4639 | $matcher = 'match_'.'MalformedBracketInjection'; $key = $matcher; $pos = $this->pos; |
||
4640 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4641 | if ($subres !== FALSE) { |
||
4642 | $this->store( $result, $subres ); |
||
4643 | $_751 = TRUE; break; |
||
4644 | } |
||
4645 | $result = $res_744; |
||
4646 | $this->pos = $pos_744; |
||
4647 | $_749 = NULL; |
||
4648 | do { |
||
4649 | $res_746 = $result; |
||
4650 | $pos_746 = $this->pos; |
||
4651 | $matcher = 'match_'.'Injection'; $key = $matcher; $pos = $this->pos; |
||
4652 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4653 | if ($subres !== FALSE) { |
||
4654 | $this->store( $result, $subres ); |
||
4655 | $_749 = TRUE; break; |
||
4656 | } |
||
4657 | $result = $res_746; |
||
4658 | $this->pos = $pos_746; |
||
4659 | $matcher = 'match_'.'Text'; $key = $matcher; $pos = $this->pos; |
||
4660 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4661 | if ($subres !== FALSE) { |
||
4662 | $this->store( $result, $subres ); |
||
4663 | $_749 = TRUE; break; |
||
4664 | } |
||
4665 | $result = $res_746; |
||
4666 | $this->pos = $pos_746; |
||
4667 | $_749 = FALSE; break; |
||
4668 | } |
||
4669 | while(0); |
||
4670 | if( $_749 === TRUE ) { |
||
4671 | $_751 = TRUE; break; |
||
4672 | } |
||
4673 | $result = $res_744; |
||
4674 | $this->pos = $pos_744; |
||
4675 | $_751 = FALSE; break; |
||
4676 | } |
||
4677 | while(0); |
||
4678 | if( $_751 === TRUE ) { |
||
4679 | $_753 = TRUE; break; |
||
4680 | } |
||
4681 | $result = $res_742; |
||
4682 | $this->pos = $pos_742; |
||
4683 | $_753 = FALSE; break; |
||
4684 | } |
||
4685 | while(0); |
||
4686 | if( $_753 === TRUE ) { $_755 = TRUE; break; } |
||
4687 | $result = $res_740; |
||
4688 | $this->pos = $pos_740; |
||
4689 | $_755 = FALSE; break; |
||
4690 | } |
||
4691 | while(0); |
||
4692 | if( $_755 === TRUE ) { $_757 = TRUE; break; } |
||
4693 | $result = $res_738; |
||
4694 | $this->pos = $pos_738; |
||
4695 | $_757 = FALSE; break; |
||
4696 | } |
||
4697 | while(0); |
||
4698 | if( $_757 === TRUE ) { $_759 = TRUE; break; } |
||
4699 | $result = $res_736; |
||
4700 | $this->pos = $pos_736; |
||
4701 | $_759 = FALSE; break; |
||
4702 | } |
||
4703 | while(0); |
||
4704 | if( $_759 === TRUE ) { $_761 = TRUE; break; } |
||
4705 | $result = $res_734; |
||
4706 | $this->pos = $pos_734; |
||
4707 | $_761 = FALSE; break; |
||
4708 | } |
||
4709 | while(0); |
||
4710 | if( $_761 === TRUE ) { $_763 = TRUE; break; } |
||
4711 | $result = $res_732; |
||
4712 | $this->pos = $pos_732; |
||
4713 | $_763 = FALSE; break; |
||
4714 | } |
||
4715 | while(0); |
||
4716 | if( $_763 === TRUE ) { $_765 = TRUE; break; } |
||
4717 | $result = $res_730; |
||
4718 | $this->pos = $pos_730; |
||
4719 | $_765 = FALSE; break; |
||
4720 | } |
||
4721 | while(0); |
||
4722 | if( $_765 === TRUE ) { $_767 = TRUE; break; } |
||
4723 | $result = $res_728; |
||
4724 | $this->pos = $pos_728; |
||
4725 | $_767 = FALSE; break; |
||
4726 | } |
||
4727 | while(0); |
||
4728 | if( $_767 === TRUE ) { $_769 = TRUE; break; } |
||
4729 | $result = $res_726; |
||
4730 | $this->pos = $pos_726; |
||
4731 | $_769 = FALSE; break; |
||
4732 | } |
||
4733 | while(0); |
||
4734 | if( $_769 === TRUE ) { $_771 = TRUE; break; } |
||
4735 | $result = $res_724; |
||
4736 | $this->pos = $pos_724; |
||
4737 | $_771 = FALSE; break; |
||
4738 | } |
||
4739 | while(0); |
||
4740 | if( $_771 === TRUE ) { $_773 = TRUE; break; } |
||
4741 | $result = $res_722; |
||
4742 | $this->pos = $pos_722; |
||
4743 | $_773 = FALSE; break; |
||
4744 | } |
||
4745 | while(0); |
||
4746 | if( $_773 === TRUE ) { $_775 = TRUE; break; } |
||
4747 | $result = $res_720; |
||
4748 | $this->pos = $pos_720; |
||
4749 | $_775 = FALSE; break; |
||
4750 | } |
||
4751 | while(0); |
||
4752 | if( $_775 === FALSE) { $_777 = FALSE; break; } |
||
4753 | $_777 = TRUE; break; |
||
4754 | } |
||
4755 | while(0); |
||
4756 | if( $_777 === FALSE) { |
||
4757 | $result = $res_778; |
||
4758 | $this->pos = $pos_778; |
||
4759 | unset( $res_778 ); |
||
4760 | unset( $pos_778 ); |
||
4761 | break; |
||
4762 | } |
||
4763 | $count += 1; |
||
4764 | } |
||
4765 | if ($count > 0) { return $this->finalise($result); } |
||
4766 | else { return FALSE; } |
||
4767 | } |
||
4768 | |||
4769 | |||
4770 | |||
4771 | |||
4772 | /** |
||
4773 | * The TopTemplate also includes the opening stanza to start off the template |
||
4774 | */ |
||
4775 | function TopTemplate__construct(&$res) |
||
4776 | { |
||
4777 | $res['php'] = "<?php" . PHP_EOL; |
||
4778 | } |
||
4779 | |||
4780 | /* Text: ( |
||
4781 | / [^<${\\]+ / | |
||
4782 | / (\\.) / | |
||
4783 | '<' !'%' | |
||
4784 | '$' !(/[A-Za-z_]/) | |
||
4785 | '{' !'$' | |
||
4786 | '{$' !(/[A-Za-z_]/) |
||
4787 | )+ */ |
||
4788 | protected $match_Text_typestack = array('Text'); |
||
4789 | function match_Text ($stack = array()) { |
||
4790 | $matchrule = "Text"; $result = $this->construct($matchrule, $matchrule, null); |
||
4791 | $count = 0; |
||
4792 | while (true) { |
||
4793 | $res_817 = $result; |
||
4794 | $pos_817 = $this->pos; |
||
4795 | $_816 = NULL; |
||
4796 | do { |
||
4797 | $_814 = NULL; |
||
4798 | do { |
||
4799 | $res_779 = $result; |
||
4800 | $pos_779 = $this->pos; |
||
4801 | if (( $subres = $this->rx( '/ [^<${\\\\]+ /' ) ) !== FALSE) { |
||
4802 | $result["text"] .= $subres; |
||
4803 | $_814 = TRUE; break; |
||
4804 | } |
||
4805 | $result = $res_779; |
||
4806 | $this->pos = $pos_779; |
||
4807 | $_812 = NULL; |
||
4808 | do { |
||
4809 | $res_781 = $result; |
||
4810 | $pos_781 = $this->pos; |
||
4811 | if (( $subres = $this->rx( '/ (\\\\.) /' ) ) !== FALSE) { |
||
4812 | $result["text"] .= $subres; |
||
4813 | $_812 = TRUE; break; |
||
4814 | } |
||
4815 | $result = $res_781; |
||
4816 | $this->pos = $pos_781; |
||
4817 | $_810 = NULL; |
||
4818 | do { |
||
4819 | $res_783 = $result; |
||
4820 | $pos_783 = $this->pos; |
||
4821 | $_786 = NULL; |
||
4822 | do { |
||
4823 | if (substr($this->string,$this->pos,1) == '<') { |
||
4824 | $this->pos += 1; |
||
4825 | $result["text"] .= '<'; |
||
4826 | } |
||
4827 | else { $_786 = FALSE; break; } |
||
4828 | $res_785 = $result; |
||
4829 | $pos_785 = $this->pos; |
||
4830 | if (substr($this->string,$this->pos,1) == '%') { |
||
4831 | $this->pos += 1; |
||
4832 | $result["text"] .= '%'; |
||
4833 | $result = $res_785; |
||
4834 | $this->pos = $pos_785; |
||
4835 | $_786 = FALSE; break; |
||
4836 | } |
||
4837 | else { |
||
4838 | $result = $res_785; |
||
4839 | $this->pos = $pos_785; |
||
4840 | } |
||
4841 | $_786 = TRUE; break; |
||
4842 | } |
||
4843 | while(0); |
||
4844 | if( $_786 === TRUE ) { $_810 = TRUE; break; } |
||
4845 | $result = $res_783; |
||
4846 | $this->pos = $pos_783; |
||
4847 | $_808 = NULL; |
||
4848 | do { |
||
4849 | $res_788 = $result; |
||
4850 | $pos_788 = $this->pos; |
||
4851 | $_793 = NULL; |
||
4852 | do { |
||
4853 | if (substr($this->string,$this->pos,1) == '$') { |
||
4854 | $this->pos += 1; |
||
4855 | $result["text"] .= '$'; |
||
4856 | } |
||
4857 | else { $_793 = FALSE; break; } |
||
4858 | $res_792 = $result; |
||
4859 | $pos_792 = $this->pos; |
||
4860 | $_791 = NULL; |
||
4861 | do { |
||
4862 | if (( $subres = $this->rx( '/[A-Za-z_]/' ) ) !== FALSE) { |
||
4863 | $result["text"] .= $subres; |
||
4864 | } |
||
4865 | else { $_791 = FALSE; break; } |
||
4866 | $_791 = TRUE; break; |
||
4867 | } |
||
4868 | while(0); |
||
4869 | if( $_791 === TRUE ) { |
||
4870 | $result = $res_792; |
||
4871 | $this->pos = $pos_792; |
||
4872 | $_793 = FALSE; break; |
||
4873 | } |
||
4874 | if( $_791 === FALSE) { |
||
4875 | $result = $res_792; |
||
4876 | $this->pos = $pos_792; |
||
4877 | } |
||
4878 | $_793 = TRUE; break; |
||
4879 | } |
||
4880 | while(0); |
||
4881 | if( $_793 === TRUE ) { $_808 = TRUE; break; } |
||
4882 | $result = $res_788; |
||
4883 | $this->pos = $pos_788; |
||
4884 | $_806 = NULL; |
||
4885 | do { |
||
4886 | $res_795 = $result; |
||
4887 | $pos_795 = $this->pos; |
||
4888 | $_798 = NULL; |
||
4889 | do { |
||
4890 | if (substr($this->string,$this->pos,1) == '{') { |
||
4891 | $this->pos += 1; |
||
4892 | $result["text"] .= '{'; |
||
4893 | } |
||
4894 | else { $_798 = FALSE; break; } |
||
4895 | $res_797 = $result; |
||
4896 | $pos_797 = $this->pos; |
||
4897 | if (substr($this->string,$this->pos,1) == '$') { |
||
4898 | $this->pos += 1; |
||
4899 | $result["text"] .= '$'; |
||
4900 | $result = $res_797; |
||
4901 | $this->pos = $pos_797; |
||
4902 | $_798 = FALSE; break; |
||
4903 | } |
||
4904 | else { |
||
4905 | $result = $res_797; |
||
4906 | $this->pos = $pos_797; |
||
4907 | } |
||
4908 | $_798 = TRUE; break; |
||
4909 | } |
||
4910 | while(0); |
||
4911 | if( $_798 === TRUE ) { $_806 = TRUE; break; } |
||
4912 | $result = $res_795; |
||
4913 | $this->pos = $pos_795; |
||
4914 | $_804 = NULL; |
||
4915 | do { |
||
4916 | if (( $subres = $this->literal( '{$' ) ) !== FALSE) { |
||
4917 | $result["text"] .= $subres; |
||
4918 | } |
||
4919 | else { $_804 = FALSE; break; } |
||
4920 | $res_803 = $result; |
||
4921 | $pos_803 = $this->pos; |
||
4922 | $_802 = NULL; |
||
4923 | do { |
||
4924 | if (( $subres = $this->rx( '/[A-Za-z_]/' ) ) !== FALSE) { |
||
4925 | $result["text"] .= $subres; |
||
4926 | } |
||
4927 | else { $_802 = FALSE; break; } |
||
4928 | $_802 = TRUE; break; |
||
4929 | } |
||
4930 | while(0); |
||
4931 | if( $_802 === TRUE ) { |
||
4932 | $result = $res_803; |
||
4933 | $this->pos = $pos_803; |
||
4934 | $_804 = FALSE; break; |
||
4935 | } |
||
4936 | if( $_802 === FALSE) { |
||
4937 | $result = $res_803; |
||
4938 | $this->pos = $pos_803; |
||
4939 | } |
||
4940 | $_804 = TRUE; break; |
||
4941 | } |
||
4942 | while(0); |
||
4943 | if( $_804 === TRUE ) { $_806 = TRUE; break; } |
||
4944 | $result = $res_795; |
||
4945 | $this->pos = $pos_795; |
||
4946 | $_806 = FALSE; break; |
||
4947 | } |
||
4948 | while(0); |
||
4949 | if( $_806 === TRUE ) { $_808 = TRUE; break; } |
||
4950 | $result = $res_788; |
||
4951 | $this->pos = $pos_788; |
||
4952 | $_808 = FALSE; break; |
||
4953 | } |
||
4954 | while(0); |
||
4955 | if( $_808 === TRUE ) { $_810 = TRUE; break; } |
||
4956 | $result = $res_783; |
||
4957 | $this->pos = $pos_783; |
||
4958 | $_810 = FALSE; break; |
||
4959 | } |
||
4960 | while(0); |
||
4961 | if( $_810 === TRUE ) { $_812 = TRUE; break; } |
||
4962 | $result = $res_781; |
||
4963 | $this->pos = $pos_781; |
||
4964 | $_812 = FALSE; break; |
||
4965 | } |
||
4966 | while(0); |
||
4967 | if( $_812 === TRUE ) { $_814 = TRUE; break; } |
||
4968 | $result = $res_779; |
||
4969 | $this->pos = $pos_779; |
||
4970 | $_814 = FALSE; break; |
||
4971 | } |
||
4972 | while(0); |
||
4973 | if( $_814 === FALSE) { $_816 = FALSE; break; } |
||
4974 | $_816 = TRUE; break; |
||
4975 | } |
||
4976 | while(0); |
||
4977 | if( $_816 === FALSE) { |
||
4978 | $result = $res_817; |
||
4979 | $this->pos = $pos_817; |
||
4980 | unset( $res_817 ); |
||
4981 | unset( $pos_817 ); |
||
4982 | break; |
||
4983 | } |
||
4984 | $count += 1; |
||
4985 | } |
||
4986 | if ($count > 0) { return $this->finalise($result); } |
||
4987 | else { return FALSE; } |
||
4988 | } |
||
4989 | |||
4990 | |||
4991 | |||
4992 | |||
4993 | /** |
||
4994 | * We convert text |
||
4995 | */ |
||
4996 | function Text__finalise(&$res) |
||
4997 | { |
||
4998 | $text = $res['text']; |
||
4999 | |||
5000 | // Unescape any escaped characters in the text, then put back escapes for any single quotes and backslashes |
||
5001 | $text = stripslashes($text); |
||
5002 | $text = addcslashes($text, '\'\\'); |
||
5003 | |||
5004 | // TODO: This is pretty ugly & gets applied on all files not just html. I wonder if we can make this |
||
5005 | // non-dynamically calculated |
||
5006 | $code = <<<'EOC' |
||
5007 | (\SilverStripe\View\SSViewer::getRewriteHashLinksDefault() |
||
5008 | ? \SilverStripe\Core\Convert::raw2att( preg_replace("/^(\\/)+/", "/", $_SERVER['REQUEST_URI'] ) ) |
||
5009 | : "") |
||
5010 | EOC; |
||
5011 | // Because preg_replace replacement requires escaped slashes, addcslashes here |
||
5012 | $text = preg_replace( |
||
5013 | '/(<a[^>]+href *= *)"#/i', |
||
5014 | '\\1"\' . ' . addcslashes($code, '\\') . ' . \'#', |
||
5015 | $text |
||
5016 | ); |
||
5017 | |||
5018 | $res['php'] .= '$val .= \'' . $text . '\';' . PHP_EOL; |
||
5019 | } |
||
5020 | |||
5021 | /****************** |
||
5022 | * Here ends the parser itself. Below are utility methods to use the parser |
||
5023 | */ |
||
5024 | |||
5025 | /** |
||
5026 | * Compiles some passed template source code into the php code that will execute as per the template source. |
||
5027 | * |
||
5028 | * @throws SSTemplateParseException |
||
5029 | * @param string $string The source of the template |
||
5030 | * @param string $templateName The name of the template, normally the filename the template source was loaded from |
||
5031 | * @param bool $includeDebuggingComments True is debugging comments should be included in the output |
||
5032 | * @param bool $topTemplate True if this is a top template, false if it's just a template |
||
5033 | * @return mixed|string The php that, when executed (via include or exec) will behave as per the template source |
||
5034 | */ |
||
5035 | public function compileString($string, $templateName = "", $includeDebuggingComments = false, $topTemplate = true) |
||
5070 | } |
||
5071 | |||
5072 | /** |
||
5073 | * @param string $code |
||
5074 | * @param string $templateName |
||
5075 | * @return string $code |
||
5076 | */ |
||
5077 | protected function includeDebuggingComments($code, $templateName) |
||
5105 | } |
||
5106 | |||
5107 | /** |
||
5108 | * Compiles some file that contains template source code, and returns the php code that will execute as per that |
||
5109 | * source |
||
5110 | * |
||
5111 | * @static |
||
5112 | * @param $template - A file path that contains template source code |
||
5113 | * @return mixed|string - The php that, when executed (via include or exec) will behave as per the template source |
||
5114 | */ |
||
5115 | public function compileFile($template) |
||
5116 | { |
||
5117 | return $this->compileString(file_get_contents($template), $template); |
||
5118 | } |
||
5119 | } |
||
5120 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.