Total Complexity | 1124 |
Total Lines | 4892 |
Duplicated Lines | 0 % |
Changes | 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 | * array( |
||
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 = array(); |
||
73 | |||
74 | /** |
||
75 | * Stores the user-supplied open block extension rules in the form: |
||
76 | * array( |
||
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 = array(); |
||
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 = array(), $openBlocks = array()) |
||
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 = array(); |
||
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 = array(); |
||
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) |
||
159 | { |
||
160 | $this->validateExtensionBlock($name, $callable, 'Open block'); |
||
161 | $this->openBlocks[$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) |
||
172 | { |
||
173 | if (!is_string($name)) { |
||
174 | throw new InvalidArgumentException( |
||
175 | sprintf( |
||
176 | "Name argument for %s must be a string", |
||
177 | $type |
||
178 | ) |
||
179 | ); |
||
180 | } elseif (!is_callable($callable)) { |
||
181 | throw new InvalidArgumentException( |
||
182 | sprintf( |
||
183 | "Callable %s argument named '%s' is not callable", |
||
184 | $type, |
||
185 | $name |
||
186 | ) |
||
187 | ); |
||
188 | } |
||
189 | } |
||
190 | |||
191 | /* Template: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock | |
||
192 | OpenBlock | MalformedBlock | 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_50 = $result; |
||
199 | $pos_50 = $this->pos; |
||
200 | $_49 = NULL; |
||
201 | do { |
||
202 | $_47 = 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 | $_47 = TRUE; break; |
||
211 | } |
||
212 | $result = $res_0; |
||
213 | $this->pos = $pos_0; |
||
214 | $_45 = 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 | $_45 = TRUE; break; |
||
223 | } |
||
224 | $result = $res_2; |
||
225 | $this->pos = $pos_2; |
||
226 | $_43 = 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 | $_43 = TRUE; break; |
||
235 | } |
||
236 | $result = $res_4; |
||
237 | $this->pos = $pos_4; |
||
238 | $_41 = 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 | $_41 = TRUE; break; |
||
247 | } |
||
248 | $result = $res_6; |
||
249 | $this->pos = $pos_6; |
||
250 | $_39 = 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 | $_39 = TRUE; break; |
||
259 | } |
||
260 | $result = $res_8; |
||
261 | $this->pos = $pos_8; |
||
262 | $_37 = 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 | $_37 = TRUE; break; |
||
271 | } |
||
272 | $result = $res_10; |
||
273 | $this->pos = $pos_10; |
||
274 | $_35 = 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 | $_35 = TRUE; break; |
||
283 | } |
||
284 | $result = $res_12; |
||
285 | $this->pos = $pos_12; |
||
286 | $_33 = 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 | $_33 = TRUE; break; |
||
295 | } |
||
296 | $result = $res_14; |
||
297 | $this->pos = $pos_14; |
||
298 | $_31 = 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 | $_31 = TRUE; break; |
||
307 | } |
||
308 | $result = $res_16; |
||
309 | $this->pos = $pos_16; |
||
310 | $_29 = 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 | $_29 = TRUE; break; |
||
319 | } |
||
320 | $result = $res_18; |
||
321 | $this->pos = $pos_18; |
||
322 | $_27 = 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 | $_27 = TRUE; break; |
||
331 | } |
||
332 | $result = $res_20; |
||
333 | $this->pos = $pos_20; |
||
334 | $_25 = NULL; |
||
335 | do { |
||
336 | $res_22 = $result; |
||
337 | $pos_22 = $this->pos; |
||
338 | $matcher = 'match_'.'Injection'; $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 | $_25 = TRUE; break; |
||
343 | } |
||
344 | $result = $res_22; |
||
345 | $this->pos = $pos_22; |
||
346 | $matcher = 'match_'.'Text'; $key = $matcher; $pos = $this->pos; |
||
347 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
348 | if ($subres !== FALSE) { |
||
349 | $this->store( $result, $subres ); |
||
350 | $_25 = TRUE; break; |
||
351 | } |
||
352 | $result = $res_22; |
||
353 | $this->pos = $pos_22; |
||
354 | $_25 = FALSE; break; |
||
355 | } |
||
356 | while(0); |
||
357 | if( $_25 === TRUE ) { $_27 = TRUE; break; } |
||
358 | $result = $res_20; |
||
359 | $this->pos = $pos_20; |
||
360 | $_27 = FALSE; break; |
||
361 | } |
||
362 | while(0); |
||
363 | if( $_27 === TRUE ) { $_29 = TRUE; break; } |
||
364 | $result = $res_18; |
||
365 | $this->pos = $pos_18; |
||
366 | $_29 = FALSE; break; |
||
367 | } |
||
368 | while(0); |
||
369 | if( $_29 === TRUE ) { $_31 = TRUE; break; } |
||
370 | $result = $res_16; |
||
371 | $this->pos = $pos_16; |
||
372 | $_31 = FALSE; break; |
||
373 | } |
||
374 | while(0); |
||
375 | if( $_31 === TRUE ) { $_33 = TRUE; break; } |
||
376 | $result = $res_14; |
||
377 | $this->pos = $pos_14; |
||
378 | $_33 = FALSE; break; |
||
379 | } |
||
380 | while(0); |
||
381 | if( $_33 === TRUE ) { $_35 = TRUE; break; } |
||
382 | $result = $res_12; |
||
383 | $this->pos = $pos_12; |
||
384 | $_35 = FALSE; break; |
||
385 | } |
||
386 | while(0); |
||
387 | if( $_35 === TRUE ) { $_37 = TRUE; break; } |
||
388 | $result = $res_10; |
||
389 | $this->pos = $pos_10; |
||
390 | $_37 = FALSE; break; |
||
391 | } |
||
392 | while(0); |
||
393 | if( $_37 === TRUE ) { $_39 = TRUE; break; } |
||
394 | $result = $res_8; |
||
395 | $this->pos = $pos_8; |
||
396 | $_39 = FALSE; break; |
||
397 | } |
||
398 | while(0); |
||
399 | if( $_39 === TRUE ) { $_41 = TRUE; break; } |
||
400 | $result = $res_6; |
||
401 | $this->pos = $pos_6; |
||
402 | $_41 = FALSE; break; |
||
403 | } |
||
404 | while(0); |
||
405 | if( $_41 === TRUE ) { $_43 = TRUE; break; } |
||
406 | $result = $res_4; |
||
407 | $this->pos = $pos_4; |
||
408 | $_43 = FALSE; break; |
||
409 | } |
||
410 | while(0); |
||
411 | if( $_43 === TRUE ) { $_45 = TRUE; break; } |
||
412 | $result = $res_2; |
||
413 | $this->pos = $pos_2; |
||
414 | $_45 = FALSE; break; |
||
415 | } |
||
416 | while(0); |
||
417 | if( $_45 === TRUE ) { $_47 = TRUE; break; } |
||
418 | $result = $res_0; |
||
419 | $this->pos = $pos_0; |
||
420 | $_47 = FALSE; break; |
||
421 | } |
||
422 | while(0); |
||
423 | if( $_47 === FALSE) { $_49 = FALSE; break; } |
||
424 | $_49 = TRUE; break; |
||
425 | } |
||
426 | while(0); |
||
427 | if( $_49 === FALSE) { |
||
428 | $result = $res_50; |
||
429 | $this->pos = $pos_50; |
||
430 | unset( $res_50 ); |
||
431 | unset( $pos_50 ); |
||
432 | break; |
||
433 | } |
||
434 | $count += 1; |
||
435 | } |
||
436 | if ($count > 0) { return $this->finalise($result); } |
||
437 | else { return FALSE; } |
||
438 | } |
||
439 | |||
440 | |||
441 | |||
442 | function Template_STR(&$res, $sub) |
||
443 | { |
||
444 | $res['php'] .= $sub['php'] . PHP_EOL ; |
||
445 | } |
||
446 | |||
447 | /* Word: / [A-Za-z_] [A-Za-z0-9_]* / */ |
||
448 | protected $match_Word_typestack = array('Word'); |
||
449 | function match_Word ($stack = array()) { |
||
456 | } |
||
457 | |||
458 | |||
459 | /* NamespacedWord: / [A-Za-z_\/\\] [A-Za-z0-9_\/\\]* / */ |
||
460 | protected $match_NamespacedWord_typestack = array('NamespacedWord'); |
||
461 | function match_NamespacedWord ($stack = array()) { |
||
462 | $matchrule = "NamespacedWord"; $result = $this->construct($matchrule, $matchrule, null); |
||
463 | if (( $subres = $this->rx( '/ [A-Za-z_\/\\\\] [A-Za-z0-9_\/\\\\]* /' ) ) !== FALSE) { |
||
464 | $result["text"] .= $subres; |
||
465 | return $this->finalise($result); |
||
466 | } |
||
467 | else { return FALSE; } |
||
468 | } |
||
469 | |||
470 | |||
471 | /* Number: / [0-9]+ / */ |
||
472 | protected $match_Number_typestack = array('Number'); |
||
473 | function match_Number ($stack = array()) { |
||
474 | $matchrule = "Number"; $result = $this->construct($matchrule, $matchrule, null); |
||
475 | if (( $subres = $this->rx( '/ [0-9]+ /' ) ) !== FALSE) { |
||
476 | $result["text"] .= $subres; |
||
477 | return $this->finalise($result); |
||
478 | } |
||
479 | else { return FALSE; } |
||
480 | } |
||
481 | |||
482 | |||
483 | /* Value: / [A-Za-z0-9_]+ / */ |
||
484 | protected $match_Value_typestack = array('Value'); |
||
485 | function match_Value ($stack = array()) { |
||
486 | $matchrule = "Value"; $result = $this->construct($matchrule, $matchrule, null); |
||
487 | if (( $subres = $this->rx( '/ [A-Za-z0-9_]+ /' ) ) !== FALSE) { |
||
488 | $result["text"] .= $subres; |
||
489 | return $this->finalise($result); |
||
490 | } |
||
491 | else { return FALSE; } |
||
492 | } |
||
493 | |||
494 | |||
495 | /* CallArguments: :Argument ( < "," < :Argument )* */ |
||
496 | protected $match_CallArguments_typestack = array('CallArguments'); |
||
497 | function match_CallArguments ($stack = array()) { |
||
498 | $matchrule = "CallArguments"; $result = $this->construct($matchrule, $matchrule, null); |
||
499 | $_62 = NULL; |
||
500 | do { |
||
501 | $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
||
502 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
503 | if ($subres !== FALSE) { |
||
504 | $this->store( $result, $subres, "Argument" ); |
||
505 | } |
||
506 | else { $_62 = FALSE; break; } |
||
507 | while (true) { |
||
508 | $res_61 = $result; |
||
509 | $pos_61 = $this->pos; |
||
510 | $_60 = NULL; |
||
511 | do { |
||
512 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
513 | if (substr($this->string,$this->pos,1) == ',') { |
||
514 | $this->pos += 1; |
||
515 | $result["text"] .= ','; |
||
516 | } |
||
517 | else { $_60 = FALSE; break; } |
||
518 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
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 { $_60 = FALSE; break; } |
||
525 | $_60 = TRUE; break; |
||
526 | } |
||
527 | while(0); |
||
528 | if( $_60 === FALSE) { |
||
529 | $result = $res_61; |
||
530 | $this->pos = $pos_61; |
||
531 | unset( $res_61 ); |
||
532 | unset( $pos_61 ); |
||
533 | break; |
||
534 | } |
||
535 | } |
||
536 | $_62 = TRUE; break; |
||
537 | } |
||
538 | while(0); |
||
539 | if( $_62 === TRUE ) { return $this->finalise($result); } |
||
540 | if( $_62 === FALSE) { return FALSE; } |
||
541 | } |
||
542 | |||
543 | |||
544 | |||
545 | |||
546 | /** |
||
547 | * Values are bare words in templates, but strings in PHP. We rely on PHP's type conversion to back-convert |
||
548 | * strings to numbers when needed. |
||
549 | */ |
||
550 | function CallArguments_Argument(&$res, $sub) |
||
551 | { |
||
552 | if (!empty($res['php'])) { |
||
553 | $res['php'] .= ', '; |
||
554 | } |
||
555 | |||
556 | $res['php'] .= ($sub['ArgumentMode'] == 'default') ? $sub['string_php'] : |
||
557 | str_replace('$$FINAL', 'XML_val', $sub['php']); |
||
558 | } |
||
559 | |||
560 | /* Call: Method:Word ( "(" < :CallArguments? > ")" )? */ |
||
561 | protected $match_Call_typestack = array('Call'); |
||
562 | function match_Call ($stack = array()) { |
||
563 | $matchrule = "Call"; $result = $this->construct($matchrule, $matchrule, null); |
||
564 | $_72 = NULL; |
||
565 | do { |
||
566 | $matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
||
567 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
568 | if ($subres !== FALSE) { |
||
569 | $this->store( $result, $subres, "Method" ); |
||
570 | } |
||
571 | else { $_72 = FALSE; break; } |
||
572 | $res_71 = $result; |
||
573 | $pos_71 = $this->pos; |
||
574 | $_70 = NULL; |
||
575 | do { |
||
576 | if (substr($this->string,$this->pos,1) == '(') { |
||
577 | $this->pos += 1; |
||
578 | $result["text"] .= '('; |
||
579 | } |
||
580 | else { $_70 = FALSE; break; } |
||
581 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
582 | $res_67 = $result; |
||
583 | $pos_67 = $this->pos; |
||
584 | $matcher = 'match_'.'CallArguments'; $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, "CallArguments" ); |
||
588 | } |
||
589 | else { |
||
590 | $result = $res_67; |
||
591 | $this->pos = $pos_67; |
||
592 | unset( $res_67 ); |
||
593 | unset( $pos_67 ); |
||
594 | } |
||
595 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
596 | if (substr($this->string,$this->pos,1) == ')') { |
||
597 | $this->pos += 1; |
||
598 | $result["text"] .= ')'; |
||
599 | } |
||
600 | else { $_70 = FALSE; break; } |
||
601 | $_70 = TRUE; break; |
||
602 | } |
||
603 | while(0); |
||
604 | if( $_70 === FALSE) { |
||
605 | $result = $res_71; |
||
606 | $this->pos = $pos_71; |
||
607 | unset( $res_71 ); |
||
608 | unset( $pos_71 ); |
||
609 | } |
||
610 | $_72 = TRUE; break; |
||
611 | } |
||
612 | while(0); |
||
613 | if( $_72 === TRUE ) { return $this->finalise($result); } |
||
614 | if( $_72 === FALSE) { return FALSE; } |
||
615 | } |
||
616 | |||
617 | |||
618 | /* LookupStep: :Call &"." */ |
||
619 | protected $match_LookupStep_typestack = array('LookupStep'); |
||
620 | function match_LookupStep ($stack = array()) { |
||
621 | $matchrule = "LookupStep"; $result = $this->construct($matchrule, $matchrule, null); |
||
622 | $_76 = NULL; |
||
623 | do { |
||
624 | $matcher = 'match_'.'Call'; $key = $matcher; $pos = $this->pos; |
||
625 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
626 | if ($subres !== FALSE) { |
||
627 | $this->store( $result, $subres, "Call" ); |
||
628 | } |
||
629 | else { $_76 = FALSE; break; } |
||
630 | $res_75 = $result; |
||
631 | $pos_75 = $this->pos; |
||
632 | if (substr($this->string,$this->pos,1) == '.') { |
||
633 | $this->pos += 1; |
||
634 | $result["text"] .= '.'; |
||
635 | $result = $res_75; |
||
636 | $this->pos = $pos_75; |
||
637 | } |
||
638 | else { |
||
639 | $result = $res_75; |
||
640 | $this->pos = $pos_75; |
||
641 | $_76 = FALSE; break; |
||
642 | } |
||
643 | $_76 = TRUE; break; |
||
644 | } |
||
645 | while(0); |
||
646 | if( $_76 === TRUE ) { return $this->finalise($result); } |
||
647 | if( $_76 === FALSE) { return FALSE; } |
||
648 | } |
||
649 | |||
650 | |||
651 | /* LastLookupStep: :Call */ |
||
652 | protected $match_LastLookupStep_typestack = array('LastLookupStep'); |
||
653 | function match_LastLookupStep ($stack = array()) { |
||
654 | $matchrule = "LastLookupStep"; $result = $this->construct($matchrule, $matchrule, null); |
||
655 | $matcher = 'match_'.'Call'; $key = $matcher; $pos = $this->pos; |
||
656 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
657 | if ($subres !== FALSE) { |
||
658 | $this->store( $result, $subres, "Call" ); |
||
659 | return $this->finalise($result); |
||
660 | } |
||
661 | else { return FALSE; } |
||
662 | } |
||
663 | |||
664 | |||
665 | /* Lookup: LookupStep ("." LookupStep)* "." LastLookupStep | LastLookupStep */ |
||
666 | protected $match_Lookup_typestack = array('Lookup'); |
||
667 | function match_Lookup ($stack = array()) { |
||
668 | $matchrule = "Lookup"; $result = $this->construct($matchrule, $matchrule, null); |
||
669 | $_90 = NULL; |
||
670 | do { |
||
671 | $res_79 = $result; |
||
672 | $pos_79 = $this->pos; |
||
673 | $_87 = NULL; |
||
674 | do { |
||
675 | $matcher = 'match_'.'LookupStep'; $key = $matcher; $pos = $this->pos; |
||
676 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
677 | if ($subres !== FALSE) { |
||
678 | $this->store( $result, $subres ); |
||
679 | } |
||
680 | else { $_87 = FALSE; break; } |
||
681 | while (true) { |
||
682 | $res_84 = $result; |
||
683 | $pos_84 = $this->pos; |
||
684 | $_83 = NULL; |
||
685 | do { |
||
686 | if (substr($this->string,$this->pos,1) == '.') { |
||
687 | $this->pos += 1; |
||
688 | $result["text"] .= '.'; |
||
689 | } |
||
690 | else { $_83 = FALSE; break; } |
||
691 | $matcher = 'match_'.'LookupStep'; $key = $matcher; $pos = $this->pos; |
||
692 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
693 | if ($subres !== FALSE) { |
||
694 | $this->store( $result, $subres ); |
||
695 | } |
||
696 | else { $_83 = FALSE; break; } |
||
697 | $_83 = TRUE; break; |
||
698 | } |
||
699 | while(0); |
||
700 | if( $_83 === FALSE) { |
||
701 | $result = $res_84; |
||
702 | $this->pos = $pos_84; |
||
703 | unset( $res_84 ); |
||
704 | unset( $pos_84 ); |
||
705 | break; |
||
706 | } |
||
707 | } |
||
708 | if (substr($this->string,$this->pos,1) == '.') { |
||
709 | $this->pos += 1; |
||
710 | $result["text"] .= '.'; |
||
711 | } |
||
712 | else { $_87 = FALSE; break; } |
||
713 | $matcher = 'match_'.'LastLookupStep'; $key = $matcher; $pos = $this->pos; |
||
714 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
715 | if ($subres !== FALSE) { |
||
716 | $this->store( $result, $subres ); |
||
717 | } |
||
718 | else { $_87 = FALSE; break; } |
||
719 | $_87 = TRUE; break; |
||
720 | } |
||
721 | while(0); |
||
722 | if( $_87 === TRUE ) { $_90 = TRUE; break; } |
||
723 | $result = $res_79; |
||
724 | $this->pos = $pos_79; |
||
725 | $matcher = 'match_'.'LastLookupStep'; $key = $matcher; $pos = $this->pos; |
||
726 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
727 | if ($subres !== FALSE) { |
||
728 | $this->store( $result, $subres ); |
||
729 | $_90 = TRUE; break; |
||
730 | } |
||
731 | $result = $res_79; |
||
732 | $this->pos = $pos_79; |
||
733 | $_90 = FALSE; break; |
||
734 | } |
||
735 | while(0); |
||
736 | if( $_90 === TRUE ) { return $this->finalise($result); } |
||
737 | if( $_90 === FALSE) { return FALSE; } |
||
738 | } |
||
739 | |||
740 | |||
741 | |||
742 | |||
743 | function Lookup__construct(&$res) |
||
744 | { |
||
745 | $res['php'] = '$scope->locally()'; |
||
746 | $res['LookupSteps'] = array(); |
||
747 | } |
||
748 | |||
749 | /** |
||
750 | * The basic generated PHP of LookupStep and LastLookupStep is the same, except that LookupStep calls 'obj' to |
||
751 | * get the next ViewableData in the sequence, and LastLookupStep calls different methods (XML_val, hasValue, obj) |
||
752 | * depending on the context the lookup is used in. |
||
753 | */ |
||
754 | function Lookup_AddLookupStep(&$res, $sub, $method) |
||
755 | { |
||
756 | $res['LookupSteps'][] = $sub; |
||
757 | |||
758 | $property = $sub['Call']['Method']['text']; |
||
759 | |||
760 | if (isset($sub['Call']['CallArguments']) && $arguments = $sub['Call']['CallArguments']['php']) { |
||
761 | $res['php'] .= "->$method('$property', array($arguments), true)"; |
||
762 | } else { |
||
763 | $res['php'] .= "->$method('$property', null, true)"; |
||
764 | } |
||
765 | } |
||
766 | |||
767 | function Lookup_LookupStep(&$res, $sub) |
||
768 | { |
||
769 | $this->Lookup_AddLookupStep($res, $sub, 'obj'); |
||
770 | } |
||
771 | |||
772 | function Lookup_LastLookupStep(&$res, $sub) |
||
773 | { |
||
774 | $this->Lookup_AddLookupStep($res, $sub, '$$FINAL'); |
||
775 | } |
||
776 | |||
777 | |||
778 | /* Translate: "<%t" < Entity < (Default:QuotedString)? < (!("is" "=") < "is" < Context:QuotedString)? < |
||
779 | (InjectionVariables)? > "%>" */ |
||
780 | protected $match_Translate_typestack = array('Translate'); |
||
781 | function match_Translate ($stack = array()) { |
||
782 | $matchrule = "Translate"; $result = $this->construct($matchrule, $matchrule, null); |
||
783 | $_116 = NULL; |
||
784 | do { |
||
785 | if (( $subres = $this->literal( '<%t' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
786 | else { $_116 = FALSE; break; } |
||
787 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
788 | $matcher = 'match_'.'Entity'; $key = $matcher; $pos = $this->pos; |
||
789 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
790 | if ($subres !== FALSE) { |
||
791 | $this->store( $result, $subres ); |
||
792 | } |
||
793 | else { $_116 = FALSE; break; } |
||
794 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
795 | $res_98 = $result; |
||
796 | $pos_98 = $this->pos; |
||
797 | $_97 = NULL; |
||
798 | do { |
||
799 | $matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos; |
||
800 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
801 | if ($subres !== FALSE) { |
||
802 | $this->store( $result, $subres, "Default" ); |
||
803 | } |
||
804 | else { $_97 = FALSE; break; } |
||
805 | $_97 = TRUE; break; |
||
806 | } |
||
807 | while(0); |
||
808 | if( $_97 === FALSE) { |
||
809 | $result = $res_98; |
||
810 | $this->pos = $pos_98; |
||
811 | unset( $res_98 ); |
||
812 | unset( $pos_98 ); |
||
813 | } |
||
814 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
815 | $res_109 = $result; |
||
816 | $pos_109 = $this->pos; |
||
817 | $_108 = NULL; |
||
818 | do { |
||
819 | $res_103 = $result; |
||
820 | $pos_103 = $this->pos; |
||
821 | $_102 = NULL; |
||
822 | do { |
||
823 | if (( $subres = $this->literal( 'is' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
824 | else { $_102 = FALSE; break; } |
||
825 | if (substr($this->string,$this->pos,1) == '=') { |
||
826 | $this->pos += 1; |
||
827 | $result["text"] .= '='; |
||
828 | } |
||
829 | else { $_102 = FALSE; break; } |
||
830 | $_102 = TRUE; break; |
||
831 | } |
||
832 | while(0); |
||
833 | if( $_102 === TRUE ) { |
||
834 | $result = $res_103; |
||
835 | $this->pos = $pos_103; |
||
836 | $_108 = FALSE; break; |
||
837 | } |
||
838 | if( $_102 === FALSE) { |
||
839 | $result = $res_103; |
||
840 | $this->pos = $pos_103; |
||
841 | } |
||
842 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
843 | if (( $subres = $this->literal( 'is' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
844 | else { $_108 = FALSE; break; } |
||
845 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
846 | $matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos; |
||
847 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
848 | if ($subres !== FALSE) { |
||
849 | $this->store( $result, $subres, "Context" ); |
||
850 | } |
||
851 | else { $_108 = FALSE; break; } |
||
852 | $_108 = TRUE; break; |
||
853 | } |
||
854 | while(0); |
||
855 | if( $_108 === FALSE) { |
||
856 | $result = $res_109; |
||
857 | $this->pos = $pos_109; |
||
858 | unset( $res_109 ); |
||
859 | unset( $pos_109 ); |
||
860 | } |
||
861 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
862 | $res_113 = $result; |
||
863 | $pos_113 = $this->pos; |
||
864 | $_112 = NULL; |
||
865 | do { |
||
866 | $matcher = 'match_'.'InjectionVariables'; $key = $matcher; $pos = $this->pos; |
||
867 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
868 | if ($subres !== FALSE) { |
||
869 | $this->store( $result, $subres ); |
||
870 | } |
||
871 | else { $_112 = FALSE; break; } |
||
872 | $_112 = TRUE; break; |
||
873 | } |
||
874 | while(0); |
||
875 | if( $_112 === FALSE) { |
||
876 | $result = $res_113; |
||
877 | $this->pos = $pos_113; |
||
878 | unset( $res_113 ); |
||
879 | unset( $pos_113 ); |
||
880 | } |
||
881 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
882 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
883 | else { $_116 = FALSE; break; } |
||
884 | $_116 = TRUE; break; |
||
885 | } |
||
886 | while(0); |
||
887 | if( $_116 === TRUE ) { return $this->finalise($result); } |
||
888 | if( $_116 === FALSE) { return FALSE; } |
||
889 | } |
||
890 | |||
891 | |||
892 | /* InjectionVariables: (< InjectionName:Word "=" Argument)+ */ |
||
893 | protected $match_InjectionVariables_typestack = array('InjectionVariables'); |
||
894 | function match_InjectionVariables ($stack = array()) { |
||
895 | $matchrule = "InjectionVariables"; $result = $this->construct($matchrule, $matchrule, null); |
||
896 | $count = 0; |
||
897 | while (true) { |
||
898 | $res_123 = $result; |
||
899 | $pos_123 = $this->pos; |
||
900 | $_122 = NULL; |
||
901 | do { |
||
902 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
903 | $matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
||
904 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
905 | if ($subres !== FALSE) { |
||
906 | $this->store( $result, $subres, "InjectionName" ); |
||
907 | } |
||
908 | else { $_122 = FALSE; break; } |
||
909 | if (substr($this->string,$this->pos,1) == '=') { |
||
910 | $this->pos += 1; |
||
911 | $result["text"] .= '='; |
||
912 | } |
||
913 | else { $_122 = FALSE; break; } |
||
914 | $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
||
915 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
916 | if ($subres !== FALSE) { |
||
917 | $this->store( $result, $subres ); |
||
918 | } |
||
919 | else { $_122 = FALSE; break; } |
||
920 | $_122 = TRUE; break; |
||
921 | } |
||
922 | while(0); |
||
923 | if( $_122 === FALSE) { |
||
924 | $result = $res_123; |
||
925 | $this->pos = $pos_123; |
||
926 | unset( $res_123 ); |
||
927 | unset( $pos_123 ); |
||
928 | break; |
||
929 | } |
||
930 | $count += 1; |
||
931 | } |
||
932 | if ($count > 0) { return $this->finalise($result); } |
||
933 | else { return FALSE; } |
||
934 | } |
||
935 | |||
936 | |||
937 | /* Entity: / [A-Za-z_\\] [\w\.\\]* / */ |
||
938 | protected $match_Entity_typestack = array('Entity'); |
||
939 | function match_Entity ($stack = array()) { |
||
940 | $matchrule = "Entity"; $result = $this->construct($matchrule, $matchrule, null); |
||
941 | if (( $subres = $this->rx( '/ [A-Za-z_\\\\] [\w\.\\\\]* /' ) ) !== FALSE) { |
||
942 | $result["text"] .= $subres; |
||
943 | return $this->finalise($result); |
||
944 | } |
||
945 | else { return FALSE; } |
||
946 | } |
||
947 | |||
948 | |||
949 | |||
950 | |||
951 | function Translate__construct(&$res) |
||
952 | { |
||
953 | $res['php'] = '$val .= _t('; |
||
954 | } |
||
955 | |||
956 | function Translate_Entity(&$res, $sub) |
||
957 | { |
||
958 | $res['php'] .= "'$sub[text]'"; |
||
959 | } |
||
960 | |||
961 | function Translate_Default(&$res, $sub) |
||
962 | { |
||
963 | $res['php'] .= ",$sub[text]"; |
||
964 | } |
||
965 | |||
966 | function Translate_Context(&$res, $sub) |
||
967 | { |
||
968 | $res['php'] .= ",$sub[text]"; |
||
969 | } |
||
970 | |||
971 | function Translate_InjectionVariables(&$res, $sub) |
||
972 | { |
||
973 | $res['php'] .= ",$sub[php]"; |
||
974 | } |
||
975 | |||
976 | function Translate__finalise(&$res) |
||
977 | { |
||
978 | $res['php'] .= ');'; |
||
979 | } |
||
980 | |||
981 | function InjectionVariables__construct(&$res) |
||
982 | { |
||
983 | $res['php'] = "array("; |
||
984 | } |
||
985 | |||
986 | function InjectionVariables_InjectionName(&$res, $sub) |
||
987 | { |
||
988 | $res['php'] .= "'$sub[text]'=>"; |
||
989 | } |
||
990 | |||
991 | function InjectionVariables_Argument(&$res, $sub) |
||
992 | { |
||
993 | $res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']) . ','; |
||
994 | } |
||
995 | |||
996 | function InjectionVariables__finalise(&$res) |
||
997 | { |
||
998 | if (substr($res['php'], -1) == ',') { |
||
999 | $res['php'] = substr($res['php'], 0, -1); //remove last comma in the array |
||
1000 | } |
||
1001 | $res['php'] .= ')'; |
||
1002 | } |
||
1003 | |||
1004 | |||
1005 | /* SimpleInjection: '$' :Lookup */ |
||
1006 | protected $match_SimpleInjection_typestack = array('SimpleInjection'); |
||
1007 | function match_SimpleInjection ($stack = array()) { |
||
1008 | $matchrule = "SimpleInjection"; $result = $this->construct($matchrule, $matchrule, null); |
||
1009 | $_127 = NULL; |
||
1010 | do { |
||
1011 | if (substr($this->string,$this->pos,1) == '$') { |
||
1012 | $this->pos += 1; |
||
1013 | $result["text"] .= '$'; |
||
1014 | } |
||
1015 | else { $_127 = FALSE; break; } |
||
1016 | $matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos; |
||
1017 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1018 | if ($subres !== FALSE) { |
||
1019 | $this->store( $result, $subres, "Lookup" ); |
||
1020 | } |
||
1021 | else { $_127 = FALSE; break; } |
||
1022 | $_127 = TRUE; break; |
||
1023 | } |
||
1024 | while(0); |
||
1025 | if( $_127 === TRUE ) { return $this->finalise($result); } |
||
1026 | if( $_127 === FALSE) { return FALSE; } |
||
1027 | } |
||
1028 | |||
1029 | |||
1030 | /* BracketInjection: '{$' :Lookup "}" */ |
||
1031 | protected $match_BracketInjection_typestack = array('BracketInjection'); |
||
1032 | function match_BracketInjection ($stack = array()) { |
||
1033 | $matchrule = "BracketInjection"; $result = $this->construct($matchrule, $matchrule, null); |
||
1034 | $_132 = NULL; |
||
1035 | do { |
||
1036 | if (( $subres = $this->literal( '{$' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1037 | else { $_132 = FALSE; break; } |
||
1038 | $matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos; |
||
1039 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1040 | if ($subres !== FALSE) { |
||
1041 | $this->store( $result, $subres, "Lookup" ); |
||
1042 | } |
||
1043 | else { $_132 = FALSE; break; } |
||
1044 | if (substr($this->string,$this->pos,1) == '}') { |
||
1045 | $this->pos += 1; |
||
1046 | $result["text"] .= '}'; |
||
1047 | } |
||
1048 | else { $_132 = FALSE; break; } |
||
1049 | $_132 = TRUE; break; |
||
1050 | } |
||
1051 | while(0); |
||
1052 | if( $_132 === TRUE ) { return $this->finalise($result); } |
||
1053 | if( $_132 === FALSE) { return FALSE; } |
||
1054 | } |
||
1055 | |||
1056 | |||
1057 | /* Injection: BracketInjection | SimpleInjection */ |
||
1058 | protected $match_Injection_typestack = array('Injection'); |
||
1059 | function match_Injection ($stack = array()) { |
||
1060 | $matchrule = "Injection"; $result = $this->construct($matchrule, $matchrule, null); |
||
1061 | $_137 = NULL; |
||
1062 | do { |
||
1063 | $res_134 = $result; |
||
1064 | $pos_134 = $this->pos; |
||
1065 | $matcher = 'match_'.'BracketInjection'; $key = $matcher; $pos = $this->pos; |
||
1066 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1067 | if ($subres !== FALSE) { |
||
1068 | $this->store( $result, $subres ); |
||
1069 | $_137 = TRUE; break; |
||
1070 | } |
||
1071 | $result = $res_134; |
||
1072 | $this->pos = $pos_134; |
||
1073 | $matcher = 'match_'.'SimpleInjection'; $key = $matcher; $pos = $this->pos; |
||
1074 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1075 | if ($subres !== FALSE) { |
||
1076 | $this->store( $result, $subres ); |
||
1077 | $_137 = TRUE; break; |
||
1078 | } |
||
1079 | $result = $res_134; |
||
1080 | $this->pos = $pos_134; |
||
1081 | $_137 = FALSE; break; |
||
1082 | } |
||
1083 | while(0); |
||
1084 | if( $_137 === TRUE ) { return $this->finalise($result); } |
||
1085 | if( $_137 === FALSE) { return FALSE; } |
||
1086 | } |
||
1087 | |||
1088 | |||
1089 | |||
1090 | function Injection_STR(&$res, $sub) |
||
1091 | { |
||
1092 | $res['php'] = '$val .= '. str_replace('$$FINAL', 'XML_val', $sub['Lookup']['php']) . ';'; |
||
1093 | } |
||
1094 | |||
1095 | /* DollarMarkedLookup: SimpleInjection */ |
||
1096 | protected $match_DollarMarkedLookup_typestack = array('DollarMarkedLookup'); |
||
1097 | function match_DollarMarkedLookup ($stack = array()) { |
||
1098 | $matchrule = "DollarMarkedLookup"; $result = $this->construct($matchrule, $matchrule, null); |
||
1099 | $matcher = 'match_'.'SimpleInjection'; $key = $matcher; $pos = $this->pos; |
||
1100 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1101 | if ($subres !== FALSE) { |
||
1102 | $this->store( $result, $subres ); |
||
1103 | return $this->finalise($result); |
||
1104 | } |
||
1105 | else { return FALSE; } |
||
1106 | } |
||
1107 | |||
1108 | |||
1109 | |||
1110 | function DollarMarkedLookup_STR(&$res, $sub) |
||
1111 | { |
||
1112 | $res['Lookup'] = $sub['Lookup']; |
||
1113 | } |
||
1114 | |||
1115 | /* QuotedString: q:/['"]/ String:/ (\\\\ | \\. | [^$q\\])* / '$q' */ |
||
1116 | protected $match_QuotedString_typestack = array('QuotedString'); |
||
1117 | function match_QuotedString ($stack = array()) { |
||
1118 | $matchrule = "QuotedString"; $result = $this->construct($matchrule, $matchrule, null); |
||
1119 | $_143 = NULL; |
||
1120 | do { |
||
1121 | $stack[] = $result; $result = $this->construct( $matchrule, "q" ); |
||
1122 | if (( $subres = $this->rx( '/[\'"]/' ) ) !== FALSE) { |
||
1123 | $result["text"] .= $subres; |
||
1124 | $subres = $result; $result = array_pop($stack); |
||
1125 | $this->store( $result, $subres, 'q' ); |
||
1126 | } |
||
1127 | else { |
||
1128 | $result = array_pop($stack); |
||
1129 | $_143 = FALSE; break; |
||
1130 | } |
||
1131 | $stack[] = $result; $result = $this->construct( $matchrule, "String" ); |
||
1132 | if (( $subres = $this->rx( '/ (\\\\\\\\ | \\\\. | [^'.$this->expression($result, $stack, 'q').'\\\\])* /' ) ) !== FALSE) { |
||
1133 | $result["text"] .= $subres; |
||
1134 | $subres = $result; $result = array_pop($stack); |
||
1135 | $this->store( $result, $subres, 'String' ); |
||
1136 | } |
||
1137 | else { |
||
1138 | $result = array_pop($stack); |
||
1139 | $_143 = FALSE; break; |
||
1140 | } |
||
1141 | if (( $subres = $this->literal( ''.$this->expression($result, $stack, 'q').'' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1142 | else { $_143 = FALSE; break; } |
||
1143 | $_143 = TRUE; break; |
||
1144 | } |
||
1145 | while(0); |
||
1146 | if( $_143 === TRUE ) { return $this->finalise($result); } |
||
1147 | if( $_143 === FALSE) { return FALSE; } |
||
1148 | } |
||
1149 | |||
1150 | |||
1151 | /* FreeString: /[^,)%!=><|&]+/ */ |
||
1152 | protected $match_FreeString_typestack = array('FreeString'); |
||
1153 | function match_FreeString ($stack = array()) { |
||
1154 | $matchrule = "FreeString"; $result = $this->construct($matchrule, $matchrule, null); |
||
1155 | if (( $subres = $this->rx( '/[^,)%!=><|&]+/' ) ) !== FALSE) { |
||
1156 | $result["text"] .= $subres; |
||
1157 | return $this->finalise($result); |
||
1158 | } |
||
1159 | else { return FALSE; } |
||
1160 | } |
||
1161 | |||
1162 | |||
1163 | /* Argument: |
||
1164 | :DollarMarkedLookup | |
||
1165 | :QuotedString | |
||
1166 | :Lookup !(< FreeString)| |
||
1167 | :FreeString */ |
||
1168 | protected $match_Argument_typestack = array('Argument'); |
||
1169 | function match_Argument ($stack = array()) { |
||
1170 | $matchrule = "Argument"; $result = $this->construct($matchrule, $matchrule, null); |
||
1171 | $_163 = NULL; |
||
1172 | do { |
||
1173 | $res_146 = $result; |
||
1174 | $pos_146 = $this->pos; |
||
1175 | $matcher = 'match_'.'DollarMarkedLookup'; $key = $matcher; $pos = $this->pos; |
||
1176 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1177 | if ($subres !== FALSE) { |
||
1178 | $this->store( $result, $subres, "DollarMarkedLookup" ); |
||
1179 | $_163 = TRUE; break; |
||
1180 | } |
||
1181 | $result = $res_146; |
||
1182 | $this->pos = $pos_146; |
||
1183 | $_161 = NULL; |
||
1184 | do { |
||
1185 | $res_148 = $result; |
||
1186 | $pos_148 = $this->pos; |
||
1187 | $matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos; |
||
1188 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1189 | if ($subres !== FALSE) { |
||
1190 | $this->store( $result, $subres, "QuotedString" ); |
||
1191 | $_161 = TRUE; break; |
||
1192 | } |
||
1193 | $result = $res_148; |
||
1194 | $this->pos = $pos_148; |
||
1195 | $_159 = NULL; |
||
1196 | do { |
||
1197 | $res_150 = $result; |
||
1198 | $pos_150 = $this->pos; |
||
1199 | $_156 = NULL; |
||
1200 | do { |
||
1201 | $matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos; |
||
1202 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1203 | if ($subres !== FALSE) { |
||
1204 | $this->store( $result, $subres, "Lookup" ); |
||
1205 | } |
||
1206 | else { $_156 = FALSE; break; } |
||
1207 | $res_155 = $result; |
||
1208 | $pos_155 = $this->pos; |
||
1209 | $_154 = NULL; |
||
1210 | do { |
||
1211 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1212 | $matcher = 'match_'.'FreeString'; $key = $matcher; $pos = $this->pos; |
||
1213 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1214 | if ($subres !== FALSE) { |
||
1215 | $this->store( $result, $subres ); |
||
1216 | } |
||
1217 | else { $_154 = FALSE; break; } |
||
1218 | $_154 = TRUE; break; |
||
1219 | } |
||
1220 | while(0); |
||
1221 | if( $_154 === TRUE ) { |
||
1222 | $result = $res_155; |
||
1223 | $this->pos = $pos_155; |
||
1224 | $_156 = FALSE; break; |
||
1225 | } |
||
1226 | if( $_154 === FALSE) { |
||
1227 | $result = $res_155; |
||
1228 | $this->pos = $pos_155; |
||
1229 | } |
||
1230 | $_156 = TRUE; break; |
||
1231 | } |
||
1232 | while(0); |
||
1233 | if( $_156 === TRUE ) { $_159 = TRUE; break; } |
||
1234 | $result = $res_150; |
||
1235 | $this->pos = $pos_150; |
||
1236 | $matcher = 'match_'.'FreeString'; $key = $matcher; $pos = $this->pos; |
||
1237 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1238 | if ($subres !== FALSE) { |
||
1239 | $this->store( $result, $subres, "FreeString" ); |
||
1240 | $_159 = TRUE; break; |
||
1241 | } |
||
1242 | $result = $res_150; |
||
1243 | $this->pos = $pos_150; |
||
1244 | $_159 = FALSE; break; |
||
1245 | } |
||
1246 | while(0); |
||
1247 | if( $_159 === TRUE ) { $_161 = TRUE; break; } |
||
1248 | $result = $res_148; |
||
1249 | $this->pos = $pos_148; |
||
1250 | $_161 = FALSE; break; |
||
1251 | } |
||
1252 | while(0); |
||
1253 | if( $_161 === TRUE ) { $_163 = TRUE; break; } |
||
1254 | $result = $res_146; |
||
1255 | $this->pos = $pos_146; |
||
1256 | $_163 = FALSE; break; |
||
1257 | } |
||
1258 | while(0); |
||
1259 | if( $_163 === TRUE ) { return $this->finalise($result); } |
||
1260 | if( $_163 === FALSE) { return FALSE; } |
||
1261 | } |
||
1262 | |||
1263 | |||
1264 | |||
1265 | |||
1266 | /** |
||
1267 | * If we get a bare value, we don't know enough to determine exactly what php would be the translation, because |
||
1268 | * we don't know if the position of use indicates a lookup or a string argument. |
||
1269 | * |
||
1270 | * Instead, we record 'ArgumentMode' as a member of this matches results node, which can be: |
||
1271 | * - lookup if this argument was unambiguously a lookup (marked as such) |
||
1272 | * - string is this argument was unambiguously a string (marked as such, or impossible to parse as lookup) |
||
1273 | * - default if this argument needs to be handled as per 2.4 |
||
1274 | * |
||
1275 | * In the case of 'default', there is no php member of the results node, but instead 'lookup_php', which |
||
1276 | * should be used by the parent if the context indicates a lookup, and 'string_php' which should be used |
||
1277 | * if the context indicates a string |
||
1278 | */ |
||
1279 | |||
1280 | function Argument_DollarMarkedLookup(&$res, $sub) |
||
1281 | { |
||
1282 | $res['ArgumentMode'] = 'lookup'; |
||
1283 | $res['php'] = $sub['Lookup']['php']; |
||
1284 | } |
||
1285 | |||
1286 | function Argument_QuotedString(&$res, $sub) |
||
1287 | { |
||
1288 | $res['ArgumentMode'] = 'string'; |
||
1289 | $res['php'] = "'" . str_replace("'", "\\'", $sub['String']['text']) . "'"; |
||
1290 | } |
||
1291 | |||
1292 | function Argument_Lookup(&$res, $sub) |
||
1293 | { |
||
1294 | if (count($sub['LookupSteps']) == 1 && !isset($sub['LookupSteps'][0]['Call']['Arguments'])) { |
||
1295 | $res['ArgumentMode'] = 'default'; |
||
1296 | $res['lookup_php'] = $sub['php']; |
||
1297 | $res['string_php'] = "'".$sub['LookupSteps'][0]['Call']['Method']['text']."'"; |
||
1298 | } else { |
||
1299 | $res['ArgumentMode'] = 'lookup'; |
||
1300 | $res['php'] = $sub['php']; |
||
1301 | } |
||
1302 | } |
||
1303 | |||
1304 | function Argument_FreeString(&$res, $sub) |
||
1305 | { |
||
1306 | $res['ArgumentMode'] = 'string'; |
||
1307 | $res['php'] = "'" . str_replace("'", "\\'", trim($sub['text'])) . "'"; |
||
1308 | } |
||
1309 | |||
1310 | /* ComparisonOperator: "!=" | "==" | ">=" | ">" | "<=" | "<" | "=" */ |
||
1311 | protected $match_ComparisonOperator_typestack = array('ComparisonOperator'); |
||
1312 | function match_ComparisonOperator ($stack = array()) { |
||
1313 | $matchrule = "ComparisonOperator"; $result = $this->construct($matchrule, $matchrule, null); |
||
1314 | $_188 = NULL; |
||
1315 | do { |
||
1316 | $res_165 = $result; |
||
1317 | $pos_165 = $this->pos; |
||
1318 | if (( $subres = $this->literal( '!=' ) ) !== FALSE) { |
||
1319 | $result["text"] .= $subres; |
||
1320 | $_188 = TRUE; break; |
||
1321 | } |
||
1322 | $result = $res_165; |
||
1323 | $this->pos = $pos_165; |
||
1324 | $_186 = NULL; |
||
1325 | do { |
||
1326 | $res_167 = $result; |
||
1327 | $pos_167 = $this->pos; |
||
1328 | if (( $subres = $this->literal( '==' ) ) !== FALSE) { |
||
1329 | $result["text"] .= $subres; |
||
1330 | $_186 = TRUE; break; |
||
1331 | } |
||
1332 | $result = $res_167; |
||
1333 | $this->pos = $pos_167; |
||
1334 | $_184 = NULL; |
||
1335 | do { |
||
1336 | $res_169 = $result; |
||
1337 | $pos_169 = $this->pos; |
||
1338 | if (( $subres = $this->literal( '>=' ) ) !== FALSE) { |
||
1339 | $result["text"] .= $subres; |
||
1340 | $_184 = TRUE; break; |
||
1341 | } |
||
1342 | $result = $res_169; |
||
1343 | $this->pos = $pos_169; |
||
1344 | $_182 = NULL; |
||
1345 | do { |
||
1346 | $res_171 = $result; |
||
1347 | $pos_171 = $this->pos; |
||
1348 | if (substr($this->string,$this->pos,1) == '>') { |
||
1349 | $this->pos += 1; |
||
1350 | $result["text"] .= '>'; |
||
1351 | $_182 = TRUE; break; |
||
1352 | } |
||
1353 | $result = $res_171; |
||
1354 | $this->pos = $pos_171; |
||
1355 | $_180 = NULL; |
||
1356 | do { |
||
1357 | $res_173 = $result; |
||
1358 | $pos_173 = $this->pos; |
||
1359 | if (( $subres = $this->literal( '<=' ) ) !== FALSE) { |
||
1360 | $result["text"] .= $subres; |
||
1361 | $_180 = TRUE; break; |
||
1362 | } |
||
1363 | $result = $res_173; |
||
1364 | $this->pos = $pos_173; |
||
1365 | $_178 = NULL; |
||
1366 | do { |
||
1367 | $res_175 = $result; |
||
1368 | $pos_175 = $this->pos; |
||
1369 | if (substr($this->string,$this->pos,1) == '<') { |
||
1370 | $this->pos += 1; |
||
1371 | $result["text"] .= '<'; |
||
1372 | $_178 = TRUE; break; |
||
1373 | } |
||
1374 | $result = $res_175; |
||
1375 | $this->pos = $pos_175; |
||
1376 | if (substr($this->string,$this->pos,1) == '=') { |
||
1377 | $this->pos += 1; |
||
1378 | $result["text"] .= '='; |
||
1379 | $_178 = TRUE; break; |
||
1380 | } |
||
1381 | $result = $res_175; |
||
1382 | $this->pos = $pos_175; |
||
1383 | $_178 = FALSE; break; |
||
1384 | } |
||
1385 | while(0); |
||
1386 | if( $_178 === TRUE ) { $_180 = TRUE; break; } |
||
1387 | $result = $res_173; |
||
1388 | $this->pos = $pos_173; |
||
1389 | $_180 = FALSE; break; |
||
1390 | } |
||
1391 | while(0); |
||
1392 | if( $_180 === TRUE ) { $_182 = TRUE; break; } |
||
1393 | $result = $res_171; |
||
1394 | $this->pos = $pos_171; |
||
1395 | $_182 = FALSE; break; |
||
1396 | } |
||
1397 | while(0); |
||
1398 | if( $_182 === TRUE ) { $_184 = TRUE; break; } |
||
1399 | $result = $res_169; |
||
1400 | $this->pos = $pos_169; |
||
1401 | $_184 = FALSE; break; |
||
1402 | } |
||
1403 | while(0); |
||
1404 | if( $_184 === TRUE ) { $_186 = TRUE; break; } |
||
1405 | $result = $res_167; |
||
1406 | $this->pos = $pos_167; |
||
1407 | $_186 = FALSE; break; |
||
1408 | } |
||
1409 | while(0); |
||
1410 | if( $_186 === TRUE ) { $_188 = TRUE; break; } |
||
1411 | $result = $res_165; |
||
1412 | $this->pos = $pos_165; |
||
1413 | $_188 = FALSE; break; |
||
1414 | } |
||
1415 | while(0); |
||
1416 | if( $_188 === TRUE ) { return $this->finalise($result); } |
||
1417 | if( $_188 === FALSE) { return FALSE; } |
||
1418 | } |
||
1419 | |||
1420 | |||
1421 | /* Comparison: Argument < ComparisonOperator > Argument */ |
||
1422 | protected $match_Comparison_typestack = array('Comparison'); |
||
1423 | function match_Comparison ($stack = array()) { |
||
1424 | $matchrule = "Comparison"; $result = $this->construct($matchrule, $matchrule, null); |
||
1425 | $_195 = NULL; |
||
1426 | do { |
||
1427 | $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
||
1428 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1429 | if ($subres !== FALSE) { |
||
1430 | $this->store( $result, $subres ); |
||
1431 | } |
||
1432 | else { $_195 = FALSE; break; } |
||
1433 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1434 | $matcher = 'match_'.'ComparisonOperator'; $key = $matcher; $pos = $this->pos; |
||
1435 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1436 | if ($subres !== FALSE) { |
||
1437 | $this->store( $result, $subres ); |
||
1438 | } |
||
1439 | else { $_195 = FALSE; break; } |
||
1440 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1441 | $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
||
1442 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1443 | if ($subres !== FALSE) { |
||
1444 | $this->store( $result, $subres ); |
||
1445 | } |
||
1446 | else { $_195 = FALSE; break; } |
||
1447 | $_195 = TRUE; break; |
||
1448 | } |
||
1449 | while(0); |
||
1450 | if( $_195 === TRUE ) { return $this->finalise($result); } |
||
1451 | if( $_195 === FALSE) { return FALSE; } |
||
1452 | } |
||
1453 | |||
1454 | |||
1455 | |||
1456 | function Comparison_Argument(&$res, $sub) |
||
1457 | { |
||
1458 | if ($sub['ArgumentMode'] == 'default') { |
||
1459 | if (!empty($res['php'])) { |
||
1460 | $res['php'] .= $sub['string_php']; |
||
1461 | } else { |
||
1462 | $res['php'] = str_replace('$$FINAL', 'XML_val', $sub['lookup_php']); |
||
1463 | } |
||
1464 | } else { |
||
1465 | $res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']); |
||
1466 | } |
||
1467 | } |
||
1468 | |||
1469 | function Comparison_ComparisonOperator(&$res, $sub) |
||
1470 | { |
||
1471 | $res['php'] .= ($sub['text'] == '=' ? '==' : $sub['text']); |
||
1472 | } |
||
1473 | |||
1474 | /* PresenceCheck: (Not:'not' <)? Argument */ |
||
1475 | protected $match_PresenceCheck_typestack = array('PresenceCheck'); |
||
1476 | function match_PresenceCheck ($stack = array()) { |
||
1477 | $matchrule = "PresenceCheck"; $result = $this->construct($matchrule, $matchrule, null); |
||
1478 | $_202 = NULL; |
||
1479 | do { |
||
1480 | $res_200 = $result; |
||
1481 | $pos_200 = $this->pos; |
||
1482 | $_199 = NULL; |
||
1483 | do { |
||
1484 | $stack[] = $result; $result = $this->construct( $matchrule, "Not" ); |
||
1485 | if (( $subres = $this->literal( 'not' ) ) !== FALSE) { |
||
1486 | $result["text"] .= $subres; |
||
1487 | $subres = $result; $result = array_pop($stack); |
||
1488 | $this->store( $result, $subres, 'Not' ); |
||
1489 | } |
||
1490 | else { |
||
1491 | $result = array_pop($stack); |
||
1492 | $_199 = FALSE; break; |
||
1493 | } |
||
1494 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1495 | $_199 = TRUE; break; |
||
1496 | } |
||
1497 | while(0); |
||
1498 | if( $_199 === FALSE) { |
||
1499 | $result = $res_200; |
||
1500 | $this->pos = $pos_200; |
||
1501 | unset( $res_200 ); |
||
1502 | unset( $pos_200 ); |
||
1503 | } |
||
1504 | $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
||
1505 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1506 | if ($subres !== FALSE) { |
||
1507 | $this->store( $result, $subres ); |
||
1508 | } |
||
1509 | else { $_202 = FALSE; break; } |
||
1510 | $_202 = TRUE; break; |
||
1511 | } |
||
1512 | while(0); |
||
1513 | if( $_202 === TRUE ) { return $this->finalise($result); } |
||
1514 | if( $_202 === FALSE) { return FALSE; } |
||
1515 | } |
||
1516 | |||
1517 | |||
1518 | |||
1519 | function PresenceCheck_Not(&$res, $sub) |
||
1520 | { |
||
1521 | $res['php'] = '!'; |
||
1522 | } |
||
1523 | |||
1524 | function PresenceCheck_Argument(&$res, $sub) |
||
1525 | { |
||
1526 | if ($sub['ArgumentMode'] == 'string') { |
||
1527 | $res['php'] .= '((bool)'.$sub['php'].')'; |
||
1528 | } else { |
||
1529 | $php = ($sub['ArgumentMode'] == 'default' ? $sub['lookup_php'] : $sub['php']); |
||
1530 | // TODO: kinda hacky - maybe we need a way to pass state down the parse chain so |
||
1531 | // Lookup_LastLookupStep and Argument_BareWord can produce hasValue instead of XML_val |
||
1532 | $res['php'] .= str_replace('$$FINAL', 'hasValue', $php); |
||
1533 | } |
||
1534 | } |
||
1535 | |||
1536 | /* IfArgumentPortion: Comparison | PresenceCheck */ |
||
1537 | protected $match_IfArgumentPortion_typestack = array('IfArgumentPortion'); |
||
1538 | function match_IfArgumentPortion ($stack = array()) { |
||
1539 | $matchrule = "IfArgumentPortion"; $result = $this->construct($matchrule, $matchrule, null); |
||
1540 | $_207 = NULL; |
||
1541 | do { |
||
1542 | $res_204 = $result; |
||
1543 | $pos_204 = $this->pos; |
||
1544 | $matcher = 'match_'.'Comparison'; $key = $matcher; $pos = $this->pos; |
||
1545 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1546 | if ($subres !== FALSE) { |
||
1547 | $this->store( $result, $subres ); |
||
1548 | $_207 = TRUE; break; |
||
1549 | } |
||
1550 | $result = $res_204; |
||
1551 | $this->pos = $pos_204; |
||
1552 | $matcher = 'match_'.'PresenceCheck'; $key = $matcher; $pos = $this->pos; |
||
1553 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1554 | if ($subres !== FALSE) { |
||
1555 | $this->store( $result, $subres ); |
||
1556 | $_207 = TRUE; break; |
||
1557 | } |
||
1558 | $result = $res_204; |
||
1559 | $this->pos = $pos_204; |
||
1560 | $_207 = FALSE; break; |
||
1561 | } |
||
1562 | while(0); |
||
1563 | if( $_207 === TRUE ) { return $this->finalise($result); } |
||
1564 | if( $_207 === FALSE) { return FALSE; } |
||
1565 | } |
||
1566 | |||
1567 | |||
1568 | |||
1569 | function IfArgumentPortion_STR(&$res, $sub) |
||
1570 | { |
||
1571 | $res['php'] = $sub['php']; |
||
1572 | } |
||
1573 | |||
1574 | /* BooleanOperator: "||" | "&&" */ |
||
1575 | protected $match_BooleanOperator_typestack = array('BooleanOperator'); |
||
1576 | function match_BooleanOperator ($stack = array()) { |
||
1577 | $matchrule = "BooleanOperator"; $result = $this->construct($matchrule, $matchrule, null); |
||
1578 | $_212 = NULL; |
||
1579 | do { |
||
1580 | $res_209 = $result; |
||
1581 | $pos_209 = $this->pos; |
||
1582 | if (( $subres = $this->literal( '||' ) ) !== FALSE) { |
||
1583 | $result["text"] .= $subres; |
||
1584 | $_212 = TRUE; break; |
||
1585 | } |
||
1586 | $result = $res_209; |
||
1587 | $this->pos = $pos_209; |
||
1588 | if (( $subres = $this->literal( '&&' ) ) !== FALSE) { |
||
1589 | $result["text"] .= $subres; |
||
1590 | $_212 = TRUE; break; |
||
1591 | } |
||
1592 | $result = $res_209; |
||
1593 | $this->pos = $pos_209; |
||
1594 | $_212 = FALSE; break; |
||
1595 | } |
||
1596 | while(0); |
||
1597 | if( $_212 === TRUE ) { return $this->finalise($result); } |
||
1598 | if( $_212 === FALSE) { return FALSE; } |
||
1599 | } |
||
1600 | |||
1601 | |||
1602 | /* IfArgument: :IfArgumentPortion ( < :BooleanOperator < :IfArgumentPortion )* */ |
||
1603 | protected $match_IfArgument_typestack = array('IfArgument'); |
||
1604 | function match_IfArgument ($stack = array()) { |
||
1605 | $matchrule = "IfArgument"; $result = $this->construct($matchrule, $matchrule, null); |
||
1606 | $_221 = NULL; |
||
1607 | do { |
||
1608 | $matcher = 'match_'.'IfArgumentPortion'; $key = $matcher; $pos = $this->pos; |
||
1609 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1610 | if ($subres !== FALSE) { |
||
1611 | $this->store( $result, $subres, "IfArgumentPortion" ); |
||
1612 | } |
||
1613 | else { $_221 = FALSE; break; } |
||
1614 | while (true) { |
||
1615 | $res_220 = $result; |
||
1616 | $pos_220 = $this->pos; |
||
1617 | $_219 = NULL; |
||
1618 | do { |
||
1619 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1620 | $matcher = 'match_'.'BooleanOperator'; $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, "BooleanOperator" ); |
||
1624 | } |
||
1625 | else { $_219 = FALSE; break; } |
||
1626 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1627 | $matcher = 'match_'.'IfArgumentPortion'; $key = $matcher; $pos = $this->pos; |
||
1628 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1629 | if ($subres !== FALSE) { |
||
1630 | $this->store( $result, $subres, "IfArgumentPortion" ); |
||
1631 | } |
||
1632 | else { $_219 = FALSE; break; } |
||
1633 | $_219 = TRUE; break; |
||
1634 | } |
||
1635 | while(0); |
||
1636 | if( $_219 === FALSE) { |
||
1637 | $result = $res_220; |
||
1638 | $this->pos = $pos_220; |
||
1639 | unset( $res_220 ); |
||
1640 | unset( $pos_220 ); |
||
1641 | break; |
||
1642 | } |
||
1643 | } |
||
1644 | $_221 = TRUE; break; |
||
1645 | } |
||
1646 | while(0); |
||
1647 | if( $_221 === TRUE ) { return $this->finalise($result); } |
||
1648 | if( $_221 === FALSE) { return FALSE; } |
||
1649 | } |
||
1650 | |||
1651 | |||
1652 | |||
1653 | function IfArgument_IfArgumentPortion(&$res, $sub) |
||
1654 | { |
||
1655 | $res['php'] .= $sub['php']; |
||
1656 | } |
||
1657 | |||
1658 | function IfArgument_BooleanOperator(&$res, $sub) |
||
1659 | { |
||
1660 | $res['php'] .= $sub['text']; |
||
1661 | } |
||
1662 | |||
1663 | /* IfPart: '<%' < 'if' [ :IfArgument > '%>' Template:$TemplateMatcher? */ |
||
1664 | protected $match_IfPart_typestack = array('IfPart'); |
||
1665 | function match_IfPart ($stack = array()) { |
||
1666 | $matchrule = "IfPart"; $result = $this->construct($matchrule, $matchrule, null); |
||
1667 | $_231 = NULL; |
||
1668 | do { |
||
1669 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1670 | else { $_231 = FALSE; break; } |
||
1671 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1672 | if (( $subres = $this->literal( 'if' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1673 | else { $_231 = FALSE; break; } |
||
1674 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1675 | else { $_231 = FALSE; break; } |
||
1676 | $matcher = 'match_'.'IfArgument'; $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, "IfArgument" ); |
||
1680 | } |
||
1681 | else { $_231 = FALSE; break; } |
||
1682 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1683 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1684 | else { $_231 = FALSE; break; } |
||
1685 | $res_230 = $result; |
||
1686 | $pos_230 = $this->pos; |
||
1687 | $matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $key = $matcher; $pos = $this->pos; |
||
1688 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1689 | if ($subres !== FALSE) { |
||
1690 | $this->store( $result, $subres, "Template" ); |
||
1691 | } |
||
1692 | else { |
||
1693 | $result = $res_230; |
||
1694 | $this->pos = $pos_230; |
||
1695 | unset( $res_230 ); |
||
1696 | unset( $pos_230 ); |
||
1697 | } |
||
1698 | $_231 = TRUE; break; |
||
1699 | } |
||
1700 | while(0); |
||
1701 | if( $_231 === TRUE ) { return $this->finalise($result); } |
||
1702 | if( $_231 === FALSE) { return FALSE; } |
||
1703 | } |
||
1704 | |||
1705 | |||
1706 | /* ElseIfPart: '<%' < 'else_if' [ :IfArgument > '%>' Template:$TemplateMatcher? */ |
||
1707 | protected $match_ElseIfPart_typestack = array('ElseIfPart'); |
||
1708 | function match_ElseIfPart ($stack = array()) { |
||
1709 | $matchrule = "ElseIfPart"; $result = $this->construct($matchrule, $matchrule, null); |
||
1710 | $_241 = NULL; |
||
1711 | do { |
||
1712 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1713 | else { $_241 = FALSE; break; } |
||
1714 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1715 | if (( $subres = $this->literal( 'else_if' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1716 | else { $_241 = FALSE; break; } |
||
1717 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1718 | else { $_241 = FALSE; break; } |
||
1719 | $matcher = 'match_'.'IfArgument'; $key = $matcher; $pos = $this->pos; |
||
1720 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1721 | if ($subres !== FALSE) { |
||
1722 | $this->store( $result, $subres, "IfArgument" ); |
||
1723 | } |
||
1724 | else { $_241 = FALSE; break; } |
||
1725 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1726 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1727 | else { $_241 = FALSE; break; } |
||
1728 | $res_240 = $result; |
||
1729 | $pos_240 = $this->pos; |
||
1730 | $matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $key = $matcher; $pos = $this->pos; |
||
1731 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1732 | if ($subres !== FALSE) { |
||
1733 | $this->store( $result, $subres, "Template" ); |
||
1734 | } |
||
1735 | else { |
||
1736 | $result = $res_240; |
||
1737 | $this->pos = $pos_240; |
||
1738 | unset( $res_240 ); |
||
1739 | unset( $pos_240 ); |
||
1740 | } |
||
1741 | $_241 = TRUE; break; |
||
1742 | } |
||
1743 | while(0); |
||
1744 | if( $_241 === TRUE ) { return $this->finalise($result); } |
||
1745 | if( $_241 === FALSE) { return FALSE; } |
||
1746 | } |
||
1747 | |||
1748 | |||
1749 | /* ElsePart: '<%' < 'else' > '%>' Template:$TemplateMatcher? */ |
||
1750 | protected $match_ElsePart_typestack = array('ElsePart'); |
||
1751 | function match_ElsePart ($stack = array()) { |
||
1752 | $matchrule = "ElsePart"; $result = $this->construct($matchrule, $matchrule, null); |
||
1753 | $_249 = NULL; |
||
1754 | do { |
||
1755 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1756 | else { $_249 = FALSE; break; } |
||
1757 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1758 | if (( $subres = $this->literal( 'else' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1759 | else { $_249 = FALSE; break; } |
||
1760 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1761 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1762 | else { $_249 = FALSE; break; } |
||
1763 | $res_248 = $result; |
||
1764 | $pos_248 = $this->pos; |
||
1765 | $matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $key = $matcher; $pos = $this->pos; |
||
1766 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1767 | if ($subres !== FALSE) { |
||
1768 | $this->store( $result, $subres, "Template" ); |
||
1769 | } |
||
1770 | else { |
||
1771 | $result = $res_248; |
||
1772 | $this->pos = $pos_248; |
||
1773 | unset( $res_248 ); |
||
1774 | unset( $pos_248 ); |
||
1775 | } |
||
1776 | $_249 = TRUE; break; |
||
1777 | } |
||
1778 | while(0); |
||
1779 | if( $_249 === TRUE ) { return $this->finalise($result); } |
||
1780 | if( $_249 === FALSE) { return FALSE; } |
||
1781 | } |
||
1782 | |||
1783 | |||
1784 | /* If: IfPart ElseIfPart* ElsePart? '<%' < 'end_if' > '%>' */ |
||
1785 | protected $match_If_typestack = array('If'); |
||
1786 | function match_If ($stack = array()) { |
||
1787 | $matchrule = "If"; $result = $this->construct($matchrule, $matchrule, null); |
||
1788 | $_259 = NULL; |
||
1789 | do { |
||
1790 | $matcher = 'match_'.'IfPart'; $key = $matcher; $pos = $this->pos; |
||
1791 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1792 | if ($subres !== FALSE) { |
||
1793 | $this->store( $result, $subres ); |
||
1794 | } |
||
1795 | else { $_259 = FALSE; break; } |
||
1796 | while (true) { |
||
1797 | $res_252 = $result; |
||
1798 | $pos_252 = $this->pos; |
||
1799 | $matcher = 'match_'.'ElseIfPart'; $key = $matcher; $pos = $this->pos; |
||
1800 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1801 | if ($subres !== FALSE) { |
||
1802 | $this->store( $result, $subres ); |
||
1803 | } |
||
1804 | else { |
||
1805 | $result = $res_252; |
||
1806 | $this->pos = $pos_252; |
||
1807 | unset( $res_252 ); |
||
1808 | unset( $pos_252 ); |
||
1809 | break; |
||
1810 | } |
||
1811 | } |
||
1812 | $res_253 = $result; |
||
1813 | $pos_253 = $this->pos; |
||
1814 | $matcher = 'match_'.'ElsePart'; $key = $matcher; $pos = $this->pos; |
||
1815 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1816 | if ($subres !== FALSE) { |
||
1817 | $this->store( $result, $subres ); |
||
1818 | } |
||
1819 | else { |
||
1820 | $result = $res_253; |
||
1821 | $this->pos = $pos_253; |
||
1822 | unset( $res_253 ); |
||
1823 | unset( $pos_253 ); |
||
1824 | } |
||
1825 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1826 | else { $_259 = FALSE; break; } |
||
1827 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1828 | if (( $subres = $this->literal( 'end_if' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1829 | else { $_259 = FALSE; break; } |
||
1830 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1831 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
1832 | else { $_259 = FALSE; break; } |
||
1833 | $_259 = TRUE; break; |
||
1834 | } |
||
1835 | while(0); |
||
1836 | if( $_259 === TRUE ) { return $this->finalise($result); } |
||
1837 | if( $_259 === FALSE) { return FALSE; } |
||
1838 | } |
||
1839 | |||
1840 | |||
1841 | |||
1842 | function If_IfPart(&$res, $sub) |
||
1843 | { |
||
1844 | $res['php'] = |
||
1845 | 'if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL . |
||
1846 | (isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL . |
||
1847 | '}'; |
||
1848 | } |
||
1849 | |||
1850 | function If_ElseIfPart(&$res, $sub) |
||
1851 | { |
||
1852 | $res['php'] .= |
||
1853 | 'else if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL . |
||
1854 | (isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL . |
||
1855 | '}'; |
||
1856 | } |
||
1857 | |||
1858 | function If_ElsePart(&$res, $sub) |
||
1859 | { |
||
1860 | $res['php'] .= |
||
1861 | 'else { ' . PHP_EOL . |
||
1862 | (isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL . |
||
1863 | '}'; |
||
1864 | } |
||
1865 | |||
1866 | /* Require: '<%' < 'require' [ Call:(Method:Word "(" < :CallArguments > ")") > '%>' */ |
||
1867 | protected $match_Require_typestack = array('Require'); |
||
1868 | function match_Require ($stack = array()) { |
||
1925 | } |
||
1926 | |||
1927 | |||
1928 | |||
1929 | function Require_Call(&$res, $sub) |
||
1930 | { |
||
1931 | $requirements = '\\SilverStripe\\View\\Requirements'; |
||
1932 | $res['php'] = "{$requirements}::".$sub['Method']['text'].'('.$sub['CallArguments']['php'].');'; |
||
1933 | } |
||
1934 | |||
1935 | |||
1936 | /* CacheBlockArgument: |
||
1937 | !( "if " | "unless " ) |
||
1938 | ( |
||
1939 | :DollarMarkedLookup | |
||
1940 | :QuotedString | |
||
1941 | :Lookup |
||
1942 | ) */ |
||
1943 | protected $match_CacheBlockArgument_typestack = array('CacheBlockArgument'); |
||
1944 | function match_CacheBlockArgument ($stack = array()) { |
||
1945 | $matchrule = "CacheBlockArgument"; $result = $this->construct($matchrule, $matchrule, null); |
||
1946 | $_295 = NULL; |
||
1947 | do { |
||
1948 | $res_283 = $result; |
||
1949 | $pos_283 = $this->pos; |
||
1950 | $_282 = NULL; |
||
1951 | do { |
||
1952 | $_280 = NULL; |
||
1953 | do { |
||
1954 | $res_277 = $result; |
||
1955 | $pos_277 = $this->pos; |
||
1956 | if (( $subres = $this->literal( 'if ' ) ) !== FALSE) { |
||
1957 | $result["text"] .= $subres; |
||
1958 | $_280 = TRUE; break; |
||
1959 | } |
||
1960 | $result = $res_277; |
||
1961 | $this->pos = $pos_277; |
||
1962 | if (( $subres = $this->literal( 'unless ' ) ) !== FALSE) { |
||
1963 | $result["text"] .= $subres; |
||
1964 | $_280 = TRUE; break; |
||
1965 | } |
||
1966 | $result = $res_277; |
||
1967 | $this->pos = $pos_277; |
||
1968 | $_280 = FALSE; break; |
||
1969 | } |
||
1970 | while(0); |
||
1971 | if( $_280 === FALSE) { $_282 = FALSE; break; } |
||
1972 | $_282 = TRUE; break; |
||
1973 | } |
||
1974 | while(0); |
||
1975 | if( $_282 === TRUE ) { |
||
1976 | $result = $res_283; |
||
1977 | $this->pos = $pos_283; |
||
1978 | $_295 = FALSE; break; |
||
1979 | } |
||
1980 | if( $_282 === FALSE) { |
||
1981 | $result = $res_283; |
||
1982 | $this->pos = $pos_283; |
||
1983 | } |
||
1984 | $_293 = NULL; |
||
1985 | do { |
||
1986 | $_291 = NULL; |
||
1987 | do { |
||
1988 | $res_284 = $result; |
||
1989 | $pos_284 = $this->pos; |
||
1990 | $matcher = 'match_'.'DollarMarkedLookup'; $key = $matcher; $pos = $this->pos; |
||
1991 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
1992 | if ($subres !== FALSE) { |
||
1993 | $this->store( $result, $subres, "DollarMarkedLookup" ); |
||
1994 | $_291 = TRUE; break; |
||
1995 | } |
||
1996 | $result = $res_284; |
||
1997 | $this->pos = $pos_284; |
||
1998 | $_289 = NULL; |
||
1999 | do { |
||
2000 | $res_286 = $result; |
||
2001 | $pos_286 = $this->pos; |
||
2002 | $matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos; |
||
2003 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2004 | if ($subres !== FALSE) { |
||
2005 | $this->store( $result, $subres, "QuotedString" ); |
||
2006 | $_289 = TRUE; break; |
||
2007 | } |
||
2008 | $result = $res_286; |
||
2009 | $this->pos = $pos_286; |
||
2010 | $matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos; |
||
2011 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2012 | if ($subres !== FALSE) { |
||
2013 | $this->store( $result, $subres, "Lookup" ); |
||
2014 | $_289 = TRUE; break; |
||
2015 | } |
||
2016 | $result = $res_286; |
||
2017 | $this->pos = $pos_286; |
||
2018 | $_289 = FALSE; break; |
||
2019 | } |
||
2020 | while(0); |
||
2021 | if( $_289 === TRUE ) { $_291 = TRUE; break; } |
||
2022 | $result = $res_284; |
||
2023 | $this->pos = $pos_284; |
||
2024 | $_291 = FALSE; break; |
||
2025 | } |
||
2026 | while(0); |
||
2027 | if( $_291 === FALSE) { $_293 = FALSE; break; } |
||
2028 | $_293 = TRUE; break; |
||
2029 | } |
||
2030 | while(0); |
||
2031 | if( $_293 === FALSE) { $_295 = FALSE; break; } |
||
2032 | $_295 = TRUE; break; |
||
2033 | } |
||
2034 | while(0); |
||
2035 | if( $_295 === TRUE ) { return $this->finalise($result); } |
||
2036 | if( $_295 === FALSE) { return FALSE; } |
||
2037 | } |
||
2038 | |||
2039 | |||
2040 | |||
2041 | function CacheBlockArgument_DollarMarkedLookup(&$res, $sub) |
||
2042 | { |
||
2043 | $res['php'] = $sub['Lookup']['php']; |
||
2044 | } |
||
2045 | |||
2046 | function CacheBlockArgument_QuotedString(&$res, $sub) |
||
2047 | { |
||
2048 | $res['php'] = "'" . str_replace("'", "\\'", $sub['String']['text']) . "'"; |
||
2049 | } |
||
2050 | |||
2051 | function CacheBlockArgument_Lookup(&$res, $sub) |
||
2052 | { |
||
2053 | $res['php'] = $sub['php']; |
||
2054 | } |
||
2055 | |||
2056 | /* CacheBlockArguments: CacheBlockArgument ( < "," < CacheBlockArgument )* */ |
||
2057 | protected $match_CacheBlockArguments_typestack = array('CacheBlockArguments'); |
||
2058 | function match_CacheBlockArguments ($stack = array()) { |
||
2059 | $matchrule = "CacheBlockArguments"; $result = $this->construct($matchrule, $matchrule, null); |
||
2060 | $_304 = NULL; |
||
2061 | do { |
||
2062 | $matcher = 'match_'.'CacheBlockArgument'; $key = $matcher; $pos = $this->pos; |
||
2063 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2064 | if ($subres !== FALSE) { |
||
2065 | $this->store( $result, $subres ); |
||
2066 | } |
||
2067 | else { $_304 = FALSE; break; } |
||
2068 | while (true) { |
||
2069 | $res_303 = $result; |
||
2070 | $pos_303 = $this->pos; |
||
2071 | $_302 = NULL; |
||
2072 | do { |
||
2073 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2074 | if (substr($this->string,$this->pos,1) == ',') { |
||
2075 | $this->pos += 1; |
||
2076 | $result["text"] .= ','; |
||
2077 | } |
||
2078 | else { $_302 = FALSE; break; } |
||
2079 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2080 | $matcher = 'match_'.'CacheBlockArgument'; $key = $matcher; $pos = $this->pos; |
||
2081 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2082 | if ($subres !== FALSE) { |
||
2083 | $this->store( $result, $subres ); |
||
2084 | } |
||
2085 | else { $_302 = FALSE; break; } |
||
2086 | $_302 = TRUE; break; |
||
2087 | } |
||
2088 | while(0); |
||
2089 | if( $_302 === FALSE) { |
||
2090 | $result = $res_303; |
||
2091 | $this->pos = $pos_303; |
||
2092 | unset( $res_303 ); |
||
2093 | unset( $pos_303 ); |
||
2094 | break; |
||
2095 | } |
||
2096 | } |
||
2097 | $_304 = TRUE; break; |
||
2098 | } |
||
2099 | while(0); |
||
2100 | if( $_304 === TRUE ) { return $this->finalise($result); } |
||
2101 | if( $_304 === FALSE) { return FALSE; } |
||
2102 | } |
||
2103 | |||
2104 | |||
2105 | |||
2106 | function CacheBlockArguments_CacheBlockArgument(&$res, $sub) |
||
2107 | { |
||
2108 | if (!empty($res['php'])) { |
||
2109 | $res['php'] .= ".'_'."; |
||
2110 | } else { |
||
2111 | $res['php'] = ''; |
||
2112 | } |
||
2113 | |||
2114 | $res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']); |
||
2115 | } |
||
2116 | |||
2117 | /* CacheBlockTemplate: (Comment | Translate | If | Require | OldI18NTag | Include | ClosedBlock | |
||
2118 | OpenBlock | MalformedBlock | Injection | Text)+ */ |
||
2119 | protected $match_CacheBlockTemplate_typestack = array('CacheBlockTemplate','Template'); |
||
2120 | function match_CacheBlockTemplate ($stack = array()) { |
||
2121 | $matchrule = "CacheBlockTemplate"; $result = $this->construct($matchrule, $matchrule, array('TemplateMatcher' => 'CacheRestrictedTemplate')); |
||
2122 | $count = 0; |
||
2123 | while (true) { |
||
2124 | $res_348 = $result; |
||
2125 | $pos_348 = $this->pos; |
||
2126 | $_347 = NULL; |
||
2127 | do { |
||
2128 | $_345 = NULL; |
||
2129 | do { |
||
2130 | $res_306 = $result; |
||
2131 | $pos_306 = $this->pos; |
||
2132 | $matcher = 'match_'.'Comment'; $key = $matcher; $pos = $this->pos; |
||
2133 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2134 | if ($subres !== FALSE) { |
||
2135 | $this->store( $result, $subres ); |
||
2136 | $_345 = TRUE; break; |
||
2137 | } |
||
2138 | $result = $res_306; |
||
2139 | $this->pos = $pos_306; |
||
2140 | $_343 = NULL; |
||
2141 | do { |
||
2142 | $res_308 = $result; |
||
2143 | $pos_308 = $this->pos; |
||
2144 | $matcher = 'match_'.'Translate'; $key = $matcher; $pos = $this->pos; |
||
2145 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2146 | if ($subres !== FALSE) { |
||
2147 | $this->store( $result, $subres ); |
||
2148 | $_343 = TRUE; break; |
||
2149 | } |
||
2150 | $result = $res_308; |
||
2151 | $this->pos = $pos_308; |
||
2152 | $_341 = NULL; |
||
2153 | do { |
||
2154 | $res_310 = $result; |
||
2155 | $pos_310 = $this->pos; |
||
2156 | $matcher = 'match_'.'If'; $key = $matcher; $pos = $this->pos; |
||
2157 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2158 | if ($subres !== FALSE) { |
||
2159 | $this->store( $result, $subres ); |
||
2160 | $_341 = TRUE; break; |
||
2161 | } |
||
2162 | $result = $res_310; |
||
2163 | $this->pos = $pos_310; |
||
2164 | $_339 = NULL; |
||
2165 | do { |
||
2166 | $res_312 = $result; |
||
2167 | $pos_312 = $this->pos; |
||
2168 | $matcher = 'match_'.'Require'; $key = $matcher; $pos = $this->pos; |
||
2169 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2170 | if ($subres !== FALSE) { |
||
2171 | $this->store( $result, $subres ); |
||
2172 | $_339 = TRUE; break; |
||
2173 | } |
||
2174 | $result = $res_312; |
||
2175 | $this->pos = $pos_312; |
||
2176 | $_337 = NULL; |
||
2177 | do { |
||
2178 | $res_314 = $result; |
||
2179 | $pos_314 = $this->pos; |
||
2180 | $matcher = 'match_'.'OldI18NTag'; $key = $matcher; $pos = $this->pos; |
||
2181 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2182 | if ($subres !== FALSE) { |
||
2183 | $this->store( $result, $subres ); |
||
2184 | $_337 = TRUE; break; |
||
2185 | } |
||
2186 | $result = $res_314; |
||
2187 | $this->pos = $pos_314; |
||
2188 | $_335 = NULL; |
||
2189 | do { |
||
2190 | $res_316 = $result; |
||
2191 | $pos_316 = $this->pos; |
||
2192 | $matcher = 'match_'.'Include'; $key = $matcher; $pos = $this->pos; |
||
2193 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2194 | if ($subres !== FALSE) { |
||
2195 | $this->store( $result, $subres ); |
||
2196 | $_335 = TRUE; break; |
||
2197 | } |
||
2198 | $result = $res_316; |
||
2199 | $this->pos = $pos_316; |
||
2200 | $_333 = NULL; |
||
2201 | do { |
||
2202 | $res_318 = $result; |
||
2203 | $pos_318 = $this->pos; |
||
2204 | $matcher = 'match_'.'ClosedBlock'; $key = $matcher; $pos = $this->pos; |
||
2205 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2206 | if ($subres !== FALSE) { |
||
2207 | $this->store( $result, $subres ); |
||
2208 | $_333 = TRUE; break; |
||
2209 | } |
||
2210 | $result = $res_318; |
||
2211 | $this->pos = $pos_318; |
||
2212 | $_331 = NULL; |
||
2213 | do { |
||
2214 | $res_320 = $result; |
||
2215 | $pos_320 = $this->pos; |
||
2216 | $matcher = 'match_'.'OpenBlock'; $key = $matcher; $pos = $this->pos; |
||
2217 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2218 | if ($subres !== FALSE) { |
||
2219 | $this->store( $result, $subres ); |
||
2220 | $_331 = TRUE; break; |
||
2221 | } |
||
2222 | $result = $res_320; |
||
2223 | $this->pos = $pos_320; |
||
2224 | $_329 = NULL; |
||
2225 | do { |
||
2226 | $res_322 = $result; |
||
2227 | $pos_322 = $this->pos; |
||
2228 | $matcher = 'match_'.'MalformedBlock'; $key = $matcher; $pos = $this->pos; |
||
2229 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2230 | if ($subres !== FALSE) { |
||
2231 | $this->store( $result, $subres ); |
||
2232 | $_329 = TRUE; break; |
||
2233 | } |
||
2234 | $result = $res_322; |
||
2235 | $this->pos = $pos_322; |
||
2236 | $_327 = NULL; |
||
2237 | do { |
||
2238 | $res_324 = $result; |
||
2239 | $pos_324 = $this->pos; |
||
2240 | $matcher = 'match_'.'Injection'; $key = $matcher; $pos = $this->pos; |
||
2241 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2242 | if ($subres !== FALSE) { |
||
2243 | $this->store( $result, $subres ); |
||
2244 | $_327 = TRUE; break; |
||
2245 | } |
||
2246 | $result = $res_324; |
||
2247 | $this->pos = $pos_324; |
||
2248 | $matcher = 'match_'.'Text'; $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 | $_327 = TRUE; break; |
||
2253 | } |
||
2254 | $result = $res_324; |
||
2255 | $this->pos = $pos_324; |
||
2256 | $_327 = FALSE; break; |
||
2257 | } |
||
2258 | while(0); |
||
2259 | if( $_327 === TRUE ) { $_329 = TRUE; break; } |
||
2260 | $result = $res_322; |
||
2261 | $this->pos = $pos_322; |
||
2262 | $_329 = FALSE; break; |
||
2263 | } |
||
2264 | while(0); |
||
2265 | if( $_329 === TRUE ) { $_331 = TRUE; break; } |
||
2266 | $result = $res_320; |
||
2267 | $this->pos = $pos_320; |
||
2268 | $_331 = FALSE; break; |
||
2269 | } |
||
2270 | while(0); |
||
2271 | if( $_331 === TRUE ) { $_333 = TRUE; break; } |
||
2272 | $result = $res_318; |
||
2273 | $this->pos = $pos_318; |
||
2274 | $_333 = FALSE; break; |
||
2275 | } |
||
2276 | while(0); |
||
2277 | if( $_333 === TRUE ) { $_335 = TRUE; break; } |
||
2278 | $result = $res_316; |
||
2279 | $this->pos = $pos_316; |
||
2280 | $_335 = FALSE; break; |
||
2281 | } |
||
2282 | while(0); |
||
2283 | if( $_335 === TRUE ) { $_337 = TRUE; break; } |
||
2284 | $result = $res_314; |
||
2285 | $this->pos = $pos_314; |
||
2286 | $_337 = FALSE; break; |
||
2287 | } |
||
2288 | while(0); |
||
2289 | if( $_337 === TRUE ) { $_339 = TRUE; break; } |
||
2290 | $result = $res_312; |
||
2291 | $this->pos = $pos_312; |
||
2292 | $_339 = FALSE; break; |
||
2293 | } |
||
2294 | while(0); |
||
2295 | if( $_339 === TRUE ) { $_341 = TRUE; break; } |
||
2296 | $result = $res_310; |
||
2297 | $this->pos = $pos_310; |
||
2298 | $_341 = FALSE; break; |
||
2299 | } |
||
2300 | while(0); |
||
2301 | if( $_341 === TRUE ) { $_343 = TRUE; break; } |
||
2302 | $result = $res_308; |
||
2303 | $this->pos = $pos_308; |
||
2304 | $_343 = FALSE; break; |
||
2305 | } |
||
2306 | while(0); |
||
2307 | if( $_343 === TRUE ) { $_345 = TRUE; break; } |
||
2308 | $result = $res_306; |
||
2309 | $this->pos = $pos_306; |
||
2310 | $_345 = FALSE; break; |
||
2311 | } |
||
2312 | while(0); |
||
2313 | if( $_345 === FALSE) { $_347 = FALSE; break; } |
||
2314 | $_347 = TRUE; break; |
||
2315 | } |
||
2316 | while(0); |
||
2317 | if( $_347 === FALSE) { |
||
2318 | $result = $res_348; |
||
2319 | $this->pos = $pos_348; |
||
2320 | unset( $res_348 ); |
||
2321 | unset( $pos_348 ); |
||
2322 | break; |
||
2323 | } |
||
2324 | $count += 1; |
||
2325 | } |
||
2326 | if ($count > 0) { return $this->finalise($result); } |
||
2327 | else { return FALSE; } |
||
2328 | } |
||
2329 | |||
2330 | |||
2331 | |||
2332 | |||
2333 | /* UncachedBlock: |
||
2334 | '<%' < "uncached" < CacheBlockArguments? ( < Conditional:("if"|"unless") > Condition:IfArgument )? > '%>' |
||
2335 | Template:$TemplateMatcher? |
||
2336 | '<%' < 'end_' ("uncached"|"cached"|"cacheblock") > '%>' */ |
||
2337 | protected $match_UncachedBlock_typestack = array('UncachedBlock'); |
||
2338 | function match_UncachedBlock ($stack = array()) { |
||
2339 | $matchrule = "UncachedBlock"; $result = $this->construct($matchrule, $matchrule, null); |
||
2340 | $_385 = NULL; |
||
2341 | do { |
||
2342 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2343 | else { $_385 = FALSE; break; } |
||
2344 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2345 | if (( $subres = $this->literal( 'uncached' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2346 | else { $_385 = FALSE; break; } |
||
2347 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2348 | $res_353 = $result; |
||
2349 | $pos_353 = $this->pos; |
||
2350 | $matcher = 'match_'.'CacheBlockArguments'; $key = $matcher; $pos = $this->pos; |
||
2351 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2352 | if ($subres !== FALSE) { |
||
2353 | $this->store( $result, $subres ); |
||
2354 | } |
||
2355 | else { |
||
2356 | $result = $res_353; |
||
2357 | $this->pos = $pos_353; |
||
2358 | unset( $res_353 ); |
||
2359 | unset( $pos_353 ); |
||
2360 | } |
||
2361 | $res_365 = $result; |
||
2362 | $pos_365 = $this->pos; |
||
2363 | $_364 = NULL; |
||
2364 | do { |
||
2365 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2366 | $stack[] = $result; $result = $this->construct( $matchrule, "Conditional" ); |
||
2367 | $_360 = NULL; |
||
2368 | do { |
||
2369 | $_358 = NULL; |
||
2370 | do { |
||
2371 | $res_355 = $result; |
||
2372 | $pos_355 = $this->pos; |
||
2373 | if (( $subres = $this->literal( 'if' ) ) !== FALSE) { |
||
2374 | $result["text"] .= $subres; |
||
2375 | $_358 = TRUE; break; |
||
2376 | } |
||
2377 | $result = $res_355; |
||
2378 | $this->pos = $pos_355; |
||
2379 | if (( $subres = $this->literal( 'unless' ) ) !== FALSE) { |
||
2380 | $result["text"] .= $subres; |
||
2381 | $_358 = TRUE; break; |
||
2382 | } |
||
2383 | $result = $res_355; |
||
2384 | $this->pos = $pos_355; |
||
2385 | $_358 = FALSE; break; |
||
2386 | } |
||
2387 | while(0); |
||
2388 | if( $_358 === FALSE) { $_360 = FALSE; break; } |
||
2389 | $_360 = TRUE; break; |
||
2390 | } |
||
2391 | while(0); |
||
2392 | if( $_360 === TRUE ) { |
||
2393 | $subres = $result; $result = array_pop($stack); |
||
2394 | $this->store( $result, $subres, 'Conditional' ); |
||
2395 | } |
||
2396 | if( $_360 === FALSE) { |
||
2397 | $result = array_pop($stack); |
||
2398 | $_364 = FALSE; break; |
||
2399 | } |
||
2400 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2401 | $matcher = 'match_'.'IfArgument'; $key = $matcher; $pos = $this->pos; |
||
2402 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2403 | if ($subres !== FALSE) { |
||
2404 | $this->store( $result, $subres, "Condition" ); |
||
2405 | } |
||
2406 | else { $_364 = FALSE; break; } |
||
2407 | $_364 = TRUE; break; |
||
2408 | } |
||
2409 | while(0); |
||
2410 | if( $_364 === FALSE) { |
||
2411 | $result = $res_365; |
||
2412 | $this->pos = $pos_365; |
||
2413 | unset( $res_365 ); |
||
2414 | unset( $pos_365 ); |
||
2415 | } |
||
2416 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2417 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2418 | else { $_385 = FALSE; break; } |
||
2419 | $res_368 = $result; |
||
2420 | $pos_368 = $this->pos; |
||
2421 | $matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $key = $matcher; $pos = $this->pos; |
||
2422 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2423 | if ($subres !== FALSE) { |
||
2424 | $this->store( $result, $subres, "Template" ); |
||
2425 | } |
||
2426 | else { |
||
2427 | $result = $res_368; |
||
2428 | $this->pos = $pos_368; |
||
2429 | unset( $res_368 ); |
||
2430 | unset( $pos_368 ); |
||
2431 | } |
||
2432 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2433 | else { $_385 = FALSE; break; } |
||
2434 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2435 | if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2436 | else { $_385 = FALSE; break; } |
||
2437 | $_381 = NULL; |
||
2438 | do { |
||
2439 | $_379 = NULL; |
||
2440 | do { |
||
2441 | $res_372 = $result; |
||
2442 | $pos_372 = $this->pos; |
||
2443 | if (( $subres = $this->literal( 'uncached' ) ) !== FALSE) { |
||
2444 | $result["text"] .= $subres; |
||
2445 | $_379 = TRUE; break; |
||
2446 | } |
||
2447 | $result = $res_372; |
||
2448 | $this->pos = $pos_372; |
||
2449 | $_377 = NULL; |
||
2450 | do { |
||
2451 | $res_374 = $result; |
||
2452 | $pos_374 = $this->pos; |
||
2453 | if (( $subres = $this->literal( 'cached' ) ) !== FALSE) { |
||
2454 | $result["text"] .= $subres; |
||
2455 | $_377 = TRUE; break; |
||
2456 | } |
||
2457 | $result = $res_374; |
||
2458 | $this->pos = $pos_374; |
||
2459 | if (( $subres = $this->literal( 'cacheblock' ) ) !== FALSE) { |
||
2460 | $result["text"] .= $subres; |
||
2461 | $_377 = TRUE; break; |
||
2462 | } |
||
2463 | $result = $res_374; |
||
2464 | $this->pos = $pos_374; |
||
2465 | $_377 = FALSE; break; |
||
2466 | } |
||
2467 | while(0); |
||
2468 | if( $_377 === TRUE ) { $_379 = TRUE; break; } |
||
2469 | $result = $res_372; |
||
2470 | $this->pos = $pos_372; |
||
2471 | $_379 = FALSE; break; |
||
2472 | } |
||
2473 | while(0); |
||
2474 | if( $_379 === FALSE) { $_381 = FALSE; break; } |
||
2475 | $_381 = TRUE; break; |
||
2476 | } |
||
2477 | while(0); |
||
2478 | if( $_381 === FALSE) { $_385 = FALSE; break; } |
||
2479 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2480 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2481 | else { $_385 = FALSE; break; } |
||
2482 | $_385 = TRUE; break; |
||
2483 | } |
||
2484 | while(0); |
||
2485 | if( $_385 === TRUE ) { return $this->finalise($result); } |
||
2486 | if( $_385 === FALSE) { return FALSE; } |
||
2487 | } |
||
2488 | |||
2489 | |||
2490 | |||
2491 | function UncachedBlock_Template(&$res, $sub) |
||
2492 | { |
||
2493 | $res['php'] = $sub['php']; |
||
2494 | } |
||
2495 | |||
2496 | /* CacheRestrictedTemplate: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock | |
||
2497 | OpenBlock | MalformedBlock | Injection | Text)+ */ |
||
2498 | protected $match_CacheRestrictedTemplate_typestack = array('CacheRestrictedTemplate','Template'); |
||
2499 | function match_CacheRestrictedTemplate ($stack = array()) { |
||
2500 | $matchrule = "CacheRestrictedTemplate"; $result = $this->construct($matchrule, $matchrule, null); |
||
2501 | $count = 0; |
||
2502 | while (true) { |
||
2503 | $res_437 = $result; |
||
2504 | $pos_437 = $this->pos; |
||
2505 | $_436 = NULL; |
||
2506 | do { |
||
2507 | $_434 = NULL; |
||
2508 | do { |
||
2509 | $res_387 = $result; |
||
2510 | $pos_387 = $this->pos; |
||
2511 | $matcher = 'match_'.'Comment'; $key = $matcher; $pos = $this->pos; |
||
2512 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2513 | if ($subres !== FALSE) { |
||
2514 | $this->store( $result, $subres ); |
||
2515 | $_434 = TRUE; break; |
||
2516 | } |
||
2517 | $result = $res_387; |
||
2518 | $this->pos = $pos_387; |
||
2519 | $_432 = NULL; |
||
2520 | do { |
||
2521 | $res_389 = $result; |
||
2522 | $pos_389 = $this->pos; |
||
2523 | $matcher = 'match_'.'Translate'; $key = $matcher; $pos = $this->pos; |
||
2524 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2525 | if ($subres !== FALSE) { |
||
2526 | $this->store( $result, $subres ); |
||
2527 | $_432 = TRUE; break; |
||
2528 | } |
||
2529 | $result = $res_389; |
||
2530 | $this->pos = $pos_389; |
||
2531 | $_430 = NULL; |
||
2532 | do { |
||
2533 | $res_391 = $result; |
||
2534 | $pos_391 = $this->pos; |
||
2535 | $matcher = 'match_'.'If'; $key = $matcher; $pos = $this->pos; |
||
2536 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2537 | if ($subres !== FALSE) { |
||
2538 | $this->store( $result, $subres ); |
||
2539 | $_430 = TRUE; break; |
||
2540 | } |
||
2541 | $result = $res_391; |
||
2542 | $this->pos = $pos_391; |
||
2543 | $_428 = NULL; |
||
2544 | do { |
||
2545 | $res_393 = $result; |
||
2546 | $pos_393 = $this->pos; |
||
2547 | $matcher = 'match_'.'Require'; $key = $matcher; $pos = $this->pos; |
||
2548 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2549 | if ($subres !== FALSE) { |
||
2550 | $this->store( $result, $subres ); |
||
2551 | $_428 = TRUE; break; |
||
2552 | } |
||
2553 | $result = $res_393; |
||
2554 | $this->pos = $pos_393; |
||
2555 | $_426 = NULL; |
||
2556 | do { |
||
2557 | $res_395 = $result; |
||
2558 | $pos_395 = $this->pos; |
||
2559 | $matcher = 'match_'.'CacheBlock'; $key = $matcher; $pos = $this->pos; |
||
2560 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2561 | if ($subres !== FALSE) { |
||
2562 | $this->store( $result, $subres ); |
||
2563 | $_426 = TRUE; break; |
||
2564 | } |
||
2565 | $result = $res_395; |
||
2566 | $this->pos = $pos_395; |
||
2567 | $_424 = NULL; |
||
2568 | do { |
||
2569 | $res_397 = $result; |
||
2570 | $pos_397 = $this->pos; |
||
2571 | $matcher = 'match_'.'UncachedBlock'; $key = $matcher; $pos = $this->pos; |
||
2572 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2573 | if ($subres !== FALSE) { |
||
2574 | $this->store( $result, $subres ); |
||
2575 | $_424 = TRUE; break; |
||
2576 | } |
||
2577 | $result = $res_397; |
||
2578 | $this->pos = $pos_397; |
||
2579 | $_422 = NULL; |
||
2580 | do { |
||
2581 | $res_399 = $result; |
||
2582 | $pos_399 = $this->pos; |
||
2583 | $matcher = 'match_'.'OldI18NTag'; $key = $matcher; $pos = $this->pos; |
||
2584 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2585 | if ($subres !== FALSE) { |
||
2586 | $this->store( $result, $subres ); |
||
2587 | $_422 = TRUE; break; |
||
2588 | } |
||
2589 | $result = $res_399; |
||
2590 | $this->pos = $pos_399; |
||
2591 | $_420 = NULL; |
||
2592 | do { |
||
2593 | $res_401 = $result; |
||
2594 | $pos_401 = $this->pos; |
||
2595 | $matcher = 'match_'.'Include'; $key = $matcher; $pos = $this->pos; |
||
2596 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2597 | if ($subres !== FALSE) { |
||
2598 | $this->store( $result, $subres ); |
||
2599 | $_420 = TRUE; break; |
||
2600 | } |
||
2601 | $result = $res_401; |
||
2602 | $this->pos = $pos_401; |
||
2603 | $_418 = NULL; |
||
2604 | do { |
||
2605 | $res_403 = $result; |
||
2606 | $pos_403 = $this->pos; |
||
2607 | $matcher = 'match_'.'ClosedBlock'; $key = $matcher; $pos = $this->pos; |
||
2608 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2609 | if ($subres !== FALSE) { |
||
2610 | $this->store( $result, $subres ); |
||
2611 | $_418 = TRUE; break; |
||
2612 | } |
||
2613 | $result = $res_403; |
||
2614 | $this->pos = $pos_403; |
||
2615 | $_416 = NULL; |
||
2616 | do { |
||
2617 | $res_405 = $result; |
||
2618 | $pos_405 = $this->pos; |
||
2619 | $matcher = 'match_'.'OpenBlock'; $key = $matcher; $pos = $this->pos; |
||
2620 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2621 | if ($subres !== FALSE) { |
||
2622 | $this->store( $result, $subres ); |
||
2623 | $_416 = TRUE; break; |
||
2624 | } |
||
2625 | $result = $res_405; |
||
2626 | $this->pos = $pos_405; |
||
2627 | $_414 = NULL; |
||
2628 | do { |
||
2629 | $res_407 = $result; |
||
2630 | $pos_407 = $this->pos; |
||
2631 | $matcher = 'match_'.'MalformedBlock'; $key = $matcher; $pos = $this->pos; |
||
2632 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2633 | if ($subres !== FALSE) { |
||
2634 | $this->store( $result, $subres ); |
||
2635 | $_414 = TRUE; break; |
||
2636 | } |
||
2637 | $result = $res_407; |
||
2638 | $this->pos = $pos_407; |
||
2639 | $_412 = NULL; |
||
2640 | do { |
||
2641 | $res_409 = $result; |
||
2642 | $pos_409 = $this->pos; |
||
2643 | $matcher = 'match_'.'Injection'; $key = $matcher; $pos = $this->pos; |
||
2644 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2645 | if ($subres !== FALSE) { |
||
2646 | $this->store( $result, $subres ); |
||
2647 | $_412 = TRUE; break; |
||
2648 | } |
||
2649 | $result = $res_409; |
||
2650 | $this->pos = $pos_409; |
||
2651 | $matcher = 'match_'.'Text'; $key = $matcher; $pos = $this->pos; |
||
2652 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2653 | if ($subres !== FALSE) { |
||
2654 | $this->store( $result, $subres ); |
||
2655 | $_412 = TRUE; break; |
||
2656 | } |
||
2657 | $result = $res_409; |
||
2658 | $this->pos = $pos_409; |
||
2659 | $_412 = FALSE; break; |
||
2660 | } |
||
2661 | while(0); |
||
2662 | if( $_412 === TRUE ) { $_414 = TRUE; break; } |
||
2663 | $result = $res_407; |
||
2664 | $this->pos = $pos_407; |
||
2665 | $_414 = FALSE; break; |
||
2666 | } |
||
2667 | while(0); |
||
2668 | if( $_414 === TRUE ) { $_416 = TRUE; break; } |
||
2669 | $result = $res_405; |
||
2670 | $this->pos = $pos_405; |
||
2671 | $_416 = FALSE; break; |
||
2672 | } |
||
2673 | while(0); |
||
2674 | if( $_416 === TRUE ) { $_418 = TRUE; break; } |
||
2675 | $result = $res_403; |
||
2676 | $this->pos = $pos_403; |
||
2677 | $_418 = FALSE; break; |
||
2678 | } |
||
2679 | while(0); |
||
2680 | if( $_418 === TRUE ) { $_420 = TRUE; break; } |
||
2681 | $result = $res_401; |
||
2682 | $this->pos = $pos_401; |
||
2683 | $_420 = FALSE; break; |
||
2684 | } |
||
2685 | while(0); |
||
2686 | if( $_420 === TRUE ) { $_422 = TRUE; break; } |
||
2687 | $result = $res_399; |
||
2688 | $this->pos = $pos_399; |
||
2689 | $_422 = FALSE; break; |
||
2690 | } |
||
2691 | while(0); |
||
2692 | if( $_422 === TRUE ) { $_424 = TRUE; break; } |
||
2693 | $result = $res_397; |
||
2694 | $this->pos = $pos_397; |
||
2695 | $_424 = FALSE; break; |
||
2696 | } |
||
2697 | while(0); |
||
2698 | if( $_424 === TRUE ) { $_426 = TRUE; break; } |
||
2699 | $result = $res_395; |
||
2700 | $this->pos = $pos_395; |
||
2701 | $_426 = FALSE; break; |
||
2702 | } |
||
2703 | while(0); |
||
2704 | if( $_426 === TRUE ) { $_428 = TRUE; break; } |
||
2705 | $result = $res_393; |
||
2706 | $this->pos = $pos_393; |
||
2707 | $_428 = FALSE; break; |
||
2708 | } |
||
2709 | while(0); |
||
2710 | if( $_428 === TRUE ) { $_430 = TRUE; break; } |
||
2711 | $result = $res_391; |
||
2712 | $this->pos = $pos_391; |
||
2713 | $_430 = FALSE; break; |
||
2714 | } |
||
2715 | while(0); |
||
2716 | if( $_430 === TRUE ) { $_432 = TRUE; break; } |
||
2717 | $result = $res_389; |
||
2718 | $this->pos = $pos_389; |
||
2719 | $_432 = FALSE; break; |
||
2720 | } |
||
2721 | while(0); |
||
2722 | if( $_432 === TRUE ) { $_434 = TRUE; break; } |
||
2723 | $result = $res_387; |
||
2724 | $this->pos = $pos_387; |
||
2725 | $_434 = FALSE; break; |
||
2726 | } |
||
2727 | while(0); |
||
2728 | if( $_434 === FALSE) { $_436 = FALSE; break; } |
||
2729 | $_436 = TRUE; break; |
||
2730 | } |
||
2731 | while(0); |
||
2732 | if( $_436 === FALSE) { |
||
2733 | $result = $res_437; |
||
2734 | $this->pos = $pos_437; |
||
2735 | unset( $res_437 ); |
||
2736 | unset( $pos_437 ); |
||
2737 | break; |
||
2738 | } |
||
2739 | $count += 1; |
||
2740 | } |
||
2741 | if ($count > 0) { return $this->finalise($result); } |
||
2742 | else { return FALSE; } |
||
2743 | } |
||
2744 | |||
2745 | |||
2746 | |||
2747 | function CacheRestrictedTemplate_CacheBlock(&$res, $sub) |
||
2748 | { |
||
2749 | throw new SSTemplateParseException('You cant have cache blocks nested within with, loop or control blocks ' . |
||
2750 | 'that are within cache blocks', $this); |
||
2751 | } |
||
2752 | |||
2753 | function CacheRestrictedTemplate_UncachedBlock(&$res, $sub) |
||
2754 | { |
||
2755 | throw new SSTemplateParseException('You cant have uncache blocks nested within with, loop or control blocks ' . |
||
2756 | 'that are within cache blocks', $this); |
||
2757 | } |
||
2758 | |||
2759 | /* CacheBlock: |
||
2760 | '<%' < CacheTag:("cached"|"cacheblock") < (CacheBlockArguments)? ( < Conditional:("if"|"unless") > |
||
2761 | Condition:IfArgument )? > '%>' |
||
2762 | (CacheBlock | UncachedBlock | CacheBlockTemplate)* |
||
2763 | '<%' < 'end_' ("cached"|"uncached"|"cacheblock") > '%>' */ |
||
2764 | protected $match_CacheBlock_typestack = array('CacheBlock'); |
||
2765 | function match_CacheBlock ($stack = array()) { |
||
2766 | $matchrule = "CacheBlock"; $result = $this->construct($matchrule, $matchrule, null); |
||
2767 | $_492 = NULL; |
||
2768 | do { |
||
2769 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2770 | else { $_492 = FALSE; break; } |
||
2771 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2772 | $stack[] = $result; $result = $this->construct( $matchrule, "CacheTag" ); |
||
2773 | $_445 = NULL; |
||
2774 | do { |
||
2775 | $_443 = NULL; |
||
2776 | do { |
||
2777 | $res_440 = $result; |
||
2778 | $pos_440 = $this->pos; |
||
2779 | if (( $subres = $this->literal( 'cached' ) ) !== FALSE) { |
||
2780 | $result["text"] .= $subres; |
||
2781 | $_443 = TRUE; break; |
||
2782 | } |
||
2783 | $result = $res_440; |
||
2784 | $this->pos = $pos_440; |
||
2785 | if (( $subres = $this->literal( 'cacheblock' ) ) !== FALSE) { |
||
2786 | $result["text"] .= $subres; |
||
2787 | $_443 = TRUE; break; |
||
2788 | } |
||
2789 | $result = $res_440; |
||
2790 | $this->pos = $pos_440; |
||
2791 | $_443 = FALSE; break; |
||
2792 | } |
||
2793 | while(0); |
||
2794 | if( $_443 === FALSE) { $_445 = FALSE; break; } |
||
2795 | $_445 = TRUE; break; |
||
2796 | } |
||
2797 | while(0); |
||
2798 | if( $_445 === TRUE ) { |
||
2799 | $subres = $result; $result = array_pop($stack); |
||
2800 | $this->store( $result, $subres, 'CacheTag' ); |
||
2801 | } |
||
2802 | if( $_445 === FALSE) { |
||
2803 | $result = array_pop($stack); |
||
2804 | $_492 = FALSE; break; |
||
2805 | } |
||
2806 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2807 | $res_450 = $result; |
||
2808 | $pos_450 = $this->pos; |
||
2809 | $_449 = NULL; |
||
2810 | do { |
||
2811 | $matcher = 'match_'.'CacheBlockArguments'; $key = $matcher; $pos = $this->pos; |
||
2812 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2813 | if ($subres !== FALSE) { |
||
2814 | $this->store( $result, $subres ); |
||
2815 | } |
||
2816 | else { $_449 = FALSE; break; } |
||
2817 | $_449 = TRUE; break; |
||
2818 | } |
||
2819 | while(0); |
||
2820 | if( $_449 === FALSE) { |
||
2821 | $result = $res_450; |
||
2822 | $this->pos = $pos_450; |
||
2823 | unset( $res_450 ); |
||
2824 | unset( $pos_450 ); |
||
2825 | } |
||
2826 | $res_462 = $result; |
||
2827 | $pos_462 = $this->pos; |
||
2828 | $_461 = NULL; |
||
2829 | do { |
||
2830 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2831 | $stack[] = $result; $result = $this->construct( $matchrule, "Conditional" ); |
||
2832 | $_457 = NULL; |
||
2833 | do { |
||
2834 | $_455 = NULL; |
||
2835 | do { |
||
2836 | $res_452 = $result; |
||
2837 | $pos_452 = $this->pos; |
||
2838 | if (( $subres = $this->literal( 'if' ) ) !== FALSE) { |
||
2839 | $result["text"] .= $subres; |
||
2840 | $_455 = TRUE; break; |
||
2841 | } |
||
2842 | $result = $res_452; |
||
2843 | $this->pos = $pos_452; |
||
2844 | if (( $subres = $this->literal( 'unless' ) ) !== FALSE) { |
||
2845 | $result["text"] .= $subres; |
||
2846 | $_455 = TRUE; break; |
||
2847 | } |
||
2848 | $result = $res_452; |
||
2849 | $this->pos = $pos_452; |
||
2850 | $_455 = FALSE; break; |
||
2851 | } |
||
2852 | while(0); |
||
2853 | if( $_455 === FALSE) { $_457 = FALSE; break; } |
||
2854 | $_457 = TRUE; break; |
||
2855 | } |
||
2856 | while(0); |
||
2857 | if( $_457 === TRUE ) { |
||
2858 | $subres = $result; $result = array_pop($stack); |
||
2859 | $this->store( $result, $subres, 'Conditional' ); |
||
2860 | } |
||
2861 | if( $_457 === FALSE) { |
||
2862 | $result = array_pop($stack); |
||
2863 | $_461 = FALSE; break; |
||
2864 | } |
||
2865 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2866 | $matcher = 'match_'.'IfArgument'; $key = $matcher; $pos = $this->pos; |
||
2867 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2868 | if ($subres !== FALSE) { |
||
2869 | $this->store( $result, $subres, "Condition" ); |
||
2870 | } |
||
2871 | else { $_461 = FALSE; break; } |
||
2872 | $_461 = TRUE; break; |
||
2873 | } |
||
2874 | while(0); |
||
2875 | if( $_461 === FALSE) { |
||
2876 | $result = $res_462; |
||
2877 | $this->pos = $pos_462; |
||
2878 | unset( $res_462 ); |
||
2879 | unset( $pos_462 ); |
||
2880 | } |
||
2881 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2882 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2883 | else { $_492 = FALSE; break; } |
||
2884 | while (true) { |
||
2885 | $res_475 = $result; |
||
2886 | $pos_475 = $this->pos; |
||
2887 | $_474 = NULL; |
||
2888 | do { |
||
2889 | $_472 = NULL; |
||
2890 | do { |
||
2891 | $res_465 = $result; |
||
2892 | $pos_465 = $this->pos; |
||
2893 | $matcher = 'match_'.'CacheBlock'; $key = $matcher; $pos = $this->pos; |
||
2894 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2895 | if ($subres !== FALSE) { |
||
2896 | $this->store( $result, $subres ); |
||
2897 | $_472 = TRUE; break; |
||
2898 | } |
||
2899 | $result = $res_465; |
||
2900 | $this->pos = $pos_465; |
||
2901 | $_470 = NULL; |
||
2902 | do { |
||
2903 | $res_467 = $result; |
||
2904 | $pos_467 = $this->pos; |
||
2905 | $matcher = 'match_'.'UncachedBlock'; $key = $matcher; $pos = $this->pos; |
||
2906 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2907 | if ($subres !== FALSE) { |
||
2908 | $this->store( $result, $subres ); |
||
2909 | $_470 = TRUE; break; |
||
2910 | } |
||
2911 | $result = $res_467; |
||
2912 | $this->pos = $pos_467; |
||
2913 | $matcher = 'match_'.'CacheBlockTemplate'; $key = $matcher; $pos = $this->pos; |
||
2914 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
2915 | if ($subres !== FALSE) { |
||
2916 | $this->store( $result, $subres ); |
||
2917 | $_470 = TRUE; break; |
||
2918 | } |
||
2919 | $result = $res_467; |
||
2920 | $this->pos = $pos_467; |
||
2921 | $_470 = FALSE; break; |
||
2922 | } |
||
2923 | while(0); |
||
2924 | if( $_470 === TRUE ) { $_472 = TRUE; break; } |
||
2925 | $result = $res_465; |
||
2926 | $this->pos = $pos_465; |
||
2927 | $_472 = FALSE; break; |
||
2928 | } |
||
2929 | while(0); |
||
2930 | if( $_472 === FALSE) { $_474 = FALSE; break; } |
||
2931 | $_474 = TRUE; break; |
||
2932 | } |
||
2933 | while(0); |
||
2934 | if( $_474 === FALSE) { |
||
2935 | $result = $res_475; |
||
2936 | $this->pos = $pos_475; |
||
2937 | unset( $res_475 ); |
||
2938 | unset( $pos_475 ); |
||
2939 | break; |
||
2940 | } |
||
2941 | } |
||
2942 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2943 | else { $_492 = FALSE; break; } |
||
2944 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2945 | if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2946 | else { $_492 = FALSE; break; } |
||
2947 | $_488 = NULL; |
||
2948 | do { |
||
2949 | $_486 = NULL; |
||
2950 | do { |
||
2951 | $res_479 = $result; |
||
2952 | $pos_479 = $this->pos; |
||
2953 | if (( $subres = $this->literal( 'cached' ) ) !== FALSE) { |
||
2954 | $result["text"] .= $subres; |
||
2955 | $_486 = TRUE; break; |
||
2956 | } |
||
2957 | $result = $res_479; |
||
2958 | $this->pos = $pos_479; |
||
2959 | $_484 = NULL; |
||
2960 | do { |
||
2961 | $res_481 = $result; |
||
2962 | $pos_481 = $this->pos; |
||
2963 | if (( $subres = $this->literal( 'uncached' ) ) !== FALSE) { |
||
2964 | $result["text"] .= $subres; |
||
2965 | $_484 = TRUE; break; |
||
2966 | } |
||
2967 | $result = $res_481; |
||
2968 | $this->pos = $pos_481; |
||
2969 | if (( $subres = $this->literal( 'cacheblock' ) ) !== FALSE) { |
||
2970 | $result["text"] .= $subres; |
||
2971 | $_484 = TRUE; break; |
||
2972 | } |
||
2973 | $result = $res_481; |
||
2974 | $this->pos = $pos_481; |
||
2975 | $_484 = FALSE; break; |
||
2976 | } |
||
2977 | while(0); |
||
2978 | if( $_484 === TRUE ) { $_486 = TRUE; break; } |
||
2979 | $result = $res_479; |
||
2980 | $this->pos = $pos_479; |
||
2981 | $_486 = FALSE; break; |
||
2982 | } |
||
2983 | while(0); |
||
2984 | if( $_486 === FALSE) { $_488 = FALSE; break; } |
||
2985 | $_488 = TRUE; break; |
||
2986 | } |
||
2987 | while(0); |
||
2988 | if( $_488 === FALSE) { $_492 = FALSE; break; } |
||
2989 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2990 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
2991 | else { $_492 = FALSE; break; } |
||
2992 | $_492 = TRUE; break; |
||
2993 | } |
||
2994 | while(0); |
||
2995 | if( $_492 === TRUE ) { return $this->finalise($result); } |
||
2996 | if( $_492 === FALSE) { return FALSE; } |
||
2997 | } |
||
2998 | |||
2999 | |||
3000 | |||
3001 | function CacheBlock__construct(&$res) |
||
3002 | { |
||
3003 | $res['subblocks'] = 0; |
||
3004 | } |
||
3005 | |||
3006 | function CacheBlock_CacheBlockArguments(&$res, $sub) |
||
3009 | } |
||
3010 | |||
3011 | function CacheBlock_Condition(&$res, $sub) |
||
3012 | { |
||
3013 | $res['condition'] = ($res['Conditional']['text'] == 'if' ? '(' : '!(') . $sub['php'] . ') && '; |
||
3014 | } |
||
3015 | |||
3016 | function CacheBlock_CacheBlock(&$res, $sub) |
||
3017 | { |
||
3018 | $res['php'] .= $sub['php']; |
||
3019 | } |
||
3020 | |||
3021 | function CacheBlock_UncachedBlock(&$res, $sub) |
||
3022 | { |
||
3023 | $res['php'] .= $sub['php']; |
||
3024 | } |
||
3025 | |||
3026 | function CacheBlock_CacheBlockTemplate(&$res, $sub) |
||
3027 | { |
||
3028 | // Get the block counter |
||
3029 | $block = ++$res['subblocks']; |
||
3030 | // Build the key for this block from the global key (evaluated in a closure within the template), |
||
3031 | // the passed cache key, the block index, and the sha hash of the template. |
||
3032 | $res['php'] .= '$keyExpression = function() use ($scope, $cache) {' . PHP_EOL; |
||
3033 | $res['php'] .= '$val = \'\';' . PHP_EOL; |
||
3034 | if ($globalKey = SSViewer::config()->get('global_key')) { |
||
3035 | // Embed the code necessary to evaluate the globalKey directly into the template, |
||
3036 | // so that SSTemplateParser only needs to be called during template regeneration. |
||
3037 | // Warning: If the global key is changed, it's necessary to flush the template cache. |
||
3038 | $parser = Injector::inst()->get(__CLASS__, false); |
||
3039 | $result = $parser->compileString($globalKey, '', false, false); |
||
3040 | if (!$result) { |
||
3041 | throw new SSTemplateParseException('Unexpected problem parsing template', $parser); |
||
3042 | } |
||
3043 | $res['php'] .= $result . PHP_EOL; |
||
3044 | } |
||
3045 | $res['php'] .= 'return $val;' . PHP_EOL; |
||
3046 | $res['php'] .= '};' . PHP_EOL; |
||
3047 | $key = 'sha1($keyExpression())' // Global key |
||
3048 | . '.\'_' . sha1($sub['php']) // sha of template |
||
3049 | . (isset($res['key']) && $res['key'] ? "_'.sha1(".$res['key'].")" : "'") // Passed key |
||
3050 | . ".'_$block'"; // block index |
||
3051 | // Get any condition |
||
3052 | $condition = isset($res['condition']) ? $res['condition'] : ''; |
||
3053 | |||
3054 | $res['php'] .= 'if ('.$condition.'($partial = $cache->get('.$key.'))) $val .= $partial;' . PHP_EOL; |
||
3055 | $res['php'] .= 'else { $oldval = $val; $val = "";' . PHP_EOL; |
||
3056 | $res['php'] .= $sub['php'] . PHP_EOL; |
||
3057 | $res['php'] .= $condition . ' $cache->set('.$key.', $val); $val = $oldval . $val;' . PHP_EOL; |
||
3058 | $res['php'] .= '}'; |
||
3059 | } |
||
3060 | |||
3061 | /* OldTPart: "_t" N "(" N QuotedString (N "," N CallArguments)? N ")" N (";")? */ |
||
3062 | protected $match_OldTPart_typestack = array('OldTPart'); |
||
3063 | function match_OldTPart ($stack = array()) { |
||
3064 | $matchrule = "OldTPart"; $result = $this->construct($matchrule, $matchrule, null); |
||
3065 | $_511 = NULL; |
||
3066 | do { |
||
3067 | if (( $subres = $this->literal( '_t' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3068 | else { $_511 = FALSE; break; } |
||
3069 | $matcher = 'match_'.'N'; $key = $matcher; $pos = $this->pos; |
||
3070 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3071 | if ($subres !== FALSE) { |
||
3072 | $this->store( $result, $subres ); |
||
3073 | } |
||
3074 | else { $_511 = FALSE; break; } |
||
3075 | if (substr($this->string,$this->pos,1) == '(') { |
||
3076 | $this->pos += 1; |
||
3077 | $result["text"] .= '('; |
||
3078 | } |
||
3079 | else { $_511 = FALSE; break; } |
||
3080 | $matcher = 'match_'.'N'; $key = $matcher; $pos = $this->pos; |
||
3081 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3082 | if ($subres !== FALSE) { |
||
3083 | $this->store( $result, $subres ); |
||
3084 | } |
||
3085 | else { $_511 = FALSE; break; } |
||
3086 | $matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos; |
||
3087 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3088 | if ($subres !== FALSE) { |
||
3089 | $this->store( $result, $subres ); |
||
3090 | } |
||
3091 | else { $_511 = FALSE; break; } |
||
3092 | $res_504 = $result; |
||
3093 | $pos_504 = $this->pos; |
||
3094 | $_503 = NULL; |
||
3095 | do { |
||
3096 | $matcher = 'match_'.'N'; $key = $matcher; $pos = $this->pos; |
||
3097 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3098 | if ($subres !== FALSE) { |
||
3099 | $this->store( $result, $subres ); |
||
3100 | } |
||
3101 | else { $_503 = FALSE; break; } |
||
3102 | if (substr($this->string,$this->pos,1) == ',') { |
||
3103 | $this->pos += 1; |
||
3104 | $result["text"] .= ','; |
||
3105 | } |
||
3106 | else { $_503 = FALSE; break; } |
||
3107 | $matcher = 'match_'.'N'; $key = $matcher; $pos = $this->pos; |
||
3108 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3109 | if ($subres !== FALSE) { |
||
3110 | $this->store( $result, $subres ); |
||
3111 | } |
||
3112 | else { $_503 = FALSE; break; } |
||
3113 | $matcher = 'match_'.'CallArguments'; $key = $matcher; $pos = $this->pos; |
||
3114 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3115 | if ($subres !== FALSE) { |
||
3116 | $this->store( $result, $subres ); |
||
3117 | } |
||
3118 | else { $_503 = FALSE; break; } |
||
3119 | $_503 = TRUE; break; |
||
3120 | } |
||
3121 | while(0); |
||
3122 | if( $_503 === FALSE) { |
||
3123 | $result = $res_504; |
||
3124 | $this->pos = $pos_504; |
||
3125 | unset( $res_504 ); |
||
3126 | unset( $pos_504 ); |
||
3127 | } |
||
3128 | $matcher = 'match_'.'N'; $key = $matcher; $pos = $this->pos; |
||
3129 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3130 | if ($subres !== FALSE) { |
||
3131 | $this->store( $result, $subres ); |
||
3132 | } |
||
3133 | else { $_511 = FALSE; break; } |
||
3134 | if (substr($this->string,$this->pos,1) == ')') { |
||
3135 | $this->pos += 1; |
||
3136 | $result["text"] .= ')'; |
||
3137 | } |
||
3138 | else { $_511 = FALSE; break; } |
||
3139 | $matcher = 'match_'.'N'; $key = $matcher; $pos = $this->pos; |
||
3140 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3141 | if ($subres !== FALSE) { |
||
3142 | $this->store( $result, $subres ); |
||
3143 | } |
||
3144 | else { $_511 = FALSE; break; } |
||
3145 | $res_510 = $result; |
||
3146 | $pos_510 = $this->pos; |
||
3147 | $_509 = NULL; |
||
3148 | do { |
||
3149 | if (substr($this->string,$this->pos,1) == ';') { |
||
3150 | $this->pos += 1; |
||
3151 | $result["text"] .= ';'; |
||
3152 | } |
||
3153 | else { $_509 = FALSE; break; } |
||
3154 | $_509 = TRUE; break; |
||
3155 | } |
||
3156 | while(0); |
||
3157 | if( $_509 === FALSE) { |
||
3158 | $result = $res_510; |
||
3159 | $this->pos = $pos_510; |
||
3160 | unset( $res_510 ); |
||
3161 | unset( $pos_510 ); |
||
3162 | } |
||
3163 | $_511 = TRUE; break; |
||
3164 | } |
||
3165 | while(0); |
||
3166 | if( $_511 === TRUE ) { return $this->finalise($result); } |
||
3167 | if( $_511 === FALSE) { return FALSE; } |
||
3168 | } |
||
3169 | |||
3170 | |||
3171 | /* N: / [\s\n]* / */ |
||
3172 | protected $match_N_typestack = array('N'); |
||
3173 | function match_N ($stack = array()) { |
||
3174 | $matchrule = "N"; $result = $this->construct($matchrule, $matchrule, null); |
||
3175 | if (( $subres = $this->rx( '/ [\s\n]* /' ) ) !== FALSE) { |
||
3176 | $result["text"] .= $subres; |
||
3177 | return $this->finalise($result); |
||
3178 | } |
||
3179 | else { return FALSE; } |
||
3180 | } |
||
3181 | |||
3182 | |||
3183 | |||
3184 | function OldTPart__construct(&$res) |
||
3185 | { |
||
3186 | $res['php'] = "_t("; |
||
3187 | } |
||
3188 | |||
3189 | function OldTPart_QuotedString(&$res, $sub) |
||
3190 | { |
||
3191 | $entity = $sub['String']['text']; |
||
3192 | if (strpos($entity, '.') === false) { |
||
3193 | $res['php'] .= "\$scope->XML_val('I18NNamespace').'.$entity'"; |
||
3194 | } else { |
||
3195 | $res['php'] .= "'$entity'"; |
||
3196 | } |
||
3197 | } |
||
3198 | |||
3199 | function OldTPart_CallArguments(&$res, $sub) |
||
3200 | { |
||
3201 | $res['php'] .= ',' . $sub['php']; |
||
3202 | } |
||
3203 | |||
3204 | function OldTPart__finalise(&$res) |
||
3205 | { |
||
3206 | $res['php'] .= ')'; |
||
3207 | } |
||
3208 | |||
3209 | /* OldTTag: "<%" < OldTPart > "%>" */ |
||
3210 | protected $match_OldTTag_typestack = array('OldTTag'); |
||
3211 | function match_OldTTag ($stack = array()) { |
||
3212 | $matchrule = "OldTTag"; $result = $this->construct($matchrule, $matchrule, null); |
||
3213 | $_519 = NULL; |
||
3214 | do { |
||
3215 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3216 | else { $_519 = FALSE; break; } |
||
3217 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3218 | $matcher = 'match_'.'OldTPart'; $key = $matcher; $pos = $this->pos; |
||
3219 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3220 | if ($subres !== FALSE) { |
||
3221 | $this->store( $result, $subres ); |
||
3222 | } |
||
3223 | else { $_519 = FALSE; break; } |
||
3224 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3225 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3226 | else { $_519 = FALSE; break; } |
||
3227 | $_519 = TRUE; break; |
||
3228 | } |
||
3229 | while(0); |
||
3230 | if( $_519 === TRUE ) { return $this->finalise($result); } |
||
3231 | if( $_519 === FALSE) { return FALSE; } |
||
3232 | } |
||
3233 | |||
3234 | |||
3235 | |||
3236 | function OldTTag_OldTPart(&$res, $sub) |
||
3237 | { |
||
3238 | $res['php'] = $sub['php']; |
||
3239 | } |
||
3240 | |||
3241 | /* OldSprintfTag: "<%" < "sprintf" < "(" < OldTPart < "," < CallArguments > ")" > "%>" */ |
||
3242 | protected $match_OldSprintfTag_typestack = array('OldSprintfTag'); |
||
3243 | function match_OldSprintfTag ($stack = array()) { |
||
3244 | $matchrule = "OldSprintfTag"; $result = $this->construct($matchrule, $matchrule, null); |
||
3245 | $_536 = NULL; |
||
3246 | do { |
||
3247 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3248 | else { $_536 = FALSE; break; } |
||
3249 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3250 | if (( $subres = $this->literal( 'sprintf' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3251 | else { $_536 = FALSE; break; } |
||
3252 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3253 | if (substr($this->string,$this->pos,1) == '(') { |
||
3254 | $this->pos += 1; |
||
3255 | $result["text"] .= '('; |
||
3256 | } |
||
3257 | else { $_536 = FALSE; break; } |
||
3258 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3259 | $matcher = 'match_'.'OldTPart'; $key = $matcher; $pos = $this->pos; |
||
3260 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3261 | if ($subres !== FALSE) { |
||
3262 | $this->store( $result, $subres ); |
||
3263 | } |
||
3264 | else { $_536 = FALSE; break; } |
||
3265 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3266 | if (substr($this->string,$this->pos,1) == ',') { |
||
3267 | $this->pos += 1; |
||
3268 | $result["text"] .= ','; |
||
3269 | } |
||
3270 | else { $_536 = FALSE; break; } |
||
3271 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3272 | $matcher = 'match_'.'CallArguments'; $key = $matcher; $pos = $this->pos; |
||
3273 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3274 | if ($subres !== FALSE) { |
||
3275 | $this->store( $result, $subres ); |
||
3276 | } |
||
3277 | else { $_536 = FALSE; break; } |
||
3278 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3279 | if (substr($this->string,$this->pos,1) == ')') { |
||
3280 | $this->pos += 1; |
||
3281 | $result["text"] .= ')'; |
||
3282 | } |
||
3283 | else { $_536 = FALSE; break; } |
||
3284 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3285 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3286 | else { $_536 = FALSE; break; } |
||
3287 | $_536 = TRUE; break; |
||
3288 | } |
||
3289 | while(0); |
||
3290 | if( $_536 === TRUE ) { return $this->finalise($result); } |
||
3291 | if( $_536 === FALSE) { return FALSE; } |
||
3292 | } |
||
3293 | |||
3294 | |||
3295 | |||
3296 | function OldSprintfTag__construct(&$res) |
||
3297 | { |
||
3298 | $res['php'] = "sprintf("; |
||
3299 | } |
||
3300 | |||
3301 | function OldSprintfTag_OldTPart(&$res, $sub) |
||
3302 | { |
||
3303 | $res['php'] .= $sub['php']; |
||
3304 | } |
||
3305 | |||
3306 | function OldSprintfTag_CallArguments(&$res, $sub) |
||
3307 | { |
||
3308 | $res['php'] .= ',' . $sub['php'] . ')'; |
||
3309 | } |
||
3310 | |||
3311 | /* OldI18NTag: OldSprintfTag | OldTTag */ |
||
3312 | protected $match_OldI18NTag_typestack = array('OldI18NTag'); |
||
3313 | function match_OldI18NTag ($stack = array()) { |
||
3314 | $matchrule = "OldI18NTag"; $result = $this->construct($matchrule, $matchrule, null); |
||
3315 | $_541 = NULL; |
||
3316 | do { |
||
3317 | $res_538 = $result; |
||
3318 | $pos_538 = $this->pos; |
||
3319 | $matcher = 'match_'.'OldSprintfTag'; $key = $matcher; $pos = $this->pos; |
||
3320 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3321 | if ($subres !== FALSE) { |
||
3322 | $this->store( $result, $subres ); |
||
3323 | $_541 = TRUE; break; |
||
3324 | } |
||
3325 | $result = $res_538; |
||
3326 | $this->pos = $pos_538; |
||
3327 | $matcher = 'match_'.'OldTTag'; $key = $matcher; $pos = $this->pos; |
||
3328 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3329 | if ($subres !== FALSE) { |
||
3330 | $this->store( $result, $subres ); |
||
3331 | $_541 = TRUE; break; |
||
3332 | } |
||
3333 | $result = $res_538; |
||
3334 | $this->pos = $pos_538; |
||
3335 | $_541 = FALSE; break; |
||
3336 | } |
||
3337 | while(0); |
||
3338 | if( $_541 === TRUE ) { return $this->finalise($result); } |
||
3339 | if( $_541 === FALSE) { return FALSE; } |
||
3340 | } |
||
3341 | |||
3342 | |||
3343 | |||
3344 | function OldI18NTag_STR(&$res, $sub) |
||
3345 | { |
||
3346 | $res['php'] = '$val .= ' . $sub['php'] . ';'; |
||
3347 | } |
||
3348 | |||
3349 | /* NamedArgument: Name:Word "=" Value:Argument */ |
||
3350 | protected $match_NamedArgument_typestack = array('NamedArgument'); |
||
3351 | function match_NamedArgument ($stack = array()) { |
||
3352 | $matchrule = "NamedArgument"; $result = $this->construct($matchrule, $matchrule, null); |
||
3353 | $_546 = NULL; |
||
3354 | do { |
||
3355 | $matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
||
3356 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3357 | if ($subres !== FALSE) { |
||
3358 | $this->store( $result, $subres, "Name" ); |
||
3359 | } |
||
3360 | else { $_546 = FALSE; break; } |
||
3361 | if (substr($this->string,$this->pos,1) == '=') { |
||
3362 | $this->pos += 1; |
||
3363 | $result["text"] .= '='; |
||
3364 | } |
||
3365 | else { $_546 = FALSE; break; } |
||
3366 | $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
||
3367 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3368 | if ($subres !== FALSE) { |
||
3369 | $this->store( $result, $subres, "Value" ); |
||
3370 | } |
||
3371 | else { $_546 = FALSE; break; } |
||
3372 | $_546 = TRUE; break; |
||
3373 | } |
||
3374 | while(0); |
||
3375 | if( $_546 === TRUE ) { return $this->finalise($result); } |
||
3376 | if( $_546 === FALSE) { return FALSE; } |
||
3377 | } |
||
3378 | |||
3379 | |||
3380 | |||
3381 | function NamedArgument_Name(&$res, $sub) |
||
3382 | { |
||
3383 | $res['php'] = "'" . $sub['text'] . "' => "; |
||
3384 | } |
||
3385 | |||
3386 | function NamedArgument_Value(&$res, $sub) |
||
3387 | { |
||
3388 | switch ($sub['ArgumentMode']) { |
||
3389 | case 'string': |
||
3390 | $res['php'] .= $sub['php']; |
||
3391 | break; |
||
3392 | |||
3393 | case 'default': |
||
3394 | $res['php'] .= $sub['string_php']; |
||
3395 | break; |
||
3396 | |||
3397 | default: |
||
3398 | $res['php'] .= str_replace('$$FINAL', 'obj', $sub['php']) . '->self()'; |
||
3399 | break; |
||
3400 | } |
||
3401 | } |
||
3402 | |||
3403 | /* Include: "<%" < "include" < Template:NamespacedWord < (NamedArgument ( < "," < NamedArgument )*)? > "%>" */ |
||
3404 | protected $match_Include_typestack = array('Include'); |
||
3405 | function match_Include ($stack = array()) { |
||
3406 | $matchrule = "Include"; $result = $this->construct($matchrule, $matchrule, null); |
||
3407 | $_565 = NULL; |
||
3408 | do { |
||
3409 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3410 | else { $_565 = FALSE; break; } |
||
3411 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3412 | if (( $subres = $this->literal( 'include' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3413 | else { $_565 = FALSE; break; } |
||
3414 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3415 | $matcher = 'match_'.'NamespacedWord'; $key = $matcher; $pos = $this->pos; |
||
3416 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3417 | if ($subres !== FALSE) { |
||
3418 | $this->store( $result, $subres, "Template" ); |
||
3419 | } |
||
3420 | else { $_565 = FALSE; break; } |
||
3421 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3422 | $res_562 = $result; |
||
3423 | $pos_562 = $this->pos; |
||
3424 | $_561 = NULL; |
||
3425 | do { |
||
3426 | $matcher = 'match_'.'NamedArgument'; $key = $matcher; $pos = $this->pos; |
||
3427 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3428 | if ($subres !== FALSE) { |
||
3429 | $this->store( $result, $subres ); |
||
3430 | } |
||
3431 | else { $_561 = FALSE; break; } |
||
3432 | while (true) { |
||
3433 | $res_560 = $result; |
||
3434 | $pos_560 = $this->pos; |
||
3435 | $_559 = NULL; |
||
3436 | do { |
||
3437 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3438 | if (substr($this->string,$this->pos,1) == ',') { |
||
3439 | $this->pos += 1; |
||
3440 | $result["text"] .= ','; |
||
3441 | } |
||
3442 | else { $_559 = FALSE; break; } |
||
3443 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3444 | $matcher = 'match_'.'NamedArgument'; $key = $matcher; $pos = $this->pos; |
||
3445 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3446 | if ($subres !== FALSE) { |
||
3447 | $this->store( $result, $subres ); |
||
3448 | } |
||
3449 | else { $_559 = FALSE; break; } |
||
3450 | $_559 = TRUE; break; |
||
3451 | } |
||
3452 | while(0); |
||
3453 | if( $_559 === FALSE) { |
||
3454 | $result = $res_560; |
||
3455 | $this->pos = $pos_560; |
||
3456 | unset( $res_560 ); |
||
3457 | unset( $pos_560 ); |
||
3458 | break; |
||
3459 | } |
||
3460 | } |
||
3461 | $_561 = TRUE; break; |
||
3462 | } |
||
3463 | while(0); |
||
3464 | if( $_561 === FALSE) { |
||
3465 | $result = $res_562; |
||
3466 | $this->pos = $pos_562; |
||
3467 | unset( $res_562 ); |
||
3468 | unset( $pos_562 ); |
||
3469 | } |
||
3470 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3471 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3472 | else { $_565 = FALSE; break; } |
||
3473 | $_565 = TRUE; break; |
||
3474 | } |
||
3475 | while(0); |
||
3476 | if( $_565 === TRUE ) { return $this->finalise($result); } |
||
3477 | if( $_565 === FALSE) { return FALSE; } |
||
3478 | } |
||
3479 | |||
3480 | |||
3481 | |||
3482 | function Include__construct(&$res) |
||
3483 | { |
||
3484 | $res['arguments'] = array(); |
||
3485 | } |
||
3486 | |||
3487 | function Include_Template(&$res, $sub) |
||
3488 | { |
||
3489 | $res['template'] = "'" . $sub['text'] . "'"; |
||
3490 | } |
||
3491 | |||
3492 | function Include_NamedArgument(&$res, $sub) |
||
3493 | { |
||
3494 | $res['arguments'][] = $sub['php']; |
||
3495 | } |
||
3496 | |||
3497 | function Include__finalise(&$res) |
||
3498 | { |
||
3499 | $template = $res['template']; |
||
3500 | $arguments = $res['arguments']; |
||
3501 | |||
3502 | // Note: 'type' here is important to disable subTemplates in SSViewer::getSubtemplateFor() |
||
3503 | $res['php'] = '$val .= \\SilverStripe\\View\\SSViewer::execute_template([["type" => "Includes", '.$template.'], '.$template.'], $scope->getItem(), array(' . |
||
3504 | implode(',', $arguments)."), \$scope);\n"; |
||
3505 | |||
3506 | if ($this->includeDebuggingComments) { // Add include filename comments on dev sites |
||
3507 | $res['php'] = |
||
3508 | '$val .= \'<!-- include '.addslashes($template).' -->\';'. "\n". |
||
3509 | $res['php']. |
||
3510 | '$val .= \'<!-- end include '.addslashes($template).' -->\';'. "\n"; |
||
3511 | } |
||
3512 | } |
||
3513 | |||
3514 | /* BlockArguments: :Argument ( < "," < :Argument)* */ |
||
3515 | protected $match_BlockArguments_typestack = array('BlockArguments'); |
||
3516 | function match_BlockArguments ($stack = array()) { |
||
3517 | $matchrule = "BlockArguments"; $result = $this->construct($matchrule, $matchrule, null); |
||
3518 | $_574 = NULL; |
||
3519 | do { |
||
3520 | $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
||
3521 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3522 | if ($subres !== FALSE) { |
||
3523 | $this->store( $result, $subres, "Argument" ); |
||
3524 | } |
||
3525 | else { $_574 = FALSE; break; } |
||
3526 | while (true) { |
||
3527 | $res_573 = $result; |
||
3528 | $pos_573 = $this->pos; |
||
3529 | $_572 = NULL; |
||
3530 | do { |
||
3531 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3532 | if (substr($this->string,$this->pos,1) == ',') { |
||
3533 | $this->pos += 1; |
||
3534 | $result["text"] .= ','; |
||
3535 | } |
||
3536 | else { $_572 = FALSE; break; } |
||
3537 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3538 | $matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
||
3539 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3540 | if ($subres !== FALSE) { |
||
3541 | $this->store( $result, $subres, "Argument" ); |
||
3542 | } |
||
3543 | else { $_572 = FALSE; break; } |
||
3544 | $_572 = TRUE; break; |
||
3545 | } |
||
3546 | while(0); |
||
3547 | if( $_572 === FALSE) { |
||
3548 | $result = $res_573; |
||
3549 | $this->pos = $pos_573; |
||
3550 | unset( $res_573 ); |
||
3551 | unset( $pos_573 ); |
||
3552 | break; |
||
3553 | } |
||
3554 | } |
||
3555 | $_574 = TRUE; break; |
||
3556 | } |
||
3557 | while(0); |
||
3558 | if( $_574 === TRUE ) { return $this->finalise($result); } |
||
3559 | if( $_574 === FALSE) { return FALSE; } |
||
3560 | } |
||
3561 | |||
3562 | |||
3563 | /* NotBlockTag: "end_" | (("if" | "else_if" | "else" | "require" | "cached" | "uncached" | "cacheblock" | "include")]) */ |
||
3564 | protected $match_NotBlockTag_typestack = array('NotBlockTag'); |
||
3565 | function match_NotBlockTag ($stack = array()) { |
||
3566 | $matchrule = "NotBlockTag"; $result = $this->construct($matchrule, $matchrule, null); |
||
3567 | $_612 = NULL; |
||
3568 | do { |
||
3569 | $res_576 = $result; |
||
3570 | $pos_576 = $this->pos; |
||
3571 | if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { |
||
3572 | $result["text"] .= $subres; |
||
3573 | $_612 = TRUE; break; |
||
3574 | } |
||
3575 | $result = $res_576; |
||
3576 | $this->pos = $pos_576; |
||
3577 | $_610 = NULL; |
||
3578 | do { |
||
3579 | $_607 = NULL; |
||
3580 | do { |
||
3581 | $_605 = NULL; |
||
3582 | do { |
||
3583 | $res_578 = $result; |
||
3584 | $pos_578 = $this->pos; |
||
3585 | if (( $subres = $this->literal( 'if' ) ) !== FALSE) { |
||
3586 | $result["text"] .= $subres; |
||
3587 | $_605 = TRUE; break; |
||
3588 | } |
||
3589 | $result = $res_578; |
||
3590 | $this->pos = $pos_578; |
||
3591 | $_603 = NULL; |
||
3592 | do { |
||
3593 | $res_580 = $result; |
||
3594 | $pos_580 = $this->pos; |
||
3595 | if (( $subres = $this->literal( 'else_if' ) ) !== FALSE) { |
||
3596 | $result["text"] .= $subres; |
||
3597 | $_603 = TRUE; break; |
||
3598 | } |
||
3599 | $result = $res_580; |
||
3600 | $this->pos = $pos_580; |
||
3601 | $_601 = NULL; |
||
3602 | do { |
||
3603 | $res_582 = $result; |
||
3604 | $pos_582 = $this->pos; |
||
3605 | if (( $subres = $this->literal( 'else' ) ) !== FALSE) { |
||
3606 | $result["text"] .= $subres; |
||
3607 | $_601 = TRUE; break; |
||
3608 | } |
||
3609 | $result = $res_582; |
||
3610 | $this->pos = $pos_582; |
||
3611 | $_599 = NULL; |
||
3612 | do { |
||
3613 | $res_584 = $result; |
||
3614 | $pos_584 = $this->pos; |
||
3615 | if (( $subres = $this->literal( 'require' ) ) !== FALSE) { |
||
3616 | $result["text"] .= $subres; |
||
3617 | $_599 = TRUE; break; |
||
3618 | } |
||
3619 | $result = $res_584; |
||
3620 | $this->pos = $pos_584; |
||
3621 | $_597 = NULL; |
||
3622 | do { |
||
3623 | $res_586 = $result; |
||
3624 | $pos_586 = $this->pos; |
||
3625 | if (( $subres = $this->literal( 'cached' ) ) !== FALSE) { |
||
3626 | $result["text"] .= $subres; |
||
3627 | $_597 = TRUE; break; |
||
3628 | } |
||
3629 | $result = $res_586; |
||
3630 | $this->pos = $pos_586; |
||
3631 | $_595 = NULL; |
||
3632 | do { |
||
3633 | $res_588 = $result; |
||
3634 | $pos_588 = $this->pos; |
||
3635 | if (( $subres = $this->literal( 'uncached' ) ) !== FALSE) { |
||
3636 | $result["text"] .= $subres; |
||
3637 | $_595 = TRUE; break; |
||
3638 | } |
||
3639 | $result = $res_588; |
||
3640 | $this->pos = $pos_588; |
||
3641 | $_593 = NULL; |
||
3642 | do { |
||
3643 | $res_590 = $result; |
||
3644 | $pos_590 = $this->pos; |
||
3645 | if (( $subres = $this->literal( 'cacheblock' ) ) !== FALSE) { |
||
3646 | $result["text"] .= $subres; |
||
3647 | $_593 = TRUE; break; |
||
3648 | } |
||
3649 | $result = $res_590; |
||
3650 | $this->pos = $pos_590; |
||
3651 | if (( $subres = $this->literal( 'include' ) ) !== FALSE) { |
||
3652 | $result["text"] .= $subres; |
||
3653 | $_593 = TRUE; break; |
||
3654 | } |
||
3655 | $result = $res_590; |
||
3656 | $this->pos = $pos_590; |
||
3657 | $_593 = FALSE; break; |
||
3658 | } |
||
3659 | while(0); |
||
3660 | if( $_593 === TRUE ) { $_595 = TRUE; break; } |
||
3661 | $result = $res_588; |
||
3662 | $this->pos = $pos_588; |
||
3663 | $_595 = FALSE; break; |
||
3664 | } |
||
3665 | while(0); |
||
3666 | if( $_595 === TRUE ) { $_597 = TRUE; break; } |
||
3667 | $result = $res_586; |
||
3668 | $this->pos = $pos_586; |
||
3669 | $_597 = FALSE; break; |
||
3670 | } |
||
3671 | while(0); |
||
3672 | if( $_597 === TRUE ) { $_599 = TRUE; break; } |
||
3673 | $result = $res_584; |
||
3674 | $this->pos = $pos_584; |
||
3675 | $_599 = FALSE; break; |
||
3676 | } |
||
3677 | while(0); |
||
3678 | if( $_599 === TRUE ) { $_601 = TRUE; break; } |
||
3679 | $result = $res_582; |
||
3680 | $this->pos = $pos_582; |
||
3681 | $_601 = FALSE; break; |
||
3682 | } |
||
3683 | while(0); |
||
3684 | if( $_601 === TRUE ) { $_603 = TRUE; break; } |
||
3685 | $result = $res_580; |
||
3686 | $this->pos = $pos_580; |
||
3687 | $_603 = FALSE; break; |
||
3688 | } |
||
3689 | while(0); |
||
3690 | if( $_603 === TRUE ) { $_605 = TRUE; break; } |
||
3691 | $result = $res_578; |
||
3692 | $this->pos = $pos_578; |
||
3693 | $_605 = FALSE; break; |
||
3694 | } |
||
3695 | while(0); |
||
3696 | if( $_605 === FALSE) { $_607 = FALSE; break; } |
||
3697 | $_607 = TRUE; break; |
||
3698 | } |
||
3699 | while(0); |
||
3700 | if( $_607 === FALSE) { $_610 = FALSE; break; } |
||
3701 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3702 | else { $_610 = FALSE; break; } |
||
3703 | $_610 = TRUE; break; |
||
3704 | } |
||
3705 | while(0); |
||
3706 | if( $_610 === TRUE ) { $_612 = TRUE; break; } |
||
3707 | $result = $res_576; |
||
3708 | $this->pos = $pos_576; |
||
3709 | $_612 = FALSE; break; |
||
3710 | } |
||
3711 | while(0); |
||
3712 | if( $_612 === TRUE ) { return $this->finalise($result); } |
||
3713 | if( $_612 === FALSE) { return FALSE; } |
||
3714 | } |
||
3715 | |||
3716 | |||
3717 | /* ClosedBlock: '<%' < !NotBlockTag BlockName:Word ( [ :BlockArguments ] )? > Zap:'%>' Template:$TemplateMatcher? |
||
3718 | '<%' < 'end_' '$BlockName' > '%>' */ |
||
3719 | protected $match_ClosedBlock_typestack = array('ClosedBlock'); |
||
3720 | function match_ClosedBlock ($stack = array()) { |
||
3721 | $matchrule = "ClosedBlock"; $result = $this->construct($matchrule, $matchrule, null); |
||
3722 | $_632 = NULL; |
||
3723 | do { |
||
3724 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3725 | else { $_632 = FALSE; break; } |
||
3726 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3727 | $res_616 = $result; |
||
3728 | $pos_616 = $this->pos; |
||
3729 | $matcher = 'match_'.'NotBlockTag'; $key = $matcher; $pos = $this->pos; |
||
3730 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3731 | if ($subres !== FALSE) { |
||
3732 | $this->store( $result, $subres ); |
||
3733 | $result = $res_616; |
||
3734 | $this->pos = $pos_616; |
||
3735 | $_632 = FALSE; break; |
||
3736 | } |
||
3737 | else { |
||
3738 | $result = $res_616; |
||
3739 | $this->pos = $pos_616; |
||
3740 | } |
||
3741 | $matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
||
3742 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3743 | if ($subres !== FALSE) { |
||
3744 | $this->store( $result, $subres, "BlockName" ); |
||
3745 | } |
||
3746 | else { $_632 = FALSE; break; } |
||
3747 | $res_622 = $result; |
||
3748 | $pos_622 = $this->pos; |
||
3749 | $_621 = NULL; |
||
3750 | do { |
||
3751 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3752 | else { $_621 = FALSE; break; } |
||
3753 | $matcher = 'match_'.'BlockArguments'; $key = $matcher; $pos = $this->pos; |
||
3754 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3755 | if ($subres !== FALSE) { |
||
3756 | $this->store( $result, $subres, "BlockArguments" ); |
||
3757 | } |
||
3758 | else { $_621 = FALSE; break; } |
||
3759 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3760 | else { $_621 = FALSE; break; } |
||
3761 | $_621 = TRUE; break; |
||
3762 | } |
||
3763 | while(0); |
||
3764 | if( $_621 === FALSE) { |
||
3765 | $result = $res_622; |
||
3766 | $this->pos = $pos_622; |
||
3767 | unset( $res_622 ); |
||
3768 | unset( $pos_622 ); |
||
3769 | } |
||
3770 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3771 | $stack[] = $result; $result = $this->construct( $matchrule, "Zap" ); |
||
3772 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { |
||
3773 | $result["text"] .= $subres; |
||
3774 | $subres = $result; $result = array_pop($stack); |
||
3775 | $this->store( $result, $subres, 'Zap' ); |
||
3776 | } |
||
3777 | else { |
||
3778 | $result = array_pop($stack); |
||
3779 | $_632 = FALSE; break; |
||
3780 | } |
||
3781 | $res_625 = $result; |
||
3782 | $pos_625 = $this->pos; |
||
3783 | $matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $key = $matcher; $pos = $this->pos; |
||
3784 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3785 | if ($subres !== FALSE) { |
||
3786 | $this->store( $result, $subres, "Template" ); |
||
3787 | } |
||
3788 | else { |
||
3789 | $result = $res_625; |
||
3790 | $this->pos = $pos_625; |
||
3791 | unset( $res_625 ); |
||
3792 | unset( $pos_625 ); |
||
3793 | } |
||
3794 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3795 | else { $_632 = FALSE; break; } |
||
3796 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3797 | if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3798 | else { $_632 = FALSE; break; } |
||
3799 | if (( $subres = $this->literal( ''.$this->expression($result, $stack, 'BlockName').'' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3800 | else { $_632 = FALSE; break; } |
||
3801 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3802 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3803 | else { $_632 = FALSE; break; } |
||
3804 | $_632 = TRUE; break; |
||
3805 | } |
||
3806 | while(0); |
||
3807 | if( $_632 === TRUE ) { return $this->finalise($result); } |
||
3808 | if( $_632 === FALSE) { return FALSE; } |
||
3809 | } |
||
3810 | |||
3811 | |||
3812 | |||
3813 | |||
3814 | /** |
||
3815 | * As mentioned in the parser comment, block handling is kept fairly generic for extensibility. The match rule |
||
3816 | * builds up two important elements in the match result array: |
||
3817 | * 'ArgumentCount' - how many arguments were passed in the opening tag |
||
3818 | * 'Arguments' an array of the Argument match rule result arrays |
||
3819 | * |
||
3820 | * Once a block has successfully been matched against, it will then look for the actual handler, which should |
||
3821 | * be on this class (either defined or extended on) as ClosedBlock_Handler_Name(&$res), where Name is the |
||
3822 | * tag name, first letter captialized (i.e Control, Loop, With, etc). |
||
3823 | * |
||
3824 | * This function will be called with the match rule result array as it's first argument. It should return |
||
3825 | * the php result of this block as it's return value, or throw an error if incorrect arguments were passed. |
||
3826 | */ |
||
3827 | |||
3828 | function ClosedBlock__construct(&$res) |
||
3829 | { |
||
3830 | $res['ArgumentCount'] = 0; |
||
3831 | } |
||
3832 | |||
3833 | function ClosedBlock_BlockArguments(&$res, $sub) |
||
3834 | { |
||
3835 | if (isset($sub['Argument']['ArgumentMode'])) { |
||
3836 | $res['Arguments'] = array($sub['Argument']); |
||
3837 | $res['ArgumentCount'] = 1; |
||
3838 | } else { |
||
3839 | $res['Arguments'] = $sub['Argument']; |
||
3840 | $res['ArgumentCount'] = count($res['Arguments']); |
||
3841 | } |
||
3842 | } |
||
3843 | |||
3844 | function ClosedBlock__finalise(&$res) |
||
3845 | { |
||
3846 | $blockname = $res['BlockName']['text']; |
||
3847 | |||
3848 | $method = 'ClosedBlock_Handle_'.$blockname; |
||
3849 | if (method_exists($this, $method)) { |
||
3850 | $res['php'] = $this->$method($res); |
||
3851 | } elseif (isset($this->closedBlocks[$blockname])) { |
||
3852 | $res['php'] = call_user_func($this->closedBlocks[$blockname], $res); |
||
3853 | } else { |
||
3854 | throw new SSTemplateParseException('Unknown closed block "'.$blockname.'" encountered. Perhaps you are ' . |
||
3855 | 'not supposed to close this block, or have mis-spelled it?', $this); |
||
3856 | } |
||
3857 | } |
||
3858 | |||
3859 | /** |
||
3860 | * This is an example of a block handler function. This one handles the loop tag. |
||
3861 | */ |
||
3862 | function ClosedBlock_Handle_Loop(&$res) |
||
3888 | } |
||
3889 | |||
3890 | /** |
||
3891 | * The closed block handler for with blocks |
||
3892 | */ |
||
3893 | function ClosedBlock_Handle_With(&$res) |
||
3894 | { |
||
3895 | if ($res['ArgumentCount'] != 1) { |
||
3896 | throw new SSTemplateParseException('Either no or too many arguments in with block. Must be one ' . |
||
3897 | 'argument only.', $this); |
||
3898 | } |
||
3899 | |||
3900 | $arg = $res['Arguments'][0]; |
||
3901 | if ($arg['ArgumentMode'] == 'string') { |
||
3902 | throw new SSTemplateParseException('Control block cant take string as argument.', $this); |
||
3903 | } |
||
3904 | |||
3905 | $on = str_replace('$$FINAL', 'obj', ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']); |
||
3906 | return |
||
3907 | $on . '; $scope->pushScope();' . PHP_EOL . |
||
3908 | $res['Template']['php'] . PHP_EOL . |
||
3909 | '; $scope->popScope(); '; |
||
3910 | } |
||
3911 | |||
3912 | /* OpenBlock: '<%' < !NotBlockTag BlockName:Word ( [ :BlockArguments ] )? > '%>' */ |
||
3913 | protected $match_OpenBlock_typestack = array('OpenBlock'); |
||
3914 | function match_OpenBlock ($stack = array()) { |
||
3915 | $matchrule = "OpenBlock"; $result = $this->construct($matchrule, $matchrule, null); |
||
3916 | $_645 = NULL; |
||
3917 | do { |
||
3918 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3919 | else { $_645 = FALSE; break; } |
||
3920 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3921 | $res_636 = $result; |
||
3922 | $pos_636 = $this->pos; |
||
3923 | $matcher = 'match_'.'NotBlockTag'; $key = $matcher; $pos = $this->pos; |
||
3924 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3925 | if ($subres !== FALSE) { |
||
3926 | $this->store( $result, $subres ); |
||
3927 | $result = $res_636; |
||
3928 | $this->pos = $pos_636; |
||
3929 | $_645 = FALSE; break; |
||
3930 | } |
||
3931 | else { |
||
3932 | $result = $res_636; |
||
3933 | $this->pos = $pos_636; |
||
3934 | } |
||
3935 | $matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
||
3936 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3937 | if ($subres !== FALSE) { |
||
3938 | $this->store( $result, $subres, "BlockName" ); |
||
3939 | } |
||
3940 | else { $_645 = FALSE; break; } |
||
3941 | $res_642 = $result; |
||
3942 | $pos_642 = $this->pos; |
||
3943 | $_641 = NULL; |
||
3944 | do { |
||
3945 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3946 | else { $_641 = FALSE; break; } |
||
3947 | $matcher = 'match_'.'BlockArguments'; $key = $matcher; $pos = $this->pos; |
||
3948 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
3949 | if ($subres !== FALSE) { |
||
3950 | $this->store( $result, $subres, "BlockArguments" ); |
||
3951 | } |
||
3952 | else { $_641 = FALSE; break; } |
||
3953 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3954 | else { $_641 = FALSE; break; } |
||
3955 | $_641 = TRUE; break; |
||
3956 | } |
||
3957 | while(0); |
||
3958 | if( $_641 === FALSE) { |
||
3959 | $result = $res_642; |
||
3960 | $this->pos = $pos_642; |
||
3961 | unset( $res_642 ); |
||
3962 | unset( $pos_642 ); |
||
3963 | } |
||
3964 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3965 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
3966 | else { $_645 = FALSE; break; } |
||
3967 | $_645 = TRUE; break; |
||
3968 | } |
||
3969 | while(0); |
||
3970 | if( $_645 === TRUE ) { return $this->finalise($result); } |
||
3971 | if( $_645 === FALSE) { return FALSE; } |
||
3972 | } |
||
3973 | |||
3974 | |||
3975 | |||
3976 | function OpenBlock__construct(&$res) |
||
3977 | { |
||
3978 | $res['ArgumentCount'] = 0; |
||
3979 | } |
||
3980 | |||
3981 | function OpenBlock_BlockArguments(&$res, $sub) |
||
3982 | { |
||
3983 | if (isset($sub['Argument']['ArgumentMode'])) { |
||
3984 | $res['Arguments'] = array($sub['Argument']); |
||
3985 | $res['ArgumentCount'] = 1; |
||
3986 | } else { |
||
3987 | $res['Arguments'] = $sub['Argument']; |
||
3988 | $res['ArgumentCount'] = count($res['Arguments']); |
||
3989 | } |
||
3990 | } |
||
3991 | |||
3992 | function OpenBlock__finalise(&$res) |
||
3993 | { |
||
3994 | $blockname = $res['BlockName']['text']; |
||
3995 | |||
3996 | $method = 'OpenBlock_Handle_'.$blockname; |
||
3997 | if (method_exists($this, $method)) { |
||
3998 | $res['php'] = $this->$method($res); |
||
3999 | } elseif (isset($this->openBlocks[$blockname])) { |
||
4000 | $res['php'] = call_user_func($this->openBlocks[$blockname], $res); |
||
4001 | } else { |
||
4002 | throw new SSTemplateParseException('Unknown open block "'.$blockname.'" encountered. Perhaps you missed ' . |
||
4003 | ' the closing tag or have mis-spelled it?', $this); |
||
4004 | } |
||
4005 | } |
||
4006 | |||
4007 | /** |
||
4008 | * This is an open block handler, for the <% debug %> utility tag |
||
4009 | */ |
||
4010 | function OpenBlock_Handle_Debug(&$res) |
||
4011 | { |
||
4012 | if ($res['ArgumentCount'] == 0) { |
||
4013 | return '$scope->debug();'; |
||
4014 | } elseif ($res['ArgumentCount'] == 1) { |
||
4015 | $arg = $res['Arguments'][0]; |
||
4016 | |||
4017 | if ($arg['ArgumentMode'] == 'string') { |
||
4018 | return 'Debug::show('.$arg['php'].');'; |
||
4019 | } |
||
4020 | |||
4021 | $php = ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']; |
||
4022 | return '$val .= Debug::show('.str_replace('FINALGET!', 'cachedCall', $php).');'; |
||
4023 | } else { |
||
4024 | throw new SSTemplateParseException('Debug takes 0 or 1 argument only.', $this); |
||
4025 | } |
||
4026 | } |
||
4027 | |||
4028 | /** |
||
4029 | * This is an open block handler, for the <% base_tag %> tag |
||
4030 | */ |
||
4031 | function OpenBlock_Handle_Base_tag(&$res) |
||
4032 | { |
||
4033 | if ($res['ArgumentCount'] != 0) { |
||
4034 | throw new SSTemplateParseException('Base_tag takes no arguments', $this); |
||
4035 | } |
||
4036 | return '$val .= \\SilverStripe\\View\\SSViewer::get_base_tag($val);'; |
||
4037 | } |
||
4038 | |||
4039 | /** |
||
4040 | * This is an open block handler, for the <% current_page %> tag |
||
4041 | */ |
||
4042 | function OpenBlock_Handle_Current_page(&$res) |
||
4048 | } |
||
4049 | |||
4050 | /* MismatchedEndBlock: '<%' < 'end_' :Word > '%>' */ |
||
4051 | protected $match_MismatchedEndBlock_typestack = array('MismatchedEndBlock'); |
||
4052 | function match_MismatchedEndBlock ($stack = array()) { |
||
4053 | $matchrule = "MismatchedEndBlock"; $result = $this->construct($matchrule, $matchrule, null); |
||
4054 | $_653 = NULL; |
||
4055 | do { |
||
4056 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4057 | else { $_653 = FALSE; break; } |
||
4058 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4059 | if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4060 | else { $_653 = FALSE; break; } |
||
4061 | $matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
||
4062 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4063 | if ($subres !== FALSE) { |
||
4064 | $this->store( $result, $subres, "Word" ); |
||
4065 | } |
||
4066 | else { $_653 = FALSE; break; } |
||
4067 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4068 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4069 | else { $_653 = FALSE; break; } |
||
4070 | $_653 = TRUE; break; |
||
4071 | } |
||
4072 | while(0); |
||
4073 | if( $_653 === TRUE ) { return $this->finalise($result); } |
||
4074 | if( $_653 === FALSE) { return FALSE; } |
||
4075 | } |
||
4076 | |||
4077 | |||
4078 | |||
4079 | function MismatchedEndBlock__finalise(&$res) |
||
4080 | { |
||
4081 | $blockname = $res['Word']['text']; |
||
4082 | throw new SSTemplateParseException('Unexpected close tag end_' . $blockname . |
||
4083 | ' encountered. Perhaps you have mis-nested blocks, or have mis-spelled a tag?', $this); |
||
4084 | } |
||
4085 | |||
4086 | /* MalformedOpenTag: '<%' < !NotBlockTag Tag:Word !( ( [ :BlockArguments ] )? > '%>' ) */ |
||
4087 | protected $match_MalformedOpenTag_typestack = array('MalformedOpenTag'); |
||
4088 | function match_MalformedOpenTag ($stack = array()) { |
||
4089 | $matchrule = "MalformedOpenTag"; $result = $this->construct($matchrule, $matchrule, null); |
||
4090 | $_668 = NULL; |
||
4091 | do { |
||
4092 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4093 | else { $_668 = FALSE; break; } |
||
4094 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4095 | $res_657 = $result; |
||
4096 | $pos_657 = $this->pos; |
||
4097 | $matcher = 'match_'.'NotBlockTag'; $key = $matcher; $pos = $this->pos; |
||
4098 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4099 | if ($subres !== FALSE) { |
||
4100 | $this->store( $result, $subres ); |
||
4101 | $result = $res_657; |
||
4102 | $this->pos = $pos_657; |
||
4103 | $_668 = FALSE; break; |
||
4104 | } |
||
4105 | else { |
||
4106 | $result = $res_657; |
||
4107 | $this->pos = $pos_657; |
||
4108 | } |
||
4109 | $matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
||
4110 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4111 | if ($subres !== FALSE) { |
||
4112 | $this->store( $result, $subres, "Tag" ); |
||
4113 | } |
||
4114 | else { $_668 = FALSE; break; } |
||
4115 | $res_667 = $result; |
||
4116 | $pos_667 = $this->pos; |
||
4117 | $_666 = NULL; |
||
4118 | do { |
||
4119 | $res_663 = $result; |
||
4120 | $pos_663 = $this->pos; |
||
4121 | $_662 = NULL; |
||
4122 | do { |
||
4123 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4124 | else { $_662 = FALSE; break; } |
||
4125 | $matcher = 'match_'.'BlockArguments'; $key = $matcher; $pos = $this->pos; |
||
4126 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4127 | if ($subres !== FALSE) { |
||
4128 | $this->store( $result, $subres, "BlockArguments" ); |
||
4129 | } |
||
4130 | else { $_662 = FALSE; break; } |
||
4131 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4132 | else { $_662 = FALSE; break; } |
||
4133 | $_662 = TRUE; break; |
||
4134 | } |
||
4135 | while(0); |
||
4136 | if( $_662 === FALSE) { |
||
4137 | $result = $res_663; |
||
4138 | $this->pos = $pos_663; |
||
4139 | unset( $res_663 ); |
||
4140 | unset( $pos_663 ); |
||
4141 | } |
||
4142 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4143 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4144 | else { $_666 = FALSE; break; } |
||
4145 | $_666 = TRUE; break; |
||
4146 | } |
||
4147 | while(0); |
||
4148 | if( $_666 === TRUE ) { |
||
4149 | $result = $res_667; |
||
4150 | $this->pos = $pos_667; |
||
4151 | $_668 = FALSE; break; |
||
4152 | } |
||
4153 | if( $_666 === FALSE) { |
||
4154 | $result = $res_667; |
||
4155 | $this->pos = $pos_667; |
||
4156 | } |
||
4157 | $_668 = TRUE; break; |
||
4158 | } |
||
4159 | while(0); |
||
4160 | if( $_668 === TRUE ) { return $this->finalise($result); } |
||
4161 | if( $_668 === FALSE) { return FALSE; } |
||
4162 | } |
||
4163 | |||
4164 | |||
4165 | |||
4166 | function MalformedOpenTag__finalise(&$res) |
||
4167 | { |
||
4168 | $tag = $res['Tag']['text']; |
||
4169 | throw new SSTemplateParseException("Malformed opening block tag $tag. Perhaps you have tried to use operators?", $this); |
||
4170 | } |
||
4171 | |||
4172 | /* MalformedCloseTag: '<%' < Tag:('end_' :Word ) !( > '%>' ) */ |
||
4173 | protected $match_MalformedCloseTag_typestack = array('MalformedCloseTag'); |
||
4174 | function match_MalformedCloseTag ($stack = array()) { |
||
4175 | $matchrule = "MalformedCloseTag"; $result = $this->construct($matchrule, $matchrule, null); |
||
4176 | $_680 = NULL; |
||
4177 | do { |
||
4178 | if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4179 | else { $_680 = FALSE; break; } |
||
4180 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4181 | $stack[] = $result; $result = $this->construct( $matchrule, "Tag" ); |
||
4182 | $_674 = NULL; |
||
4183 | do { |
||
4184 | if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4185 | else { $_674 = FALSE; break; } |
||
4186 | $matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
||
4187 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4188 | if ($subres !== FALSE) { |
||
4189 | $this->store( $result, $subres, "Word" ); |
||
4190 | } |
||
4191 | else { $_674 = FALSE; break; } |
||
4192 | $_674 = TRUE; break; |
||
4193 | } |
||
4194 | while(0); |
||
4195 | if( $_674 === TRUE ) { |
||
4196 | $subres = $result; $result = array_pop($stack); |
||
4197 | $this->store( $result, $subres, 'Tag' ); |
||
4198 | } |
||
4199 | if( $_674 === FALSE) { |
||
4200 | $result = array_pop($stack); |
||
4201 | $_680 = FALSE; break; |
||
4202 | } |
||
4203 | $res_679 = $result; |
||
4204 | $pos_679 = $this->pos; |
||
4205 | $_678 = NULL; |
||
4206 | do { |
||
4207 | if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4208 | if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
||
4209 | else { $_678 = FALSE; break; } |
||
4210 | $_678 = TRUE; break; |
||
4211 | } |
||
4212 | while(0); |
||
4213 | if( $_678 === TRUE ) { |
||
4214 | $result = $res_679; |
||
4215 | $this->pos = $pos_679; |
||
4216 | $_680 = FALSE; break; |
||
4217 | } |
||
4218 | if( $_678 === FALSE) { |
||
4219 | $result = $res_679; |
||
4220 | $this->pos = $pos_679; |
||
4221 | } |
||
4222 | $_680 = TRUE; break; |
||
4223 | } |
||
4224 | while(0); |
||
4225 | if( $_680 === TRUE ) { return $this->finalise($result); } |
||
4226 | if( $_680 === FALSE) { return FALSE; } |
||
4227 | } |
||
4228 | |||
4229 | |||
4230 | |||
4231 | function MalformedCloseTag__finalise(&$res) |
||
4236 | } |
||
4237 | |||
4238 | /* MalformedBlock: MalformedOpenTag | MalformedCloseTag */ |
||
4239 | protected $match_MalformedBlock_typestack = array('MalformedBlock'); |
||
4240 | function match_MalformedBlock ($stack = array()) { |
||
4241 | $matchrule = "MalformedBlock"; $result = $this->construct($matchrule, $matchrule, null); |
||
4242 | $_685 = NULL; |
||
4243 | do { |
||
4244 | $res_682 = $result; |
||
4245 | $pos_682 = $this->pos; |
||
4246 | $matcher = 'match_'.'MalformedOpenTag'; $key = $matcher; $pos = $this->pos; |
||
4247 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4248 | if ($subres !== FALSE) { |
||
4249 | $this->store( $result, $subres ); |
||
4250 | $_685 = TRUE; break; |
||
4251 | } |
||
4252 | $result = $res_682; |
||
4253 | $this->pos = $pos_682; |
||
4254 | $matcher = 'match_'.'MalformedCloseTag'; $key = $matcher; $pos = $this->pos; |
||
4255 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4256 | if ($subres !== FALSE) { |
||
4257 | $this->store( $result, $subres ); |
||
4258 | $_685 = TRUE; break; |
||
4259 | } |
||
4260 | $result = $res_682; |
||
4261 | $this->pos = $pos_682; |
||
4262 | $_685 = FALSE; break; |
||
4263 | } |
||
4264 | while(0); |
||
4265 | if( $_685 === TRUE ) { return $this->finalise($result); } |
||
4266 | if( $_685 === FALSE) { return FALSE; } |
||
4267 | } |
||
4268 | |||
4269 | |||
4270 | |||
4271 | |||
4272 | /* Comment: "<%--" (!"--%>" /(?s)./)+ "--%>" */ |
||
4273 | protected $match_Comment_typestack = array('Comment'); |
||
4274 | function match_Comment ($stack = array()) { |
||
4321 | } |
||
4322 | |||
4323 | |||
4324 | |||
4325 | function Comment__construct(&$res) |
||
4326 | { |
||
4327 | $res['php'] = ''; |
||
4328 | } |
||
4329 | |||
4330 | /* TopTemplate: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock | |
||
4331 | OpenBlock | MalformedBlock | MismatchedEndBlock | Injection | Text)+ */ |
||
4332 | protected $match_TopTemplate_typestack = array('TopTemplate','Template'); |
||
4333 | function match_TopTemplate ($stack = array()) { |
||
4334 | $matchrule = "TopTemplate"; $result = $this->construct($matchrule, $matchrule, array('TemplateMatcher' => 'Template')); |
||
4335 | $count = 0; |
||
4336 | while (true) { |
||
4337 | $res_749 = $result; |
||
4338 | $pos_749 = $this->pos; |
||
4339 | $_748 = NULL; |
||
4340 | do { |
||
4341 | $_746 = NULL; |
||
4342 | do { |
||
4343 | $res_695 = $result; |
||
4344 | $pos_695 = $this->pos; |
||
4345 | $matcher = 'match_'.'Comment'; $key = $matcher; $pos = $this->pos; |
||
4346 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4347 | if ($subres !== FALSE) { |
||
4348 | $this->store( $result, $subres ); |
||
4349 | $_746 = TRUE; break; |
||
4350 | } |
||
4351 | $result = $res_695; |
||
4352 | $this->pos = $pos_695; |
||
4353 | $_744 = NULL; |
||
4354 | do { |
||
4355 | $res_697 = $result; |
||
4356 | $pos_697 = $this->pos; |
||
4357 | $matcher = 'match_'.'Translate'; $key = $matcher; $pos = $this->pos; |
||
4358 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4359 | if ($subres !== FALSE) { |
||
4360 | $this->store( $result, $subres ); |
||
4361 | $_744 = TRUE; break; |
||
4362 | } |
||
4363 | $result = $res_697; |
||
4364 | $this->pos = $pos_697; |
||
4365 | $_742 = NULL; |
||
4366 | do { |
||
4367 | $res_699 = $result; |
||
4368 | $pos_699 = $this->pos; |
||
4369 | $matcher = 'match_'.'If'; $key = $matcher; $pos = $this->pos; |
||
4370 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4371 | if ($subres !== FALSE) { |
||
4372 | $this->store( $result, $subres ); |
||
4373 | $_742 = TRUE; break; |
||
4374 | } |
||
4375 | $result = $res_699; |
||
4376 | $this->pos = $pos_699; |
||
4377 | $_740 = NULL; |
||
4378 | do { |
||
4379 | $res_701 = $result; |
||
4380 | $pos_701 = $this->pos; |
||
4381 | $matcher = 'match_'.'Require'; $key = $matcher; $pos = $this->pos; |
||
4382 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4383 | if ($subres !== FALSE) { |
||
4384 | $this->store( $result, $subres ); |
||
4385 | $_740 = TRUE; break; |
||
4386 | } |
||
4387 | $result = $res_701; |
||
4388 | $this->pos = $pos_701; |
||
4389 | $_738 = NULL; |
||
4390 | do { |
||
4391 | $res_703 = $result; |
||
4392 | $pos_703 = $this->pos; |
||
4393 | $matcher = 'match_'.'CacheBlock'; $key = $matcher; $pos = $this->pos; |
||
4394 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4395 | if ($subres !== FALSE) { |
||
4396 | $this->store( $result, $subres ); |
||
4397 | $_738 = TRUE; break; |
||
4398 | } |
||
4399 | $result = $res_703; |
||
4400 | $this->pos = $pos_703; |
||
4401 | $_736 = NULL; |
||
4402 | do { |
||
4403 | $res_705 = $result; |
||
4404 | $pos_705 = $this->pos; |
||
4405 | $matcher = 'match_'.'UncachedBlock'; $key = $matcher; $pos = $this->pos; |
||
4406 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4407 | if ($subres !== FALSE) { |
||
4408 | $this->store( $result, $subres ); |
||
4409 | $_736 = TRUE; break; |
||
4410 | } |
||
4411 | $result = $res_705; |
||
4412 | $this->pos = $pos_705; |
||
4413 | $_734 = NULL; |
||
4414 | do { |
||
4415 | $res_707 = $result; |
||
4416 | $pos_707 = $this->pos; |
||
4417 | $matcher = 'match_'.'OldI18NTag'; $key = $matcher; $pos = $this->pos; |
||
4418 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4419 | if ($subres !== FALSE) { |
||
4420 | $this->store( $result, $subres ); |
||
4421 | $_734 = TRUE; break; |
||
4422 | } |
||
4423 | $result = $res_707; |
||
4424 | $this->pos = $pos_707; |
||
4425 | $_732 = NULL; |
||
4426 | do { |
||
4427 | $res_709 = $result; |
||
4428 | $pos_709 = $this->pos; |
||
4429 | $matcher = 'match_'.'Include'; $key = $matcher; $pos = $this->pos; |
||
4430 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4431 | if ($subres !== FALSE) { |
||
4432 | $this->store( $result, $subres ); |
||
4433 | $_732 = TRUE; break; |
||
4434 | } |
||
4435 | $result = $res_709; |
||
4436 | $this->pos = $pos_709; |
||
4437 | $_730 = NULL; |
||
4438 | do { |
||
4439 | $res_711 = $result; |
||
4440 | $pos_711 = $this->pos; |
||
4441 | $matcher = 'match_'.'ClosedBlock'; $key = $matcher; $pos = $this->pos; |
||
4442 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4443 | if ($subres !== FALSE) { |
||
4444 | $this->store( $result, $subres ); |
||
4445 | $_730 = TRUE; break; |
||
4446 | } |
||
4447 | $result = $res_711; |
||
4448 | $this->pos = $pos_711; |
||
4449 | $_728 = NULL; |
||
4450 | do { |
||
4451 | $res_713 = $result; |
||
4452 | $pos_713 = $this->pos; |
||
4453 | $matcher = 'match_'.'OpenBlock'; $key = $matcher; $pos = $this->pos; |
||
4454 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4455 | if ($subres !== FALSE) { |
||
4456 | $this->store( $result, $subres ); |
||
4457 | $_728 = TRUE; break; |
||
4458 | } |
||
4459 | $result = $res_713; |
||
4460 | $this->pos = $pos_713; |
||
4461 | $_726 = NULL; |
||
4462 | do { |
||
4463 | $res_715 = $result; |
||
4464 | $pos_715 = $this->pos; |
||
4465 | $matcher = 'match_'.'MalformedBlock'; $key = $matcher; $pos = $this->pos; |
||
4466 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4467 | if ($subres !== FALSE) { |
||
4468 | $this->store( $result, $subres ); |
||
4469 | $_726 = TRUE; break; |
||
4470 | } |
||
4471 | $result = $res_715; |
||
4472 | $this->pos = $pos_715; |
||
4473 | $_724 = NULL; |
||
4474 | do { |
||
4475 | $res_717 = $result; |
||
4476 | $pos_717 = $this->pos; |
||
4477 | $matcher = 'match_'.'MismatchedEndBlock'; $key = $matcher; $pos = $this->pos; |
||
4478 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4479 | if ($subres !== FALSE) { |
||
4480 | $this->store( $result, $subres ); |
||
4481 | $_724 = TRUE; break; |
||
4482 | } |
||
4483 | $result = $res_717; |
||
4484 | $this->pos = $pos_717; |
||
4485 | $_722 = NULL; |
||
4486 | do { |
||
4487 | $res_719 = $result; |
||
4488 | $pos_719 = $this->pos; |
||
4489 | $matcher = 'match_'.'Injection'; $key = $matcher; $pos = $this->pos; |
||
4490 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4491 | if ($subres !== FALSE) { |
||
4492 | $this->store( $result, $subres ); |
||
4493 | $_722 = TRUE; break; |
||
4494 | } |
||
4495 | $result = $res_719; |
||
4496 | $this->pos = $pos_719; |
||
4497 | $matcher = 'match_'.'Text'; $key = $matcher; $pos = $this->pos; |
||
4498 | $subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
||
4499 | if ($subres !== FALSE) { |
||
4500 | $this->store( $result, $subres ); |
||
4501 | $_722 = TRUE; break; |
||
4502 | } |
||
4503 | $result = $res_719; |
||
4504 | $this->pos = $pos_719; |
||
4505 | $_722 = FALSE; break; |
||
4506 | } |
||
4507 | while(0); |
||
4508 | if( $_722 === TRUE ) { |
||
4509 | $_724 = TRUE; break; |
||
4510 | } |
||
4511 | $result = $res_717; |
||
4512 | $this->pos = $pos_717; |
||
4513 | $_724 = FALSE; break; |
||
4514 | } |
||
4515 | while(0); |
||
4516 | if( $_724 === TRUE ) { $_726 = TRUE; break; } |
||
4517 | $result = $res_715; |
||
4518 | $this->pos = $pos_715; |
||
4519 | $_726 = FALSE; break; |
||
4520 | } |
||
4521 | while(0); |
||
4522 | if( $_726 === TRUE ) { $_728 = TRUE; break; } |
||
4523 | $result = $res_713; |
||
4524 | $this->pos = $pos_713; |
||
4525 | $_728 = FALSE; break; |
||
4526 | } |
||
4527 | while(0); |
||
4528 | if( $_728 === TRUE ) { $_730 = TRUE; break; } |
||
4529 | $result = $res_711; |
||
4530 | $this->pos = $pos_711; |
||
4531 | $_730 = FALSE; break; |
||
4532 | } |
||
4533 | while(0); |
||
4534 | if( $_730 === TRUE ) { $_732 = TRUE; break; } |
||
4535 | $result = $res_709; |
||
4536 | $this->pos = $pos_709; |
||
4537 | $_732 = FALSE; break; |
||
4538 | } |
||
4539 | while(0); |
||
4540 | if( $_732 === TRUE ) { $_734 = TRUE; break; } |
||
4541 | $result = $res_707; |
||
4542 | $this->pos = $pos_707; |
||
4543 | $_734 = FALSE; break; |
||
4544 | } |
||
4545 | while(0); |
||
4546 | if( $_734 === TRUE ) { $_736 = TRUE; break; } |
||
4547 | $result = $res_705; |
||
4548 | $this->pos = $pos_705; |
||
4549 | $_736 = FALSE; break; |
||
4550 | } |
||
4551 | while(0); |
||
4552 | if( $_736 === TRUE ) { $_738 = TRUE; break; } |
||
4553 | $result = $res_703; |
||
4554 | $this->pos = $pos_703; |
||
4555 | $_738 = FALSE; break; |
||
4556 | } |
||
4557 | while(0); |
||
4558 | if( $_738 === TRUE ) { $_740 = TRUE; break; } |
||
4559 | $result = $res_701; |
||
4560 | $this->pos = $pos_701; |
||
4561 | $_740 = FALSE; break; |
||
4562 | } |
||
4563 | while(0); |
||
4564 | if( $_740 === TRUE ) { $_742 = TRUE; break; } |
||
4565 | $result = $res_699; |
||
4566 | $this->pos = $pos_699; |
||
4567 | $_742 = FALSE; break; |
||
4568 | } |
||
4569 | while(0); |
||
4570 | if( $_742 === TRUE ) { $_744 = TRUE; break; } |
||
4571 | $result = $res_697; |
||
4572 | $this->pos = $pos_697; |
||
4573 | $_744 = FALSE; break; |
||
4574 | } |
||
4575 | while(0); |
||
4576 | if( $_744 === TRUE ) { $_746 = TRUE; break; } |
||
4577 | $result = $res_695; |
||
4578 | $this->pos = $pos_695; |
||
4579 | $_746 = FALSE; break; |
||
4580 | } |
||
4581 | while(0); |
||
4582 | if( $_746 === FALSE) { $_748 = FALSE; break; } |
||
4583 | $_748 = TRUE; break; |
||
4584 | } |
||
4585 | while(0); |
||
4586 | if( $_748 === FALSE) { |
||
4587 | $result = $res_749; |
||
4588 | $this->pos = $pos_749; |
||
4589 | unset( $res_749 ); |
||
4590 | unset( $pos_749 ); |
||
4591 | break; |
||
4592 | } |
||
4593 | $count += 1; |
||
4594 | } |
||
4595 | if ($count > 0) { return $this->finalise($result); } |
||
4596 | else { return FALSE; } |
||
4597 | } |
||
4598 | |||
4599 | |||
4600 | |||
4601 | |||
4602 | /** |
||
4603 | * The TopTemplate also includes the opening stanza to start off the template |
||
4604 | */ |
||
4605 | function TopTemplate__construct(&$res) |
||
4606 | { |
||
4607 | $res['php'] = "<?php" . PHP_EOL; |
||
4608 | } |
||
4609 | |||
4610 | /* Text: ( |
||
4611 | / [^<${\\]+ / | |
||
4612 | / (\\.) / | |
||
4613 | '<' !'%' | |
||
4614 | '$' !(/[A-Za-z_]/) | |
||
4615 | '{' !'$' | |
||
4616 | '{$' !(/[A-Za-z_]/) |
||
4617 | )+ */ |
||
4618 | protected $match_Text_typestack = array('Text'); |
||
4619 | function match_Text ($stack = array()) { |
||
4620 | $matchrule = "Text"; $result = $this->construct($matchrule, $matchrule, null); |
||
4621 | $count = 0; |
||
4622 | while (true) { |
||
4623 | $res_788 = $result; |
||
4624 | $pos_788 = $this->pos; |
||
4625 | $_787 = NULL; |
||
4626 | do { |
||
4627 | $_785 = NULL; |
||
4628 | do { |
||
4629 | $res_750 = $result; |
||
4630 | $pos_750 = $this->pos; |
||
4631 | if (( $subres = $this->rx( '/ [^<${\\\\]+ /' ) ) !== FALSE) { |
||
4632 | $result["text"] .= $subres; |
||
4633 | $_785 = TRUE; break; |
||
4634 | } |
||
4635 | $result = $res_750; |
||
4636 | $this->pos = $pos_750; |
||
4637 | $_783 = NULL; |
||
4638 | do { |
||
4639 | $res_752 = $result; |
||
4640 | $pos_752 = $this->pos; |
||
4641 | if (( $subres = $this->rx( '/ (\\\\.) /' ) ) !== FALSE) { |
||
4642 | $result["text"] .= $subres; |
||
4643 | $_783 = TRUE; break; |
||
4644 | } |
||
4645 | $result = $res_752; |
||
4646 | $this->pos = $pos_752; |
||
4647 | $_781 = NULL; |
||
4648 | do { |
||
4649 | $res_754 = $result; |
||
4650 | $pos_754 = $this->pos; |
||
4651 | $_757 = NULL; |
||
4652 | do { |
||
4653 | if (substr($this->string,$this->pos,1) == '<') { |
||
4654 | $this->pos += 1; |
||
4655 | $result["text"] .= '<'; |
||
4656 | } |
||
4657 | else { $_757 = FALSE; break; } |
||
4658 | $res_756 = $result; |
||
4659 | $pos_756 = $this->pos; |
||
4660 | if (substr($this->string,$this->pos,1) == '%') { |
||
4661 | $this->pos += 1; |
||
4662 | $result["text"] .= '%'; |
||
4663 | $result = $res_756; |
||
4664 | $this->pos = $pos_756; |
||
4665 | $_757 = FALSE; break; |
||
4666 | } |
||
4667 | else { |
||
4668 | $result = $res_756; |
||
4669 | $this->pos = $pos_756; |
||
4670 | } |
||
4671 | $_757 = TRUE; break; |
||
4672 | } |
||
4673 | while(0); |
||
4674 | if( $_757 === TRUE ) { $_781 = TRUE; break; } |
||
4675 | $result = $res_754; |
||
4676 | $this->pos = $pos_754; |
||
4677 | $_779 = NULL; |
||
4678 | do { |
||
4679 | $res_759 = $result; |
||
4680 | $pos_759 = $this->pos; |
||
4681 | $_764 = NULL; |
||
4682 | do { |
||
4683 | if (substr($this->string,$this->pos,1) == '$') { |
||
4684 | $this->pos += 1; |
||
4685 | $result["text"] .= '$'; |
||
4686 | } |
||
4687 | else { $_764 = FALSE; break; } |
||
4688 | $res_763 = $result; |
||
4689 | $pos_763 = $this->pos; |
||
4690 | $_762 = NULL; |
||
4691 | do { |
||
4692 | if (( $subres = $this->rx( '/[A-Za-z_]/' ) ) !== FALSE) { |
||
4693 | $result["text"] .= $subres; |
||
4694 | } |
||
4695 | else { $_762 = FALSE; break; } |
||
4696 | $_762 = TRUE; break; |
||
4697 | } |
||
4698 | while(0); |
||
4699 | if( $_762 === TRUE ) { |
||
4700 | $result = $res_763; |
||
4701 | $this->pos = $pos_763; |
||
4702 | $_764 = FALSE; break; |
||
4703 | } |
||
4704 | if( $_762 === FALSE) { |
||
4705 | $result = $res_763; |
||
4706 | $this->pos = $pos_763; |
||
4707 | } |
||
4708 | $_764 = TRUE; break; |
||
4709 | } |
||
4710 | while(0); |
||
4711 | if( $_764 === TRUE ) { $_779 = TRUE; break; } |
||
4712 | $result = $res_759; |
||
4713 | $this->pos = $pos_759; |
||
4714 | $_777 = NULL; |
||
4715 | do { |
||
4716 | $res_766 = $result; |
||
4717 | $pos_766 = $this->pos; |
||
4718 | $_769 = NULL; |
||
4719 | do { |
||
4720 | if (substr($this->string,$this->pos,1) == '{') { |
||
4721 | $this->pos += 1; |
||
4722 | $result["text"] .= '{'; |
||
4723 | } |
||
4724 | else { $_769 = FALSE; break; } |
||
4725 | $res_768 = $result; |
||
4726 | $pos_768 = $this->pos; |
||
4727 | if (substr($this->string,$this->pos,1) == '$') { |
||
4728 | $this->pos += 1; |
||
4729 | $result["text"] .= '$'; |
||
4730 | $result = $res_768; |
||
4731 | $this->pos = $pos_768; |
||
4732 | $_769 = FALSE; break; |
||
4733 | } |
||
4734 | else { |
||
4735 | $result = $res_768; |
||
4736 | $this->pos = $pos_768; |
||
4737 | } |
||
4738 | $_769 = TRUE; break; |
||
4739 | } |
||
4740 | while(0); |
||
4741 | if( $_769 === TRUE ) { $_777 = TRUE; break; } |
||
4742 | $result = $res_766; |
||
4743 | $this->pos = $pos_766; |
||
4744 | $_775 = NULL; |
||
4745 | do { |
||
4746 | if (( $subres = $this->literal( '{$' ) ) !== FALSE) { |
||
4747 | $result["text"] .= $subres; |
||
4748 | } |
||
4749 | else { $_775 = FALSE; break; } |
||
4750 | $res_774 = $result; |
||
4751 | $pos_774 = $this->pos; |
||
4752 | $_773 = NULL; |
||
4753 | do { |
||
4754 | if (( $subres = $this->rx( '/[A-Za-z_]/' ) ) !== FALSE) { |
||
4755 | $result["text"] .= $subres; |
||
4756 | } |
||
4757 | else { $_773 = FALSE; break; } |
||
4758 | $_773 = TRUE; break; |
||
4759 | } |
||
4760 | while(0); |
||
4761 | if( $_773 === TRUE ) { |
||
4762 | $result = $res_774; |
||
4763 | $this->pos = $pos_774; |
||
4764 | $_775 = FALSE; break; |
||
4765 | } |
||
4766 | if( $_773 === FALSE) { |
||
4767 | $result = $res_774; |
||
4768 | $this->pos = $pos_774; |
||
4769 | } |
||
4770 | $_775 = TRUE; break; |
||
4771 | } |
||
4772 | while(0); |
||
4773 | if( $_775 === TRUE ) { $_777 = TRUE; break; } |
||
4774 | $result = $res_766; |
||
4775 | $this->pos = $pos_766; |
||
4776 | $_777 = FALSE; break; |
||
4777 | } |
||
4778 | while(0); |
||
4779 | if( $_777 === TRUE ) { $_779 = TRUE; break; } |
||
4780 | $result = $res_759; |
||
4781 | $this->pos = $pos_759; |
||
4782 | $_779 = FALSE; break; |
||
4783 | } |
||
4784 | while(0); |
||
4785 | if( $_779 === TRUE ) { $_781 = TRUE; break; } |
||
4786 | $result = $res_754; |
||
4787 | $this->pos = $pos_754; |
||
4788 | $_781 = FALSE; break; |
||
4789 | } |
||
4790 | while(0); |
||
4791 | if( $_781 === TRUE ) { $_783 = TRUE; break; } |
||
4792 | $result = $res_752; |
||
4793 | $this->pos = $pos_752; |
||
4794 | $_783 = FALSE; break; |
||
4795 | } |
||
4796 | while(0); |
||
4797 | if( $_783 === TRUE ) { $_785 = TRUE; break; } |
||
4798 | $result = $res_750; |
||
4799 | $this->pos = $pos_750; |
||
4800 | $_785 = FALSE; break; |
||
4801 | } |
||
4802 | while(0); |
||
4803 | if( $_785 === FALSE) { $_787 = FALSE; break; } |
||
4804 | $_787 = TRUE; break; |
||
4805 | } |
||
4806 | while(0); |
||
4807 | if( $_787 === FALSE) { |
||
4808 | $result = $res_788; |
||
4809 | $this->pos = $pos_788; |
||
4810 | unset( $res_788 ); |
||
4811 | unset( $pos_788 ); |
||
4812 | break; |
||
4813 | } |
||
4814 | $count += 1; |
||
4815 | } |
||
4816 | if ($count > 0) { return $this->finalise($result); } |
||
4817 | else { return FALSE; } |
||
4818 | } |
||
4819 | |||
4820 | |||
4821 | |||
4822 | |||
4823 | /** |
||
4824 | * We convert text |
||
4825 | */ |
||
4826 | function Text__finalise(&$res) |
||
4827 | { |
||
4828 | $text = $res['text']; |
||
4829 | |||
4830 | // Unescape any escaped characters in the text, then put back escapes for any single quotes and backslashes |
||
4831 | $text = stripslashes($text); |
||
4832 | $text = addcslashes($text, '\'\\'); |
||
4833 | |||
4834 | // TODO: This is pretty ugly & gets applied on all files not just html. I wonder if we can make this |
||
4835 | // non-dynamically calculated |
||
4836 | $code = <<<'EOC' |
||
4837 | (\SilverStripe\View\SSViewer::getRewriteHashLinksDefault() |
||
4838 | ? \SilverStripe\Core\Convert::raw2att( preg_replace("/^(\\/)+/", "/", $_SERVER['REQUEST_URI'] ) ) |
||
4839 | : "") |
||
4840 | EOC; |
||
4841 | // Because preg_replace replacement requires escaped slashes, addcslashes here |
||
4842 | $text = preg_replace( |
||
4843 | '/(<a[^>]+href *= *)"#/i', |
||
4844 | '\\1"\' . ' . addcslashes($code, '\\') . ' . \'#', |
||
4845 | $text |
||
4846 | ); |
||
4847 | |||
4848 | $res['php'] .= '$val .= \'' . $text . '\';' . PHP_EOL; |
||
4849 | } |
||
4850 | |||
4851 | /****************** |
||
4852 | * Here ends the parser itself. Below are utility methods to use the parser |
||
4853 | */ |
||
4854 | |||
4855 | /** |
||
4856 | * Compiles some passed template source code into the php code that will execute as per the template source. |
||
4857 | * |
||
4858 | * @throws SSTemplateParseException |
||
4859 | * @param string $string The source of the template |
||
4860 | * @param string $templateName The name of the template, normally the filename the template source was loaded from |
||
4861 | * @param bool $includeDebuggingComments True is debugging comments should be included in the output |
||
4862 | * @param bool $topTemplate True if this is a top template, false if it's just a template |
||
4863 | * @return mixed|string The php that, when executed (via include or exec) will behave as per the template source |
||
4864 | */ |
||
4865 | public function compileString($string, $templateName = "", $includeDebuggingComments = false, $topTemplate = true) |
||
4900 | } |
||
4901 | |||
4902 | /** |
||
4903 | * @param string $code |
||
4904 | * @return string $code |
||
4905 | */ |
||
4906 | protected function includeDebuggingComments($code, $templateName) |
||
4934 | } |
||
4935 | |||
4936 | /** |
||
4937 | * Compiles some file that contains template source code, and returns the php code that will execute as per that |
||
4938 | * source |
||
4939 | * |
||
4940 | * @static |
||
4941 | * @param $template - A file path that contains template source code |
||
4942 | * @return mixed|string - The php that, when executed (via include or exec) will behave as per the template source |
||
4943 | */ |
||
4944 | public function compileFile($template) |
||
4945 | { |
||
4946 | return $this->compileString(file_get_contents($template), $template); |
||
4947 | } |
||
4948 | } |
||
4949 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.