|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
WARNING: This file has been machine generated. Do not edit it, or your changes will be overwritten next time it is compiled. |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
// We want this to work when run by hand too |
|
11
|
|
|
if (defined(THIRDPARTY_PATH)) { |
|
12
|
|
|
require_once(THIRDPARTY_PATH . '/php-peg/Parser.php'); |
|
13
|
|
|
} |
|
14
|
|
|
else { |
|
15
|
|
|
$base = dirname(__FILE__); |
|
16
|
|
|
require_once($base.'/../thirdparty/php-peg/Parser.php'); |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* This is the exception raised when failing to parse a template. Note that we don't currently do any static analysis, |
|
21
|
|
|
* so we can't know if the template will run, just if it's malformed. It also won't catch mistakes that still look |
|
22
|
|
|
* valid. |
|
23
|
|
|
* |
|
24
|
|
|
* @package framework |
|
25
|
|
|
* @subpackage view |
|
26
|
|
|
*/ |
|
27
|
|
|
class SSTemplateParseException extends Exception { |
|
28
|
|
|
|
|
29
|
|
|
function __construct($message, $parser) { |
|
30
|
|
|
$prior = substr($parser->string, 0, $parser->pos); |
|
31
|
|
|
|
|
32
|
|
|
preg_match_all('/\r\n|\r|\n/', $prior, $matches); |
|
33
|
|
|
$line = count($matches[0])+1; |
|
34
|
|
|
|
|
35
|
|
|
parent::__construct("Parse error in template on line $line. Error was: $message"); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* This is the parser for the SilverStripe template language. It gets called on a string and uses a php-peg parser |
|
42
|
|
|
* to match that string against the language structure, building up the PHP code to execute that structure as it |
|
43
|
|
|
* parses |
|
44
|
|
|
* |
|
45
|
|
|
* The $result array that is built up as part of the parsing (see thirdparty/php-peg/README.md for more on how |
|
46
|
|
|
* parsers build results) has one special member, 'php', which contains the php equivalent of that part of the |
|
47
|
|
|
* template tree. |
|
48
|
|
|
* |
|
49
|
|
|
* Some match rules generate alternate php, or other variations, so check the per-match documentation too. |
|
50
|
|
|
* |
|
51
|
|
|
* Terms used: |
|
52
|
|
|
* |
|
53
|
|
|
* Marked: A string or lookup in the template that has been explictly marked as such - lookups by prepending with |
|
54
|
|
|
* "$" (like $Foo.Bar), strings by wrapping with single or double quotes ('Foo' or "Foo") |
|
55
|
|
|
* |
|
56
|
|
|
* Bare: The opposite of marked. An argument that has to has it's type inferred by usage and 2.4 defaults. |
|
57
|
|
|
* |
|
58
|
|
|
* Example of using a bare argument for a loop block: <% loop Foo %> |
|
59
|
|
|
* |
|
60
|
|
|
* Block: One of two SS template structures. The special characters "<%" and "%>" are used to wrap the opening and |
|
61
|
|
|
* (required or forbidden depending on which block exactly) closing block marks. |
|
62
|
|
|
* |
|
63
|
|
|
* Open Block: An SS template block that doesn't wrap any content or have a closing end tag (in fact, a closing end |
|
64
|
|
|
* tag is forbidden) |
|
65
|
|
|
* |
|
66
|
|
|
* Closed Block: An SS template block that wraps content, and requires a counterpart <% end_blockname %> tag |
|
67
|
|
|
* |
|
68
|
|
|
* Angle Bracket: angle brackets "<" and ">" are used to eat whitespace between template elements |
|
69
|
|
|
* N: eats white space including newlines (using in legacy _t support) |
|
70
|
|
|
* |
|
71
|
|
|
* @package framework |
|
72
|
|
|
* @subpackage view |
|
73
|
|
|
*/ |
|
74
|
|
|
class SSTemplateParser extends Parser implements TemplateParser { |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @var bool - Set true by SSTemplateParser::compileString if the template should include comments intended |
|
78
|
|
|
* for debugging (template source, included files, etc) |
|
79
|
|
|
*/ |
|
80
|
|
|
protected $includeDebuggingComments = false; |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Stores the user-supplied closed block extension rules in the form: |
|
84
|
|
|
* array( |
|
85
|
|
|
* 'name' => function (&$res) {} |
|
86
|
|
|
* ) |
|
87
|
|
|
* See SSTemplateParser::ClosedBlock_Handle_Loop for an example of what the callable should look like |
|
88
|
|
|
* @var array |
|
89
|
|
|
*/ |
|
90
|
|
|
protected $closedBlocks = array(); |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Stores the user-supplied open block extension rules in the form: |
|
94
|
|
|
* array( |
|
95
|
|
|
* 'name' => function (&$res) {} |
|
96
|
|
|
* ) |
|
97
|
|
|
* See SSTemplateParser::OpenBlock_Handle_Base_tag for an example of what the callable should look like |
|
98
|
|
|
* @var array |
|
99
|
|
|
*/ |
|
100
|
|
|
protected $openBlocks = array(); |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Allow the injection of new closed & open block callables |
|
104
|
|
|
* @param array $closedBlocks |
|
105
|
|
|
* @param array $openBlocks |
|
106
|
|
|
*/ |
|
107
|
|
|
public function __construct($closedBlocks = array(), $openBlocks = array()) { |
|
108
|
|
|
$this->setClosedBlocks($closedBlocks); |
|
109
|
|
|
$this->setOpenBlocks($openBlocks); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Override the function that constructs the result arrays to also prepare a 'php' item in the array |
|
114
|
|
|
*/ |
|
115
|
|
|
function construct($matchrule, $name, $arguments = null) { |
|
116
|
|
|
$res = parent::construct($matchrule, $name, $arguments); |
|
117
|
|
|
if (!isset($res['php'])) $res['php'] = ''; |
|
118
|
|
|
return $res; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* Set the closed blocks that the template parser should use |
|
123
|
|
|
* |
|
124
|
|
|
* This method will delete any existing closed blocks, please use addClosedBlock if you don't |
|
125
|
|
|
* want to overwrite |
|
126
|
|
|
* @param array $closedBlocks |
|
127
|
|
|
* @throws InvalidArgumentException |
|
128
|
|
|
*/ |
|
129
|
|
|
public function setClosedBlocks($closedBlocks) { |
|
130
|
|
|
$this->closedBlocks = array(); |
|
131
|
|
|
foreach ((array) $closedBlocks as $name => $callable) { |
|
132
|
|
|
$this->addClosedBlock($name, $callable); |
|
133
|
|
|
} |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* Set the open blocks that the template parser should use |
|
138
|
|
|
* |
|
139
|
|
|
* This method will delete any existing open blocks, please use addOpenBlock if you don't |
|
140
|
|
|
* want to overwrite |
|
141
|
|
|
* @param array $openBlocks |
|
142
|
|
|
* @throws InvalidArgumentException |
|
143
|
|
|
*/ |
|
144
|
|
|
public function setOpenBlocks($openBlocks) { |
|
145
|
|
|
$this->openBlocks = array(); |
|
146
|
|
|
foreach ((array) $openBlocks as $name => $callable) { |
|
147
|
|
|
$this->addOpenBlock($name, $callable); |
|
148
|
|
|
} |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* Add a closed block callable to allow <% name %><% end_name %> syntax |
|
153
|
|
|
* @param string $name The name of the token to be used in the syntax <% name %><% end_name %> |
|
154
|
|
|
* @param callable $callable The function that modifies the generation of template code |
|
155
|
|
|
* @throws InvalidArgumentException |
|
156
|
|
|
*/ |
|
157
|
|
|
public function addClosedBlock($name, $callable) { |
|
158
|
|
|
$this->validateExtensionBlock($name, $callable, 'Closed block'); |
|
159
|
|
|
$this->closedBlocks[$name] = $callable; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* Add a closed block callable to allow <% name %> syntax |
|
164
|
|
|
* @param string $name The name of the token to be used in the syntax <% name %> |
|
165
|
|
|
* @param callable $callable The function that modifies the generation of template code |
|
166
|
|
|
* @throws InvalidArgumentException |
|
167
|
|
|
*/ |
|
168
|
|
|
public function addOpenBlock($name, $callable) { |
|
169
|
|
|
$this->validateExtensionBlock($name, $callable, 'Open block'); |
|
170
|
|
|
$this->openBlocks[$name] = $callable; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* Ensures that the arguments to addOpenBlock and addClosedBlock are valid |
|
175
|
|
|
* @param $name |
|
176
|
|
|
* @param $callable |
|
177
|
|
|
* @param $type |
|
178
|
|
|
* @throws InvalidArgumentException |
|
179
|
|
|
*/ |
|
180
|
|
|
protected function validateExtensionBlock($name, $callable, $type) { |
|
181
|
|
|
if (!is_string($name)) { |
|
182
|
|
|
throw new InvalidArgumentException( |
|
183
|
|
|
sprintf( |
|
184
|
|
|
"Name argument for %s must be a string", |
|
185
|
|
|
$type |
|
186
|
|
|
) |
|
187
|
|
|
); |
|
188
|
|
|
} elseif (!is_callable($callable)) { |
|
189
|
|
|
throw new InvalidArgumentException( |
|
190
|
|
|
sprintf( |
|
191
|
|
|
"Callable %s argument named '%s' is not callable", |
|
192
|
|
|
$type, |
|
193
|
|
|
$name |
|
194
|
|
|
) |
|
195
|
|
|
); |
|
196
|
|
|
} |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
/* Template: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock | |
|
200
|
|
|
OpenBlock | MalformedBlock | Injection | Text)+ */ |
|
201
|
|
|
protected $match_Template_typestack = array('Template'); |
|
202
|
|
|
function match_Template ($stack = array()) { |
|
203
|
|
|
$matchrule = "Template"; $result = $this->construct($matchrule, $matchrule, null); |
|
204
|
|
|
$count = 0; |
|
205
|
|
|
while (true) { |
|
206
|
|
|
$res_50 = $result; |
|
207
|
|
|
$pos_50 = $this->pos; |
|
|
|
|
|
|
208
|
|
|
$_49 = NULL; |
|
209
|
|
|
do { |
|
|
|
|
|
|
210
|
|
|
$_47 = NULL; |
|
211
|
|
|
do { |
|
212
|
|
|
$res_0 = $result; |
|
213
|
|
|
$pos_0 = $this->pos; |
|
214
|
|
|
$matcher = 'match_'.'Comment'; $key = $matcher; $pos = $this->pos; |
|
215
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
216
|
|
|
if ($subres !== FALSE) { |
|
217
|
|
|
$this->store( $result, $subres ); |
|
218
|
|
|
$_47 = TRUE; break; |
|
219
|
|
|
} |
|
220
|
|
|
$result = $res_0; |
|
221
|
|
|
$this->pos = $pos_0; |
|
222
|
|
|
$_45 = NULL; |
|
223
|
|
|
do { |
|
224
|
|
|
$res_2 = $result; |
|
225
|
|
|
$pos_2 = $this->pos; |
|
226
|
|
|
$matcher = 'match_'.'Translate'; $key = $matcher; $pos = $this->pos; |
|
227
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
228
|
|
|
if ($subres !== FALSE) { |
|
229
|
|
|
$this->store( $result, $subres ); |
|
230
|
|
|
$_45 = TRUE; break; |
|
231
|
|
|
} |
|
232
|
|
|
$result = $res_2; |
|
233
|
|
|
$this->pos = $pos_2; |
|
234
|
|
|
$_43 = NULL; |
|
235
|
|
|
do { |
|
236
|
|
|
$res_4 = $result; |
|
237
|
|
|
$pos_4 = $this->pos; |
|
238
|
|
|
$matcher = 'match_'.'If'; $key = $matcher; $pos = $this->pos; |
|
239
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
240
|
|
|
if ($subres !== FALSE) { |
|
241
|
|
|
$this->store( $result, $subres ); |
|
242
|
|
|
$_43 = TRUE; break; |
|
243
|
|
|
} |
|
244
|
|
|
$result = $res_4; |
|
245
|
|
|
$this->pos = $pos_4; |
|
246
|
|
|
$_41 = NULL; |
|
247
|
|
|
do { |
|
248
|
|
|
$res_6 = $result; |
|
249
|
|
|
$pos_6 = $this->pos; |
|
250
|
|
|
$matcher = 'match_'.'Require'; $key = $matcher; $pos = $this->pos; |
|
251
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
252
|
|
|
if ($subres !== FALSE) { |
|
253
|
|
|
$this->store( $result, $subres ); |
|
254
|
|
|
$_41 = TRUE; break; |
|
255
|
|
|
} |
|
256
|
|
|
$result = $res_6; |
|
257
|
|
|
$this->pos = $pos_6; |
|
258
|
|
|
$_39 = NULL; |
|
259
|
|
|
do { |
|
260
|
|
|
$res_8 = $result; |
|
261
|
|
|
$pos_8 = $this->pos; |
|
262
|
|
|
$matcher = 'match_'.'CacheBlock'; $key = $matcher; $pos = $this->pos; |
|
263
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
264
|
|
|
if ($subres !== FALSE) { |
|
265
|
|
|
$this->store( $result, $subres ); |
|
266
|
|
|
$_39 = TRUE; break; |
|
267
|
|
|
} |
|
268
|
|
|
$result = $res_8; |
|
269
|
|
|
$this->pos = $pos_8; |
|
270
|
|
|
$_37 = NULL; |
|
271
|
|
|
do { |
|
272
|
|
|
$res_10 = $result; |
|
273
|
|
|
$pos_10 = $this->pos; |
|
274
|
|
|
$matcher = 'match_'.'UncachedBlock'; $key = $matcher; $pos = $this->pos; |
|
275
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
276
|
|
|
if ($subres !== FALSE) { |
|
277
|
|
|
$this->store( $result, $subres ); |
|
278
|
|
|
$_37 = TRUE; break; |
|
279
|
|
|
} |
|
280
|
|
|
$result = $res_10; |
|
281
|
|
|
$this->pos = $pos_10; |
|
282
|
|
|
$_35 = NULL; |
|
283
|
|
|
do { |
|
284
|
|
|
$res_12 = $result; |
|
285
|
|
|
$pos_12 = $this->pos; |
|
286
|
|
|
$matcher = 'match_'.'OldI18NTag'; $key = $matcher; $pos = $this->pos; |
|
287
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
288
|
|
|
if ($subres !== FALSE) { |
|
289
|
|
|
$this->store( $result, $subres ); |
|
290
|
|
|
$_35 = TRUE; break; |
|
291
|
|
|
} |
|
292
|
|
|
$result = $res_12; |
|
293
|
|
|
$this->pos = $pos_12; |
|
294
|
|
|
$_33 = NULL; |
|
295
|
|
|
do { |
|
296
|
|
|
$res_14 = $result; |
|
297
|
|
|
$pos_14 = $this->pos; |
|
298
|
|
|
$matcher = 'match_'.'Include'; $key = $matcher; $pos = $this->pos; |
|
299
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
300
|
|
|
if ($subres !== FALSE) { |
|
301
|
|
|
$this->store( $result, $subres ); |
|
302
|
|
|
$_33 = TRUE; break; |
|
303
|
|
|
} |
|
304
|
|
|
$result = $res_14; |
|
305
|
|
|
$this->pos = $pos_14; |
|
306
|
|
|
$_31 = NULL; |
|
307
|
|
|
do { |
|
308
|
|
|
$res_16 = $result; |
|
309
|
|
|
$pos_16 = $this->pos; |
|
310
|
|
|
$matcher = 'match_'.'ClosedBlock'; $key = $matcher; $pos = $this->pos; |
|
311
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
312
|
|
|
if ($subres !== FALSE) { |
|
313
|
|
|
$this->store( $result, $subres ); |
|
314
|
|
|
$_31 = TRUE; break; |
|
315
|
|
|
} |
|
316
|
|
|
$result = $res_16; |
|
317
|
|
|
$this->pos = $pos_16; |
|
318
|
|
|
$_29 = NULL; |
|
319
|
|
|
do { |
|
320
|
|
|
$res_18 = $result; |
|
321
|
|
|
$pos_18 = $this->pos; |
|
322
|
|
|
$matcher = 'match_'.'OpenBlock'; $key = $matcher; $pos = $this->pos; |
|
323
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
324
|
|
|
if ($subres !== FALSE) { |
|
325
|
|
|
$this->store( $result, $subres ); |
|
326
|
|
|
$_29 = TRUE; break; |
|
327
|
|
|
} |
|
328
|
|
|
$result = $res_18; |
|
329
|
|
|
$this->pos = $pos_18; |
|
330
|
|
|
$_27 = NULL; |
|
331
|
|
|
do { |
|
332
|
|
|
$res_20 = $result; |
|
333
|
|
|
$pos_20 = $this->pos; |
|
334
|
|
|
$matcher = 'match_'.'MalformedBlock'; $key = $matcher; $pos = $this->pos; |
|
335
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
336
|
|
|
if ($subres !== FALSE) { |
|
337
|
|
|
$this->store( $result, $subres ); |
|
338
|
|
|
$_27 = TRUE; break; |
|
339
|
|
|
} |
|
340
|
|
|
$result = $res_20; |
|
341
|
|
|
$this->pos = $pos_20; |
|
342
|
|
|
$_25 = NULL; |
|
343
|
|
|
do { |
|
344
|
|
|
$res_22 = $result; |
|
345
|
|
|
$pos_22 = $this->pos; |
|
346
|
|
|
$matcher = 'match_'.'Injection'; $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
|
|
|
$matcher = 'match_'.'Text'; $key = $matcher; $pos = $this->pos; |
|
355
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
356
|
|
|
if ($subres !== FALSE) { |
|
357
|
|
|
$this->store( $result, $subres ); |
|
358
|
|
|
$_25 = TRUE; break; |
|
359
|
|
|
} |
|
360
|
|
|
$result = $res_22; |
|
361
|
|
|
$this->pos = $pos_22; |
|
362
|
|
|
$_25 = FALSE; break; |
|
363
|
|
|
} |
|
364
|
|
|
while(0); |
|
365
|
|
|
if( $_25 === TRUE ) { $_27 = TRUE; break; } |
|
366
|
|
|
$result = $res_20; |
|
367
|
|
|
$this->pos = $pos_20; |
|
368
|
|
|
$_27 = FALSE; break; |
|
369
|
|
|
} |
|
370
|
|
|
while(0); |
|
371
|
|
|
if( $_27 === TRUE ) { $_29 = TRUE; break; } |
|
372
|
|
|
$result = $res_18; |
|
373
|
|
|
$this->pos = $pos_18; |
|
374
|
|
|
$_29 = FALSE; break; |
|
375
|
|
|
} |
|
376
|
|
|
while(0); |
|
377
|
|
|
if( $_29 === TRUE ) { $_31 = TRUE; break; } |
|
378
|
|
|
$result = $res_16; |
|
379
|
|
|
$this->pos = $pos_16; |
|
380
|
|
|
$_31 = FALSE; break; |
|
381
|
|
|
} |
|
382
|
|
|
while(0); |
|
383
|
|
|
if( $_31 === TRUE ) { $_33 = TRUE; break; } |
|
384
|
|
|
$result = $res_14; |
|
385
|
|
|
$this->pos = $pos_14; |
|
386
|
|
|
$_33 = FALSE; break; |
|
387
|
|
|
} |
|
388
|
|
|
while(0); |
|
389
|
|
|
if( $_33 === TRUE ) { $_35 = TRUE; break; } |
|
390
|
|
|
$result = $res_12; |
|
391
|
|
|
$this->pos = $pos_12; |
|
392
|
|
|
$_35 = FALSE; break; |
|
393
|
|
|
} |
|
394
|
|
|
while(0); |
|
395
|
|
|
if( $_35 === TRUE ) { $_37 = TRUE; break; } |
|
396
|
|
|
$result = $res_10; |
|
397
|
|
|
$this->pos = $pos_10; |
|
398
|
|
|
$_37 = FALSE; break; |
|
399
|
|
|
} |
|
400
|
|
|
while(0); |
|
401
|
|
|
if( $_37 === TRUE ) { $_39 = TRUE; break; } |
|
402
|
|
|
$result = $res_8; |
|
403
|
|
|
$this->pos = $pos_8; |
|
404
|
|
|
$_39 = FALSE; break; |
|
405
|
|
|
} |
|
406
|
|
|
while(0); |
|
407
|
|
|
if( $_39 === TRUE ) { $_41 = TRUE; break; } |
|
408
|
|
|
$result = $res_6; |
|
409
|
|
|
$this->pos = $pos_6; |
|
410
|
|
|
$_41 = FALSE; break; |
|
411
|
|
|
} |
|
412
|
|
|
while(0); |
|
413
|
|
|
if( $_41 === TRUE ) { $_43 = TRUE; break; } |
|
414
|
|
|
$result = $res_4; |
|
415
|
|
|
$this->pos = $pos_4; |
|
416
|
|
|
$_43 = FALSE; break; |
|
417
|
|
|
} |
|
418
|
|
|
while(0); |
|
419
|
|
|
if( $_43 === TRUE ) { $_45 = TRUE; break; } |
|
420
|
|
|
$result = $res_2; |
|
421
|
|
|
$this->pos = $pos_2; |
|
422
|
|
|
$_45 = FALSE; break; |
|
423
|
|
|
} |
|
424
|
|
|
while(0); |
|
425
|
|
|
if( $_45 === TRUE ) { $_47 = TRUE; break; } |
|
426
|
|
|
$result = $res_0; |
|
427
|
|
|
$this->pos = $pos_0; |
|
428
|
|
|
$_47 = FALSE; break; |
|
429
|
|
|
} |
|
430
|
|
|
while(0); |
|
431
|
|
|
if( $_47 === FALSE) { $_49 = FALSE; break; } |
|
432
|
|
|
$_49 = TRUE; break; |
|
433
|
|
|
} |
|
434
|
|
|
while(0); |
|
435
|
|
|
if( $_49 === FALSE) { |
|
436
|
|
|
$result = $res_50; |
|
437
|
|
|
$this->pos = $pos_50; |
|
438
|
|
|
unset( $res_50 ); |
|
439
|
|
|
unset( $pos_50 ); |
|
440
|
|
|
break; |
|
441
|
|
|
} |
|
442
|
|
|
$count += 1; |
|
443
|
|
|
} |
|
444
|
|
|
if ($count > 0) { return $this->finalise($result); } |
|
445
|
|
|
else { return FALSE; } |
|
446
|
|
|
} |
|
447
|
|
|
|
|
448
|
|
|
|
|
449
|
|
|
|
|
450
|
|
|
function Template_STR(&$res, $sub) { |
|
451
|
|
|
$res['php'] .= $sub['php'] . PHP_EOL ; |
|
452
|
|
|
} |
|
453
|
|
|
|
|
454
|
|
|
/* Word: / [A-Za-z_] [A-Za-z0-9_]* / */ |
|
455
|
|
|
protected $match_Word_typestack = array('Word'); |
|
456
|
|
|
function match_Word ($stack = array()) { |
|
|
|
|
|
|
457
|
|
|
$matchrule = "Word"; $result = $this->construct($matchrule, $matchrule, null); |
|
458
|
|
|
if (( $subres = $this->rx( '/ [A-Za-z_] [A-Za-z0-9_]* /' ) ) !== FALSE) { |
|
459
|
|
|
$result["text"] .= $subres; |
|
460
|
|
|
return $this->finalise($result); |
|
461
|
|
|
} |
|
462
|
|
|
else { return FALSE; } |
|
463
|
|
|
} |
|
464
|
|
|
|
|
465
|
|
|
|
|
466
|
|
|
/* Number: / [0-9]+ / */ |
|
467
|
|
|
protected $match_Number_typestack = array('Number'); |
|
468
|
|
|
function match_Number ($stack = array()) { |
|
|
|
|
|
|
469
|
|
|
$matchrule = "Number"; $result = $this->construct($matchrule, $matchrule, null); |
|
470
|
|
|
if (( $subres = $this->rx( '/ [0-9]+ /' ) ) !== FALSE) { |
|
471
|
|
|
$result["text"] .= $subres; |
|
472
|
|
|
return $this->finalise($result); |
|
473
|
|
|
} |
|
474
|
|
|
else { return FALSE; } |
|
475
|
|
|
} |
|
476
|
|
|
|
|
477
|
|
|
|
|
478
|
|
|
/* Value: / [A-Za-z0-9_]+ / */ |
|
479
|
|
|
protected $match_Value_typestack = array('Value'); |
|
480
|
|
|
function match_Value ($stack = array()) { |
|
|
|
|
|
|
481
|
|
|
$matchrule = "Value"; $result = $this->construct($matchrule, $matchrule, null); |
|
482
|
|
|
if (( $subres = $this->rx( '/ [A-Za-z0-9_]+ /' ) ) !== FALSE) { |
|
483
|
|
|
$result["text"] .= $subres; |
|
484
|
|
|
return $this->finalise($result); |
|
485
|
|
|
} |
|
486
|
|
|
else { return FALSE; } |
|
487
|
|
|
} |
|
488
|
|
|
|
|
489
|
|
|
|
|
490
|
|
|
/* CallArguments: :Argument ( < "," < :Argument )* */ |
|
491
|
|
|
protected $match_CallArguments_typestack = array('CallArguments'); |
|
492
|
|
|
function match_CallArguments ($stack = array()) { |
|
493
|
|
|
$matchrule = "CallArguments"; $result = $this->construct($matchrule, $matchrule, null); |
|
494
|
|
|
$_61 = NULL; |
|
495
|
|
|
do { |
|
|
|
|
|
|
496
|
|
|
$matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
|
497
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
498
|
|
|
if ($subres !== FALSE) { |
|
499
|
|
|
$this->store( $result, $subres, "Argument" ); |
|
500
|
|
|
} |
|
501
|
|
|
else { $_61 = FALSE; break; } |
|
502
|
|
|
while (true) { |
|
503
|
|
|
$res_60 = $result; |
|
504
|
|
|
$pos_60 = $this->pos; |
|
505
|
|
|
$_59 = NULL; |
|
506
|
|
|
do { |
|
507
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
508
|
|
|
if (substr($this->string,$this->pos,1) == ',') { |
|
|
|
|
|
|
509
|
|
|
$this->pos += 1; |
|
510
|
|
|
$result["text"] .= ','; |
|
511
|
|
|
} |
|
512
|
|
|
else { $_59 = FALSE; break; } |
|
513
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
514
|
|
|
$matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
|
515
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
516
|
|
|
if ($subres !== FALSE) { |
|
517
|
|
|
$this->store( $result, $subres, "Argument" ); |
|
518
|
|
|
} |
|
519
|
|
|
else { $_59 = FALSE; break; } |
|
520
|
|
|
$_59 = TRUE; break; |
|
521
|
|
|
} |
|
522
|
|
|
while(0); |
|
523
|
|
|
if( $_59 === FALSE) { |
|
524
|
|
|
$result = $res_60; |
|
525
|
|
|
$this->pos = $pos_60; |
|
526
|
|
|
unset( $res_60 ); |
|
527
|
|
|
unset( $pos_60 ); |
|
528
|
|
|
break; |
|
529
|
|
|
} |
|
530
|
|
|
} |
|
531
|
|
|
$_61 = TRUE; break; |
|
532
|
|
|
} |
|
533
|
|
|
while(0); |
|
534
|
|
|
if( $_61 === TRUE ) { return $this->finalise($result); } |
|
535
|
|
|
if( $_61 === FALSE) { return FALSE; } |
|
536
|
|
|
} |
|
537
|
|
|
|
|
538
|
|
|
|
|
539
|
|
|
|
|
540
|
|
|
|
|
541
|
|
|
/** |
|
542
|
|
|
* Values are bare words in templates, but strings in PHP. We rely on PHP's type conversion to back-convert |
|
543
|
|
|
* strings to numbers when needed. |
|
544
|
|
|
*/ |
|
545
|
|
|
function CallArguments_Argument(&$res, $sub) { |
|
546
|
|
|
if (!empty($res['php'])) $res['php'] .= ', '; |
|
547
|
|
|
|
|
548
|
|
|
$res['php'] .= ($sub['ArgumentMode'] == 'default') ? $sub['string_php'] : |
|
549
|
|
|
str_replace('$$FINAL', 'XML_val', $sub['php']); |
|
550
|
|
|
} |
|
551
|
|
|
|
|
552
|
|
|
/* Call: Method:Word ( "(" < :CallArguments? > ")" )? */ |
|
553
|
|
|
protected $match_Call_typestack = array('Call'); |
|
554
|
|
|
function match_Call ($stack = array()) { |
|
555
|
|
|
$matchrule = "Call"; $result = $this->construct($matchrule, $matchrule, null); |
|
556
|
|
|
$_71 = NULL; |
|
557
|
|
|
do { |
|
|
|
|
|
|
558
|
|
|
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
|
559
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
560
|
|
|
if ($subres !== FALSE) { |
|
561
|
|
|
$this->store( $result, $subres, "Method" ); |
|
562
|
|
|
} |
|
563
|
|
|
else { $_71 = FALSE; break; } |
|
564
|
|
|
$res_70 = $result; |
|
565
|
|
|
$pos_70 = $this->pos; |
|
566
|
|
|
$_69 = NULL; |
|
567
|
|
|
do { |
|
568
|
|
|
if (substr($this->string,$this->pos,1) == '(') { |
|
|
|
|
|
|
569
|
|
|
$this->pos += 1; |
|
570
|
|
|
$result["text"] .= '('; |
|
571
|
|
|
} |
|
572
|
|
|
else { $_69 = FALSE; break; } |
|
573
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
574
|
|
|
$res_66 = $result; |
|
575
|
|
|
$pos_66 = $this->pos; |
|
576
|
|
|
$matcher = 'match_'.'CallArguments'; $key = $matcher; $pos = $this->pos; |
|
577
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
578
|
|
|
if ($subres !== FALSE) { |
|
579
|
|
|
$this->store( $result, $subres, "CallArguments" ); |
|
580
|
|
|
} |
|
581
|
|
|
else { |
|
582
|
|
|
$result = $res_66; |
|
583
|
|
|
$this->pos = $pos_66; |
|
584
|
|
|
unset( $res_66 ); |
|
585
|
|
|
unset( $pos_66 ); |
|
586
|
|
|
} |
|
587
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
588
|
|
|
if (substr($this->string,$this->pos,1) == ')') { |
|
|
|
|
|
|
589
|
|
|
$this->pos += 1; |
|
590
|
|
|
$result["text"] .= ')'; |
|
591
|
|
|
} |
|
592
|
|
|
else { $_69 = FALSE; break; } |
|
593
|
|
|
$_69 = TRUE; break; |
|
594
|
|
|
} |
|
595
|
|
|
while(0); |
|
596
|
|
|
if( $_69 === FALSE) { |
|
597
|
|
|
$result = $res_70; |
|
598
|
|
|
$this->pos = $pos_70; |
|
599
|
|
|
unset( $res_70 ); |
|
600
|
|
|
unset( $pos_70 ); |
|
601
|
|
|
} |
|
602
|
|
|
$_71 = TRUE; break; |
|
603
|
|
|
} |
|
604
|
|
|
while(0); |
|
605
|
|
|
if( $_71 === TRUE ) { return $this->finalise($result); } |
|
606
|
|
|
if( $_71 === FALSE) { return FALSE; } |
|
607
|
|
|
} |
|
608
|
|
|
|
|
609
|
|
|
|
|
610
|
|
|
/* LookupStep: :Call &"." */ |
|
|
|
|
|
|
611
|
|
|
protected $match_LookupStep_typestack = array('LookupStep'); |
|
612
|
|
|
function match_LookupStep ($stack = array()) { |
|
613
|
|
|
$matchrule = "LookupStep"; $result = $this->construct($matchrule, $matchrule, null); |
|
614
|
|
|
$_75 = NULL; |
|
615
|
|
|
do { |
|
|
|
|
|
|
616
|
|
|
$matcher = 'match_'.'Call'; $key = $matcher; $pos = $this->pos; |
|
617
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
618
|
|
|
if ($subres !== FALSE) { |
|
619
|
|
|
$this->store( $result, $subres, "Call" ); |
|
620
|
|
|
} |
|
621
|
|
|
else { $_75 = FALSE; break; } |
|
622
|
|
|
$res_74 = $result; |
|
623
|
|
|
$pos_74 = $this->pos; |
|
624
|
|
|
if (substr($this->string,$this->pos,1) == '.') { |
|
|
|
|
|
|
625
|
|
|
$this->pos += 1; |
|
626
|
|
|
$result["text"] .= '.'; |
|
627
|
|
|
$result = $res_74; |
|
628
|
|
|
$this->pos = $pos_74; |
|
629
|
|
|
} |
|
630
|
|
|
else { |
|
631
|
|
|
$result = $res_74; |
|
632
|
|
|
$this->pos = $pos_74; |
|
633
|
|
|
$_75 = FALSE; break; |
|
634
|
|
|
} |
|
635
|
|
|
$_75 = TRUE; break; |
|
636
|
|
|
} |
|
637
|
|
|
while(0); |
|
638
|
|
|
if( $_75 === TRUE ) { return $this->finalise($result); } |
|
639
|
|
|
if( $_75 === FALSE) { return FALSE; } |
|
640
|
|
|
} |
|
641
|
|
|
|
|
642
|
|
|
|
|
643
|
|
|
/* LastLookupStep: :Call */ |
|
644
|
|
|
protected $match_LastLookupStep_typestack = array('LastLookupStep'); |
|
645
|
|
|
function match_LastLookupStep ($stack = array()) { |
|
646
|
|
|
$matchrule = "LastLookupStep"; $result = $this->construct($matchrule, $matchrule, null); |
|
647
|
|
|
$matcher = 'match_'.'Call'; $key = $matcher; $pos = $this->pos; |
|
648
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
649
|
|
|
if ($subres !== FALSE) { |
|
650
|
|
|
$this->store( $result, $subres, "Call" ); |
|
651
|
|
|
return $this->finalise($result); |
|
652
|
|
|
} |
|
653
|
|
|
else { return FALSE; } |
|
654
|
|
|
} |
|
655
|
|
|
|
|
656
|
|
|
|
|
657
|
|
|
/* Lookup: LookupStep ("." LookupStep)* "." LastLookupStep | LastLookupStep */ |
|
658
|
|
|
protected $match_Lookup_typestack = array('Lookup'); |
|
659
|
|
|
function match_Lookup ($stack = array()) { |
|
660
|
|
|
$matchrule = "Lookup"; $result = $this->construct($matchrule, $matchrule, null); |
|
661
|
|
|
$_89 = NULL; |
|
662
|
|
|
do { |
|
|
|
|
|
|
663
|
|
|
$res_78 = $result; |
|
664
|
|
|
$pos_78 = $this->pos; |
|
665
|
|
|
$_86 = NULL; |
|
666
|
|
|
do { |
|
667
|
|
|
$matcher = 'match_'.'LookupStep'; $key = $matcher; $pos = $this->pos; |
|
668
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
669
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
670
|
|
|
else { $_86 = FALSE; break; } |
|
671
|
|
|
while (true) { |
|
672
|
|
|
$res_83 = $result; |
|
673
|
|
|
$pos_83 = $this->pos; |
|
674
|
|
|
$_82 = NULL; |
|
675
|
|
|
do { |
|
676
|
|
|
if (substr($this->string,$this->pos,1) == '.') { |
|
|
|
|
|
|
677
|
|
|
$this->pos += 1; |
|
678
|
|
|
$result["text"] .= '.'; |
|
679
|
|
|
} |
|
680
|
|
|
else { $_82 = FALSE; break; } |
|
681
|
|
|
$matcher = 'match_'.'LookupStep'; $key = $matcher; $pos = $this->pos; |
|
682
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
683
|
|
|
if ($subres !== FALSE) { |
|
684
|
|
|
$this->store( $result, $subres ); |
|
685
|
|
|
} |
|
686
|
|
|
else { $_82 = FALSE; break; } |
|
687
|
|
|
$_82 = TRUE; break; |
|
688
|
|
|
} |
|
689
|
|
|
while(0); |
|
690
|
|
|
if( $_82 === FALSE) { |
|
691
|
|
|
$result = $res_83; |
|
692
|
|
|
$this->pos = $pos_83; |
|
693
|
|
|
unset( $res_83 ); |
|
694
|
|
|
unset( $pos_83 ); |
|
695
|
|
|
break; |
|
696
|
|
|
} |
|
697
|
|
|
} |
|
698
|
|
|
if (substr($this->string,$this->pos,1) == '.') { |
|
|
|
|
|
|
699
|
|
|
$this->pos += 1; |
|
700
|
|
|
$result["text"] .= '.'; |
|
701
|
|
|
} |
|
702
|
|
|
else { $_86 = FALSE; break; } |
|
703
|
|
|
$matcher = 'match_'.'LastLookupStep'; $key = $matcher; $pos = $this->pos; |
|
704
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
705
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
706
|
|
|
else { $_86 = FALSE; break; } |
|
707
|
|
|
$_86 = TRUE; break; |
|
708
|
|
|
} |
|
709
|
|
|
while(0); |
|
710
|
|
|
if( $_86 === TRUE ) { $_89 = TRUE; break; } |
|
711
|
|
|
$result = $res_78; |
|
712
|
|
|
$this->pos = $pos_78; |
|
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
|
|
|
$_89 = TRUE; break; |
|
718
|
|
|
} |
|
719
|
|
|
$result = $res_78; |
|
720
|
|
|
$this->pos = $pos_78; |
|
721
|
|
|
$_89 = FALSE; break; |
|
722
|
|
|
} |
|
723
|
|
|
while(0); |
|
724
|
|
|
if( $_89 === TRUE ) { return $this->finalise($result); } |
|
725
|
|
|
if( $_89 === FALSE) { return FALSE; } |
|
726
|
|
|
} |
|
727
|
|
|
|
|
728
|
|
|
|
|
729
|
|
|
|
|
730
|
|
|
|
|
731
|
|
|
function Lookup__construct(&$res) { |
|
732
|
|
|
$res['php'] = '$scope->locally()'; |
|
733
|
|
|
$res['LookupSteps'] = array(); |
|
734
|
|
|
} |
|
735
|
|
|
|
|
736
|
|
|
/** |
|
737
|
|
|
* The basic generated PHP of LookupStep and LastLookupStep is the same, except that LookupStep calls 'obj' to |
|
738
|
|
|
* get the next ViewableData in the sequence, and LastLookupStep calls different methods (XML_val, hasValue, obj) |
|
739
|
|
|
* depending on the context the lookup is used in. |
|
740
|
|
|
*/ |
|
741
|
|
|
function Lookup_AddLookupStep(&$res, $sub, $method) { |
|
742
|
|
|
$res['LookupSteps'][] = $sub; |
|
743
|
|
|
|
|
744
|
|
|
$property = $sub['Call']['Method']['text']; |
|
745
|
|
|
|
|
746
|
|
|
if (isset($sub['Call']['CallArguments']) && $arguments = $sub['Call']['CallArguments']['php']) { |
|
747
|
|
|
$res['php'] .= "->$method('$property', array($arguments), true)"; |
|
748
|
|
|
} |
|
749
|
|
|
else { |
|
750
|
|
|
$res['php'] .= "->$method('$property', null, true)"; |
|
751
|
|
|
} |
|
752
|
|
|
} |
|
753
|
|
|
|
|
754
|
|
|
function Lookup_LookupStep(&$res, $sub) { |
|
755
|
|
|
$this->Lookup_AddLookupStep($res, $sub, 'obj'); |
|
756
|
|
|
} |
|
757
|
|
|
|
|
758
|
|
|
function Lookup_LastLookupStep(&$res, $sub) { |
|
759
|
|
|
$this->Lookup_AddLookupStep($res, $sub, '$$FINAL'); |
|
760
|
|
|
} |
|
761
|
|
|
|
|
762
|
|
|
|
|
763
|
|
|
/* Translate: "<%t" < Entity < (Default:QuotedString)? < (!("is" "=") < "is" < Context:QuotedString)? < |
|
|
|
|
|
|
764
|
|
|
(InjectionVariables)? > "%>" */ |
|
765
|
|
|
protected $match_Translate_typestack = array('Translate'); |
|
766
|
|
|
function match_Translate ($stack = array()) { |
|
767
|
|
|
$matchrule = "Translate"; $result = $this->construct($matchrule, $matchrule, null); |
|
768
|
|
|
$_115 = NULL; |
|
769
|
|
|
do { |
|
|
|
|
|
|
770
|
|
|
if (( $subres = $this->literal( '<%t' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
771
|
|
|
else { $_115 = FALSE; break; } |
|
772
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
773
|
|
|
$matcher = 'match_'.'Entity'; $key = $matcher; $pos = $this->pos; |
|
774
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
775
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
776
|
|
|
else { $_115 = FALSE; break; } |
|
777
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
778
|
|
|
$res_97 = $result; |
|
779
|
|
|
$pos_97 = $this->pos; |
|
780
|
|
|
$_96 = NULL; |
|
781
|
|
|
do { |
|
782
|
|
|
$matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos; |
|
783
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
784
|
|
|
if ($subres !== FALSE) { |
|
785
|
|
|
$this->store( $result, $subres, "Default" ); |
|
786
|
|
|
} |
|
787
|
|
|
else { $_96 = FALSE; break; } |
|
788
|
|
|
$_96 = TRUE; break; |
|
789
|
|
|
} |
|
790
|
|
|
while(0); |
|
791
|
|
|
if( $_96 === FALSE) { |
|
792
|
|
|
$result = $res_97; |
|
793
|
|
|
$this->pos = $pos_97; |
|
794
|
|
|
unset( $res_97 ); |
|
795
|
|
|
unset( $pos_97 ); |
|
796
|
|
|
} |
|
797
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
798
|
|
|
$res_108 = $result; |
|
799
|
|
|
$pos_108 = $this->pos; |
|
800
|
|
|
$_107 = NULL; |
|
801
|
|
|
do { |
|
802
|
|
|
$res_102 = $result; |
|
803
|
|
|
$pos_102 = $this->pos; |
|
804
|
|
|
$_101 = NULL; |
|
805
|
|
|
do { |
|
806
|
|
|
if (( $subres = $this->literal( 'is' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
807
|
|
|
else { $_101 = FALSE; break; } |
|
808
|
|
|
if (substr($this->string,$this->pos,1) == '=') { |
|
|
|
|
|
|
809
|
|
|
$this->pos += 1; |
|
810
|
|
|
$result["text"] .= '='; |
|
811
|
|
|
} |
|
812
|
|
|
else { $_101 = FALSE; break; } |
|
813
|
|
|
$_101 = TRUE; break; |
|
814
|
|
|
} |
|
815
|
|
|
while(0); |
|
816
|
|
|
if( $_101 === TRUE ) { |
|
817
|
|
|
$result = $res_102; |
|
818
|
|
|
$this->pos = $pos_102; |
|
819
|
|
|
$_107 = FALSE; break; |
|
820
|
|
|
} |
|
821
|
|
|
if( $_101 === FALSE) { |
|
822
|
|
|
$result = $res_102; |
|
823
|
|
|
$this->pos = $pos_102; |
|
824
|
|
|
} |
|
825
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
826
|
|
|
if (( $subres = $this->literal( 'is' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
827
|
|
|
else { $_107 = FALSE; break; } |
|
828
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
829
|
|
|
$matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos; |
|
830
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
831
|
|
|
if ($subres !== FALSE) { |
|
832
|
|
|
$this->store( $result, $subres, "Context" ); |
|
833
|
|
|
} |
|
834
|
|
|
else { $_107 = FALSE; break; } |
|
835
|
|
|
$_107 = TRUE; break; |
|
836
|
|
|
} |
|
837
|
|
|
while(0); |
|
838
|
|
|
if( $_107 === FALSE) { |
|
839
|
|
|
$result = $res_108; |
|
840
|
|
|
$this->pos = $pos_108; |
|
841
|
|
|
unset( $res_108 ); |
|
842
|
|
|
unset( $pos_108 ); |
|
843
|
|
|
} |
|
844
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
845
|
|
|
$res_112 = $result; |
|
846
|
|
|
$pos_112 = $this->pos; |
|
847
|
|
|
$_111 = NULL; |
|
848
|
|
|
do { |
|
849
|
|
|
$matcher = 'match_'.'InjectionVariables'; $key = $matcher; $pos = $this->pos; |
|
850
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
851
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
852
|
|
|
else { $_111 = FALSE; break; } |
|
853
|
|
|
$_111 = TRUE; break; |
|
854
|
|
|
} |
|
855
|
|
|
while(0); |
|
856
|
|
|
if( $_111 === FALSE) { |
|
857
|
|
|
$result = $res_112; |
|
858
|
|
|
$this->pos = $pos_112; |
|
859
|
|
|
unset( $res_112 ); |
|
860
|
|
|
unset( $pos_112 ); |
|
861
|
|
|
} |
|
862
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
863
|
|
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
864
|
|
|
else { $_115 = FALSE; break; } |
|
865
|
|
|
$_115 = TRUE; break; |
|
866
|
|
|
} |
|
867
|
|
|
while(0); |
|
868
|
|
|
if( $_115 === TRUE ) { return $this->finalise($result); } |
|
869
|
|
|
if( $_115 === FALSE) { return FALSE; } |
|
870
|
|
|
} |
|
871
|
|
|
|
|
872
|
|
|
|
|
873
|
|
|
/* InjectionVariables: (< InjectionName:Word "=" Argument)+ */ |
|
874
|
|
|
protected $match_InjectionVariables_typestack = array('InjectionVariables'); |
|
875
|
|
|
function match_InjectionVariables ($stack = array()) { |
|
876
|
|
|
$matchrule = "InjectionVariables"; $result = $this->construct($matchrule, $matchrule, null); |
|
877
|
|
|
$count = 0; |
|
878
|
|
|
while (true) { |
|
879
|
|
|
$res_122 = $result; |
|
880
|
|
|
$pos_122 = $this->pos; |
|
881
|
|
|
$_121 = NULL; |
|
882
|
|
|
do { |
|
|
|
|
|
|
883
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
884
|
|
|
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
|
885
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
886
|
|
|
if ($subres !== FALSE) { |
|
887
|
|
|
$this->store( $result, $subres, "InjectionName" ); |
|
888
|
|
|
} |
|
889
|
|
|
else { $_121 = FALSE; break; } |
|
890
|
|
|
if (substr($this->string,$this->pos,1) == '=') { |
|
|
|
|
|
|
891
|
|
|
$this->pos += 1; |
|
892
|
|
|
$result["text"] .= '='; |
|
893
|
|
|
} |
|
894
|
|
|
else { $_121 = FALSE; break; } |
|
895
|
|
|
$matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
|
896
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
897
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
898
|
|
|
else { $_121 = FALSE; break; } |
|
899
|
|
|
$_121 = TRUE; break; |
|
900
|
|
|
} |
|
901
|
|
|
while(0); |
|
902
|
|
|
if( $_121 === FALSE) { |
|
903
|
|
|
$result = $res_122; |
|
904
|
|
|
$this->pos = $pos_122; |
|
905
|
|
|
unset( $res_122 ); |
|
906
|
|
|
unset( $pos_122 ); |
|
907
|
|
|
break; |
|
908
|
|
|
} |
|
909
|
|
|
$count += 1; |
|
910
|
|
|
} |
|
911
|
|
|
if ($count > 0) { return $this->finalise($result); } |
|
912
|
|
|
else { return FALSE; } |
|
913
|
|
|
} |
|
914
|
|
|
|
|
915
|
|
|
|
|
916
|
|
|
/* Entity: / [A-Za-z_] [\w\.]* / */ |
|
917
|
|
|
protected $match_Entity_typestack = array('Entity'); |
|
918
|
|
|
function match_Entity ($stack = array()) { |
|
|
|
|
|
|
919
|
|
|
$matchrule = "Entity"; $result = $this->construct($matchrule, $matchrule, null); |
|
920
|
|
|
if (( $subres = $this->rx( '/ [A-Za-z_] [\w\.]* /' ) ) !== FALSE) { |
|
921
|
|
|
$result["text"] .= $subres; |
|
922
|
|
|
return $this->finalise($result); |
|
923
|
|
|
} |
|
924
|
|
|
else { return FALSE; } |
|
925
|
|
|
} |
|
926
|
|
|
|
|
927
|
|
|
|
|
928
|
|
|
|
|
929
|
|
|
|
|
930
|
|
|
function Translate__construct(&$res) { |
|
931
|
|
|
$res['php'] = '$val .= _t('; |
|
932
|
|
|
} |
|
933
|
|
|
|
|
934
|
|
|
function Translate_Entity(&$res, $sub) { |
|
935
|
|
|
$res['php'] .= "'$sub[text]'"; |
|
936
|
|
|
} |
|
937
|
|
|
|
|
938
|
|
|
function Translate_Default(&$res, $sub) { |
|
939
|
|
|
$res['php'] .= ",$sub[text]"; |
|
940
|
|
|
} |
|
941
|
|
|
|
|
942
|
|
|
function Translate_Context(&$res, $sub) { |
|
943
|
|
|
$res['php'] .= ",$sub[text]"; |
|
944
|
|
|
} |
|
945
|
|
|
|
|
946
|
|
|
function Translate_InjectionVariables(&$res, $sub) { |
|
947
|
|
|
$res['php'] .= ",$sub[php]"; |
|
948
|
|
|
} |
|
949
|
|
|
|
|
950
|
|
|
function Translate__finalise(&$res) { |
|
951
|
|
|
$res['php'] .= ');'; |
|
952
|
|
|
} |
|
953
|
|
|
|
|
954
|
|
|
function InjectionVariables__construct(&$res) { |
|
955
|
|
|
$res['php'] = "array("; |
|
956
|
|
|
} |
|
957
|
|
|
|
|
958
|
|
|
function InjectionVariables_InjectionName(&$res, $sub) { |
|
959
|
|
|
$res['php'] .= "'$sub[text]'=>"; |
|
960
|
|
|
} |
|
961
|
|
|
|
|
962
|
|
|
function InjectionVariables_Argument(&$res, $sub) { |
|
963
|
|
|
$res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']) . ','; |
|
964
|
|
|
} |
|
965
|
|
|
|
|
966
|
|
|
function InjectionVariables__finalise(&$res) { |
|
967
|
|
|
if (substr($res['php'], -1) == ',') $res['php'] = substr($res['php'], 0, -1); //remove last comma in the array |
|
968
|
|
|
$res['php'] .= ')'; |
|
969
|
|
|
} |
|
970
|
|
|
|
|
971
|
|
|
|
|
972
|
|
|
/* SimpleInjection: '$' :Lookup */ |
|
973
|
|
|
protected $match_SimpleInjection_typestack = array('SimpleInjection'); |
|
974
|
|
|
function match_SimpleInjection ($stack = array()) { |
|
975
|
|
|
$matchrule = "SimpleInjection"; $result = $this->construct($matchrule, $matchrule, null); |
|
976
|
|
|
$_126 = NULL; |
|
977
|
|
|
do { |
|
|
|
|
|
|
978
|
|
|
if (substr($this->string,$this->pos,1) == '$') { |
|
|
|
|
|
|
979
|
|
|
$this->pos += 1; |
|
980
|
|
|
$result["text"] .= '$'; |
|
981
|
|
|
} |
|
982
|
|
|
else { $_126 = FALSE; break; } |
|
983
|
|
|
$matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos; |
|
984
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
985
|
|
|
if ($subres !== FALSE) { |
|
986
|
|
|
$this->store( $result, $subres, "Lookup" ); |
|
987
|
|
|
} |
|
988
|
|
|
else { $_126 = FALSE; break; } |
|
989
|
|
|
$_126 = TRUE; break; |
|
990
|
|
|
} |
|
991
|
|
|
while(0); |
|
992
|
|
|
if( $_126 === TRUE ) { return $this->finalise($result); } |
|
993
|
|
|
if( $_126 === FALSE) { return FALSE; } |
|
994
|
|
|
} |
|
995
|
|
|
|
|
996
|
|
|
|
|
997
|
|
|
/* BracketInjection: '{$' :Lookup "}" */ |
|
998
|
|
|
protected $match_BracketInjection_typestack = array('BracketInjection'); |
|
999
|
|
|
function match_BracketInjection ($stack = array()) { |
|
1000
|
|
|
$matchrule = "BracketInjection"; $result = $this->construct($matchrule, $matchrule, null); |
|
1001
|
|
|
$_131 = NULL; |
|
1002
|
|
|
do { |
|
|
|
|
|
|
1003
|
|
|
if (( $subres = $this->literal( '{$' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1004
|
|
|
else { $_131 = FALSE; break; } |
|
1005
|
|
|
$matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos; |
|
1006
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1007
|
|
|
if ($subres !== FALSE) { |
|
1008
|
|
|
$this->store( $result, $subres, "Lookup" ); |
|
1009
|
|
|
} |
|
1010
|
|
|
else { $_131 = FALSE; break; } |
|
1011
|
|
|
if (substr($this->string,$this->pos,1) == '}') { |
|
|
|
|
|
|
1012
|
|
|
$this->pos += 1; |
|
1013
|
|
|
$result["text"] .= '}'; |
|
1014
|
|
|
} |
|
1015
|
|
|
else { $_131 = FALSE; break; } |
|
1016
|
|
|
$_131 = TRUE; break; |
|
1017
|
|
|
} |
|
1018
|
|
|
while(0); |
|
1019
|
|
|
if( $_131 === TRUE ) { return $this->finalise($result); } |
|
1020
|
|
|
if( $_131 === FALSE) { return FALSE; } |
|
1021
|
|
|
} |
|
1022
|
|
|
|
|
1023
|
|
|
|
|
1024
|
|
|
/* Injection: BracketInjection | SimpleInjection */ |
|
1025
|
|
|
protected $match_Injection_typestack = array('Injection'); |
|
1026
|
|
|
function match_Injection ($stack = array()) { |
|
1027
|
|
|
$matchrule = "Injection"; $result = $this->construct($matchrule, $matchrule, null); |
|
1028
|
|
|
$_136 = NULL; |
|
1029
|
|
|
do { |
|
|
|
|
|
|
1030
|
|
|
$res_133 = $result; |
|
1031
|
|
|
$pos_133 = $this->pos; |
|
1032
|
|
|
$matcher = 'match_'.'BracketInjection'; $key = $matcher; $pos = $this->pos; |
|
1033
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1034
|
|
|
if ($subres !== FALSE) { |
|
1035
|
|
|
$this->store( $result, $subres ); |
|
1036
|
|
|
$_136 = TRUE; break; |
|
1037
|
|
|
} |
|
1038
|
|
|
$result = $res_133; |
|
1039
|
|
|
$this->pos = $pos_133; |
|
1040
|
|
|
$matcher = 'match_'.'SimpleInjection'; $key = $matcher; $pos = $this->pos; |
|
1041
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1042
|
|
|
if ($subres !== FALSE) { |
|
1043
|
|
|
$this->store( $result, $subres ); |
|
1044
|
|
|
$_136 = TRUE; break; |
|
1045
|
|
|
} |
|
1046
|
|
|
$result = $res_133; |
|
1047
|
|
|
$this->pos = $pos_133; |
|
1048
|
|
|
$_136 = FALSE; break; |
|
1049
|
|
|
} |
|
1050
|
|
|
while(0); |
|
1051
|
|
|
if( $_136 === TRUE ) { return $this->finalise($result); } |
|
1052
|
|
|
if( $_136 === FALSE) { return FALSE; } |
|
1053
|
|
|
} |
|
1054
|
|
|
|
|
1055
|
|
|
|
|
1056
|
|
|
|
|
1057
|
|
|
function Injection_STR(&$res, $sub) { |
|
1058
|
|
|
$res['php'] = '$val .= '. str_replace('$$FINAL', 'XML_val', $sub['Lookup']['php']) . ';'; |
|
1059
|
|
|
} |
|
1060
|
|
|
|
|
1061
|
|
|
/* DollarMarkedLookup: SimpleInjection */ |
|
1062
|
|
|
protected $match_DollarMarkedLookup_typestack = array('DollarMarkedLookup'); |
|
1063
|
|
|
function match_DollarMarkedLookup ($stack = array()) { |
|
1064
|
|
|
$matchrule = "DollarMarkedLookup"; $result = $this->construct($matchrule, $matchrule, null); |
|
1065
|
|
|
$matcher = 'match_'.'SimpleInjection'; $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
|
|
|
return $this->finalise($result); |
|
1070
|
|
|
} |
|
1071
|
|
|
else { return FALSE; } |
|
1072
|
|
|
} |
|
1073
|
|
|
|
|
1074
|
|
|
|
|
1075
|
|
|
|
|
1076
|
|
|
function DollarMarkedLookup_STR(&$res, $sub) { |
|
1077
|
|
|
$res['Lookup'] = $sub['Lookup']; |
|
1078
|
|
|
} |
|
1079
|
|
|
|
|
1080
|
|
|
/* QuotedString: q:/['"]/ String:/ (\\\\ | \\. | [^$q\\])* / '$q' */ |
|
1081
|
|
|
protected $match_QuotedString_typestack = array('QuotedString'); |
|
1082
|
|
|
function match_QuotedString ($stack = array()) { |
|
1083
|
|
|
$matchrule = "QuotedString"; $result = $this->construct($matchrule, $matchrule, null); |
|
1084
|
|
|
$_142 = NULL; |
|
1085
|
|
|
do { |
|
|
|
|
|
|
1086
|
|
|
$stack[] = $result; $result = $this->construct( $matchrule, "q" ); |
|
1087
|
|
|
if (( $subres = $this->rx( '/[\'"]/' ) ) !== FALSE) { |
|
1088
|
|
|
$result["text"] .= $subres; |
|
1089
|
|
|
$subres = $result; $result = array_pop($stack); |
|
1090
|
|
|
$this->store( $result, $subres, 'q' ); |
|
1091
|
|
|
} |
|
1092
|
|
|
else { |
|
1093
|
|
|
$result = array_pop($stack); |
|
1094
|
|
|
$_142 = FALSE; break; |
|
1095
|
|
|
} |
|
1096
|
|
|
$stack[] = $result; $result = $this->construct( $matchrule, "String" ); |
|
1097
|
|
|
if (( $subres = $this->rx( '/ (\\\\\\\\ | \\\\. | [^'.$this->expression($result, $stack, 'q').'\\\\])* /' ) ) !== FALSE) { |
|
1098
|
|
|
$result["text"] .= $subres; |
|
1099
|
|
|
$subres = $result; $result = array_pop($stack); |
|
1100
|
|
|
$this->store( $result, $subres, 'String' ); |
|
1101
|
|
|
} |
|
1102
|
|
|
else { |
|
1103
|
|
|
$result = array_pop($stack); |
|
1104
|
|
|
$_142 = FALSE; break; |
|
1105
|
|
|
} |
|
1106
|
|
|
if (( $subres = $this->literal( ''.$this->expression($result, $stack, 'q').'' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1107
|
|
|
else { $_142 = FALSE; break; } |
|
1108
|
|
|
$_142 = TRUE; break; |
|
1109
|
|
|
} |
|
1110
|
|
|
while(0); |
|
1111
|
|
|
if( $_142 === TRUE ) { return $this->finalise($result); } |
|
1112
|
|
|
if( $_142 === FALSE) { return FALSE; } |
|
1113
|
|
|
} |
|
1114
|
|
|
|
|
1115
|
|
|
|
|
1116
|
|
|
/* FreeString: /[^,)%!=><|&]+/ */ |
|
|
|
|
|
|
1117
|
|
|
protected $match_FreeString_typestack = array('FreeString'); |
|
1118
|
|
|
function match_FreeString ($stack = array()) { |
|
|
|
|
|
|
1119
|
|
|
$matchrule = "FreeString"; $result = $this->construct($matchrule, $matchrule, null); |
|
1120
|
|
|
if (( $subres = $this->rx( '/[^,)%!=><|&]+/' ) ) !== FALSE) { |
|
1121
|
|
|
$result["text"] .= $subres; |
|
1122
|
|
|
return $this->finalise($result); |
|
1123
|
|
|
} |
|
1124
|
|
|
else { return FALSE; } |
|
1125
|
|
|
} |
|
1126
|
|
|
|
|
1127
|
|
|
|
|
1128
|
|
|
/* Argument: |
|
|
|
|
|
|
1129
|
|
|
:DollarMarkedLookup | |
|
1130
|
|
|
:QuotedString | |
|
1131
|
|
|
:Lookup !(< FreeString)| |
|
1132
|
|
|
:FreeString */ |
|
1133
|
|
|
protected $match_Argument_typestack = array('Argument'); |
|
1134
|
|
|
function match_Argument ($stack = array()) { |
|
1135
|
|
|
$matchrule = "Argument"; $result = $this->construct($matchrule, $matchrule, null); |
|
1136
|
|
|
$_162 = NULL; |
|
1137
|
|
|
do { |
|
|
|
|
|
|
1138
|
|
|
$res_145 = $result; |
|
1139
|
|
|
$pos_145 = $this->pos; |
|
1140
|
|
|
$matcher = 'match_'.'DollarMarkedLookup'; $key = $matcher; $pos = $this->pos; |
|
1141
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1142
|
|
|
if ($subres !== FALSE) { |
|
1143
|
|
|
$this->store( $result, $subres, "DollarMarkedLookup" ); |
|
1144
|
|
|
$_162 = TRUE; break; |
|
1145
|
|
|
} |
|
1146
|
|
|
$result = $res_145; |
|
1147
|
|
|
$this->pos = $pos_145; |
|
1148
|
|
|
$_160 = NULL; |
|
1149
|
|
|
do { |
|
1150
|
|
|
$res_147 = $result; |
|
1151
|
|
|
$pos_147 = $this->pos; |
|
1152
|
|
|
$matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos; |
|
1153
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1154
|
|
|
if ($subres !== FALSE) { |
|
1155
|
|
|
$this->store( $result, $subres, "QuotedString" ); |
|
1156
|
|
|
$_160 = TRUE; break; |
|
1157
|
|
|
} |
|
1158
|
|
|
$result = $res_147; |
|
1159
|
|
|
$this->pos = $pos_147; |
|
1160
|
|
|
$_158 = NULL; |
|
1161
|
|
|
do { |
|
1162
|
|
|
$res_149 = $result; |
|
1163
|
|
|
$pos_149 = $this->pos; |
|
1164
|
|
|
$_155 = NULL; |
|
1165
|
|
|
do { |
|
1166
|
|
|
$matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos; |
|
1167
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1168
|
|
|
if ($subres !== FALSE) { |
|
1169
|
|
|
$this->store( $result, $subres, "Lookup" ); |
|
1170
|
|
|
} |
|
1171
|
|
|
else { $_155 = FALSE; break; } |
|
1172
|
|
|
$res_154 = $result; |
|
1173
|
|
|
$pos_154 = $this->pos; |
|
1174
|
|
|
$_153 = NULL; |
|
1175
|
|
|
do { |
|
1176
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1177
|
|
|
$matcher = 'match_'.'FreeString'; $key = $matcher; $pos = $this->pos; |
|
1178
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1179
|
|
|
if ($subres !== FALSE) { |
|
1180
|
|
|
$this->store( $result, $subres ); |
|
1181
|
|
|
} |
|
1182
|
|
|
else { $_153 = FALSE; break; } |
|
1183
|
|
|
$_153 = TRUE; break; |
|
1184
|
|
|
} |
|
1185
|
|
|
while(0); |
|
1186
|
|
|
if( $_153 === TRUE ) { |
|
1187
|
|
|
$result = $res_154; |
|
1188
|
|
|
$this->pos = $pos_154; |
|
1189
|
|
|
$_155 = FALSE; break; |
|
1190
|
|
|
} |
|
1191
|
|
|
if( $_153 === FALSE) { |
|
1192
|
|
|
$result = $res_154; |
|
1193
|
|
|
$this->pos = $pos_154; |
|
1194
|
|
|
} |
|
1195
|
|
|
$_155 = TRUE; break; |
|
1196
|
|
|
} |
|
1197
|
|
|
while(0); |
|
1198
|
|
|
if( $_155 === TRUE ) { $_158 = TRUE; break; } |
|
1199
|
|
|
$result = $res_149; |
|
1200
|
|
|
$this->pos = $pos_149; |
|
1201
|
|
|
$matcher = 'match_'.'FreeString'; $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, "FreeString" ); |
|
1205
|
|
|
$_158 = TRUE; break; |
|
1206
|
|
|
} |
|
1207
|
|
|
$result = $res_149; |
|
1208
|
|
|
$this->pos = $pos_149; |
|
1209
|
|
|
$_158 = FALSE; break; |
|
1210
|
|
|
} |
|
1211
|
|
|
while(0); |
|
1212
|
|
|
if( $_158 === TRUE ) { $_160 = TRUE; break; } |
|
1213
|
|
|
$result = $res_147; |
|
1214
|
|
|
$this->pos = $pos_147; |
|
1215
|
|
|
$_160 = FALSE; break; |
|
1216
|
|
|
} |
|
1217
|
|
|
while(0); |
|
1218
|
|
|
if( $_160 === TRUE ) { $_162 = TRUE; break; } |
|
1219
|
|
|
$result = $res_145; |
|
1220
|
|
|
$this->pos = $pos_145; |
|
1221
|
|
|
$_162 = FALSE; break; |
|
1222
|
|
|
} |
|
1223
|
|
|
while(0); |
|
1224
|
|
|
if( $_162 === TRUE ) { return $this->finalise($result); } |
|
1225
|
|
|
if( $_162 === FALSE) { return FALSE; } |
|
1226
|
|
|
} |
|
1227
|
|
|
|
|
1228
|
|
|
|
|
1229
|
|
|
|
|
1230
|
|
|
|
|
1231
|
|
|
/** |
|
1232
|
|
|
* If we get a bare value, we don't know enough to determine exactly what php would be the translation, because |
|
1233
|
|
|
* we don't know if the position of use indicates a lookup or a string argument. |
|
1234
|
|
|
* |
|
1235
|
|
|
* Instead, we record 'ArgumentMode' as a member of this matches results node, which can be: |
|
1236
|
|
|
* - lookup if this argument was unambiguously a lookup (marked as such) |
|
1237
|
|
|
* - string is this argument was unambiguously a string (marked as such, or impossible to parse as lookup) |
|
1238
|
|
|
* - default if this argument needs to be handled as per 2.4 |
|
1239
|
|
|
* |
|
1240
|
|
|
* In the case of 'default', there is no php member of the results node, but instead 'lookup_php', which |
|
1241
|
|
|
* should be used by the parent if the context indicates a lookup, and 'string_php' which should be used |
|
1242
|
|
|
* if the context indicates a string |
|
1243
|
|
|
*/ |
|
1244
|
|
|
|
|
1245
|
|
|
function Argument_DollarMarkedLookup(&$res, $sub) { |
|
1246
|
|
|
$res['ArgumentMode'] = 'lookup'; |
|
1247
|
|
|
$res['php'] = $sub['Lookup']['php']; |
|
1248
|
|
|
} |
|
1249
|
|
|
|
|
1250
|
|
|
function Argument_QuotedString(&$res, $sub) { |
|
1251
|
|
|
$res['ArgumentMode'] = 'string'; |
|
1252
|
|
|
$res['php'] = "'" . str_replace("'", "\\'", $sub['String']['text']) . "'"; |
|
1253
|
|
|
} |
|
1254
|
|
|
|
|
1255
|
|
|
function Argument_Lookup(&$res, $sub) { |
|
1256
|
|
|
if (count($sub['LookupSteps']) == 1 && !isset($sub['LookupSteps'][0]['Call']['Arguments'])) { |
|
1257
|
|
|
$res['ArgumentMode'] = 'default'; |
|
1258
|
|
|
$res['lookup_php'] = $sub['php']; |
|
1259
|
|
|
$res['string_php'] = "'".$sub['LookupSteps'][0]['Call']['Method']['text']."'"; |
|
1260
|
|
|
} |
|
1261
|
|
|
else { |
|
1262
|
|
|
$res['ArgumentMode'] = 'lookup'; |
|
1263
|
|
|
$res['php'] = $sub['php']; |
|
1264
|
|
|
} |
|
1265
|
|
|
} |
|
1266
|
|
|
|
|
1267
|
|
|
function Argument_FreeString(&$res, $sub) { |
|
1268
|
|
|
$res['ArgumentMode'] = 'string'; |
|
1269
|
|
|
$res['php'] = "'" . str_replace("'", "\\'", trim($sub['text'])) . "'"; |
|
1270
|
|
|
} |
|
1271
|
|
|
|
|
1272
|
|
|
/* ComparisonOperator: "!=" | "==" | ">=" | ">" | "<=" | "<" | "=" */ |
|
|
|
|
|
|
1273
|
|
|
protected $match_ComparisonOperator_typestack = array('ComparisonOperator'); |
|
1274
|
|
|
function match_ComparisonOperator ($stack = array()) { |
|
|
|
|
|
|
1275
|
|
|
$matchrule = "ComparisonOperator"; $result = $this->construct($matchrule, $matchrule, null); |
|
1276
|
|
|
$_187 = NULL; |
|
1277
|
|
|
do { |
|
|
|
|
|
|
1278
|
|
|
$res_164 = $result; |
|
1279
|
|
|
$pos_164 = $this->pos; |
|
1280
|
|
|
if (( $subres = $this->literal( '!=' ) ) !== FALSE) { |
|
1281
|
|
|
$result["text"] .= $subres; |
|
1282
|
|
|
$_187 = TRUE; break; |
|
1283
|
|
|
} |
|
1284
|
|
|
$result = $res_164; |
|
1285
|
|
|
$this->pos = $pos_164; |
|
1286
|
|
|
$_185 = NULL; |
|
1287
|
|
|
do { |
|
1288
|
|
|
$res_166 = $result; |
|
1289
|
|
|
$pos_166 = $this->pos; |
|
1290
|
|
|
if (( $subres = $this->literal( '==' ) ) !== FALSE) { |
|
1291
|
|
|
$result["text"] .= $subres; |
|
1292
|
|
|
$_185 = TRUE; break; |
|
1293
|
|
|
} |
|
1294
|
|
|
$result = $res_166; |
|
1295
|
|
|
$this->pos = $pos_166; |
|
1296
|
|
|
$_183 = NULL; |
|
1297
|
|
|
do { |
|
1298
|
|
|
$res_168 = $result; |
|
1299
|
|
|
$pos_168 = $this->pos; |
|
1300
|
|
|
if (( $subres = $this->literal( '>=' ) ) !== FALSE) { |
|
1301
|
|
|
$result["text"] .= $subres; |
|
1302
|
|
|
$_183 = TRUE; break; |
|
1303
|
|
|
} |
|
1304
|
|
|
$result = $res_168; |
|
1305
|
|
|
$this->pos = $pos_168; |
|
1306
|
|
|
$_181 = NULL; |
|
1307
|
|
|
do { |
|
1308
|
|
|
$res_170 = $result; |
|
1309
|
|
|
$pos_170 = $this->pos; |
|
1310
|
|
|
if (substr($this->string,$this->pos,1) == '>') { |
|
|
|
|
|
|
1311
|
|
|
$this->pos += 1; |
|
1312
|
|
|
$result["text"] .= '>'; |
|
1313
|
|
|
$_181 = TRUE; break; |
|
1314
|
|
|
} |
|
1315
|
|
|
$result = $res_170; |
|
1316
|
|
|
$this->pos = $pos_170; |
|
1317
|
|
|
$_179 = NULL; |
|
1318
|
|
|
do { |
|
1319
|
|
|
$res_172 = $result; |
|
1320
|
|
|
$pos_172 = $this->pos; |
|
1321
|
|
|
if (( $subres = $this->literal( '<=' ) ) !== FALSE) { |
|
1322
|
|
|
$result["text"] .= $subres; |
|
1323
|
|
|
$_179 = TRUE; break; |
|
1324
|
|
|
} |
|
1325
|
|
|
$result = $res_172; |
|
1326
|
|
|
$this->pos = $pos_172; |
|
1327
|
|
|
$_177 = NULL; |
|
1328
|
|
|
do { |
|
1329
|
|
|
$res_174 = $result; |
|
1330
|
|
|
$pos_174 = $this->pos; |
|
1331
|
|
|
if (substr($this->string,$this->pos,1) == '<') { |
|
|
|
|
|
|
1332
|
|
|
$this->pos += 1; |
|
1333
|
|
|
$result["text"] .= '<'; |
|
1334
|
|
|
$_177 = TRUE; break; |
|
1335
|
|
|
} |
|
1336
|
|
|
$result = $res_174; |
|
1337
|
|
|
$this->pos = $pos_174; |
|
1338
|
|
|
if (substr($this->string,$this->pos,1) == '=') { |
|
|
|
|
|
|
1339
|
|
|
$this->pos += 1; |
|
1340
|
|
|
$result["text"] .= '='; |
|
1341
|
|
|
$_177 = TRUE; break; |
|
1342
|
|
|
} |
|
1343
|
|
|
$result = $res_174; |
|
1344
|
|
|
$this->pos = $pos_174; |
|
1345
|
|
|
$_177 = FALSE; break; |
|
1346
|
|
|
} |
|
1347
|
|
|
while(0); |
|
1348
|
|
|
if( $_177 === TRUE ) { $_179 = TRUE; break; } |
|
1349
|
|
|
$result = $res_172; |
|
1350
|
|
|
$this->pos = $pos_172; |
|
1351
|
|
|
$_179 = FALSE; break; |
|
1352
|
|
|
} |
|
1353
|
|
|
while(0); |
|
1354
|
|
|
if( $_179 === TRUE ) { $_181 = TRUE; break; } |
|
1355
|
|
|
$result = $res_170; |
|
1356
|
|
|
$this->pos = $pos_170; |
|
1357
|
|
|
$_181 = FALSE; break; |
|
1358
|
|
|
} |
|
1359
|
|
|
while(0); |
|
1360
|
|
|
if( $_181 === TRUE ) { $_183 = TRUE; break; } |
|
1361
|
|
|
$result = $res_168; |
|
1362
|
|
|
$this->pos = $pos_168; |
|
1363
|
|
|
$_183 = FALSE; break; |
|
1364
|
|
|
} |
|
1365
|
|
|
while(0); |
|
1366
|
|
|
if( $_183 === TRUE ) { $_185 = TRUE; break; } |
|
1367
|
|
|
$result = $res_166; |
|
1368
|
|
|
$this->pos = $pos_166; |
|
1369
|
|
|
$_185 = FALSE; break; |
|
1370
|
|
|
} |
|
1371
|
|
|
while(0); |
|
1372
|
|
|
if( $_185 === TRUE ) { $_187 = TRUE; break; } |
|
1373
|
|
|
$result = $res_164; |
|
1374
|
|
|
$this->pos = $pos_164; |
|
1375
|
|
|
$_187 = FALSE; break; |
|
1376
|
|
|
} |
|
1377
|
|
|
while(0); |
|
1378
|
|
|
if( $_187 === TRUE ) { return $this->finalise($result); } |
|
1379
|
|
|
if( $_187 === FALSE) { return FALSE; } |
|
1380
|
|
|
} |
|
1381
|
|
|
|
|
1382
|
|
|
|
|
1383
|
|
|
/* Comparison: Argument < ComparisonOperator > Argument */ |
|
1384
|
|
|
protected $match_Comparison_typestack = array('Comparison'); |
|
1385
|
|
|
function match_Comparison ($stack = array()) { |
|
1386
|
|
|
$matchrule = "Comparison"; $result = $this->construct($matchrule, $matchrule, null); |
|
1387
|
|
|
$_194 = NULL; |
|
1388
|
|
|
do { |
|
|
|
|
|
|
1389
|
|
|
$matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
|
1390
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1391
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
1392
|
|
|
else { $_194 = FALSE; break; } |
|
1393
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1394
|
|
|
$matcher = 'match_'.'ComparisonOperator'; $key = $matcher; $pos = $this->pos; |
|
1395
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1396
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
1397
|
|
|
else { $_194 = FALSE; break; } |
|
1398
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1399
|
|
|
$matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
|
1400
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1401
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
1402
|
|
|
else { $_194 = FALSE; break; } |
|
1403
|
|
|
$_194 = TRUE; break; |
|
1404
|
|
|
} |
|
1405
|
|
|
while(0); |
|
1406
|
|
|
if( $_194 === TRUE ) { return $this->finalise($result); } |
|
1407
|
|
|
if( $_194 === FALSE) { return FALSE; } |
|
1408
|
|
|
} |
|
1409
|
|
|
|
|
1410
|
|
|
|
|
1411
|
|
|
|
|
1412
|
|
|
function Comparison_Argument(&$res, $sub) { |
|
1413
|
|
|
if ($sub['ArgumentMode'] == 'default') { |
|
1414
|
|
|
if (!empty($res['php'])) $res['php'] .= $sub['string_php']; |
|
1415
|
|
|
else $res['php'] = str_replace('$$FINAL', 'XML_val', $sub['lookup_php']); |
|
1416
|
|
|
} |
|
1417
|
|
|
else { |
|
1418
|
|
|
$res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']); |
|
1419
|
|
|
} |
|
1420
|
|
|
} |
|
1421
|
|
|
|
|
1422
|
|
|
function Comparison_ComparisonOperator(&$res, $sub) { |
|
1423
|
|
|
$res['php'] .= ($sub['text'] == '=' ? '==' : $sub['text']); |
|
1424
|
|
|
} |
|
1425
|
|
|
|
|
1426
|
|
|
/* PresenceCheck: (Not:'not' <)? Argument */ |
|
1427
|
|
|
protected $match_PresenceCheck_typestack = array('PresenceCheck'); |
|
1428
|
|
|
function match_PresenceCheck ($stack = array()) { |
|
1429
|
|
|
$matchrule = "PresenceCheck"; $result = $this->construct($matchrule, $matchrule, null); |
|
1430
|
|
|
$_201 = NULL; |
|
1431
|
|
|
do { |
|
|
|
|
|
|
1432
|
|
|
$res_199 = $result; |
|
1433
|
|
|
$pos_199 = $this->pos; |
|
1434
|
|
|
$_198 = NULL; |
|
1435
|
|
|
do { |
|
1436
|
|
|
$stack[] = $result; $result = $this->construct( $matchrule, "Not" ); |
|
1437
|
|
|
if (( $subres = $this->literal( 'not' ) ) !== FALSE) { |
|
1438
|
|
|
$result["text"] .= $subres; |
|
1439
|
|
|
$subres = $result; $result = array_pop($stack); |
|
1440
|
|
|
$this->store( $result, $subres, 'Not' ); |
|
1441
|
|
|
} |
|
1442
|
|
|
else { |
|
1443
|
|
|
$result = array_pop($stack); |
|
1444
|
|
|
$_198 = FALSE; break; |
|
1445
|
|
|
} |
|
1446
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1447
|
|
|
$_198 = TRUE; break; |
|
1448
|
|
|
} |
|
1449
|
|
|
while(0); |
|
1450
|
|
|
if( $_198 === FALSE) { |
|
1451
|
|
|
$result = $res_199; |
|
1452
|
|
|
$this->pos = $pos_199; |
|
1453
|
|
|
unset( $res_199 ); |
|
1454
|
|
|
unset( $pos_199 ); |
|
1455
|
|
|
} |
|
1456
|
|
|
$matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
|
1457
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1458
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
1459
|
|
|
else { $_201 = FALSE; break; } |
|
1460
|
|
|
$_201 = TRUE; break; |
|
1461
|
|
|
} |
|
1462
|
|
|
while(0); |
|
1463
|
|
|
if( $_201 === TRUE ) { return $this->finalise($result); } |
|
1464
|
|
|
if( $_201 === FALSE) { return FALSE; } |
|
1465
|
|
|
} |
|
1466
|
|
|
|
|
1467
|
|
|
|
|
1468
|
|
|
|
|
1469
|
|
|
function PresenceCheck_Not(&$res, $sub) { |
|
|
|
|
|
|
1470
|
|
|
$res['php'] = '!'; |
|
1471
|
|
|
} |
|
1472
|
|
|
|
|
1473
|
|
|
function PresenceCheck_Argument(&$res, $sub) { |
|
1474
|
|
|
if ($sub['ArgumentMode'] == 'string') { |
|
1475
|
|
|
$res['php'] .= '((bool)'.$sub['php'].')'; |
|
1476
|
|
|
} |
|
1477
|
|
|
else { |
|
1478
|
|
|
$php = ($sub['ArgumentMode'] == 'default' ? $sub['lookup_php'] : $sub['php']); |
|
1479
|
|
|
// TODO: kinda hacky - maybe we need a way to pass state down the parse chain so |
|
1480
|
|
|
// Lookup_LastLookupStep and Argument_BareWord can produce hasValue instead of XML_val |
|
1481
|
|
|
$res['php'] .= str_replace('$$FINAL', 'hasValue', $php); |
|
1482
|
|
|
} |
|
1483
|
|
|
} |
|
1484
|
|
|
|
|
1485
|
|
|
/* IfArgumentPortion: Comparison | PresenceCheck */ |
|
1486
|
|
|
protected $match_IfArgumentPortion_typestack = array('IfArgumentPortion'); |
|
1487
|
|
|
function match_IfArgumentPortion ($stack = array()) { |
|
1488
|
|
|
$matchrule = "IfArgumentPortion"; $result = $this->construct($matchrule, $matchrule, null); |
|
1489
|
|
|
$_206 = NULL; |
|
1490
|
|
|
do { |
|
|
|
|
|
|
1491
|
|
|
$res_203 = $result; |
|
1492
|
|
|
$pos_203 = $this->pos; |
|
1493
|
|
|
$matcher = 'match_'.'Comparison'; $key = $matcher; $pos = $this->pos; |
|
1494
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1495
|
|
|
if ($subres !== FALSE) { |
|
1496
|
|
|
$this->store( $result, $subres ); |
|
1497
|
|
|
$_206 = TRUE; break; |
|
1498
|
|
|
} |
|
1499
|
|
|
$result = $res_203; |
|
1500
|
|
|
$this->pos = $pos_203; |
|
1501
|
|
|
$matcher = 'match_'.'PresenceCheck'; $key = $matcher; $pos = $this->pos; |
|
1502
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1503
|
|
|
if ($subres !== FALSE) { |
|
1504
|
|
|
$this->store( $result, $subres ); |
|
1505
|
|
|
$_206 = TRUE; break; |
|
1506
|
|
|
} |
|
1507
|
|
|
$result = $res_203; |
|
1508
|
|
|
$this->pos = $pos_203; |
|
1509
|
|
|
$_206 = FALSE; break; |
|
1510
|
|
|
} |
|
1511
|
|
|
while(0); |
|
1512
|
|
|
if( $_206 === TRUE ) { return $this->finalise($result); } |
|
1513
|
|
|
if( $_206 === FALSE) { return FALSE; } |
|
1514
|
|
|
} |
|
1515
|
|
|
|
|
1516
|
|
|
|
|
1517
|
|
|
|
|
1518
|
|
|
function IfArgumentPortion_STR(&$res, $sub) { |
|
1519
|
|
|
$res['php'] = $sub['php']; |
|
1520
|
|
|
} |
|
1521
|
|
|
|
|
1522
|
|
|
/* BooleanOperator: "||" | "&&" */ |
|
|
|
|
|
|
1523
|
|
|
protected $match_BooleanOperator_typestack = array('BooleanOperator'); |
|
1524
|
|
|
function match_BooleanOperator ($stack = array()) { |
|
|
|
|
|
|
1525
|
|
|
$matchrule = "BooleanOperator"; $result = $this->construct($matchrule, $matchrule, null); |
|
1526
|
|
|
$_211 = NULL; |
|
1527
|
|
|
do { |
|
|
|
|
|
|
1528
|
|
|
$res_208 = $result; |
|
1529
|
|
|
$pos_208 = $this->pos; |
|
1530
|
|
|
if (( $subres = $this->literal( '||' ) ) !== FALSE) { |
|
1531
|
|
|
$result["text"] .= $subres; |
|
1532
|
|
|
$_211 = TRUE; break; |
|
1533
|
|
|
} |
|
1534
|
|
|
$result = $res_208; |
|
1535
|
|
|
$this->pos = $pos_208; |
|
1536
|
|
|
if (( $subres = $this->literal( '&&' ) ) !== FALSE) { |
|
1537
|
|
|
$result["text"] .= $subres; |
|
1538
|
|
|
$_211 = TRUE; break; |
|
1539
|
|
|
} |
|
1540
|
|
|
$result = $res_208; |
|
1541
|
|
|
$this->pos = $pos_208; |
|
1542
|
|
|
$_211 = FALSE; break; |
|
1543
|
|
|
} |
|
1544
|
|
|
while(0); |
|
1545
|
|
|
if( $_211 === TRUE ) { return $this->finalise($result); } |
|
1546
|
|
|
if( $_211 === FALSE) { return FALSE; } |
|
1547
|
|
|
} |
|
1548
|
|
|
|
|
1549
|
|
|
|
|
1550
|
|
|
/* IfArgument: :IfArgumentPortion ( < :BooleanOperator < :IfArgumentPortion )* */ |
|
1551
|
|
|
protected $match_IfArgument_typestack = array('IfArgument'); |
|
1552
|
|
|
function match_IfArgument ($stack = array()) { |
|
1553
|
|
|
$matchrule = "IfArgument"; $result = $this->construct($matchrule, $matchrule, null); |
|
1554
|
|
|
$_220 = NULL; |
|
1555
|
|
|
do { |
|
|
|
|
|
|
1556
|
|
|
$matcher = 'match_'.'IfArgumentPortion'; $key = $matcher; $pos = $this->pos; |
|
1557
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1558
|
|
|
if ($subres !== FALSE) { |
|
1559
|
|
|
$this->store( $result, $subres, "IfArgumentPortion" ); |
|
1560
|
|
|
} |
|
1561
|
|
|
else { $_220 = FALSE; break; } |
|
1562
|
|
|
while (true) { |
|
1563
|
|
|
$res_219 = $result; |
|
1564
|
|
|
$pos_219 = $this->pos; |
|
1565
|
|
|
$_218 = NULL; |
|
1566
|
|
|
do { |
|
1567
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1568
|
|
|
$matcher = 'match_'.'BooleanOperator'; $key = $matcher; $pos = $this->pos; |
|
1569
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1570
|
|
|
if ($subres !== FALSE) { |
|
1571
|
|
|
$this->store( $result, $subres, "BooleanOperator" ); |
|
1572
|
|
|
} |
|
1573
|
|
|
else { $_218 = FALSE; break; } |
|
1574
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1575
|
|
|
$matcher = 'match_'.'IfArgumentPortion'; $key = $matcher; $pos = $this->pos; |
|
1576
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1577
|
|
|
if ($subres !== FALSE) { |
|
1578
|
|
|
$this->store( $result, $subres, "IfArgumentPortion" ); |
|
1579
|
|
|
} |
|
1580
|
|
|
else { $_218 = FALSE; break; } |
|
1581
|
|
|
$_218 = TRUE; break; |
|
1582
|
|
|
} |
|
1583
|
|
|
while(0); |
|
1584
|
|
|
if( $_218 === FALSE) { |
|
1585
|
|
|
$result = $res_219; |
|
1586
|
|
|
$this->pos = $pos_219; |
|
1587
|
|
|
unset( $res_219 ); |
|
1588
|
|
|
unset( $pos_219 ); |
|
1589
|
|
|
break; |
|
1590
|
|
|
} |
|
1591
|
|
|
} |
|
1592
|
|
|
$_220 = TRUE; break; |
|
1593
|
|
|
} |
|
1594
|
|
|
while(0); |
|
1595
|
|
|
if( $_220 === TRUE ) { return $this->finalise($result); } |
|
1596
|
|
|
if( $_220 === FALSE) { return FALSE; } |
|
1597
|
|
|
} |
|
1598
|
|
|
|
|
1599
|
|
|
|
|
1600
|
|
|
|
|
1601
|
|
|
function IfArgument_IfArgumentPortion(&$res, $sub) { |
|
1602
|
|
|
$res['php'] .= $sub['php']; |
|
1603
|
|
|
} |
|
1604
|
|
|
|
|
1605
|
|
|
function IfArgument_BooleanOperator(&$res, $sub) { |
|
1606
|
|
|
$res['php'] .= $sub['text']; |
|
1607
|
|
|
} |
|
1608
|
|
|
|
|
1609
|
|
|
/* IfPart: '<%' < 'if' [ :IfArgument > '%>' Template:$TemplateMatcher? */ |
|
1610
|
|
|
protected $match_IfPart_typestack = array('IfPart'); |
|
1611
|
|
|
function match_IfPart ($stack = array()) { |
|
1612
|
|
|
$matchrule = "IfPart"; $result = $this->construct($matchrule, $matchrule, null); |
|
1613
|
|
|
$_230 = NULL; |
|
1614
|
|
|
do { |
|
|
|
|
|
|
1615
|
|
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1616
|
|
|
else { $_230 = FALSE; break; } |
|
1617
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1618
|
|
|
if (( $subres = $this->literal( 'if' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1619
|
|
|
else { $_230 = FALSE; break; } |
|
1620
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1621
|
|
|
else { $_230 = FALSE; break; } |
|
1622
|
|
|
$matcher = 'match_'.'IfArgument'; $key = $matcher; $pos = $this->pos; |
|
1623
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1624
|
|
|
if ($subres !== FALSE) { |
|
1625
|
|
|
$this->store( $result, $subres, "IfArgument" ); |
|
1626
|
|
|
} |
|
1627
|
|
|
else { $_230 = FALSE; break; } |
|
1628
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1629
|
|
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1630
|
|
|
else { $_230 = FALSE; break; } |
|
1631
|
|
|
$res_229 = $result; |
|
1632
|
|
|
$pos_229 = $this->pos; |
|
1633
|
|
|
$matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $key = $matcher; $pos = $this->pos; |
|
1634
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1635
|
|
|
if ($subres !== FALSE) { |
|
1636
|
|
|
$this->store( $result, $subres, "Template" ); |
|
1637
|
|
|
} |
|
1638
|
|
|
else { |
|
1639
|
|
|
$result = $res_229; |
|
1640
|
|
|
$this->pos = $pos_229; |
|
1641
|
|
|
unset( $res_229 ); |
|
1642
|
|
|
unset( $pos_229 ); |
|
1643
|
|
|
} |
|
1644
|
|
|
$_230 = TRUE; break; |
|
1645
|
|
|
} |
|
1646
|
|
|
while(0); |
|
1647
|
|
|
if( $_230 === TRUE ) { return $this->finalise($result); } |
|
1648
|
|
|
if( $_230 === FALSE) { return FALSE; } |
|
1649
|
|
|
} |
|
1650
|
|
|
|
|
1651
|
|
|
|
|
1652
|
|
|
/* ElseIfPart: '<%' < 'else_if' [ :IfArgument > '%>' Template:$TemplateMatcher? */ |
|
1653
|
|
|
protected $match_ElseIfPart_typestack = array('ElseIfPart'); |
|
1654
|
|
|
function match_ElseIfPart ($stack = array()) { |
|
1655
|
|
|
$matchrule = "ElseIfPart"; $result = $this->construct($matchrule, $matchrule, null); |
|
1656
|
|
|
$_240 = NULL; |
|
1657
|
|
|
do { |
|
|
|
|
|
|
1658
|
|
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1659
|
|
|
else { $_240 = FALSE; break; } |
|
1660
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1661
|
|
|
if (( $subres = $this->literal( 'else_if' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1662
|
|
|
else { $_240 = FALSE; break; } |
|
1663
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1664
|
|
|
else { $_240 = FALSE; break; } |
|
1665
|
|
|
$matcher = 'match_'.'IfArgument'; $key = $matcher; $pos = $this->pos; |
|
1666
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1667
|
|
|
if ($subres !== FALSE) { |
|
1668
|
|
|
$this->store( $result, $subres, "IfArgument" ); |
|
1669
|
|
|
} |
|
1670
|
|
|
else { $_240 = FALSE; break; } |
|
1671
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1672
|
|
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1673
|
|
|
else { $_240 = FALSE; break; } |
|
1674
|
|
|
$res_239 = $result; |
|
1675
|
|
|
$pos_239 = $this->pos; |
|
1676
|
|
|
$matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $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, "Template" ); |
|
1680
|
|
|
} |
|
1681
|
|
|
else { |
|
1682
|
|
|
$result = $res_239; |
|
1683
|
|
|
$this->pos = $pos_239; |
|
1684
|
|
|
unset( $res_239 ); |
|
1685
|
|
|
unset( $pos_239 ); |
|
1686
|
|
|
} |
|
1687
|
|
|
$_240 = TRUE; break; |
|
1688
|
|
|
} |
|
1689
|
|
|
while(0); |
|
1690
|
|
|
if( $_240 === TRUE ) { return $this->finalise($result); } |
|
1691
|
|
|
if( $_240 === FALSE) { return FALSE; } |
|
1692
|
|
|
} |
|
1693
|
|
|
|
|
1694
|
|
|
|
|
1695
|
|
|
/* ElsePart: '<%' < 'else' > '%>' Template:$TemplateMatcher? */ |
|
1696
|
|
|
protected $match_ElsePart_typestack = array('ElsePart'); |
|
1697
|
|
|
function match_ElsePart ($stack = array()) { |
|
1698
|
|
|
$matchrule = "ElsePart"; $result = $this->construct($matchrule, $matchrule, null); |
|
1699
|
|
|
$_248 = NULL; |
|
1700
|
|
|
do { |
|
|
|
|
|
|
1701
|
|
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1702
|
|
|
else { $_248 = FALSE; break; } |
|
1703
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1704
|
|
|
if (( $subres = $this->literal( 'else' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1705
|
|
|
else { $_248 = FALSE; break; } |
|
1706
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1707
|
|
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1708
|
|
|
else { $_248 = FALSE; break; } |
|
1709
|
|
|
$res_247 = $result; |
|
1710
|
|
|
$pos_247 = $this->pos; |
|
1711
|
|
|
$matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $key = $matcher; $pos = $this->pos; |
|
1712
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1713
|
|
|
if ($subres !== FALSE) { |
|
1714
|
|
|
$this->store( $result, $subres, "Template" ); |
|
1715
|
|
|
} |
|
1716
|
|
|
else { |
|
1717
|
|
|
$result = $res_247; |
|
1718
|
|
|
$this->pos = $pos_247; |
|
1719
|
|
|
unset( $res_247 ); |
|
1720
|
|
|
unset( $pos_247 ); |
|
1721
|
|
|
} |
|
1722
|
|
|
$_248 = TRUE; break; |
|
1723
|
|
|
} |
|
1724
|
|
|
while(0); |
|
1725
|
|
|
if( $_248 === TRUE ) { return $this->finalise($result); } |
|
1726
|
|
|
if( $_248 === FALSE) { return FALSE; } |
|
1727
|
|
|
} |
|
1728
|
|
|
|
|
1729
|
|
|
|
|
1730
|
|
|
/* If: IfPart ElseIfPart* ElsePart? '<%' < 'end_if' > '%>' */ |
|
1731
|
|
|
protected $match_If_typestack = array('If'); |
|
1732
|
|
|
function match_If ($stack = array()) { |
|
1733
|
|
|
$matchrule = "If"; $result = $this->construct($matchrule, $matchrule, null); |
|
1734
|
|
|
$_258 = NULL; |
|
1735
|
|
|
do { |
|
|
|
|
|
|
1736
|
|
|
$matcher = 'match_'.'IfPart'; $key = $matcher; $pos = $this->pos; |
|
1737
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1738
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
1739
|
|
|
else { $_258 = FALSE; break; } |
|
1740
|
|
|
while (true) { |
|
1741
|
|
|
$res_251 = $result; |
|
1742
|
|
|
$pos_251 = $this->pos; |
|
1743
|
|
|
$matcher = 'match_'.'ElseIfPart'; $key = $matcher; $pos = $this->pos; |
|
1744
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1745
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
1746
|
|
|
else { |
|
1747
|
|
|
$result = $res_251; |
|
1748
|
|
|
$this->pos = $pos_251; |
|
1749
|
|
|
unset( $res_251 ); |
|
1750
|
|
|
unset( $pos_251 ); |
|
1751
|
|
|
break; |
|
1752
|
|
|
} |
|
1753
|
|
|
} |
|
1754
|
|
|
$res_252 = $result; |
|
1755
|
|
|
$pos_252 = $this->pos; |
|
1756
|
|
|
$matcher = 'match_'.'ElsePart'; $key = $matcher; $pos = $this->pos; |
|
1757
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1758
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
1759
|
|
|
else { |
|
1760
|
|
|
$result = $res_252; |
|
1761
|
|
|
$this->pos = $pos_252; |
|
1762
|
|
|
unset( $res_252 ); |
|
1763
|
|
|
unset( $pos_252 ); |
|
1764
|
|
|
} |
|
1765
|
|
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1766
|
|
|
else { $_258 = FALSE; break; } |
|
1767
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1768
|
|
|
if (( $subres = $this->literal( 'end_if' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1769
|
|
|
else { $_258 = FALSE; break; } |
|
1770
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1771
|
|
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1772
|
|
|
else { $_258 = FALSE; break; } |
|
1773
|
|
|
$_258 = TRUE; break; |
|
1774
|
|
|
} |
|
1775
|
|
|
while(0); |
|
1776
|
|
|
if( $_258 === TRUE ) { return $this->finalise($result); } |
|
1777
|
|
|
if( $_258 === FALSE) { return FALSE; } |
|
1778
|
|
|
} |
|
1779
|
|
|
|
|
1780
|
|
|
|
|
1781
|
|
|
|
|
1782
|
|
|
function If_IfPart(&$res, $sub) { |
|
1783
|
|
|
$res['php'] = |
|
1784
|
|
|
'if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL . |
|
1785
|
|
|
(isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL . |
|
1786
|
|
|
'}'; |
|
1787
|
|
|
} |
|
1788
|
|
|
|
|
1789
|
|
|
function If_ElseIfPart(&$res, $sub) { |
|
1790
|
|
|
$res['php'] .= |
|
1791
|
|
|
'else if (' . $sub['IfArgument']['php'] . ') { ' . PHP_EOL . |
|
1792
|
|
|
(isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL . |
|
1793
|
|
|
'}'; |
|
1794
|
|
|
} |
|
1795
|
|
|
|
|
1796
|
|
|
function If_ElsePart(&$res, $sub) { |
|
1797
|
|
|
$res['php'] .= |
|
1798
|
|
|
'else { ' . PHP_EOL . |
|
1799
|
|
|
(isset($sub['Template']) ? $sub['Template']['php'] : '') . PHP_EOL . |
|
1800
|
|
|
'}'; |
|
1801
|
|
|
} |
|
1802
|
|
|
|
|
1803
|
|
|
/* Require: '<%' < 'require' [ Call:(Method:Word "(" < :CallArguments > ")") > '%>' */ |
|
1804
|
|
|
protected $match_Require_typestack = array('Require'); |
|
1805
|
|
|
function match_Require ($stack = array()) { |
|
1806
|
|
|
$matchrule = "Require"; $result = $this->construct($matchrule, $matchrule, null); |
|
1807
|
|
|
$_274 = NULL; |
|
1808
|
|
|
do { |
|
|
|
|
|
|
1809
|
|
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1810
|
|
|
else { $_274 = FALSE; break; } |
|
1811
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1812
|
|
|
if (( $subres = $this->literal( 'require' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1813
|
|
|
else { $_274 = FALSE; break; } |
|
1814
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1815
|
|
|
else { $_274 = FALSE; break; } |
|
1816
|
|
|
$stack[] = $result; $result = $this->construct( $matchrule, "Call" ); |
|
1817
|
|
|
$_270 = NULL; |
|
1818
|
|
|
do { |
|
1819
|
|
|
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
|
1820
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1821
|
|
|
if ($subres !== FALSE) { |
|
1822
|
|
|
$this->store( $result, $subres, "Method" ); |
|
1823
|
|
|
} |
|
1824
|
|
|
else { $_270 = FALSE; break; } |
|
1825
|
|
|
if (substr($this->string,$this->pos,1) == '(') { |
|
|
|
|
|
|
1826
|
|
|
$this->pos += 1; |
|
1827
|
|
|
$result["text"] .= '('; |
|
1828
|
|
|
} |
|
1829
|
|
|
else { $_270 = FALSE; break; } |
|
1830
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1831
|
|
|
$matcher = 'match_'.'CallArguments'; $key = $matcher; $pos = $this->pos; |
|
1832
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1833
|
|
|
if ($subres !== FALSE) { |
|
1834
|
|
|
$this->store( $result, $subres, "CallArguments" ); |
|
1835
|
|
|
} |
|
1836
|
|
|
else { $_270 = FALSE; break; } |
|
1837
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1838
|
|
|
if (substr($this->string,$this->pos,1) == ')') { |
|
|
|
|
|
|
1839
|
|
|
$this->pos += 1; |
|
1840
|
|
|
$result["text"] .= ')'; |
|
1841
|
|
|
} |
|
1842
|
|
|
else { $_270 = FALSE; break; } |
|
1843
|
|
|
$_270 = TRUE; break; |
|
1844
|
|
|
} |
|
1845
|
|
|
while(0); |
|
1846
|
|
|
if( $_270 === TRUE ) { |
|
1847
|
|
|
$subres = $result; $result = array_pop($stack); |
|
1848
|
|
|
$this->store( $result, $subres, 'Call' ); |
|
1849
|
|
|
} |
|
1850
|
|
|
if( $_270 === FALSE) { |
|
1851
|
|
|
$result = array_pop($stack); |
|
1852
|
|
|
$_274 = FALSE; break; |
|
1853
|
|
|
} |
|
1854
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1855
|
|
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
1856
|
|
|
else { $_274 = FALSE; break; } |
|
1857
|
|
|
$_274 = TRUE; break; |
|
1858
|
|
|
} |
|
1859
|
|
|
while(0); |
|
1860
|
|
|
if( $_274 === TRUE ) { return $this->finalise($result); } |
|
1861
|
|
|
if( $_274 === FALSE) { return FALSE; } |
|
1862
|
|
|
} |
|
1863
|
|
|
|
|
1864
|
|
|
|
|
1865
|
|
|
|
|
1866
|
|
|
function Require_Call(&$res, $sub) { |
|
1867
|
|
|
$res['php'] = "Requirements::".$sub['Method']['text'].'('.$sub['CallArguments']['php'].');'; |
|
1868
|
|
|
} |
|
1869
|
|
|
|
|
1870
|
|
|
|
|
1871
|
|
|
/* CacheBlockArgument: |
|
|
|
|
|
|
1872
|
|
|
!( "if " | "unless " ) |
|
1873
|
|
|
( |
|
1874
|
|
|
:DollarMarkedLookup | |
|
1875
|
|
|
:QuotedString | |
|
1876
|
|
|
:Lookup |
|
1877
|
|
|
) */ |
|
1878
|
|
|
protected $match_CacheBlockArgument_typestack = array('CacheBlockArgument'); |
|
1879
|
|
|
function match_CacheBlockArgument ($stack = array()) { |
|
1880
|
|
|
$matchrule = "CacheBlockArgument"; $result = $this->construct($matchrule, $matchrule, null); |
|
1881
|
|
|
$_294 = NULL; |
|
1882
|
|
|
do { |
|
|
|
|
|
|
1883
|
|
|
$res_282 = $result; |
|
1884
|
|
|
$pos_282 = $this->pos; |
|
1885
|
|
|
$_281 = NULL; |
|
1886
|
|
|
do { |
|
1887
|
|
|
$_279 = NULL; |
|
1888
|
|
|
do { |
|
1889
|
|
|
$res_276 = $result; |
|
1890
|
|
|
$pos_276 = $this->pos; |
|
1891
|
|
|
if (( $subres = $this->literal( 'if ' ) ) !== FALSE) { |
|
1892
|
|
|
$result["text"] .= $subres; |
|
1893
|
|
|
$_279 = TRUE; break; |
|
1894
|
|
|
} |
|
1895
|
|
|
$result = $res_276; |
|
1896
|
|
|
$this->pos = $pos_276; |
|
1897
|
|
|
if (( $subres = $this->literal( 'unless ' ) ) !== FALSE) { |
|
1898
|
|
|
$result["text"] .= $subres; |
|
1899
|
|
|
$_279 = TRUE; break; |
|
1900
|
|
|
} |
|
1901
|
|
|
$result = $res_276; |
|
1902
|
|
|
$this->pos = $pos_276; |
|
1903
|
|
|
$_279 = FALSE; break; |
|
1904
|
|
|
} |
|
1905
|
|
|
while(0); |
|
1906
|
|
|
if( $_279 === FALSE) { $_281 = FALSE; break; } |
|
1907
|
|
|
$_281 = TRUE; break; |
|
1908
|
|
|
} |
|
1909
|
|
|
while(0); |
|
1910
|
|
|
if( $_281 === TRUE ) { |
|
1911
|
|
|
$result = $res_282; |
|
1912
|
|
|
$this->pos = $pos_282; |
|
1913
|
|
|
$_294 = FALSE; break; |
|
1914
|
|
|
} |
|
1915
|
|
|
if( $_281 === FALSE) { |
|
1916
|
|
|
$result = $res_282; |
|
1917
|
|
|
$this->pos = $pos_282; |
|
1918
|
|
|
} |
|
1919
|
|
|
$_292 = NULL; |
|
1920
|
|
|
do { |
|
1921
|
|
|
$_290 = NULL; |
|
1922
|
|
|
do { |
|
1923
|
|
|
$res_283 = $result; |
|
1924
|
|
|
$pos_283 = $this->pos; |
|
1925
|
|
|
$matcher = 'match_'.'DollarMarkedLookup'; $key = $matcher; $pos = $this->pos; |
|
1926
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1927
|
|
|
if ($subres !== FALSE) { |
|
1928
|
|
|
$this->store( $result, $subres, "DollarMarkedLookup" ); |
|
1929
|
|
|
$_290 = TRUE; break; |
|
1930
|
|
|
} |
|
1931
|
|
|
$result = $res_283; |
|
1932
|
|
|
$this->pos = $pos_283; |
|
1933
|
|
|
$_288 = NULL; |
|
1934
|
|
|
do { |
|
1935
|
|
|
$res_285 = $result; |
|
1936
|
|
|
$pos_285 = $this->pos; |
|
1937
|
|
|
$matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos; |
|
1938
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1939
|
|
|
if ($subres !== FALSE) { |
|
1940
|
|
|
$this->store( $result, $subres, "QuotedString" ); |
|
1941
|
|
|
$_288 = TRUE; break; |
|
1942
|
|
|
} |
|
1943
|
|
|
$result = $res_285; |
|
1944
|
|
|
$this->pos = $pos_285; |
|
1945
|
|
|
$matcher = 'match_'.'Lookup'; $key = $matcher; $pos = $this->pos; |
|
1946
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1947
|
|
|
if ($subres !== FALSE) { |
|
1948
|
|
|
$this->store( $result, $subres, "Lookup" ); |
|
1949
|
|
|
$_288 = TRUE; break; |
|
1950
|
|
|
} |
|
1951
|
|
|
$result = $res_285; |
|
1952
|
|
|
$this->pos = $pos_285; |
|
1953
|
|
|
$_288 = FALSE; break; |
|
1954
|
|
|
} |
|
1955
|
|
|
while(0); |
|
1956
|
|
|
if( $_288 === TRUE ) { $_290 = TRUE; break; } |
|
1957
|
|
|
$result = $res_283; |
|
1958
|
|
|
$this->pos = $pos_283; |
|
1959
|
|
|
$_290 = FALSE; break; |
|
1960
|
|
|
} |
|
1961
|
|
|
while(0); |
|
1962
|
|
|
if( $_290 === FALSE) { $_292 = FALSE; break; } |
|
1963
|
|
|
$_292 = TRUE; break; |
|
1964
|
|
|
} |
|
1965
|
|
|
while(0); |
|
1966
|
|
|
if( $_292 === FALSE) { $_294 = FALSE; break; } |
|
1967
|
|
|
$_294 = TRUE; break; |
|
1968
|
|
|
} |
|
1969
|
|
|
while(0); |
|
1970
|
|
|
if( $_294 === TRUE ) { return $this->finalise($result); } |
|
1971
|
|
|
if( $_294 === FALSE) { return FALSE; } |
|
1972
|
|
|
} |
|
1973
|
|
|
|
|
1974
|
|
|
|
|
1975
|
|
|
|
|
1976
|
|
|
function CacheBlockArgument_DollarMarkedLookup(&$res, $sub) { |
|
1977
|
|
|
$res['php'] = $sub['Lookup']['php']; |
|
1978
|
|
|
} |
|
1979
|
|
|
|
|
1980
|
|
|
function CacheBlockArgument_QuotedString(&$res, $sub) { |
|
1981
|
|
|
$res['php'] = "'" . str_replace("'", "\\'", $sub['String']['text']) . "'"; |
|
1982
|
|
|
} |
|
1983
|
|
|
|
|
1984
|
|
|
function CacheBlockArgument_Lookup(&$res, $sub) { |
|
1985
|
|
|
$res['php'] = $sub['php']; |
|
1986
|
|
|
} |
|
1987
|
|
|
|
|
1988
|
|
|
/* CacheBlockArguments: CacheBlockArgument ( < "," < CacheBlockArgument )* */ |
|
1989
|
|
|
protected $match_CacheBlockArguments_typestack = array('CacheBlockArguments'); |
|
1990
|
|
|
function match_CacheBlockArguments ($stack = array()) { |
|
1991
|
|
|
$matchrule = "CacheBlockArguments"; $result = $this->construct($matchrule, $matchrule, null); |
|
1992
|
|
|
$_303 = NULL; |
|
1993
|
|
|
do { |
|
|
|
|
|
|
1994
|
|
|
$matcher = 'match_'.'CacheBlockArgument'; $key = $matcher; $pos = $this->pos; |
|
1995
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
1996
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
1997
|
|
|
else { $_303 = FALSE; break; } |
|
1998
|
|
|
while (true) { |
|
1999
|
|
|
$res_302 = $result; |
|
2000
|
|
|
$pos_302 = $this->pos; |
|
2001
|
|
|
$_301 = NULL; |
|
2002
|
|
|
do { |
|
2003
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2004
|
|
|
if (substr($this->string,$this->pos,1) == ',') { |
|
|
|
|
|
|
2005
|
|
|
$this->pos += 1; |
|
2006
|
|
|
$result["text"] .= ','; |
|
2007
|
|
|
} |
|
2008
|
|
|
else { $_301 = FALSE; break; } |
|
2009
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2010
|
|
|
$matcher = 'match_'.'CacheBlockArgument'; $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) { $this->store( $result, $subres ); } |
|
2013
|
|
|
else { $_301 = FALSE; break; } |
|
2014
|
|
|
$_301 = TRUE; break; |
|
2015
|
|
|
} |
|
2016
|
|
|
while(0); |
|
2017
|
|
|
if( $_301 === FALSE) { |
|
2018
|
|
|
$result = $res_302; |
|
2019
|
|
|
$this->pos = $pos_302; |
|
2020
|
|
|
unset( $res_302 ); |
|
2021
|
|
|
unset( $pos_302 ); |
|
2022
|
|
|
break; |
|
2023
|
|
|
} |
|
2024
|
|
|
} |
|
2025
|
|
|
$_303 = TRUE; break; |
|
2026
|
|
|
} |
|
2027
|
|
|
while(0); |
|
2028
|
|
|
if( $_303 === TRUE ) { return $this->finalise($result); } |
|
2029
|
|
|
if( $_303 === FALSE) { return FALSE; } |
|
2030
|
|
|
} |
|
2031
|
|
|
|
|
2032
|
|
|
|
|
2033
|
|
|
|
|
2034
|
|
|
function CacheBlockArguments_CacheBlockArgument(&$res, $sub) { |
|
2035
|
|
|
if (!empty($res['php'])) $res['php'] .= ".'_'."; |
|
2036
|
|
|
else $res['php'] = ''; |
|
2037
|
|
|
|
|
2038
|
|
|
$res['php'] .= str_replace('$$FINAL', 'XML_val', $sub['php']); |
|
2039
|
|
|
} |
|
2040
|
|
|
|
|
2041
|
|
|
/* CacheBlockTemplate: (Comment | Translate | If | Require | OldI18NTag | Include | ClosedBlock | |
|
2042
|
|
|
OpenBlock | MalformedBlock | Injection | Text)+ */ |
|
2043
|
|
|
protected $match_CacheBlockTemplate_typestack = array('CacheBlockTemplate','Template'); |
|
2044
|
|
|
function match_CacheBlockTemplate ($stack = array()) { |
|
2045
|
|
|
$matchrule = "CacheBlockTemplate"; $result = $this->construct($matchrule, $matchrule, array('TemplateMatcher' => 'CacheRestrictedTemplate')); |
|
2046
|
|
|
$count = 0; |
|
2047
|
|
|
while (true) { |
|
2048
|
|
|
$res_347 = $result; |
|
2049
|
|
|
$pos_347 = $this->pos; |
|
2050
|
|
|
$_346 = NULL; |
|
2051
|
|
|
do { |
|
|
|
|
|
|
2052
|
|
|
$_344 = NULL; |
|
2053
|
|
|
do { |
|
2054
|
|
|
$res_305 = $result; |
|
2055
|
|
|
$pos_305 = $this->pos; |
|
2056
|
|
|
$matcher = 'match_'.'Comment'; $key = $matcher; $pos = $this->pos; |
|
2057
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2058
|
|
|
if ($subres !== FALSE) { |
|
2059
|
|
|
$this->store( $result, $subres ); |
|
2060
|
|
|
$_344 = TRUE; break; |
|
2061
|
|
|
} |
|
2062
|
|
|
$result = $res_305; |
|
2063
|
|
|
$this->pos = $pos_305; |
|
2064
|
|
|
$_342 = NULL; |
|
2065
|
|
|
do { |
|
2066
|
|
|
$res_307 = $result; |
|
2067
|
|
|
$pos_307 = $this->pos; |
|
2068
|
|
|
$matcher = 'match_'.'Translate'; $key = $matcher; $pos = $this->pos; |
|
2069
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2070
|
|
|
if ($subres !== FALSE) { |
|
2071
|
|
|
$this->store( $result, $subres ); |
|
2072
|
|
|
$_342 = TRUE; break; |
|
2073
|
|
|
} |
|
2074
|
|
|
$result = $res_307; |
|
2075
|
|
|
$this->pos = $pos_307; |
|
2076
|
|
|
$_340 = NULL; |
|
2077
|
|
|
do { |
|
2078
|
|
|
$res_309 = $result; |
|
2079
|
|
|
$pos_309 = $this->pos; |
|
2080
|
|
|
$matcher = 'match_'.'If'; $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
|
|
|
$_340 = TRUE; break; |
|
2085
|
|
|
} |
|
2086
|
|
|
$result = $res_309; |
|
2087
|
|
|
$this->pos = $pos_309; |
|
2088
|
|
|
$_338 = NULL; |
|
2089
|
|
|
do { |
|
2090
|
|
|
$res_311 = $result; |
|
2091
|
|
|
$pos_311 = $this->pos; |
|
2092
|
|
|
$matcher = 'match_'.'Require'; $key = $matcher; $pos = $this->pos; |
|
2093
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2094
|
|
|
if ($subres !== FALSE) { |
|
2095
|
|
|
$this->store( $result, $subres ); |
|
2096
|
|
|
$_338 = TRUE; break; |
|
2097
|
|
|
} |
|
2098
|
|
|
$result = $res_311; |
|
2099
|
|
|
$this->pos = $pos_311; |
|
2100
|
|
|
$_336 = NULL; |
|
2101
|
|
|
do { |
|
2102
|
|
|
$res_313 = $result; |
|
2103
|
|
|
$pos_313 = $this->pos; |
|
2104
|
|
|
$matcher = 'match_'.'OldI18NTag'; $key = $matcher; $pos = $this->pos; |
|
2105
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2106
|
|
|
if ($subres !== FALSE) { |
|
2107
|
|
|
$this->store( $result, $subres ); |
|
2108
|
|
|
$_336 = TRUE; break; |
|
2109
|
|
|
} |
|
2110
|
|
|
$result = $res_313; |
|
2111
|
|
|
$this->pos = $pos_313; |
|
2112
|
|
|
$_334 = NULL; |
|
2113
|
|
|
do { |
|
2114
|
|
|
$res_315 = $result; |
|
2115
|
|
|
$pos_315 = $this->pos; |
|
2116
|
|
|
$matcher = 'match_'.'Include'; $key = $matcher; $pos = $this->pos; |
|
2117
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2118
|
|
|
if ($subres !== FALSE) { |
|
2119
|
|
|
$this->store( $result, $subres ); |
|
2120
|
|
|
$_334 = TRUE; break; |
|
2121
|
|
|
} |
|
2122
|
|
|
$result = $res_315; |
|
2123
|
|
|
$this->pos = $pos_315; |
|
2124
|
|
|
$_332 = NULL; |
|
2125
|
|
|
do { |
|
2126
|
|
|
$res_317 = $result; |
|
2127
|
|
|
$pos_317 = $this->pos; |
|
2128
|
|
|
$matcher = 'match_'.'ClosedBlock'; $key = $matcher; $pos = $this->pos; |
|
2129
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2130
|
|
|
if ($subres !== FALSE) { |
|
2131
|
|
|
$this->store( $result, $subres ); |
|
2132
|
|
|
$_332 = TRUE; break; |
|
2133
|
|
|
} |
|
2134
|
|
|
$result = $res_317; |
|
2135
|
|
|
$this->pos = $pos_317; |
|
2136
|
|
|
$_330 = NULL; |
|
2137
|
|
|
do { |
|
2138
|
|
|
$res_319 = $result; |
|
2139
|
|
|
$pos_319 = $this->pos; |
|
2140
|
|
|
$matcher = 'match_'.'OpenBlock'; $key = $matcher; $pos = $this->pos; |
|
2141
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2142
|
|
|
if ($subres !== FALSE) { |
|
2143
|
|
|
$this->store( $result, $subres ); |
|
2144
|
|
|
$_330 = TRUE; break; |
|
2145
|
|
|
} |
|
2146
|
|
|
$result = $res_319; |
|
2147
|
|
|
$this->pos = $pos_319; |
|
2148
|
|
|
$_328 = NULL; |
|
2149
|
|
|
do { |
|
2150
|
|
|
$res_321 = $result; |
|
2151
|
|
|
$pos_321 = $this->pos; |
|
2152
|
|
|
$matcher = 'match_'.'MalformedBlock'; $key = $matcher; $pos = $this->pos; |
|
2153
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2154
|
|
|
if ($subres !== FALSE) { |
|
2155
|
|
|
$this->store( $result, $subres ); |
|
2156
|
|
|
$_328 = TRUE; break; |
|
2157
|
|
|
} |
|
2158
|
|
|
$result = $res_321; |
|
2159
|
|
|
$this->pos = $pos_321; |
|
2160
|
|
|
$_326 = NULL; |
|
2161
|
|
|
do { |
|
2162
|
|
|
$res_323 = $result; |
|
2163
|
|
|
$pos_323 = $this->pos; |
|
2164
|
|
|
$matcher = 'match_'.'Injection'; $key = $matcher; $pos = $this->pos; |
|
2165
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2166
|
|
|
if ($subres !== FALSE) { |
|
2167
|
|
|
$this->store( $result, $subres ); |
|
2168
|
|
|
$_326 = TRUE; break; |
|
2169
|
|
|
} |
|
2170
|
|
|
$result = $res_323; |
|
2171
|
|
|
$this->pos = $pos_323; |
|
2172
|
|
|
$matcher = 'match_'.'Text'; $key = $matcher; $pos = $this->pos; |
|
2173
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2174
|
|
|
if ($subres !== FALSE) { |
|
2175
|
|
|
$this->store( $result, $subres ); |
|
2176
|
|
|
$_326 = TRUE; break; |
|
2177
|
|
|
} |
|
2178
|
|
|
$result = $res_323; |
|
2179
|
|
|
$this->pos = $pos_323; |
|
2180
|
|
|
$_326 = FALSE; break; |
|
2181
|
|
|
} |
|
2182
|
|
|
while(0); |
|
2183
|
|
|
if( $_326 === TRUE ) { $_328 = TRUE; break; } |
|
2184
|
|
|
$result = $res_321; |
|
2185
|
|
|
$this->pos = $pos_321; |
|
2186
|
|
|
$_328 = FALSE; break; |
|
2187
|
|
|
} |
|
2188
|
|
|
while(0); |
|
2189
|
|
|
if( $_328 === TRUE ) { $_330 = TRUE; break; } |
|
2190
|
|
|
$result = $res_319; |
|
2191
|
|
|
$this->pos = $pos_319; |
|
2192
|
|
|
$_330 = FALSE; break; |
|
2193
|
|
|
} |
|
2194
|
|
|
while(0); |
|
2195
|
|
|
if( $_330 === TRUE ) { $_332 = TRUE; break; } |
|
2196
|
|
|
$result = $res_317; |
|
2197
|
|
|
$this->pos = $pos_317; |
|
2198
|
|
|
$_332 = FALSE; break; |
|
2199
|
|
|
} |
|
2200
|
|
|
while(0); |
|
2201
|
|
|
if( $_332 === TRUE ) { $_334 = TRUE; break; } |
|
2202
|
|
|
$result = $res_315; |
|
2203
|
|
|
$this->pos = $pos_315; |
|
2204
|
|
|
$_334 = FALSE; break; |
|
2205
|
|
|
} |
|
2206
|
|
|
while(0); |
|
2207
|
|
|
if( $_334 === TRUE ) { $_336 = TRUE; break; } |
|
2208
|
|
|
$result = $res_313; |
|
2209
|
|
|
$this->pos = $pos_313; |
|
2210
|
|
|
$_336 = FALSE; break; |
|
2211
|
|
|
} |
|
2212
|
|
|
while(0); |
|
2213
|
|
|
if( $_336 === TRUE ) { $_338 = TRUE; break; } |
|
2214
|
|
|
$result = $res_311; |
|
2215
|
|
|
$this->pos = $pos_311; |
|
2216
|
|
|
$_338 = FALSE; break; |
|
2217
|
|
|
} |
|
2218
|
|
|
while(0); |
|
2219
|
|
|
if( $_338 === TRUE ) { $_340 = TRUE; break; } |
|
2220
|
|
|
$result = $res_309; |
|
2221
|
|
|
$this->pos = $pos_309; |
|
2222
|
|
|
$_340 = FALSE; break; |
|
2223
|
|
|
} |
|
2224
|
|
|
while(0); |
|
2225
|
|
|
if( $_340 === TRUE ) { $_342 = TRUE; break; } |
|
2226
|
|
|
$result = $res_307; |
|
2227
|
|
|
$this->pos = $pos_307; |
|
2228
|
|
|
$_342 = FALSE; break; |
|
2229
|
|
|
} |
|
2230
|
|
|
while(0); |
|
2231
|
|
|
if( $_342 === TRUE ) { $_344 = TRUE; break; } |
|
2232
|
|
|
$result = $res_305; |
|
2233
|
|
|
$this->pos = $pos_305; |
|
2234
|
|
|
$_344 = FALSE; break; |
|
2235
|
|
|
} |
|
2236
|
|
|
while(0); |
|
2237
|
|
|
if( $_344 === FALSE) { $_346 = FALSE; break; } |
|
2238
|
|
|
$_346 = TRUE; break; |
|
2239
|
|
|
} |
|
2240
|
|
|
while(0); |
|
2241
|
|
|
if( $_346 === FALSE) { |
|
2242
|
|
|
$result = $res_347; |
|
2243
|
|
|
$this->pos = $pos_347; |
|
2244
|
|
|
unset( $res_347 ); |
|
2245
|
|
|
unset( $pos_347 ); |
|
2246
|
|
|
break; |
|
2247
|
|
|
} |
|
2248
|
|
|
$count += 1; |
|
2249
|
|
|
} |
|
2250
|
|
|
if ($count > 0) { return $this->finalise($result); } |
|
2251
|
|
|
else { return FALSE; } |
|
2252
|
|
|
} |
|
2253
|
|
|
|
|
2254
|
|
|
|
|
2255
|
|
|
|
|
2256
|
|
|
|
|
2257
|
|
|
/* UncachedBlock: |
|
|
|
|
|
|
2258
|
|
|
'<%' < "uncached" < CacheBlockArguments? ( < Conditional:("if"|"unless") > Condition:IfArgument )? > '%>' |
|
2259
|
|
|
Template:$TemplateMatcher? |
|
2260
|
|
|
'<%' < 'end_' ("uncached"|"cached"|"cacheblock") > '%>' */ |
|
2261
|
|
|
protected $match_UncachedBlock_typestack = array('UncachedBlock'); |
|
2262
|
|
|
function match_UncachedBlock ($stack = array()) { |
|
2263
|
|
|
$matchrule = "UncachedBlock"; $result = $this->construct($matchrule, $matchrule, null); |
|
2264
|
|
|
$_384 = NULL; |
|
2265
|
|
|
do { |
|
|
|
|
|
|
2266
|
|
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2267
|
|
|
else { $_384 = FALSE; break; } |
|
2268
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2269
|
|
|
if (( $subres = $this->literal( 'uncached' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2270
|
|
|
else { $_384 = FALSE; break; } |
|
2271
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2272
|
|
|
$res_352 = $result; |
|
2273
|
|
|
$pos_352 = $this->pos; |
|
2274
|
|
|
$matcher = 'match_'.'CacheBlockArguments'; $key = $matcher; $pos = $this->pos; |
|
2275
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2276
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
2277
|
|
|
else { |
|
2278
|
|
|
$result = $res_352; |
|
2279
|
|
|
$this->pos = $pos_352; |
|
2280
|
|
|
unset( $res_352 ); |
|
2281
|
|
|
unset( $pos_352 ); |
|
2282
|
|
|
} |
|
2283
|
|
|
$res_364 = $result; |
|
2284
|
|
|
$pos_364 = $this->pos; |
|
2285
|
|
|
$_363 = NULL; |
|
2286
|
|
|
do { |
|
2287
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2288
|
|
|
$stack[] = $result; $result = $this->construct( $matchrule, "Conditional" ); |
|
2289
|
|
|
$_359 = NULL; |
|
2290
|
|
|
do { |
|
2291
|
|
|
$_357 = NULL; |
|
2292
|
|
|
do { |
|
2293
|
|
|
$res_354 = $result; |
|
2294
|
|
|
$pos_354 = $this->pos; |
|
2295
|
|
|
if (( $subres = $this->literal( 'if' ) ) !== FALSE) { |
|
2296
|
|
|
$result["text"] .= $subres; |
|
2297
|
|
|
$_357 = TRUE; break; |
|
2298
|
|
|
} |
|
2299
|
|
|
$result = $res_354; |
|
2300
|
|
|
$this->pos = $pos_354; |
|
2301
|
|
|
if (( $subres = $this->literal( 'unless' ) ) !== FALSE) { |
|
2302
|
|
|
$result["text"] .= $subres; |
|
2303
|
|
|
$_357 = TRUE; break; |
|
2304
|
|
|
} |
|
2305
|
|
|
$result = $res_354; |
|
2306
|
|
|
$this->pos = $pos_354; |
|
2307
|
|
|
$_357 = FALSE; break; |
|
2308
|
|
|
} |
|
2309
|
|
|
while(0); |
|
2310
|
|
|
if( $_357 === FALSE) { $_359 = FALSE; break; } |
|
2311
|
|
|
$_359 = TRUE; break; |
|
2312
|
|
|
} |
|
2313
|
|
|
while(0); |
|
2314
|
|
|
if( $_359 === TRUE ) { |
|
2315
|
|
|
$subres = $result; $result = array_pop($stack); |
|
2316
|
|
|
$this->store( $result, $subres, 'Conditional' ); |
|
2317
|
|
|
} |
|
2318
|
|
|
if( $_359 === FALSE) { |
|
2319
|
|
|
$result = array_pop($stack); |
|
2320
|
|
|
$_363 = FALSE; break; |
|
2321
|
|
|
} |
|
2322
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2323
|
|
|
$matcher = 'match_'.'IfArgument'; $key = $matcher; $pos = $this->pos; |
|
2324
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2325
|
|
|
if ($subres !== FALSE) { |
|
2326
|
|
|
$this->store( $result, $subres, "Condition" ); |
|
2327
|
|
|
} |
|
2328
|
|
|
else { $_363 = FALSE; break; } |
|
2329
|
|
|
$_363 = TRUE; break; |
|
2330
|
|
|
} |
|
2331
|
|
|
while(0); |
|
2332
|
|
|
if( $_363 === FALSE) { |
|
2333
|
|
|
$result = $res_364; |
|
2334
|
|
|
$this->pos = $pos_364; |
|
2335
|
|
|
unset( $res_364 ); |
|
2336
|
|
|
unset( $pos_364 ); |
|
2337
|
|
|
} |
|
2338
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2339
|
|
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2340
|
|
|
else { $_384 = FALSE; break; } |
|
2341
|
|
|
$res_367 = $result; |
|
2342
|
|
|
$pos_367 = $this->pos; |
|
2343
|
|
|
$matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $key = $matcher; $pos = $this->pos; |
|
2344
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2345
|
|
|
if ($subres !== FALSE) { |
|
2346
|
|
|
$this->store( $result, $subres, "Template" ); |
|
2347
|
|
|
} |
|
2348
|
|
|
else { |
|
2349
|
|
|
$result = $res_367; |
|
2350
|
|
|
$this->pos = $pos_367; |
|
2351
|
|
|
unset( $res_367 ); |
|
2352
|
|
|
unset( $pos_367 ); |
|
2353
|
|
|
} |
|
2354
|
|
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2355
|
|
|
else { $_384 = FALSE; break; } |
|
2356
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2357
|
|
|
if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2358
|
|
|
else { $_384 = FALSE; break; } |
|
2359
|
|
|
$_380 = NULL; |
|
2360
|
|
|
do { |
|
2361
|
|
|
$_378 = NULL; |
|
2362
|
|
|
do { |
|
2363
|
|
|
$res_371 = $result; |
|
2364
|
|
|
$pos_371 = $this->pos; |
|
2365
|
|
|
if (( $subres = $this->literal( 'uncached' ) ) !== FALSE) { |
|
2366
|
|
|
$result["text"] .= $subres; |
|
2367
|
|
|
$_378 = TRUE; break; |
|
2368
|
|
|
} |
|
2369
|
|
|
$result = $res_371; |
|
2370
|
|
|
$this->pos = $pos_371; |
|
2371
|
|
|
$_376 = NULL; |
|
2372
|
|
|
do { |
|
2373
|
|
|
$res_373 = $result; |
|
2374
|
|
|
$pos_373 = $this->pos; |
|
2375
|
|
|
if (( $subres = $this->literal( 'cached' ) ) !== FALSE) { |
|
2376
|
|
|
$result["text"] .= $subres; |
|
2377
|
|
|
$_376 = TRUE; break; |
|
2378
|
|
|
} |
|
2379
|
|
|
$result = $res_373; |
|
2380
|
|
|
$this->pos = $pos_373; |
|
2381
|
|
|
if (( $subres = $this->literal( 'cacheblock' ) ) !== FALSE) { |
|
2382
|
|
|
$result["text"] .= $subres; |
|
2383
|
|
|
$_376 = TRUE; break; |
|
2384
|
|
|
} |
|
2385
|
|
|
$result = $res_373; |
|
2386
|
|
|
$this->pos = $pos_373; |
|
2387
|
|
|
$_376 = FALSE; break; |
|
2388
|
|
|
} |
|
2389
|
|
|
while(0); |
|
2390
|
|
|
if( $_376 === TRUE ) { $_378 = TRUE; break; } |
|
2391
|
|
|
$result = $res_371; |
|
2392
|
|
|
$this->pos = $pos_371; |
|
2393
|
|
|
$_378 = FALSE; break; |
|
2394
|
|
|
} |
|
2395
|
|
|
while(0); |
|
2396
|
|
|
if( $_378 === FALSE) { $_380 = FALSE; break; } |
|
2397
|
|
|
$_380 = TRUE; break; |
|
2398
|
|
|
} |
|
2399
|
|
|
while(0); |
|
2400
|
|
|
if( $_380 === FALSE) { $_384 = FALSE; break; } |
|
2401
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2402
|
|
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2403
|
|
|
else { $_384 = FALSE; break; } |
|
2404
|
|
|
$_384 = TRUE; break; |
|
2405
|
|
|
} |
|
2406
|
|
|
while(0); |
|
2407
|
|
|
if( $_384 === TRUE ) { return $this->finalise($result); } |
|
2408
|
|
|
if( $_384 === FALSE) { return FALSE; } |
|
2409
|
|
|
} |
|
2410
|
|
|
|
|
2411
|
|
|
|
|
2412
|
|
|
|
|
2413
|
|
|
function UncachedBlock_Template(&$res, $sub){ |
|
2414
|
|
|
$res['php'] = $sub['php']; |
|
2415
|
|
|
} |
|
2416
|
|
|
|
|
2417
|
|
|
/* CacheRestrictedTemplate: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock | |
|
2418
|
|
|
OpenBlock | MalformedBlock | Injection | Text)+ */ |
|
2419
|
|
|
protected $match_CacheRestrictedTemplate_typestack = array('CacheRestrictedTemplate','Template'); |
|
2420
|
|
|
function match_CacheRestrictedTemplate ($stack = array()) { |
|
2421
|
|
|
$matchrule = "CacheRestrictedTemplate"; $result = $this->construct($matchrule, $matchrule, null); |
|
2422
|
|
|
$count = 0; |
|
2423
|
|
|
while (true) { |
|
2424
|
|
|
$res_436 = $result; |
|
2425
|
|
|
$pos_436 = $this->pos; |
|
2426
|
|
|
$_435 = NULL; |
|
2427
|
|
|
do { |
|
|
|
|
|
|
2428
|
|
|
$_433 = NULL; |
|
2429
|
|
|
do { |
|
2430
|
|
|
$res_386 = $result; |
|
2431
|
|
|
$pos_386 = $this->pos; |
|
2432
|
|
|
$matcher = 'match_'.'Comment'; $key = $matcher; $pos = $this->pos; |
|
2433
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2434
|
|
|
if ($subres !== FALSE) { |
|
2435
|
|
|
$this->store( $result, $subres ); |
|
2436
|
|
|
$_433 = TRUE; break; |
|
2437
|
|
|
} |
|
2438
|
|
|
$result = $res_386; |
|
2439
|
|
|
$this->pos = $pos_386; |
|
2440
|
|
|
$_431 = NULL; |
|
2441
|
|
|
do { |
|
2442
|
|
|
$res_388 = $result; |
|
2443
|
|
|
$pos_388 = $this->pos; |
|
2444
|
|
|
$matcher = 'match_'.'Translate'; $key = $matcher; $pos = $this->pos; |
|
2445
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2446
|
|
|
if ($subres !== FALSE) { |
|
2447
|
|
|
$this->store( $result, $subres ); |
|
2448
|
|
|
$_431 = TRUE; break; |
|
2449
|
|
|
} |
|
2450
|
|
|
$result = $res_388; |
|
2451
|
|
|
$this->pos = $pos_388; |
|
2452
|
|
|
$_429 = NULL; |
|
2453
|
|
|
do { |
|
2454
|
|
|
$res_390 = $result; |
|
2455
|
|
|
$pos_390 = $this->pos; |
|
2456
|
|
|
$matcher = 'match_'.'If'; $key = $matcher; $pos = $this->pos; |
|
2457
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2458
|
|
|
if ($subres !== FALSE) { |
|
2459
|
|
|
$this->store( $result, $subres ); |
|
2460
|
|
|
$_429 = TRUE; break; |
|
2461
|
|
|
} |
|
2462
|
|
|
$result = $res_390; |
|
2463
|
|
|
$this->pos = $pos_390; |
|
2464
|
|
|
$_427 = NULL; |
|
2465
|
|
|
do { |
|
2466
|
|
|
$res_392 = $result; |
|
2467
|
|
|
$pos_392 = $this->pos; |
|
2468
|
|
|
$matcher = 'match_'.'Require'; $key = $matcher; $pos = $this->pos; |
|
2469
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2470
|
|
|
if ($subres !== FALSE) { |
|
2471
|
|
|
$this->store( $result, $subres ); |
|
2472
|
|
|
$_427 = TRUE; break; |
|
2473
|
|
|
} |
|
2474
|
|
|
$result = $res_392; |
|
2475
|
|
|
$this->pos = $pos_392; |
|
2476
|
|
|
$_425 = NULL; |
|
2477
|
|
|
do { |
|
2478
|
|
|
$res_394 = $result; |
|
2479
|
|
|
$pos_394 = $this->pos; |
|
2480
|
|
|
$matcher = 'match_'.'CacheBlock'; $key = $matcher; $pos = $this->pos; |
|
2481
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2482
|
|
|
if ($subres !== FALSE) { |
|
2483
|
|
|
$this->store( $result, $subres ); |
|
2484
|
|
|
$_425 = TRUE; break; |
|
2485
|
|
|
} |
|
2486
|
|
|
$result = $res_394; |
|
2487
|
|
|
$this->pos = $pos_394; |
|
2488
|
|
|
$_423 = NULL; |
|
2489
|
|
|
do { |
|
2490
|
|
|
$res_396 = $result; |
|
2491
|
|
|
$pos_396 = $this->pos; |
|
2492
|
|
|
$matcher = 'match_'.'UncachedBlock'; $key = $matcher; $pos = $this->pos; |
|
2493
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2494
|
|
|
if ($subres !== FALSE) { |
|
2495
|
|
|
$this->store( $result, $subres ); |
|
2496
|
|
|
$_423 = TRUE; break; |
|
2497
|
|
|
} |
|
2498
|
|
|
$result = $res_396; |
|
2499
|
|
|
$this->pos = $pos_396; |
|
2500
|
|
|
$_421 = NULL; |
|
2501
|
|
|
do { |
|
2502
|
|
|
$res_398 = $result; |
|
2503
|
|
|
$pos_398 = $this->pos; |
|
2504
|
|
|
$matcher = 'match_'.'OldI18NTag'; $key = $matcher; $pos = $this->pos; |
|
2505
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2506
|
|
|
if ($subres !== FALSE) { |
|
2507
|
|
|
$this->store( $result, $subres ); |
|
2508
|
|
|
$_421 = TRUE; break; |
|
2509
|
|
|
} |
|
2510
|
|
|
$result = $res_398; |
|
2511
|
|
|
$this->pos = $pos_398; |
|
2512
|
|
|
$_419 = NULL; |
|
2513
|
|
|
do { |
|
2514
|
|
|
$res_400 = $result; |
|
2515
|
|
|
$pos_400 = $this->pos; |
|
2516
|
|
|
$matcher = 'match_'.'Include'; $key = $matcher; $pos = $this->pos; |
|
2517
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2518
|
|
|
if ($subres !== FALSE) { |
|
2519
|
|
|
$this->store( $result, $subres ); |
|
2520
|
|
|
$_419 = TRUE; break; |
|
2521
|
|
|
} |
|
2522
|
|
|
$result = $res_400; |
|
2523
|
|
|
$this->pos = $pos_400; |
|
2524
|
|
|
$_417 = NULL; |
|
2525
|
|
|
do { |
|
2526
|
|
|
$res_402 = $result; |
|
2527
|
|
|
$pos_402 = $this->pos; |
|
2528
|
|
|
$matcher = 'match_'.'ClosedBlock'; $key = $matcher; $pos = $this->pos; |
|
2529
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2530
|
|
|
if ($subres !== FALSE) { |
|
2531
|
|
|
$this->store( $result, $subres ); |
|
2532
|
|
|
$_417 = TRUE; break; |
|
2533
|
|
|
} |
|
2534
|
|
|
$result = $res_402; |
|
2535
|
|
|
$this->pos = $pos_402; |
|
2536
|
|
|
$_415 = NULL; |
|
2537
|
|
|
do { |
|
2538
|
|
|
$res_404 = $result; |
|
2539
|
|
|
$pos_404 = $this->pos; |
|
2540
|
|
|
$matcher = 'match_'.'OpenBlock'; $key = $matcher; $pos = $this->pos; |
|
2541
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2542
|
|
|
if ($subres !== FALSE) { |
|
2543
|
|
|
$this->store( $result, $subres ); |
|
2544
|
|
|
$_415 = TRUE; break; |
|
2545
|
|
|
} |
|
2546
|
|
|
$result = $res_404; |
|
2547
|
|
|
$this->pos = $pos_404; |
|
2548
|
|
|
$_413 = NULL; |
|
2549
|
|
|
do { |
|
2550
|
|
|
$res_406 = $result; |
|
2551
|
|
|
$pos_406 = $this->pos; |
|
2552
|
|
|
$matcher = 'match_'.'MalformedBlock'; $key = $matcher; $pos = $this->pos; |
|
2553
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2554
|
|
|
if ($subres !== FALSE) { |
|
2555
|
|
|
$this->store( $result, $subres ); |
|
2556
|
|
|
$_413 = TRUE; break; |
|
2557
|
|
|
} |
|
2558
|
|
|
$result = $res_406; |
|
2559
|
|
|
$this->pos = $pos_406; |
|
2560
|
|
|
$_411 = NULL; |
|
2561
|
|
|
do { |
|
2562
|
|
|
$res_408 = $result; |
|
2563
|
|
|
$pos_408 = $this->pos; |
|
2564
|
|
|
$matcher = 'match_'.'Injection'; $key = $matcher; $pos = $this->pos; |
|
2565
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2566
|
|
|
if ($subres !== FALSE) { |
|
2567
|
|
|
$this->store( $result, $subres ); |
|
2568
|
|
|
$_411 = TRUE; break; |
|
2569
|
|
|
} |
|
2570
|
|
|
$result = $res_408; |
|
2571
|
|
|
$this->pos = $pos_408; |
|
2572
|
|
|
$matcher = 'match_'.'Text'; $key = $matcher; $pos = $this->pos; |
|
2573
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2574
|
|
|
if ($subres !== FALSE) { |
|
2575
|
|
|
$this->store( $result, $subres ); |
|
2576
|
|
|
$_411 = TRUE; break; |
|
2577
|
|
|
} |
|
2578
|
|
|
$result = $res_408; |
|
2579
|
|
|
$this->pos = $pos_408; |
|
2580
|
|
|
$_411 = FALSE; break; |
|
2581
|
|
|
} |
|
2582
|
|
|
while(0); |
|
2583
|
|
|
if( $_411 === TRUE ) { $_413 = TRUE; break; } |
|
2584
|
|
|
$result = $res_406; |
|
2585
|
|
|
$this->pos = $pos_406; |
|
2586
|
|
|
$_413 = FALSE; break; |
|
2587
|
|
|
} |
|
2588
|
|
|
while(0); |
|
2589
|
|
|
if( $_413 === TRUE ) { $_415 = TRUE; break; } |
|
2590
|
|
|
$result = $res_404; |
|
2591
|
|
|
$this->pos = $pos_404; |
|
2592
|
|
|
$_415 = FALSE; break; |
|
2593
|
|
|
} |
|
2594
|
|
|
while(0); |
|
2595
|
|
|
if( $_415 === TRUE ) { $_417 = TRUE; break; } |
|
2596
|
|
|
$result = $res_402; |
|
2597
|
|
|
$this->pos = $pos_402; |
|
2598
|
|
|
$_417 = FALSE; break; |
|
2599
|
|
|
} |
|
2600
|
|
|
while(0); |
|
2601
|
|
|
if( $_417 === TRUE ) { $_419 = TRUE; break; } |
|
2602
|
|
|
$result = $res_400; |
|
2603
|
|
|
$this->pos = $pos_400; |
|
2604
|
|
|
$_419 = FALSE; break; |
|
2605
|
|
|
} |
|
2606
|
|
|
while(0); |
|
2607
|
|
|
if( $_419 === TRUE ) { $_421 = TRUE; break; } |
|
2608
|
|
|
$result = $res_398; |
|
2609
|
|
|
$this->pos = $pos_398; |
|
2610
|
|
|
$_421 = FALSE; break; |
|
2611
|
|
|
} |
|
2612
|
|
|
while(0); |
|
2613
|
|
|
if( $_421 === TRUE ) { $_423 = TRUE; break; } |
|
2614
|
|
|
$result = $res_396; |
|
2615
|
|
|
$this->pos = $pos_396; |
|
2616
|
|
|
$_423 = FALSE; break; |
|
2617
|
|
|
} |
|
2618
|
|
|
while(0); |
|
2619
|
|
|
if( $_423 === TRUE ) { $_425 = TRUE; break; } |
|
2620
|
|
|
$result = $res_394; |
|
2621
|
|
|
$this->pos = $pos_394; |
|
2622
|
|
|
$_425 = FALSE; break; |
|
2623
|
|
|
} |
|
2624
|
|
|
while(0); |
|
2625
|
|
|
if( $_425 === TRUE ) { $_427 = TRUE; break; } |
|
2626
|
|
|
$result = $res_392; |
|
2627
|
|
|
$this->pos = $pos_392; |
|
2628
|
|
|
$_427 = FALSE; break; |
|
2629
|
|
|
} |
|
2630
|
|
|
while(0); |
|
2631
|
|
|
if( $_427 === TRUE ) { $_429 = TRUE; break; } |
|
2632
|
|
|
$result = $res_390; |
|
2633
|
|
|
$this->pos = $pos_390; |
|
2634
|
|
|
$_429 = FALSE; break; |
|
2635
|
|
|
} |
|
2636
|
|
|
while(0); |
|
2637
|
|
|
if( $_429 === TRUE ) { $_431 = TRUE; break; } |
|
2638
|
|
|
$result = $res_388; |
|
2639
|
|
|
$this->pos = $pos_388; |
|
2640
|
|
|
$_431 = FALSE; break; |
|
2641
|
|
|
} |
|
2642
|
|
|
while(0); |
|
2643
|
|
|
if( $_431 === TRUE ) { $_433 = TRUE; break; } |
|
2644
|
|
|
$result = $res_386; |
|
2645
|
|
|
$this->pos = $pos_386; |
|
2646
|
|
|
$_433 = FALSE; break; |
|
2647
|
|
|
} |
|
2648
|
|
|
while(0); |
|
2649
|
|
|
if( $_433 === FALSE) { $_435 = FALSE; break; } |
|
2650
|
|
|
$_435 = TRUE; break; |
|
2651
|
|
|
} |
|
2652
|
|
|
while(0); |
|
2653
|
|
|
if( $_435 === FALSE) { |
|
2654
|
|
|
$result = $res_436; |
|
2655
|
|
|
$this->pos = $pos_436; |
|
2656
|
|
|
unset( $res_436 ); |
|
2657
|
|
|
unset( $pos_436 ); |
|
2658
|
|
|
break; |
|
2659
|
|
|
} |
|
2660
|
|
|
$count += 1; |
|
2661
|
|
|
} |
|
2662
|
|
|
if ($count > 0) { return $this->finalise($result); } |
|
2663
|
|
|
else { return FALSE; } |
|
2664
|
|
|
} |
|
2665
|
|
|
|
|
2666
|
|
|
|
|
2667
|
|
|
|
|
2668
|
|
|
function CacheRestrictedTemplate_CacheBlock(&$res, $sub) { |
|
|
|
|
|
|
2669
|
|
|
throw new SSTemplateParseException('You cant have cache blocks nested within with, loop or control blocks ' . |
|
2670
|
|
|
'that are within cache blocks', $this); |
|
2671
|
|
|
} |
|
2672
|
|
|
|
|
2673
|
|
|
function CacheRestrictedTemplate_UncachedBlock(&$res, $sub) { |
|
|
|
|
|
|
2674
|
|
|
throw new SSTemplateParseException('You cant have uncache blocks nested within with, loop or control blocks ' . |
|
2675
|
|
|
'that are within cache blocks', $this); |
|
2676
|
|
|
} |
|
2677
|
|
|
|
|
2678
|
|
|
/* CacheBlock: |
|
|
|
|
|
|
2679
|
|
|
'<%' < CacheTag:("cached"|"cacheblock") < (CacheBlockArguments)? ( < Conditional:("if"|"unless") > |
|
2680
|
|
|
Condition:IfArgument )? > '%>' |
|
2681
|
|
|
(CacheBlock | UncachedBlock | CacheBlockTemplate)* |
|
2682
|
|
|
'<%' < 'end_' ("cached"|"uncached"|"cacheblock") > '%>' */ |
|
2683
|
|
|
protected $match_CacheBlock_typestack = array('CacheBlock'); |
|
2684
|
|
|
function match_CacheBlock ($stack = array()) { |
|
2685
|
|
|
$matchrule = "CacheBlock"; $result = $this->construct($matchrule, $matchrule, null); |
|
2686
|
|
|
$_491 = NULL; |
|
2687
|
|
|
do { |
|
|
|
|
|
|
2688
|
|
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2689
|
|
|
else { $_491 = FALSE; break; } |
|
2690
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2691
|
|
|
$stack[] = $result; $result = $this->construct( $matchrule, "CacheTag" ); |
|
2692
|
|
|
$_444 = NULL; |
|
2693
|
|
|
do { |
|
2694
|
|
|
$_442 = NULL; |
|
2695
|
|
|
do { |
|
2696
|
|
|
$res_439 = $result; |
|
2697
|
|
|
$pos_439 = $this->pos; |
|
2698
|
|
|
if (( $subres = $this->literal( 'cached' ) ) !== FALSE) { |
|
2699
|
|
|
$result["text"] .= $subres; |
|
2700
|
|
|
$_442 = TRUE; break; |
|
2701
|
|
|
} |
|
2702
|
|
|
$result = $res_439; |
|
2703
|
|
|
$this->pos = $pos_439; |
|
2704
|
|
|
if (( $subres = $this->literal( 'cacheblock' ) ) !== FALSE) { |
|
2705
|
|
|
$result["text"] .= $subres; |
|
2706
|
|
|
$_442 = TRUE; break; |
|
2707
|
|
|
} |
|
2708
|
|
|
$result = $res_439; |
|
2709
|
|
|
$this->pos = $pos_439; |
|
2710
|
|
|
$_442 = FALSE; break; |
|
2711
|
|
|
} |
|
2712
|
|
|
while(0); |
|
2713
|
|
|
if( $_442 === FALSE) { $_444 = FALSE; break; } |
|
2714
|
|
|
$_444 = TRUE; break; |
|
2715
|
|
|
} |
|
2716
|
|
|
while(0); |
|
2717
|
|
|
if( $_444 === TRUE ) { |
|
2718
|
|
|
$subres = $result; $result = array_pop($stack); |
|
2719
|
|
|
$this->store( $result, $subres, 'CacheTag' ); |
|
2720
|
|
|
} |
|
2721
|
|
|
if( $_444 === FALSE) { |
|
2722
|
|
|
$result = array_pop($stack); |
|
2723
|
|
|
$_491 = FALSE; break; |
|
2724
|
|
|
} |
|
2725
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2726
|
|
|
$res_449 = $result; |
|
2727
|
|
|
$pos_449 = $this->pos; |
|
2728
|
|
|
$_448 = NULL; |
|
2729
|
|
|
do { |
|
2730
|
|
|
$matcher = 'match_'.'CacheBlockArguments'; $key = $matcher; $pos = $this->pos; |
|
2731
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2732
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
2733
|
|
|
else { $_448 = FALSE; break; } |
|
2734
|
|
|
$_448 = TRUE; break; |
|
2735
|
|
|
} |
|
2736
|
|
|
while(0); |
|
2737
|
|
|
if( $_448 === FALSE) { |
|
2738
|
|
|
$result = $res_449; |
|
2739
|
|
|
$this->pos = $pos_449; |
|
2740
|
|
|
unset( $res_449 ); |
|
2741
|
|
|
unset( $pos_449 ); |
|
2742
|
|
|
} |
|
2743
|
|
|
$res_461 = $result; |
|
2744
|
|
|
$pos_461 = $this->pos; |
|
2745
|
|
|
$_460 = NULL; |
|
2746
|
|
|
do { |
|
2747
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2748
|
|
|
$stack[] = $result; $result = $this->construct( $matchrule, "Conditional" ); |
|
2749
|
|
|
$_456 = NULL; |
|
2750
|
|
|
do { |
|
2751
|
|
|
$_454 = NULL; |
|
2752
|
|
|
do { |
|
2753
|
|
|
$res_451 = $result; |
|
2754
|
|
|
$pos_451 = $this->pos; |
|
2755
|
|
|
if (( $subres = $this->literal( 'if' ) ) !== FALSE) { |
|
2756
|
|
|
$result["text"] .= $subres; |
|
2757
|
|
|
$_454 = TRUE; break; |
|
2758
|
|
|
} |
|
2759
|
|
|
$result = $res_451; |
|
2760
|
|
|
$this->pos = $pos_451; |
|
2761
|
|
|
if (( $subres = $this->literal( 'unless' ) ) !== FALSE) { |
|
2762
|
|
|
$result["text"] .= $subres; |
|
2763
|
|
|
$_454 = TRUE; break; |
|
2764
|
|
|
} |
|
2765
|
|
|
$result = $res_451; |
|
2766
|
|
|
$this->pos = $pos_451; |
|
2767
|
|
|
$_454 = FALSE; break; |
|
2768
|
|
|
} |
|
2769
|
|
|
while(0); |
|
2770
|
|
|
if( $_454 === FALSE) { $_456 = FALSE; break; } |
|
2771
|
|
|
$_456 = TRUE; break; |
|
2772
|
|
|
} |
|
2773
|
|
|
while(0); |
|
2774
|
|
|
if( $_456 === TRUE ) { |
|
2775
|
|
|
$subres = $result; $result = array_pop($stack); |
|
2776
|
|
|
$this->store( $result, $subres, 'Conditional' ); |
|
2777
|
|
|
} |
|
2778
|
|
|
if( $_456 === FALSE) { |
|
2779
|
|
|
$result = array_pop($stack); |
|
2780
|
|
|
$_460 = FALSE; break; |
|
2781
|
|
|
} |
|
2782
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2783
|
|
|
$matcher = 'match_'.'IfArgument'; $key = $matcher; $pos = $this->pos; |
|
2784
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2785
|
|
|
if ($subres !== FALSE) { |
|
2786
|
|
|
$this->store( $result, $subres, "Condition" ); |
|
2787
|
|
|
} |
|
2788
|
|
|
else { $_460 = FALSE; break; } |
|
2789
|
|
|
$_460 = TRUE; break; |
|
2790
|
|
|
} |
|
2791
|
|
|
while(0); |
|
2792
|
|
|
if( $_460 === FALSE) { |
|
2793
|
|
|
$result = $res_461; |
|
2794
|
|
|
$this->pos = $pos_461; |
|
2795
|
|
|
unset( $res_461 ); |
|
2796
|
|
|
unset( $pos_461 ); |
|
2797
|
|
|
} |
|
2798
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2799
|
|
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2800
|
|
|
else { $_491 = FALSE; break; } |
|
2801
|
|
|
while (true) { |
|
2802
|
|
|
$res_474 = $result; |
|
2803
|
|
|
$pos_474 = $this->pos; |
|
2804
|
|
|
$_473 = NULL; |
|
2805
|
|
|
do { |
|
2806
|
|
|
$_471 = NULL; |
|
2807
|
|
|
do { |
|
2808
|
|
|
$res_464 = $result; |
|
2809
|
|
|
$pos_464 = $this->pos; |
|
2810
|
|
|
$matcher = 'match_'.'CacheBlock'; $key = $matcher; $pos = $this->pos; |
|
2811
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2812
|
|
|
if ($subres !== FALSE) { |
|
2813
|
|
|
$this->store( $result, $subres ); |
|
2814
|
|
|
$_471 = TRUE; break; |
|
2815
|
|
|
} |
|
2816
|
|
|
$result = $res_464; |
|
2817
|
|
|
$this->pos = $pos_464; |
|
2818
|
|
|
$_469 = NULL; |
|
2819
|
|
|
do { |
|
2820
|
|
|
$res_466 = $result; |
|
2821
|
|
|
$pos_466 = $this->pos; |
|
2822
|
|
|
$matcher = 'match_'.'UncachedBlock'; $key = $matcher; $pos = $this->pos; |
|
2823
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2824
|
|
|
if ($subres !== FALSE) { |
|
2825
|
|
|
$this->store( $result, $subres ); |
|
2826
|
|
|
$_469 = TRUE; break; |
|
2827
|
|
|
} |
|
2828
|
|
|
$result = $res_466; |
|
2829
|
|
|
$this->pos = $pos_466; |
|
2830
|
|
|
$matcher = 'match_'.'CacheBlockTemplate'; $key = $matcher; $pos = $this->pos; |
|
2831
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2832
|
|
|
if ($subres !== FALSE) { |
|
2833
|
|
|
$this->store( $result, $subres ); |
|
2834
|
|
|
$_469 = TRUE; break; |
|
2835
|
|
|
} |
|
2836
|
|
|
$result = $res_466; |
|
2837
|
|
|
$this->pos = $pos_466; |
|
2838
|
|
|
$_469 = FALSE; break; |
|
2839
|
|
|
} |
|
2840
|
|
|
while(0); |
|
2841
|
|
|
if( $_469 === TRUE ) { $_471 = TRUE; break; } |
|
2842
|
|
|
$result = $res_464; |
|
2843
|
|
|
$this->pos = $pos_464; |
|
2844
|
|
|
$_471 = FALSE; break; |
|
2845
|
|
|
} |
|
2846
|
|
|
while(0); |
|
2847
|
|
|
if( $_471 === FALSE) { $_473 = FALSE; break; } |
|
2848
|
|
|
$_473 = TRUE; break; |
|
2849
|
|
|
} |
|
2850
|
|
|
while(0); |
|
2851
|
|
|
if( $_473 === FALSE) { |
|
2852
|
|
|
$result = $res_474; |
|
2853
|
|
|
$this->pos = $pos_474; |
|
2854
|
|
|
unset( $res_474 ); |
|
2855
|
|
|
unset( $pos_474 ); |
|
2856
|
|
|
break; |
|
2857
|
|
|
} |
|
2858
|
|
|
} |
|
2859
|
|
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2860
|
|
|
else { $_491 = FALSE; break; } |
|
2861
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2862
|
|
|
if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2863
|
|
|
else { $_491 = FALSE; break; } |
|
2864
|
|
|
$_487 = NULL; |
|
2865
|
|
|
do { |
|
2866
|
|
|
$_485 = NULL; |
|
2867
|
|
|
do { |
|
2868
|
|
|
$res_478 = $result; |
|
2869
|
|
|
$pos_478 = $this->pos; |
|
2870
|
|
|
if (( $subres = $this->literal( 'cached' ) ) !== FALSE) { |
|
2871
|
|
|
$result["text"] .= $subres; |
|
2872
|
|
|
$_485 = TRUE; break; |
|
2873
|
|
|
} |
|
2874
|
|
|
$result = $res_478; |
|
2875
|
|
|
$this->pos = $pos_478; |
|
2876
|
|
|
$_483 = NULL; |
|
2877
|
|
|
do { |
|
2878
|
|
|
$res_480 = $result; |
|
2879
|
|
|
$pos_480 = $this->pos; |
|
2880
|
|
|
if (( $subres = $this->literal( 'uncached' ) ) !== FALSE) { |
|
2881
|
|
|
$result["text"] .= $subres; |
|
2882
|
|
|
$_483 = TRUE; break; |
|
2883
|
|
|
} |
|
2884
|
|
|
$result = $res_480; |
|
2885
|
|
|
$this->pos = $pos_480; |
|
2886
|
|
|
if (( $subres = $this->literal( 'cacheblock' ) ) !== FALSE) { |
|
2887
|
|
|
$result["text"] .= $subres; |
|
2888
|
|
|
$_483 = TRUE; break; |
|
2889
|
|
|
} |
|
2890
|
|
|
$result = $res_480; |
|
2891
|
|
|
$this->pos = $pos_480; |
|
2892
|
|
|
$_483 = FALSE; break; |
|
2893
|
|
|
} |
|
2894
|
|
|
while(0); |
|
2895
|
|
|
if( $_483 === TRUE ) { $_485 = TRUE; break; } |
|
2896
|
|
|
$result = $res_478; |
|
2897
|
|
|
$this->pos = $pos_478; |
|
2898
|
|
|
$_485 = FALSE; break; |
|
2899
|
|
|
} |
|
2900
|
|
|
while(0); |
|
2901
|
|
|
if( $_485 === FALSE) { $_487 = FALSE; break; } |
|
2902
|
|
|
$_487 = TRUE; break; |
|
2903
|
|
|
} |
|
2904
|
|
|
while(0); |
|
2905
|
|
|
if( $_487 === FALSE) { $_491 = FALSE; break; } |
|
2906
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2907
|
|
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2908
|
|
|
else { $_491 = FALSE; break; } |
|
2909
|
|
|
$_491 = TRUE; break; |
|
2910
|
|
|
} |
|
2911
|
|
|
while(0); |
|
2912
|
|
|
if( $_491 === TRUE ) { return $this->finalise($result); } |
|
2913
|
|
|
if( $_491 === FALSE) { return FALSE; } |
|
2914
|
|
|
} |
|
2915
|
|
|
|
|
2916
|
|
|
|
|
2917
|
|
|
|
|
2918
|
|
|
function CacheBlock__construct(&$res){ |
|
2919
|
|
|
$res['subblocks'] = 0; |
|
2920
|
|
|
} |
|
2921
|
|
|
|
|
2922
|
|
|
function CacheBlock_CacheBlockArguments(&$res, $sub){ |
|
2923
|
|
|
$res['key'] = !empty($sub['php']) ? $sub['php'] : ''; |
|
2924
|
|
|
} |
|
2925
|
|
|
|
|
2926
|
|
|
function CacheBlock_Condition(&$res, $sub){ |
|
2927
|
|
|
$res['condition'] = ($res['Conditional']['text'] == 'if' ? '(' : '!(') . $sub['php'] . ') && '; |
|
2928
|
|
|
} |
|
2929
|
|
|
|
|
2930
|
|
|
function CacheBlock_CacheBlock(&$res, $sub){ |
|
2931
|
|
|
$res['php'] .= $sub['php']; |
|
2932
|
|
|
} |
|
2933
|
|
|
|
|
2934
|
|
|
function CacheBlock_UncachedBlock(&$res, $sub){ |
|
2935
|
|
|
$res['php'] .= $sub['php']; |
|
2936
|
|
|
} |
|
2937
|
|
|
|
|
2938
|
|
|
function CacheBlock_CacheBlockTemplate(&$res, $sub){ |
|
2939
|
|
|
// Get the block counter |
|
2940
|
|
|
$block = ++$res['subblocks']; |
|
2941
|
|
|
// Build the key for this block from the global key (evaluated in a closure within the template), |
|
2942
|
|
|
// the passed cache key, the block index, and the sha hash of the template. |
|
2943
|
|
|
$res['php'] .= '$keyExpression = function() use ($scope, $cache) {' . PHP_EOL; |
|
2944
|
|
|
$res['php'] .= '$val = \'\';' . PHP_EOL; |
|
2945
|
|
|
if($globalKey = Config::inst()->get('SSViewer', 'global_key')) { |
|
2946
|
|
|
// Embed the code necessary to evaluate the globalKey directly into the template, |
|
2947
|
|
|
// so that SSTemplateParser only needs to be called during template regeneration. |
|
2948
|
|
|
// Warning: If the global key is changed, it's necessary to flush the template cache. |
|
2949
|
|
|
$parser = Injector::inst()->get('SSTemplateParser', false); |
|
2950
|
|
|
$result = $parser->compileString($globalKey, '', false, false); |
|
2951
|
|
|
if(!$result) throw new SSTemplateParseException('Unexpected problem parsing template', $parser); |
|
2952
|
|
|
$res['php'] .= $result . PHP_EOL; |
|
2953
|
|
|
} |
|
2954
|
|
|
$res['php'] .= 'return $val;' . PHP_EOL; |
|
2955
|
|
|
$res['php'] .= '};' . PHP_EOL; |
|
2956
|
|
|
$key = 'sha1($keyExpression())' // Global key |
|
2957
|
|
|
. '.\'_' . sha1($sub['php']) // sha of template |
|
2958
|
|
|
. (isset($res['key']) && $res['key'] ? "_'.sha1(".$res['key'].")" : "'") // Passed key |
|
2959
|
|
|
. ".'_$block'"; // block index |
|
2960
|
|
|
// Get any condition |
|
2961
|
|
|
$condition = isset($res['condition']) ? $res['condition'] : ''; |
|
2962
|
|
|
|
|
2963
|
|
|
$res['php'] .= 'if ('.$condition.'($partial = $cache->load('.$key.'))) $val .= $partial;' . PHP_EOL; |
|
2964
|
|
|
$res['php'] .= 'else { $oldval = $val; $val = "";' . PHP_EOL; |
|
2965
|
|
|
$res['php'] .= $sub['php'] . PHP_EOL; |
|
2966
|
|
|
$res['php'] .= $condition . ' $cache->save($val); $val = $oldval . $val;' . PHP_EOL; |
|
2967
|
|
|
$res['php'] .= '}'; |
|
2968
|
|
|
} |
|
2969
|
|
|
|
|
2970
|
|
|
/* OldTPart: "_t" N "(" N QuotedString (N "," N CallArguments)? N ")" N (";")? */ |
|
2971
|
|
|
protected $match_OldTPart_typestack = array('OldTPart'); |
|
2972
|
|
|
function match_OldTPart ($stack = array()) { |
|
2973
|
|
|
$matchrule = "OldTPart"; $result = $this->construct($matchrule, $matchrule, null); |
|
2974
|
|
|
$_510 = NULL; |
|
2975
|
|
|
do { |
|
|
|
|
|
|
2976
|
|
|
if (( $subres = $this->literal( '_t' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
2977
|
|
|
else { $_510 = FALSE; break; } |
|
2978
|
|
|
$matcher = 'match_'.'N'; $key = $matcher; $pos = $this->pos; |
|
2979
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2980
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
2981
|
|
|
else { $_510 = FALSE; break; } |
|
2982
|
|
|
if (substr($this->string,$this->pos,1) == '(') { |
|
|
|
|
|
|
2983
|
|
|
$this->pos += 1; |
|
2984
|
|
|
$result["text"] .= '('; |
|
2985
|
|
|
} |
|
2986
|
|
|
else { $_510 = FALSE; break; } |
|
2987
|
|
|
$matcher = 'match_'.'N'; $key = $matcher; $pos = $this->pos; |
|
2988
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2989
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
2990
|
|
|
else { $_510 = FALSE; break; } |
|
2991
|
|
|
$matcher = 'match_'.'QuotedString'; $key = $matcher; $pos = $this->pos; |
|
2992
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
2993
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
2994
|
|
|
else { $_510 = FALSE; break; } |
|
2995
|
|
|
$res_503 = $result; |
|
2996
|
|
|
$pos_503 = $this->pos; |
|
2997
|
|
|
$_502 = NULL; |
|
2998
|
|
|
do { |
|
2999
|
|
|
$matcher = 'match_'.'N'; $key = $matcher; $pos = $this->pos; |
|
3000
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3001
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
3002
|
|
|
else { $_502 = FALSE; break; } |
|
3003
|
|
|
if (substr($this->string,$this->pos,1) == ',') { |
|
|
|
|
|
|
3004
|
|
|
$this->pos += 1; |
|
3005
|
|
|
$result["text"] .= ','; |
|
3006
|
|
|
} |
|
3007
|
|
|
else { $_502 = FALSE; break; } |
|
3008
|
|
|
$matcher = 'match_'.'N'; $key = $matcher; $pos = $this->pos; |
|
3009
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3010
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
3011
|
|
|
else { $_502 = FALSE; break; } |
|
3012
|
|
|
$matcher = 'match_'.'CallArguments'; $key = $matcher; $pos = $this->pos; |
|
3013
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3014
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
3015
|
|
|
else { $_502 = FALSE; break; } |
|
3016
|
|
|
$_502 = TRUE; break; |
|
3017
|
|
|
} |
|
3018
|
|
|
while(0); |
|
3019
|
|
|
if( $_502 === FALSE) { |
|
3020
|
|
|
$result = $res_503; |
|
3021
|
|
|
$this->pos = $pos_503; |
|
3022
|
|
|
unset( $res_503 ); |
|
3023
|
|
|
unset( $pos_503 ); |
|
3024
|
|
|
} |
|
3025
|
|
|
$matcher = 'match_'.'N'; $key = $matcher; $pos = $this->pos; |
|
3026
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3027
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
3028
|
|
|
else { $_510 = FALSE; break; } |
|
3029
|
|
|
if (substr($this->string,$this->pos,1) == ')') { |
|
|
|
|
|
|
3030
|
|
|
$this->pos += 1; |
|
3031
|
|
|
$result["text"] .= ')'; |
|
3032
|
|
|
} |
|
3033
|
|
|
else { $_510 = FALSE; break; } |
|
3034
|
|
|
$matcher = 'match_'.'N'; $key = $matcher; $pos = $this->pos; |
|
3035
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3036
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
3037
|
|
|
else { $_510 = FALSE; break; } |
|
3038
|
|
|
$res_509 = $result; |
|
3039
|
|
|
$pos_509 = $this->pos; |
|
3040
|
|
|
$_508 = NULL; |
|
3041
|
|
|
do { |
|
3042
|
|
|
if (substr($this->string,$this->pos,1) == ';') { |
|
|
|
|
|
|
3043
|
|
|
$this->pos += 1; |
|
3044
|
|
|
$result["text"] .= ';'; |
|
3045
|
|
|
} |
|
3046
|
|
|
else { $_508 = FALSE; break; } |
|
3047
|
|
|
$_508 = TRUE; break; |
|
3048
|
|
|
} |
|
3049
|
|
|
while(0); |
|
3050
|
|
|
if( $_508 === FALSE) { |
|
3051
|
|
|
$result = $res_509; |
|
3052
|
|
|
$this->pos = $pos_509; |
|
3053
|
|
|
unset( $res_509 ); |
|
3054
|
|
|
unset( $pos_509 ); |
|
3055
|
|
|
} |
|
3056
|
|
|
$_510 = TRUE; break; |
|
3057
|
|
|
} |
|
3058
|
|
|
while(0); |
|
3059
|
|
|
if( $_510 === TRUE ) { return $this->finalise($result); } |
|
3060
|
|
|
if( $_510 === FALSE) { return FALSE; } |
|
3061
|
|
|
} |
|
3062
|
|
|
|
|
3063
|
|
|
|
|
3064
|
|
|
/* N: / [\s\n]* / */ |
|
3065
|
|
|
protected $match_N_typestack = array('N'); |
|
3066
|
|
|
function match_N ($stack = array()) { |
|
|
|
|
|
|
3067
|
|
|
$matchrule = "N"; $result = $this->construct($matchrule, $matchrule, null); |
|
3068
|
|
|
if (( $subres = $this->rx( '/ [\s\n]* /' ) ) !== FALSE) { |
|
3069
|
|
|
$result["text"] .= $subres; |
|
3070
|
|
|
return $this->finalise($result); |
|
3071
|
|
|
} |
|
3072
|
|
|
else { return FALSE; } |
|
3073
|
|
|
} |
|
3074
|
|
|
|
|
3075
|
|
|
|
|
3076
|
|
|
|
|
3077
|
|
|
function OldTPart__construct(&$res) { |
|
3078
|
|
|
$res['php'] = "_t("; |
|
3079
|
|
|
} |
|
3080
|
|
|
|
|
3081
|
|
|
function OldTPart_QuotedString(&$res, $sub) { |
|
3082
|
|
|
$entity = $sub['String']['text']; |
|
3083
|
|
|
if (strpos($entity, '.') === false) { |
|
3084
|
|
|
$res['php'] .= "\$scope->XML_val('I18NNamespace').'.$entity'"; |
|
3085
|
|
|
} |
|
3086
|
|
|
else { |
|
3087
|
|
|
$res['php'] .= "'$entity'"; |
|
3088
|
|
|
} |
|
3089
|
|
|
} |
|
3090
|
|
|
|
|
3091
|
|
|
function OldTPart_CallArguments(&$res, $sub) { |
|
3092
|
|
|
$res['php'] .= ',' . $sub['php']; |
|
3093
|
|
|
} |
|
3094
|
|
|
|
|
3095
|
|
|
function OldTPart__finalise(&$res) { |
|
3096
|
|
|
$res['php'] .= ')'; |
|
3097
|
|
|
} |
|
3098
|
|
|
|
|
3099
|
|
|
/* OldTTag: "<%" < OldTPart > "%>" */ |
|
3100
|
|
|
protected $match_OldTTag_typestack = array('OldTTag'); |
|
3101
|
|
|
function match_OldTTag ($stack = array()) { |
|
3102
|
|
|
$matchrule = "OldTTag"; $result = $this->construct($matchrule, $matchrule, null); |
|
3103
|
|
|
$_518 = NULL; |
|
3104
|
|
|
do { |
|
|
|
|
|
|
3105
|
|
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3106
|
|
|
else { $_518 = FALSE; break; } |
|
3107
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3108
|
|
|
$matcher = 'match_'.'OldTPart'; $key = $matcher; $pos = $this->pos; |
|
3109
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3110
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
3111
|
|
|
else { $_518 = FALSE; break; } |
|
3112
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3113
|
|
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3114
|
|
|
else { $_518 = FALSE; break; } |
|
3115
|
|
|
$_518 = TRUE; break; |
|
3116
|
|
|
} |
|
3117
|
|
|
while(0); |
|
3118
|
|
|
if( $_518 === TRUE ) { return $this->finalise($result); } |
|
3119
|
|
|
if( $_518 === FALSE) { return FALSE; } |
|
3120
|
|
|
} |
|
3121
|
|
|
|
|
3122
|
|
|
|
|
3123
|
|
|
|
|
3124
|
|
|
function OldTTag_OldTPart(&$res, $sub) { |
|
3125
|
|
|
$res['php'] = $sub['php']; |
|
3126
|
|
|
} |
|
3127
|
|
|
|
|
3128
|
|
|
/* OldSprintfTag: "<%" < "sprintf" < "(" < OldTPart < "," < CallArguments > ")" > "%>" */ |
|
3129
|
|
|
protected $match_OldSprintfTag_typestack = array('OldSprintfTag'); |
|
3130
|
|
|
function match_OldSprintfTag ($stack = array()) { |
|
3131
|
|
|
$matchrule = "OldSprintfTag"; $result = $this->construct($matchrule, $matchrule, null); |
|
3132
|
|
|
$_535 = NULL; |
|
3133
|
|
|
do { |
|
|
|
|
|
|
3134
|
|
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3135
|
|
|
else { $_535 = FALSE; break; } |
|
3136
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3137
|
|
|
if (( $subres = $this->literal( 'sprintf' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3138
|
|
|
else { $_535 = FALSE; break; } |
|
3139
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3140
|
|
|
if (substr($this->string,$this->pos,1) == '(') { |
|
|
|
|
|
|
3141
|
|
|
$this->pos += 1; |
|
3142
|
|
|
$result["text"] .= '('; |
|
3143
|
|
|
} |
|
3144
|
|
|
else { $_535 = FALSE; break; } |
|
3145
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3146
|
|
|
$matcher = 'match_'.'OldTPart'; $key = $matcher; $pos = $this->pos; |
|
3147
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3148
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
3149
|
|
|
else { $_535 = FALSE; break; } |
|
3150
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3151
|
|
|
if (substr($this->string,$this->pos,1) == ',') { |
|
|
|
|
|
|
3152
|
|
|
$this->pos += 1; |
|
3153
|
|
|
$result["text"] .= ','; |
|
3154
|
|
|
} |
|
3155
|
|
|
else { $_535 = FALSE; break; } |
|
3156
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3157
|
|
|
$matcher = 'match_'.'CallArguments'; $key = $matcher; $pos = $this->pos; |
|
3158
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3159
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
3160
|
|
|
else { $_535 = FALSE; break; } |
|
3161
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3162
|
|
|
if (substr($this->string,$this->pos,1) == ')') { |
|
|
|
|
|
|
3163
|
|
|
$this->pos += 1; |
|
3164
|
|
|
$result["text"] .= ')'; |
|
3165
|
|
|
} |
|
3166
|
|
|
else { $_535 = FALSE; break; } |
|
3167
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3168
|
|
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3169
|
|
|
else { $_535 = FALSE; break; } |
|
3170
|
|
|
$_535 = TRUE; break; |
|
3171
|
|
|
} |
|
3172
|
|
|
while(0); |
|
3173
|
|
|
if( $_535 === TRUE ) { return $this->finalise($result); } |
|
3174
|
|
|
if( $_535 === FALSE) { return FALSE; } |
|
3175
|
|
|
} |
|
3176
|
|
|
|
|
3177
|
|
|
|
|
3178
|
|
|
|
|
3179
|
|
|
function OldSprintfTag__construct(&$res) { |
|
3180
|
|
|
$res['php'] = "sprintf("; |
|
3181
|
|
|
} |
|
3182
|
|
|
|
|
3183
|
|
|
function OldSprintfTag_OldTPart(&$res, $sub) { |
|
3184
|
|
|
$res['php'] .= $sub['php']; |
|
3185
|
|
|
} |
|
3186
|
|
|
|
|
3187
|
|
|
function OldSprintfTag_CallArguments(&$res, $sub) { |
|
3188
|
|
|
$res['php'] .= ',' . $sub['php'] . ')'; |
|
3189
|
|
|
} |
|
3190
|
|
|
|
|
3191
|
|
|
/* OldI18NTag: OldSprintfTag | OldTTag */ |
|
3192
|
|
|
protected $match_OldI18NTag_typestack = array('OldI18NTag'); |
|
3193
|
|
|
function match_OldI18NTag ($stack = array()) { |
|
3194
|
|
|
$matchrule = "OldI18NTag"; $result = $this->construct($matchrule, $matchrule, null); |
|
3195
|
|
|
$_540 = NULL; |
|
3196
|
|
|
do { |
|
|
|
|
|
|
3197
|
|
|
$res_537 = $result; |
|
3198
|
|
|
$pos_537 = $this->pos; |
|
3199
|
|
|
$matcher = 'match_'.'OldSprintfTag'; $key = $matcher; $pos = $this->pos; |
|
3200
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3201
|
|
|
if ($subres !== FALSE) { |
|
3202
|
|
|
$this->store( $result, $subres ); |
|
3203
|
|
|
$_540 = TRUE; break; |
|
3204
|
|
|
} |
|
3205
|
|
|
$result = $res_537; |
|
3206
|
|
|
$this->pos = $pos_537; |
|
3207
|
|
|
$matcher = 'match_'.'OldTTag'; $key = $matcher; $pos = $this->pos; |
|
3208
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3209
|
|
|
if ($subres !== FALSE) { |
|
3210
|
|
|
$this->store( $result, $subres ); |
|
3211
|
|
|
$_540 = TRUE; break; |
|
3212
|
|
|
} |
|
3213
|
|
|
$result = $res_537; |
|
3214
|
|
|
$this->pos = $pos_537; |
|
3215
|
|
|
$_540 = FALSE; break; |
|
3216
|
|
|
} |
|
3217
|
|
|
while(0); |
|
3218
|
|
|
if( $_540 === TRUE ) { return $this->finalise($result); } |
|
3219
|
|
|
if( $_540 === FALSE) { return FALSE; } |
|
3220
|
|
|
} |
|
3221
|
|
|
|
|
3222
|
|
|
|
|
3223
|
|
|
|
|
3224
|
|
|
function OldI18NTag_STR(&$res, $sub) { |
|
3225
|
|
|
$res['php'] = '$val .= ' . $sub['php'] . ';'; |
|
3226
|
|
|
} |
|
3227
|
|
|
|
|
3228
|
|
|
/* NamedArgument: Name:Word "=" Value:Argument */ |
|
3229
|
|
|
protected $match_NamedArgument_typestack = array('NamedArgument'); |
|
3230
|
|
|
function match_NamedArgument ($stack = array()) { |
|
3231
|
|
|
$matchrule = "NamedArgument"; $result = $this->construct($matchrule, $matchrule, null); |
|
3232
|
|
|
$_545 = NULL; |
|
3233
|
|
|
do { |
|
|
|
|
|
|
3234
|
|
|
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
|
3235
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3236
|
|
|
if ($subres !== FALSE) { |
|
3237
|
|
|
$this->store( $result, $subres, "Name" ); |
|
3238
|
|
|
} |
|
3239
|
|
|
else { $_545 = FALSE; break; } |
|
3240
|
|
|
if (substr($this->string,$this->pos,1) == '=') { |
|
|
|
|
|
|
3241
|
|
|
$this->pos += 1; |
|
3242
|
|
|
$result["text"] .= '='; |
|
3243
|
|
|
} |
|
3244
|
|
|
else { $_545 = FALSE; break; } |
|
3245
|
|
|
$matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
|
3246
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3247
|
|
|
if ($subres !== FALSE) { |
|
3248
|
|
|
$this->store( $result, $subres, "Value" ); |
|
3249
|
|
|
} |
|
3250
|
|
|
else { $_545 = FALSE; break; } |
|
3251
|
|
|
$_545 = TRUE; break; |
|
3252
|
|
|
} |
|
3253
|
|
|
while(0); |
|
3254
|
|
|
if( $_545 === TRUE ) { return $this->finalise($result); } |
|
3255
|
|
|
if( $_545 === FALSE) { return FALSE; } |
|
3256
|
|
|
} |
|
3257
|
|
|
|
|
3258
|
|
|
|
|
3259
|
|
|
|
|
3260
|
|
|
function NamedArgument_Name(&$res, $sub) { |
|
3261
|
|
|
$res['php'] = "'" . $sub['text'] . "' => "; |
|
3262
|
|
|
} |
|
3263
|
|
|
|
|
3264
|
|
|
function NamedArgument_Value(&$res, $sub) { |
|
3265
|
|
|
switch($sub['ArgumentMode']) { |
|
3266
|
|
|
case 'string': |
|
3267
|
|
|
$res['php'] .= $sub['php']; |
|
3268
|
|
|
break; |
|
3269
|
|
|
|
|
3270
|
|
|
case 'default': |
|
3271
|
|
|
$res['php'] .= $sub['string_php']; |
|
3272
|
|
|
break; |
|
3273
|
|
|
|
|
3274
|
|
|
default: |
|
3275
|
|
|
$res['php'] .= str_replace('$$FINAL', 'obj', $sub['php']) . '->self()'; |
|
3276
|
|
|
break; |
|
3277
|
|
|
} |
|
3278
|
|
|
} |
|
3279
|
|
|
|
|
3280
|
|
|
/* Include: "<%" < "include" < Template:Word < (NamedArgument ( < "," < NamedArgument )*)? > "%>" */ |
|
3281
|
|
|
protected $match_Include_typestack = array('Include'); |
|
3282
|
|
|
function match_Include ($stack = array()) { |
|
3283
|
|
|
$matchrule = "Include"; $result = $this->construct($matchrule, $matchrule, null); |
|
3284
|
|
|
$_564 = NULL; |
|
3285
|
|
|
do { |
|
|
|
|
|
|
3286
|
|
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3287
|
|
|
else { $_564 = FALSE; break; } |
|
3288
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3289
|
|
|
if (( $subres = $this->literal( 'include' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3290
|
|
|
else { $_564 = FALSE; break; } |
|
3291
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3292
|
|
|
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
|
3293
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3294
|
|
|
if ($subres !== FALSE) { |
|
3295
|
|
|
$this->store( $result, $subres, "Template" ); |
|
3296
|
|
|
} |
|
3297
|
|
|
else { $_564 = FALSE; break; } |
|
3298
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3299
|
|
|
$res_561 = $result; |
|
3300
|
|
|
$pos_561 = $this->pos; |
|
3301
|
|
|
$_560 = NULL; |
|
3302
|
|
|
do { |
|
3303
|
|
|
$matcher = 'match_'.'NamedArgument'; $key = $matcher; $pos = $this->pos; |
|
3304
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3305
|
|
|
if ($subres !== FALSE) { $this->store( $result, $subres ); } |
|
3306
|
|
|
else { $_560 = FALSE; break; } |
|
3307
|
|
|
while (true) { |
|
3308
|
|
|
$res_559 = $result; |
|
3309
|
|
|
$pos_559 = $this->pos; |
|
3310
|
|
|
$_558 = NULL; |
|
3311
|
|
|
do { |
|
3312
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3313
|
|
|
if (substr($this->string,$this->pos,1) == ',') { |
|
|
|
|
|
|
3314
|
|
|
$this->pos += 1; |
|
3315
|
|
|
$result["text"] .= ','; |
|
3316
|
|
|
} |
|
3317
|
|
|
else { $_558 = FALSE; break; } |
|
3318
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3319
|
|
|
$matcher = 'match_'.'NamedArgument'; $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
|
|
|
} |
|
3324
|
|
|
else { $_558 = FALSE; break; } |
|
3325
|
|
|
$_558 = TRUE; break; |
|
3326
|
|
|
} |
|
3327
|
|
|
while(0); |
|
3328
|
|
|
if( $_558 === FALSE) { |
|
3329
|
|
|
$result = $res_559; |
|
3330
|
|
|
$this->pos = $pos_559; |
|
3331
|
|
|
unset( $res_559 ); |
|
3332
|
|
|
unset( $pos_559 ); |
|
3333
|
|
|
break; |
|
3334
|
|
|
} |
|
3335
|
|
|
} |
|
3336
|
|
|
$_560 = TRUE; break; |
|
3337
|
|
|
} |
|
3338
|
|
|
while(0); |
|
3339
|
|
|
if( $_560 === FALSE) { |
|
3340
|
|
|
$result = $res_561; |
|
3341
|
|
|
$this->pos = $pos_561; |
|
3342
|
|
|
unset( $res_561 ); |
|
3343
|
|
|
unset( $pos_561 ); |
|
3344
|
|
|
} |
|
3345
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3346
|
|
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3347
|
|
|
else { $_564 = FALSE; break; } |
|
3348
|
|
|
$_564 = TRUE; break; |
|
3349
|
|
|
} |
|
3350
|
|
|
while(0); |
|
3351
|
|
|
if( $_564 === TRUE ) { return $this->finalise($result); } |
|
3352
|
|
|
if( $_564 === FALSE) { return FALSE; } |
|
3353
|
|
|
} |
|
3354
|
|
|
|
|
3355
|
|
|
|
|
3356
|
|
|
|
|
3357
|
|
|
function Include__construct(&$res){ |
|
3358
|
|
|
$res['arguments'] = array(); |
|
3359
|
|
|
} |
|
3360
|
|
|
|
|
3361
|
|
|
function Include_Template(&$res, $sub){ |
|
3362
|
|
|
$res['template'] = "'" . $sub['text'] . "'"; |
|
3363
|
|
|
} |
|
3364
|
|
|
|
|
3365
|
|
|
function Include_NamedArgument(&$res, $sub){ |
|
3366
|
|
|
$res['arguments'][] = $sub['php']; |
|
3367
|
|
|
} |
|
3368
|
|
|
|
|
3369
|
|
|
function Include__finalise(&$res){ |
|
3370
|
|
|
$template = $res['template']; |
|
3371
|
|
|
$arguments = $res['arguments']; |
|
3372
|
|
|
|
|
3373
|
|
|
$res['php'] = '$val .= SSViewer::execute_template('.$template.', $scope->getItem(), array(' . |
|
3374
|
|
|
implode(',', $arguments)."), \$scope);\n"; |
|
3375
|
|
|
|
|
3376
|
|
|
if($this->includeDebuggingComments) { // Add include filename comments on dev sites |
|
3377
|
|
|
$res['php'] = |
|
3378
|
|
|
'$val .= \'<!-- include '.addslashes($template).' -->\';'. "\n". |
|
3379
|
|
|
$res['php']. |
|
3380
|
|
|
'$val .= \'<!-- end include '.addslashes($template).' -->\';'. "\n"; |
|
3381
|
|
|
} |
|
3382
|
|
|
} |
|
3383
|
|
|
|
|
3384
|
|
|
/* BlockArguments: :Argument ( < "," < :Argument)* */ |
|
3385
|
|
|
protected $match_BlockArguments_typestack = array('BlockArguments'); |
|
3386
|
|
|
function match_BlockArguments ($stack = array()) { |
|
3387
|
|
|
$matchrule = "BlockArguments"; $result = $this->construct($matchrule, $matchrule, null); |
|
3388
|
|
|
$_573 = NULL; |
|
3389
|
|
|
do { |
|
|
|
|
|
|
3390
|
|
|
$matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
|
3391
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3392
|
|
|
if ($subres !== FALSE) { |
|
3393
|
|
|
$this->store( $result, $subres, "Argument" ); |
|
3394
|
|
|
} |
|
3395
|
|
|
else { $_573 = FALSE; break; } |
|
3396
|
|
|
while (true) { |
|
3397
|
|
|
$res_572 = $result; |
|
3398
|
|
|
$pos_572 = $this->pos; |
|
3399
|
|
|
$_571 = NULL; |
|
3400
|
|
|
do { |
|
3401
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3402
|
|
|
if (substr($this->string,$this->pos,1) == ',') { |
|
|
|
|
|
|
3403
|
|
|
$this->pos += 1; |
|
3404
|
|
|
$result["text"] .= ','; |
|
3405
|
|
|
} |
|
3406
|
|
|
else { $_571 = FALSE; break; } |
|
3407
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3408
|
|
|
$matcher = 'match_'.'Argument'; $key = $matcher; $pos = $this->pos; |
|
3409
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3410
|
|
|
if ($subres !== FALSE) { |
|
3411
|
|
|
$this->store( $result, $subres, "Argument" ); |
|
3412
|
|
|
} |
|
3413
|
|
|
else { $_571 = FALSE; break; } |
|
3414
|
|
|
$_571 = TRUE; break; |
|
3415
|
|
|
} |
|
3416
|
|
|
while(0); |
|
3417
|
|
|
if( $_571 === FALSE) { |
|
3418
|
|
|
$result = $res_572; |
|
3419
|
|
|
$this->pos = $pos_572; |
|
3420
|
|
|
unset( $res_572 ); |
|
3421
|
|
|
unset( $pos_572 ); |
|
3422
|
|
|
break; |
|
3423
|
|
|
} |
|
3424
|
|
|
} |
|
3425
|
|
|
$_573 = TRUE; break; |
|
3426
|
|
|
} |
|
3427
|
|
|
while(0); |
|
3428
|
|
|
if( $_573 === TRUE ) { return $this->finalise($result); } |
|
3429
|
|
|
if( $_573 === FALSE) { return FALSE; } |
|
3430
|
|
|
} |
|
3431
|
|
|
|
|
3432
|
|
|
|
|
3433
|
|
|
/* NotBlockTag: "end_" | (("if" | "else_if" | "else" | "require" | "cached" | "uncached" | "cacheblock" | "include")]) */ |
|
|
|
|
|
|
3434
|
|
|
protected $match_NotBlockTag_typestack = array('NotBlockTag'); |
|
3435
|
|
|
function match_NotBlockTag ($stack = array()) { |
|
|
|
|
|
|
3436
|
|
|
$matchrule = "NotBlockTag"; $result = $this->construct($matchrule, $matchrule, null); |
|
3437
|
|
|
$_611 = NULL; |
|
3438
|
|
|
do { |
|
|
|
|
|
|
3439
|
|
|
$res_575 = $result; |
|
3440
|
|
|
$pos_575 = $this->pos; |
|
3441
|
|
|
if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { |
|
3442
|
|
|
$result["text"] .= $subres; |
|
3443
|
|
|
$_611 = TRUE; break; |
|
3444
|
|
|
} |
|
3445
|
|
|
$result = $res_575; |
|
3446
|
|
|
$this->pos = $pos_575; |
|
3447
|
|
|
$_609 = NULL; |
|
3448
|
|
|
do { |
|
3449
|
|
|
$_606 = NULL; |
|
3450
|
|
|
do { |
|
3451
|
|
|
$_604 = NULL; |
|
3452
|
|
|
do { |
|
3453
|
|
|
$res_577 = $result; |
|
3454
|
|
|
$pos_577 = $this->pos; |
|
3455
|
|
|
if (( $subres = $this->literal( 'if' ) ) !== FALSE) { |
|
3456
|
|
|
$result["text"] .= $subres; |
|
3457
|
|
|
$_604 = TRUE; break; |
|
3458
|
|
|
} |
|
3459
|
|
|
$result = $res_577; |
|
3460
|
|
|
$this->pos = $pos_577; |
|
3461
|
|
|
$_602 = NULL; |
|
3462
|
|
|
do { |
|
3463
|
|
|
$res_579 = $result; |
|
3464
|
|
|
$pos_579 = $this->pos; |
|
3465
|
|
|
if (( $subres = $this->literal( 'else_if' ) ) !== FALSE) { |
|
3466
|
|
|
$result["text"] .= $subres; |
|
3467
|
|
|
$_602 = TRUE; break; |
|
3468
|
|
|
} |
|
3469
|
|
|
$result = $res_579; |
|
3470
|
|
|
$this->pos = $pos_579; |
|
3471
|
|
|
$_600 = NULL; |
|
3472
|
|
|
do { |
|
3473
|
|
|
$res_581 = $result; |
|
3474
|
|
|
$pos_581 = $this->pos; |
|
3475
|
|
|
if (( $subres = $this->literal( 'else' ) ) !== FALSE) { |
|
3476
|
|
|
$result["text"] .= $subres; |
|
3477
|
|
|
$_600 = TRUE; break; |
|
3478
|
|
|
} |
|
3479
|
|
|
$result = $res_581; |
|
3480
|
|
|
$this->pos = $pos_581; |
|
3481
|
|
|
$_598 = NULL; |
|
3482
|
|
|
do { |
|
3483
|
|
|
$res_583 = $result; |
|
3484
|
|
|
$pos_583 = $this->pos; |
|
3485
|
|
|
if (( $subres = $this->literal( 'require' ) ) !== FALSE) { |
|
3486
|
|
|
$result["text"] .= $subres; |
|
3487
|
|
|
$_598 = TRUE; break; |
|
3488
|
|
|
} |
|
3489
|
|
|
$result = $res_583; |
|
3490
|
|
|
$this->pos = $pos_583; |
|
3491
|
|
|
$_596 = NULL; |
|
3492
|
|
|
do { |
|
3493
|
|
|
$res_585 = $result; |
|
3494
|
|
|
$pos_585 = $this->pos; |
|
3495
|
|
|
if (( $subres = $this->literal( 'cached' ) ) !== FALSE) { |
|
3496
|
|
|
$result["text"] .= $subres; |
|
3497
|
|
|
$_596 = TRUE; break; |
|
3498
|
|
|
} |
|
3499
|
|
|
$result = $res_585; |
|
3500
|
|
|
$this->pos = $pos_585; |
|
3501
|
|
|
$_594 = NULL; |
|
3502
|
|
|
do { |
|
3503
|
|
|
$res_587 = $result; |
|
3504
|
|
|
$pos_587 = $this->pos; |
|
3505
|
|
|
if (( $subres = $this->literal( 'uncached' ) ) !== FALSE) { |
|
3506
|
|
|
$result["text"] .= $subres; |
|
3507
|
|
|
$_594 = TRUE; break; |
|
3508
|
|
|
} |
|
3509
|
|
|
$result = $res_587; |
|
3510
|
|
|
$this->pos = $pos_587; |
|
3511
|
|
|
$_592 = NULL; |
|
3512
|
|
|
do { |
|
3513
|
|
|
$res_589 = $result; |
|
3514
|
|
|
$pos_589 = $this->pos; |
|
3515
|
|
|
if (( $subres = $this->literal( 'cacheblock' ) ) !== FALSE) { |
|
3516
|
|
|
$result["text"] .= $subres; |
|
3517
|
|
|
$_592 = TRUE; break; |
|
3518
|
|
|
} |
|
3519
|
|
|
$result = $res_589; |
|
3520
|
|
|
$this->pos = $pos_589; |
|
3521
|
|
|
if (( $subres = $this->literal( 'include' ) ) !== FALSE) { |
|
3522
|
|
|
$result["text"] .= $subres; |
|
3523
|
|
|
$_592 = TRUE; break; |
|
3524
|
|
|
} |
|
3525
|
|
|
$result = $res_589; |
|
3526
|
|
|
$this->pos = $pos_589; |
|
3527
|
|
|
$_592 = FALSE; break; |
|
3528
|
|
|
} |
|
3529
|
|
|
while(0); |
|
3530
|
|
|
if( $_592 === TRUE ) { $_594 = TRUE; break; } |
|
3531
|
|
|
$result = $res_587; |
|
3532
|
|
|
$this->pos = $pos_587; |
|
3533
|
|
|
$_594 = FALSE; break; |
|
3534
|
|
|
} |
|
3535
|
|
|
while(0); |
|
3536
|
|
|
if( $_594 === TRUE ) { $_596 = TRUE; break; } |
|
3537
|
|
|
$result = $res_585; |
|
3538
|
|
|
$this->pos = $pos_585; |
|
3539
|
|
|
$_596 = FALSE; break; |
|
3540
|
|
|
} |
|
3541
|
|
|
while(0); |
|
3542
|
|
|
if( $_596 === TRUE ) { $_598 = TRUE; break; } |
|
3543
|
|
|
$result = $res_583; |
|
3544
|
|
|
$this->pos = $pos_583; |
|
3545
|
|
|
$_598 = FALSE; break; |
|
3546
|
|
|
} |
|
3547
|
|
|
while(0); |
|
3548
|
|
|
if( $_598 === TRUE ) { $_600 = TRUE; break; } |
|
3549
|
|
|
$result = $res_581; |
|
3550
|
|
|
$this->pos = $pos_581; |
|
3551
|
|
|
$_600 = FALSE; break; |
|
3552
|
|
|
} |
|
3553
|
|
|
while(0); |
|
3554
|
|
|
if( $_600 === TRUE ) { $_602 = TRUE; break; } |
|
3555
|
|
|
$result = $res_579; |
|
3556
|
|
|
$this->pos = $pos_579; |
|
3557
|
|
|
$_602 = FALSE; break; |
|
3558
|
|
|
} |
|
3559
|
|
|
while(0); |
|
3560
|
|
|
if( $_602 === TRUE ) { $_604 = TRUE; break; } |
|
3561
|
|
|
$result = $res_577; |
|
3562
|
|
|
$this->pos = $pos_577; |
|
3563
|
|
|
$_604 = FALSE; break; |
|
3564
|
|
|
} |
|
3565
|
|
|
while(0); |
|
3566
|
|
|
if( $_604 === FALSE) { $_606 = FALSE; break; } |
|
3567
|
|
|
$_606 = TRUE; break; |
|
3568
|
|
|
} |
|
3569
|
|
|
while(0); |
|
3570
|
|
|
if( $_606 === FALSE) { $_609 = FALSE; break; } |
|
3571
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3572
|
|
|
else { $_609 = FALSE; break; } |
|
3573
|
|
|
$_609 = TRUE; break; |
|
3574
|
|
|
} |
|
3575
|
|
|
while(0); |
|
3576
|
|
|
if( $_609 === TRUE ) { $_611 = TRUE; break; } |
|
3577
|
|
|
$result = $res_575; |
|
3578
|
|
|
$this->pos = $pos_575; |
|
3579
|
|
|
$_611 = FALSE; break; |
|
3580
|
|
|
} |
|
3581
|
|
|
while(0); |
|
3582
|
|
|
if( $_611 === TRUE ) { return $this->finalise($result); } |
|
3583
|
|
|
if( $_611 === FALSE) { return FALSE; } |
|
3584
|
|
|
} |
|
3585
|
|
|
|
|
3586
|
|
|
|
|
3587
|
|
|
/* ClosedBlock: '<%' < !NotBlockTag BlockName:Word ( [ :BlockArguments ] )? > Zap:'%>' Template:$TemplateMatcher? |
|
|
|
|
|
|
3588
|
|
|
'<%' < 'end_' '$BlockName' > '%>' */ |
|
3589
|
|
|
protected $match_ClosedBlock_typestack = array('ClosedBlock'); |
|
3590
|
|
|
function match_ClosedBlock ($stack = array()) { |
|
3591
|
|
|
$matchrule = "ClosedBlock"; $result = $this->construct($matchrule, $matchrule, null); |
|
3592
|
|
|
$_631 = NULL; |
|
3593
|
|
|
do { |
|
|
|
|
|
|
3594
|
|
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3595
|
|
|
else { $_631 = FALSE; break; } |
|
3596
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3597
|
|
|
$res_615 = $result; |
|
3598
|
|
|
$pos_615 = $this->pos; |
|
3599
|
|
|
$matcher = 'match_'.'NotBlockTag'; $key = $matcher; $pos = $this->pos; |
|
3600
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3601
|
|
|
if ($subres !== FALSE) { |
|
3602
|
|
|
$this->store( $result, $subres ); |
|
3603
|
|
|
$result = $res_615; |
|
3604
|
|
|
$this->pos = $pos_615; |
|
3605
|
|
|
$_631 = FALSE; break; |
|
3606
|
|
|
} |
|
3607
|
|
|
else { |
|
3608
|
|
|
$result = $res_615; |
|
3609
|
|
|
$this->pos = $pos_615; |
|
3610
|
|
|
} |
|
3611
|
|
|
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
|
3612
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3613
|
|
|
if ($subres !== FALSE) { |
|
3614
|
|
|
$this->store( $result, $subres, "BlockName" ); |
|
3615
|
|
|
} |
|
3616
|
|
|
else { $_631 = FALSE; break; } |
|
3617
|
|
|
$res_621 = $result; |
|
3618
|
|
|
$pos_621 = $this->pos; |
|
3619
|
|
|
$_620 = NULL; |
|
3620
|
|
|
do { |
|
3621
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3622
|
|
|
else { $_620 = FALSE; break; } |
|
3623
|
|
|
$matcher = 'match_'.'BlockArguments'; $key = $matcher; $pos = $this->pos; |
|
3624
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3625
|
|
|
if ($subres !== FALSE) { |
|
3626
|
|
|
$this->store( $result, $subres, "BlockArguments" ); |
|
3627
|
|
|
} |
|
3628
|
|
|
else { $_620 = FALSE; break; } |
|
3629
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3630
|
|
|
else { $_620 = FALSE; break; } |
|
3631
|
|
|
$_620 = TRUE; break; |
|
3632
|
|
|
} |
|
3633
|
|
|
while(0); |
|
3634
|
|
|
if( $_620 === FALSE) { |
|
3635
|
|
|
$result = $res_621; |
|
3636
|
|
|
$this->pos = $pos_621; |
|
3637
|
|
|
unset( $res_621 ); |
|
3638
|
|
|
unset( $pos_621 ); |
|
3639
|
|
|
} |
|
3640
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3641
|
|
|
$stack[] = $result; $result = $this->construct( $matchrule, "Zap" ); |
|
3642
|
|
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { |
|
3643
|
|
|
$result["text"] .= $subres; |
|
3644
|
|
|
$subres = $result; $result = array_pop($stack); |
|
3645
|
|
|
$this->store( $result, $subres, 'Zap' ); |
|
3646
|
|
|
} |
|
3647
|
|
|
else { |
|
3648
|
|
|
$result = array_pop($stack); |
|
3649
|
|
|
$_631 = FALSE; break; |
|
3650
|
|
|
} |
|
3651
|
|
|
$res_624 = $result; |
|
3652
|
|
|
$pos_624 = $this->pos; |
|
3653
|
|
|
$matcher = 'match_'.$this->expression($result, $stack, 'TemplateMatcher'); $key = $matcher; $pos = $this->pos; |
|
3654
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3655
|
|
|
if ($subres !== FALSE) { |
|
3656
|
|
|
$this->store( $result, $subres, "Template" ); |
|
3657
|
|
|
} |
|
3658
|
|
|
else { |
|
3659
|
|
|
$result = $res_624; |
|
3660
|
|
|
$this->pos = $pos_624; |
|
3661
|
|
|
unset( $res_624 ); |
|
3662
|
|
|
unset( $pos_624 ); |
|
3663
|
|
|
} |
|
3664
|
|
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3665
|
|
|
else { $_631 = FALSE; break; } |
|
3666
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3667
|
|
|
if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3668
|
|
|
else { $_631 = FALSE; break; } |
|
3669
|
|
|
if (( $subres = $this->literal( ''.$this->expression($result, $stack, 'BlockName').'' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3670
|
|
|
else { $_631 = FALSE; break; } |
|
3671
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3672
|
|
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3673
|
|
|
else { $_631 = FALSE; break; } |
|
3674
|
|
|
$_631 = TRUE; break; |
|
3675
|
|
|
} |
|
3676
|
|
|
while(0); |
|
3677
|
|
|
if( $_631 === TRUE ) { return $this->finalise($result); } |
|
3678
|
|
|
if( $_631 === FALSE) { return FALSE; } |
|
3679
|
|
|
} |
|
3680
|
|
|
|
|
3681
|
|
|
|
|
3682
|
|
|
|
|
3683
|
|
|
|
|
3684
|
|
|
/** |
|
3685
|
|
|
* As mentioned in the parser comment, block handling is kept fairly generic for extensibility. The match rule |
|
3686
|
|
|
* builds up two important elements in the match result array: |
|
3687
|
|
|
* 'ArgumentCount' - how many arguments were passed in the opening tag |
|
3688
|
|
|
* 'Arguments' an array of the Argument match rule result arrays |
|
3689
|
|
|
* |
|
3690
|
|
|
* Once a block has successfully been matched against, it will then look for the actual handler, which should |
|
3691
|
|
|
* be on this class (either defined or extended on) as ClosedBlock_Handler_Name(&$res), where Name is the |
|
3692
|
|
|
* tag name, first letter captialized (i.e Control, Loop, With, etc). |
|
3693
|
|
|
* |
|
3694
|
|
|
* This function will be called with the match rule result array as it's first argument. It should return |
|
3695
|
|
|
* the php result of this block as it's return value, or throw an error if incorrect arguments were passed. |
|
3696
|
|
|
*/ |
|
3697
|
|
|
|
|
3698
|
|
|
function ClosedBlock__construct(&$res) { |
|
3699
|
|
|
$res['ArgumentCount'] = 0; |
|
3700
|
|
|
} |
|
3701
|
|
|
|
|
3702
|
|
|
function ClosedBlock_BlockArguments(&$res, $sub) { |
|
3703
|
|
|
if (isset($sub['Argument']['ArgumentMode'])) { |
|
3704
|
|
|
$res['Arguments'] = array($sub['Argument']); |
|
3705
|
|
|
$res['ArgumentCount'] = 1; |
|
3706
|
|
|
} |
|
3707
|
|
|
else { |
|
3708
|
|
|
$res['Arguments'] = $sub['Argument']; |
|
3709
|
|
|
$res['ArgumentCount'] = count($res['Arguments']); |
|
3710
|
|
|
} |
|
3711
|
|
|
} |
|
3712
|
|
|
|
|
3713
|
|
|
function ClosedBlock__finalise(&$res) { |
|
3714
|
|
|
$blockname = $res['BlockName']['text']; |
|
3715
|
|
|
|
|
3716
|
|
|
$method = 'ClosedBlock_Handle_'.$blockname; |
|
3717
|
|
|
if (method_exists($this, $method)) { |
|
3718
|
|
|
$res['php'] = $this->$method($res); |
|
3719
|
|
|
} else if (isset($this->closedBlocks[$blockname])) { |
|
3720
|
|
|
$res['php'] = call_user_func($this->closedBlocks[$blockname], $res); |
|
3721
|
|
|
} else { |
|
3722
|
|
|
throw new SSTemplateParseException('Unknown closed block "'.$blockname.'" encountered. Perhaps you are ' . |
|
3723
|
|
|
'not supposed to close this block, or have mis-spelled it?', $this); |
|
3724
|
|
|
} |
|
3725
|
|
|
} |
|
3726
|
|
|
|
|
3727
|
|
|
/** |
|
3728
|
|
|
* This is an example of a block handler function. This one handles the loop tag. |
|
3729
|
|
|
*/ |
|
3730
|
|
|
function ClosedBlock_Handle_Loop(&$res) { |
|
3731
|
|
|
if ($res['ArgumentCount'] > 1) { |
|
3732
|
|
|
throw new SSTemplateParseException('Either no or too many arguments in control block. Must be one ' . |
|
3733
|
|
|
'argument only.', $this); |
|
3734
|
|
|
} |
|
3735
|
|
|
|
|
3736
|
|
|
//loop without arguments loops on the current scope |
|
3737
|
|
|
if ($res['ArgumentCount'] == 0) { |
|
3738
|
|
|
$on = '$scope->obj(\'Up\', null, true)->obj(\'Foo\', null, true)'; |
|
3739
|
|
|
} else { //loop in the normal way |
|
3740
|
|
|
$arg = $res['Arguments'][0]; |
|
3741
|
|
|
if ($arg['ArgumentMode'] == 'string') { |
|
3742
|
|
|
throw new SSTemplateParseException('Control block cant take string as argument.', $this); |
|
3743
|
|
|
} |
|
3744
|
|
|
$on = str_replace('$$FINAL', 'obj', |
|
3745
|
|
|
($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']); |
|
3746
|
|
|
} |
|
3747
|
|
|
|
|
3748
|
|
|
return |
|
3749
|
|
|
$on . '; $scope->pushScope(); while (($key = $scope->next()) !== false) {' . PHP_EOL . |
|
3750
|
|
|
$res['Template']['php'] . PHP_EOL . |
|
3751
|
|
|
'}; $scope->popScope(); '; |
|
3752
|
|
|
} |
|
3753
|
|
|
|
|
3754
|
|
|
/** |
|
3755
|
|
|
* The deprecated closed block handler for control blocks |
|
3756
|
|
|
* @deprecated |
|
3757
|
|
|
*/ |
|
3758
|
|
|
function ClosedBlock_Handle_Control(&$res) { |
|
3759
|
|
|
Deprecation::notice('4.0', '<% control %> is deprecated. Use <% with %> or <% loop %> instead.'); |
|
3760
|
|
|
return $this->ClosedBlock_Handle_Loop($res); |
|
3761
|
|
|
} |
|
3762
|
|
|
|
|
3763
|
|
|
/** |
|
3764
|
|
|
* The closed block handler for with blocks |
|
3765
|
|
|
*/ |
|
3766
|
|
|
function ClosedBlock_Handle_With(&$res) { |
|
3767
|
|
|
if ($res['ArgumentCount'] != 1) { |
|
3768
|
|
|
throw new SSTemplateParseException('Either no or too many arguments in with block. Must be one ' . |
|
3769
|
|
|
'argument only.', $this); |
|
3770
|
|
|
} |
|
3771
|
|
|
|
|
3772
|
|
|
$arg = $res['Arguments'][0]; |
|
3773
|
|
|
if ($arg['ArgumentMode'] == 'string') { |
|
3774
|
|
|
throw new SSTemplateParseException('Control block cant take string as argument.', $this); |
|
3775
|
|
|
} |
|
3776
|
|
|
|
|
3777
|
|
|
$on = str_replace('$$FINAL', 'obj', ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']); |
|
3778
|
|
|
return |
|
3779
|
|
|
$on . '; $scope->pushScope();' . PHP_EOL . |
|
3780
|
|
|
$res['Template']['php'] . PHP_EOL . |
|
3781
|
|
|
'; $scope->popScope(); '; |
|
3782
|
|
|
} |
|
3783
|
|
|
|
|
3784
|
|
|
/* OpenBlock: '<%' < !NotBlockTag BlockName:Word ( [ :BlockArguments ] )? > '%>' */ |
|
3785
|
|
|
protected $match_OpenBlock_typestack = array('OpenBlock'); |
|
3786
|
|
|
function match_OpenBlock ($stack = array()) { |
|
3787
|
|
|
$matchrule = "OpenBlock"; $result = $this->construct($matchrule, $matchrule, null); |
|
3788
|
|
|
$_644 = NULL; |
|
3789
|
|
|
do { |
|
|
|
|
|
|
3790
|
|
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3791
|
|
|
else { $_644 = FALSE; break; } |
|
3792
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3793
|
|
|
$res_635 = $result; |
|
3794
|
|
|
$pos_635 = $this->pos; |
|
3795
|
|
|
$matcher = 'match_'.'NotBlockTag'; $key = $matcher; $pos = $this->pos; |
|
3796
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3797
|
|
|
if ($subres !== FALSE) { |
|
3798
|
|
|
$this->store( $result, $subres ); |
|
3799
|
|
|
$result = $res_635; |
|
3800
|
|
|
$this->pos = $pos_635; |
|
3801
|
|
|
$_644 = FALSE; break; |
|
3802
|
|
|
} |
|
3803
|
|
|
else { |
|
3804
|
|
|
$result = $res_635; |
|
3805
|
|
|
$this->pos = $pos_635; |
|
3806
|
|
|
} |
|
3807
|
|
|
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
|
3808
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3809
|
|
|
if ($subres !== FALSE) { |
|
3810
|
|
|
$this->store( $result, $subres, "BlockName" ); |
|
3811
|
|
|
} |
|
3812
|
|
|
else { $_644 = FALSE; break; } |
|
3813
|
|
|
$res_641 = $result; |
|
3814
|
|
|
$pos_641 = $this->pos; |
|
3815
|
|
|
$_640 = NULL; |
|
3816
|
|
|
do { |
|
3817
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3818
|
|
|
else { $_640 = FALSE; break; } |
|
3819
|
|
|
$matcher = 'match_'.'BlockArguments'; $key = $matcher; $pos = $this->pos; |
|
3820
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3821
|
|
|
if ($subres !== FALSE) { |
|
3822
|
|
|
$this->store( $result, $subres, "BlockArguments" ); |
|
3823
|
|
|
} |
|
3824
|
|
|
else { $_640 = FALSE; break; } |
|
3825
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3826
|
|
|
else { $_640 = FALSE; break; } |
|
3827
|
|
|
$_640 = TRUE; break; |
|
3828
|
|
|
} |
|
3829
|
|
|
while(0); |
|
3830
|
|
|
if( $_640 === FALSE) { |
|
3831
|
|
|
$result = $res_641; |
|
3832
|
|
|
$this->pos = $pos_641; |
|
3833
|
|
|
unset( $res_641 ); |
|
3834
|
|
|
unset( $pos_641 ); |
|
3835
|
|
|
} |
|
3836
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3837
|
|
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3838
|
|
|
else { $_644 = FALSE; break; } |
|
3839
|
|
|
$_644 = TRUE; break; |
|
3840
|
|
|
} |
|
3841
|
|
|
while(0); |
|
3842
|
|
|
if( $_644 === TRUE ) { return $this->finalise($result); } |
|
3843
|
|
|
if( $_644 === FALSE) { return FALSE; } |
|
3844
|
|
|
} |
|
3845
|
|
|
|
|
3846
|
|
|
|
|
3847
|
|
|
|
|
3848
|
|
|
function OpenBlock__construct(&$res) { |
|
3849
|
|
|
$res['ArgumentCount'] = 0; |
|
3850
|
|
|
} |
|
3851
|
|
|
|
|
3852
|
|
|
function OpenBlock_BlockArguments(&$res, $sub) { |
|
3853
|
|
|
if (isset($sub['Argument']['ArgumentMode'])) { |
|
3854
|
|
|
$res['Arguments'] = array($sub['Argument']); |
|
3855
|
|
|
$res['ArgumentCount'] = 1; |
|
3856
|
|
|
} |
|
3857
|
|
|
else { |
|
3858
|
|
|
$res['Arguments'] = $sub['Argument']; |
|
3859
|
|
|
$res['ArgumentCount'] = count($res['Arguments']); |
|
3860
|
|
|
} |
|
3861
|
|
|
} |
|
3862
|
|
|
|
|
3863
|
|
|
function OpenBlock__finalise(&$res) { |
|
3864
|
|
|
$blockname = $res['BlockName']['text']; |
|
3865
|
|
|
|
|
3866
|
|
|
$method = 'OpenBlock_Handle_'.$blockname; |
|
3867
|
|
|
if (method_exists($this, $method)) { |
|
3868
|
|
|
$res['php'] = $this->$method($res); |
|
3869
|
|
|
} elseif (isset($this->openBlocks[$blockname])) { |
|
3870
|
|
|
$res['php'] = call_user_func($this->openBlocks[$blockname], $res); |
|
3871
|
|
|
} else { |
|
3872
|
|
|
throw new SSTemplateParseException('Unknown open block "'.$blockname.'" encountered. Perhaps you missed ' . |
|
3873
|
|
|
' the closing tag or have mis-spelled it?', $this); |
|
3874
|
|
|
} |
|
3875
|
|
|
} |
|
3876
|
|
|
|
|
3877
|
|
|
/** |
|
3878
|
|
|
* This is an open block handler, for the <% debug %> utility tag |
|
3879
|
|
|
*/ |
|
3880
|
|
|
function OpenBlock_Handle_Debug(&$res) { |
|
3881
|
|
|
if ($res['ArgumentCount'] == 0) return '$scope->debug();'; |
|
3882
|
|
|
else if ($res['ArgumentCount'] == 1) { |
|
3883
|
|
|
$arg = $res['Arguments'][0]; |
|
3884
|
|
|
|
|
3885
|
|
|
if ($arg['ArgumentMode'] == 'string') return 'Debug::show('.$arg['php'].');'; |
|
3886
|
|
|
|
|
3887
|
|
|
$php = ($arg['ArgumentMode'] == 'default') ? $arg['lookup_php'] : $arg['php']; |
|
3888
|
|
|
return '$val .= Debug::show('.str_replace('FINALGET!', 'cachedCall', $php).');'; |
|
3889
|
|
|
} |
|
3890
|
|
|
else { |
|
3891
|
|
|
throw new SSTemplateParseException('Debug takes 0 or 1 argument only.', $this); |
|
3892
|
|
|
} |
|
3893
|
|
|
} |
|
3894
|
|
|
|
|
3895
|
|
|
/** |
|
3896
|
|
|
* This is an open block handler, for the <% base_tag %> tag |
|
3897
|
|
|
*/ |
|
3898
|
|
|
function OpenBlock_Handle_Base_tag(&$res) { |
|
3899
|
|
|
if ($res['ArgumentCount'] != 0) throw new SSTemplateParseException('Base_tag takes no arguments', $this); |
|
3900
|
|
|
return '$val .= SSViewer::get_base_tag($val);'; |
|
3901
|
|
|
} |
|
3902
|
|
|
|
|
3903
|
|
|
/** |
|
3904
|
|
|
* This is an open block handler, for the <% current_page %> tag |
|
3905
|
|
|
*/ |
|
3906
|
|
|
function OpenBlock_Handle_Current_page(&$res) { |
|
3907
|
|
|
if ($res['ArgumentCount'] != 0) throw new SSTemplateParseException('Current_page takes no arguments', $this); |
|
3908
|
|
|
return '$val .= $_SERVER[SCRIPT_URL];'; |
|
3909
|
|
|
} |
|
3910
|
|
|
|
|
3911
|
|
|
/* MismatchedEndBlock: '<%' < 'end_' :Word > '%>' */ |
|
3912
|
|
|
protected $match_MismatchedEndBlock_typestack = array('MismatchedEndBlock'); |
|
3913
|
|
|
function match_MismatchedEndBlock ($stack = array()) { |
|
3914
|
|
|
$matchrule = "MismatchedEndBlock"; $result = $this->construct($matchrule, $matchrule, null); |
|
3915
|
|
|
$_652 = NULL; |
|
3916
|
|
|
do { |
|
|
|
|
|
|
3917
|
|
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3918
|
|
|
else { $_652 = FALSE; break; } |
|
3919
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3920
|
|
|
if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3921
|
|
|
else { $_652 = FALSE; break; } |
|
3922
|
|
|
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
|
3923
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3924
|
|
|
if ($subres !== FALSE) { |
|
3925
|
|
|
$this->store( $result, $subres, "Word" ); |
|
3926
|
|
|
} |
|
3927
|
|
|
else { $_652 = FALSE; break; } |
|
3928
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3929
|
|
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3930
|
|
|
else { $_652 = FALSE; break; } |
|
3931
|
|
|
$_652 = TRUE; break; |
|
3932
|
|
|
} |
|
3933
|
|
|
while(0); |
|
3934
|
|
|
if( $_652 === TRUE ) { return $this->finalise($result); } |
|
3935
|
|
|
if( $_652 === FALSE) { return FALSE; } |
|
3936
|
|
|
} |
|
3937
|
|
|
|
|
3938
|
|
|
|
|
3939
|
|
|
|
|
3940
|
|
|
function MismatchedEndBlock__finalise(&$res) { |
|
3941
|
|
|
$blockname = $res['Word']['text']; |
|
3942
|
|
|
throw new SSTemplateParseException('Unexpected close tag end_' . $blockname . |
|
3943
|
|
|
' encountered. Perhaps you have mis-nested blocks, or have mis-spelled a tag?', $this); |
|
3944
|
|
|
} |
|
3945
|
|
|
|
|
3946
|
|
|
/* MalformedOpenTag: '<%' < !NotBlockTag Tag:Word !( ( [ :BlockArguments ] )? > '%>' ) */ |
|
|
|
|
|
|
3947
|
|
|
protected $match_MalformedOpenTag_typestack = array('MalformedOpenTag'); |
|
3948
|
|
|
function match_MalformedOpenTag ($stack = array()) { |
|
3949
|
|
|
$matchrule = "MalformedOpenTag"; $result = $this->construct($matchrule, $matchrule, null); |
|
3950
|
|
|
$_667 = NULL; |
|
3951
|
|
|
do { |
|
|
|
|
|
|
3952
|
|
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3953
|
|
|
else { $_667 = FALSE; break; } |
|
3954
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3955
|
|
|
$res_656 = $result; |
|
3956
|
|
|
$pos_656 = $this->pos; |
|
3957
|
|
|
$matcher = 'match_'.'NotBlockTag'; $key = $matcher; $pos = $this->pos; |
|
3958
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3959
|
|
|
if ($subres !== FALSE) { |
|
3960
|
|
|
$this->store( $result, $subres ); |
|
3961
|
|
|
$result = $res_656; |
|
3962
|
|
|
$this->pos = $pos_656; |
|
3963
|
|
|
$_667 = FALSE; break; |
|
3964
|
|
|
} |
|
3965
|
|
|
else { |
|
3966
|
|
|
$result = $res_656; |
|
3967
|
|
|
$this->pos = $pos_656; |
|
3968
|
|
|
} |
|
3969
|
|
|
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
|
3970
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3971
|
|
|
if ($subres !== FALSE) { |
|
3972
|
|
|
$this->store( $result, $subres, "Tag" ); |
|
3973
|
|
|
} |
|
3974
|
|
|
else { $_667 = FALSE; break; } |
|
3975
|
|
|
$res_666 = $result; |
|
3976
|
|
|
$pos_666 = $this->pos; |
|
3977
|
|
|
$_665 = NULL; |
|
3978
|
|
|
do { |
|
3979
|
|
|
$res_662 = $result; |
|
3980
|
|
|
$pos_662 = $this->pos; |
|
3981
|
|
|
$_661 = NULL; |
|
3982
|
|
|
do { |
|
3983
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3984
|
|
|
else { $_661 = FALSE; break; } |
|
3985
|
|
|
$matcher = 'match_'.'BlockArguments'; $key = $matcher; $pos = $this->pos; |
|
3986
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
3987
|
|
|
if ($subres !== FALSE) { |
|
3988
|
|
|
$this->store( $result, $subres, "BlockArguments" ); |
|
3989
|
|
|
} |
|
3990
|
|
|
else { $_661 = FALSE; break; } |
|
3991
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
3992
|
|
|
else { $_661 = FALSE; break; } |
|
3993
|
|
|
$_661 = TRUE; break; |
|
3994
|
|
|
} |
|
3995
|
|
|
while(0); |
|
3996
|
|
|
if( $_661 === FALSE) { |
|
3997
|
|
|
$result = $res_662; |
|
3998
|
|
|
$this->pos = $pos_662; |
|
3999
|
|
|
unset( $res_662 ); |
|
4000
|
|
|
unset( $pos_662 ); |
|
4001
|
|
|
} |
|
4002
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
4003
|
|
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
4004
|
|
|
else { $_665 = FALSE; break; } |
|
4005
|
|
|
$_665 = TRUE; break; |
|
4006
|
|
|
} |
|
4007
|
|
|
while(0); |
|
4008
|
|
|
if( $_665 === TRUE ) { |
|
4009
|
|
|
$result = $res_666; |
|
4010
|
|
|
$this->pos = $pos_666; |
|
4011
|
|
|
$_667 = FALSE; break; |
|
4012
|
|
|
} |
|
4013
|
|
|
if( $_665 === FALSE) { |
|
4014
|
|
|
$result = $res_666; |
|
4015
|
|
|
$this->pos = $pos_666; |
|
4016
|
|
|
} |
|
4017
|
|
|
$_667 = TRUE; break; |
|
4018
|
|
|
} |
|
4019
|
|
|
while(0); |
|
4020
|
|
|
if( $_667 === TRUE ) { return $this->finalise($result); } |
|
4021
|
|
|
if( $_667 === FALSE) { return FALSE; } |
|
4022
|
|
|
} |
|
4023
|
|
|
|
|
4024
|
|
|
|
|
4025
|
|
|
|
|
4026
|
|
|
function MalformedOpenTag__finalise(&$res) { |
|
4027
|
|
|
$tag = $res['Tag']['text']; |
|
4028
|
|
|
throw new SSTemplateParseException("Malformed opening block tag $tag. Perhaps you have tried to use operators?" |
|
4029
|
|
|
, $this); |
|
4030
|
|
|
} |
|
4031
|
|
|
|
|
4032
|
|
|
/* MalformedCloseTag: '<%' < Tag:('end_' :Word ) !( > '%>' ) */ |
|
|
|
|
|
|
4033
|
|
|
protected $match_MalformedCloseTag_typestack = array('MalformedCloseTag'); |
|
4034
|
|
|
function match_MalformedCloseTag ($stack = array()) { |
|
4035
|
|
|
$matchrule = "MalformedCloseTag"; $result = $this->construct($matchrule, $matchrule, null); |
|
4036
|
|
|
$_679 = NULL; |
|
4037
|
|
|
do { |
|
|
|
|
|
|
4038
|
|
|
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
4039
|
|
|
else { $_679 = FALSE; break; } |
|
4040
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
4041
|
|
|
$stack[] = $result; $result = $this->construct( $matchrule, "Tag" ); |
|
4042
|
|
|
$_673 = NULL; |
|
4043
|
|
|
do { |
|
4044
|
|
|
if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
4045
|
|
|
else { $_673 = FALSE; break; } |
|
4046
|
|
|
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos; |
|
4047
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
4048
|
|
|
if ($subres !== FALSE) { |
|
4049
|
|
|
$this->store( $result, $subres, "Word" ); |
|
4050
|
|
|
} |
|
4051
|
|
|
else { $_673 = FALSE; break; } |
|
4052
|
|
|
$_673 = TRUE; break; |
|
4053
|
|
|
} |
|
4054
|
|
|
while(0); |
|
4055
|
|
|
if( $_673 === TRUE ) { |
|
4056
|
|
|
$subres = $result; $result = array_pop($stack); |
|
4057
|
|
|
$this->store( $result, $subres, 'Tag' ); |
|
4058
|
|
|
} |
|
4059
|
|
|
if( $_673 === FALSE) { |
|
4060
|
|
|
$result = array_pop($stack); |
|
4061
|
|
|
$_679 = FALSE; break; |
|
4062
|
|
|
} |
|
4063
|
|
|
$res_678 = $result; |
|
4064
|
|
|
$pos_678 = $this->pos; |
|
4065
|
|
|
$_677 = NULL; |
|
4066
|
|
|
do { |
|
4067
|
|
|
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; } |
|
4068
|
|
|
if (( $subres = $this->literal( '%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
4069
|
|
|
else { $_677 = FALSE; break; } |
|
4070
|
|
|
$_677 = TRUE; break; |
|
4071
|
|
|
} |
|
4072
|
|
|
while(0); |
|
4073
|
|
|
if( $_677 === TRUE ) { |
|
4074
|
|
|
$result = $res_678; |
|
4075
|
|
|
$this->pos = $pos_678; |
|
4076
|
|
|
$_679 = FALSE; break; |
|
4077
|
|
|
} |
|
4078
|
|
|
if( $_677 === FALSE) { |
|
4079
|
|
|
$result = $res_678; |
|
4080
|
|
|
$this->pos = $pos_678; |
|
4081
|
|
|
} |
|
4082
|
|
|
$_679 = TRUE; break; |
|
4083
|
|
|
} |
|
4084
|
|
|
while(0); |
|
4085
|
|
|
if( $_679 === TRUE ) { return $this->finalise($result); } |
|
4086
|
|
|
if( $_679 === FALSE) { return FALSE; } |
|
4087
|
|
|
} |
|
4088
|
|
|
|
|
4089
|
|
|
|
|
4090
|
|
|
|
|
4091
|
|
|
function MalformedCloseTag__finalise(&$res) { |
|
4092
|
|
|
$tag = $res['Tag']['text']; |
|
4093
|
|
|
throw new SSTemplateParseException("Malformed closing block tag $tag. Perhaps you have tried to pass an " . |
|
4094
|
|
|
"argument to one?", $this); |
|
4095
|
|
|
} |
|
4096
|
|
|
|
|
4097
|
|
|
/* MalformedBlock: MalformedOpenTag | MalformedCloseTag */ |
|
4098
|
|
|
protected $match_MalformedBlock_typestack = array('MalformedBlock'); |
|
4099
|
|
|
function match_MalformedBlock ($stack = array()) { |
|
4100
|
|
|
$matchrule = "MalformedBlock"; $result = $this->construct($matchrule, $matchrule, null); |
|
4101
|
|
|
$_684 = NULL; |
|
4102
|
|
|
do { |
|
|
|
|
|
|
4103
|
|
|
$res_681 = $result; |
|
4104
|
|
|
$pos_681 = $this->pos; |
|
4105
|
|
|
$matcher = 'match_'.'MalformedOpenTag'; $key = $matcher; $pos = $this->pos; |
|
4106
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
4107
|
|
|
if ($subres !== FALSE) { |
|
4108
|
|
|
$this->store( $result, $subres ); |
|
4109
|
|
|
$_684 = TRUE; break; |
|
4110
|
|
|
} |
|
4111
|
|
|
$result = $res_681; |
|
4112
|
|
|
$this->pos = $pos_681; |
|
4113
|
|
|
$matcher = 'match_'.'MalformedCloseTag'; $key = $matcher; $pos = $this->pos; |
|
4114
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
4115
|
|
|
if ($subres !== FALSE) { |
|
4116
|
|
|
$this->store( $result, $subres ); |
|
4117
|
|
|
$_684 = TRUE; break; |
|
4118
|
|
|
} |
|
4119
|
|
|
$result = $res_681; |
|
4120
|
|
|
$this->pos = $pos_681; |
|
4121
|
|
|
$_684 = FALSE; break; |
|
4122
|
|
|
} |
|
4123
|
|
|
while(0); |
|
4124
|
|
|
if( $_684 === TRUE ) { return $this->finalise($result); } |
|
4125
|
|
|
if( $_684 === FALSE) { return FALSE; } |
|
4126
|
|
|
} |
|
4127
|
|
|
|
|
4128
|
|
|
|
|
4129
|
|
|
|
|
4130
|
|
|
|
|
4131
|
|
|
/* Comment: "<%--" (!"--%>" /(?s)./)+ "--%>" */ |
|
|
|
|
|
|
4132
|
|
|
protected $match_Comment_typestack = array('Comment'); |
|
4133
|
|
|
function match_Comment ($stack = array()) { |
|
|
|
|
|
|
4134
|
|
|
$matchrule = "Comment"; $result = $this->construct($matchrule, $matchrule, null); |
|
4135
|
|
|
$_692 = NULL; |
|
4136
|
|
|
do { |
|
|
|
|
|
|
4137
|
|
|
if (( $subres = $this->literal( '<%--' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
4138
|
|
|
else { $_692 = FALSE; break; } |
|
4139
|
|
|
$count = 0; |
|
4140
|
|
|
while (true) { |
|
4141
|
|
|
$res_690 = $result; |
|
4142
|
|
|
$pos_690 = $this->pos; |
|
4143
|
|
|
$_689 = NULL; |
|
4144
|
|
|
do { |
|
4145
|
|
|
$res_687 = $result; |
|
4146
|
|
|
$pos_687 = $this->pos; |
|
4147
|
|
|
if (( $subres = $this->literal( '--%>' ) ) !== FALSE) { |
|
4148
|
|
|
$result["text"] .= $subres; |
|
4149
|
|
|
$result = $res_687; |
|
4150
|
|
|
$this->pos = $pos_687; |
|
4151
|
|
|
$_689 = FALSE; break; |
|
4152
|
|
|
} |
|
4153
|
|
|
else { |
|
4154
|
|
|
$result = $res_687; |
|
4155
|
|
|
$this->pos = $pos_687; |
|
4156
|
|
|
} |
|
4157
|
|
|
if (( $subres = $this->rx( '/(?s)./' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
4158
|
|
|
else { $_689 = FALSE; break; } |
|
4159
|
|
|
$_689 = TRUE; break; |
|
4160
|
|
|
} |
|
4161
|
|
|
while(0); |
|
4162
|
|
|
if( $_689 === FALSE) { |
|
4163
|
|
|
$result = $res_690; |
|
4164
|
|
|
$this->pos = $pos_690; |
|
4165
|
|
|
unset( $res_690 ); |
|
4166
|
|
|
unset( $pos_690 ); |
|
4167
|
|
|
break; |
|
4168
|
|
|
} |
|
4169
|
|
|
$count += 1; |
|
4170
|
|
|
} |
|
4171
|
|
|
if ($count > 0) { } |
|
|
|
|
|
|
4172
|
|
|
else { $_692 = FALSE; break; } |
|
4173
|
|
|
if (( $subres = $this->literal( '--%>' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
4174
|
|
|
else { $_692 = FALSE; break; } |
|
4175
|
|
|
$_692 = TRUE; break; |
|
4176
|
|
|
} |
|
4177
|
|
|
while(0); |
|
4178
|
|
|
if( $_692 === TRUE ) { return $this->finalise($result); } |
|
4179
|
|
|
if( $_692 === FALSE) { return FALSE; } |
|
4180
|
|
|
} |
|
4181
|
|
|
|
|
4182
|
|
|
|
|
4183
|
|
|
|
|
4184
|
|
|
function Comment__construct(&$res) { |
|
4185
|
|
|
$res['php'] = ''; |
|
4186
|
|
|
} |
|
4187
|
|
|
|
|
4188
|
|
|
/* TopTemplate: (Comment | Translate | If | Require | CacheBlock | UncachedBlock | OldI18NTag | Include | ClosedBlock | |
|
4189
|
|
|
OpenBlock | MalformedBlock | MismatchedEndBlock | Injection | Text)+ */ |
|
4190
|
|
|
protected $match_TopTemplate_typestack = array('TopTemplate','Template'); |
|
4191
|
|
|
function match_TopTemplate ($stack = array()) { |
|
4192
|
|
|
$matchrule = "TopTemplate"; $result = $this->construct($matchrule, $matchrule, array('TemplateMatcher' => 'Template')); |
|
4193
|
|
|
$count = 0; |
|
4194
|
|
|
while (true) { |
|
4195
|
|
|
$res_748 = $result; |
|
4196
|
|
|
$pos_748 = $this->pos; |
|
4197
|
|
|
$_747 = NULL; |
|
4198
|
|
|
do { |
|
|
|
|
|
|
4199
|
|
|
$_745 = NULL; |
|
4200
|
|
|
do { |
|
4201
|
|
|
$res_694 = $result; |
|
4202
|
|
|
$pos_694 = $this->pos; |
|
4203
|
|
|
$matcher = 'match_'.'Comment'; $key = $matcher; $pos = $this->pos; |
|
4204
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
4205
|
|
|
if ($subres !== FALSE) { |
|
4206
|
|
|
$this->store( $result, $subres ); |
|
4207
|
|
|
$_745 = TRUE; break; |
|
4208
|
|
|
} |
|
4209
|
|
|
$result = $res_694; |
|
4210
|
|
|
$this->pos = $pos_694; |
|
4211
|
|
|
$_743 = NULL; |
|
4212
|
|
|
do { |
|
4213
|
|
|
$res_696 = $result; |
|
4214
|
|
|
$pos_696 = $this->pos; |
|
4215
|
|
|
$matcher = 'match_'.'Translate'; $key = $matcher; $pos = $this->pos; |
|
4216
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
4217
|
|
|
if ($subres !== FALSE) { |
|
4218
|
|
|
$this->store( $result, $subres ); |
|
4219
|
|
|
$_743 = TRUE; break; |
|
4220
|
|
|
} |
|
4221
|
|
|
$result = $res_696; |
|
4222
|
|
|
$this->pos = $pos_696; |
|
4223
|
|
|
$_741 = NULL; |
|
4224
|
|
|
do { |
|
4225
|
|
|
$res_698 = $result; |
|
4226
|
|
|
$pos_698 = $this->pos; |
|
4227
|
|
|
$matcher = 'match_'.'If'; $key = $matcher; $pos = $this->pos; |
|
4228
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
4229
|
|
|
if ($subres !== FALSE) { |
|
4230
|
|
|
$this->store( $result, $subres ); |
|
4231
|
|
|
$_741 = TRUE; break; |
|
4232
|
|
|
} |
|
4233
|
|
|
$result = $res_698; |
|
4234
|
|
|
$this->pos = $pos_698; |
|
4235
|
|
|
$_739 = NULL; |
|
4236
|
|
|
do { |
|
4237
|
|
|
$res_700 = $result; |
|
4238
|
|
|
$pos_700 = $this->pos; |
|
4239
|
|
|
$matcher = 'match_'.'Require'; $key = $matcher; $pos = $this->pos; |
|
4240
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
4241
|
|
|
if ($subres !== FALSE) { |
|
4242
|
|
|
$this->store( $result, $subres ); |
|
4243
|
|
|
$_739 = TRUE; break; |
|
4244
|
|
|
} |
|
4245
|
|
|
$result = $res_700; |
|
4246
|
|
|
$this->pos = $pos_700; |
|
4247
|
|
|
$_737 = NULL; |
|
4248
|
|
|
do { |
|
4249
|
|
|
$res_702 = $result; |
|
4250
|
|
|
$pos_702 = $this->pos; |
|
4251
|
|
|
$matcher = 'match_'.'CacheBlock'; $key = $matcher; $pos = $this->pos; |
|
4252
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
4253
|
|
|
if ($subres !== FALSE) { |
|
4254
|
|
|
$this->store( $result, $subres ); |
|
4255
|
|
|
$_737 = TRUE; break; |
|
4256
|
|
|
} |
|
4257
|
|
|
$result = $res_702; |
|
4258
|
|
|
$this->pos = $pos_702; |
|
4259
|
|
|
$_735 = NULL; |
|
4260
|
|
|
do { |
|
4261
|
|
|
$res_704 = $result; |
|
4262
|
|
|
$pos_704 = $this->pos; |
|
4263
|
|
|
$matcher = 'match_'.'UncachedBlock'; $key = $matcher; $pos = $this->pos; |
|
4264
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
4265
|
|
|
if ($subres !== FALSE) { |
|
4266
|
|
|
$this->store( $result, $subres ); |
|
4267
|
|
|
$_735 = TRUE; break; |
|
4268
|
|
|
} |
|
4269
|
|
|
$result = $res_704; |
|
4270
|
|
|
$this->pos = $pos_704; |
|
4271
|
|
|
$_733 = NULL; |
|
4272
|
|
|
do { |
|
4273
|
|
|
$res_706 = $result; |
|
4274
|
|
|
$pos_706 = $this->pos; |
|
4275
|
|
|
$matcher = 'match_'.'OldI18NTag'; $key = $matcher; $pos = $this->pos; |
|
4276
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
4277
|
|
|
if ($subres !== FALSE) { |
|
4278
|
|
|
$this->store( $result, $subres ); |
|
4279
|
|
|
$_733 = TRUE; break; |
|
4280
|
|
|
} |
|
4281
|
|
|
$result = $res_706; |
|
4282
|
|
|
$this->pos = $pos_706; |
|
4283
|
|
|
$_731 = NULL; |
|
4284
|
|
|
do { |
|
4285
|
|
|
$res_708 = $result; |
|
4286
|
|
|
$pos_708 = $this->pos; |
|
4287
|
|
|
$matcher = 'match_'.'Include'; $key = $matcher; $pos = $this->pos; |
|
4288
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
4289
|
|
|
if ($subres !== FALSE) { |
|
4290
|
|
|
$this->store( $result, $subres ); |
|
4291
|
|
|
$_731 = TRUE; break; |
|
4292
|
|
|
} |
|
4293
|
|
|
$result = $res_708; |
|
4294
|
|
|
$this->pos = $pos_708; |
|
4295
|
|
|
$_729 = NULL; |
|
4296
|
|
|
do { |
|
4297
|
|
|
$res_710 = $result; |
|
4298
|
|
|
$pos_710 = $this->pos; |
|
4299
|
|
|
$matcher = 'match_'.'ClosedBlock'; $key = $matcher; $pos = $this->pos; |
|
4300
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
4301
|
|
|
if ($subres !== FALSE) { |
|
4302
|
|
|
$this->store( $result, $subres ); |
|
4303
|
|
|
$_729 = TRUE; break; |
|
4304
|
|
|
} |
|
4305
|
|
|
$result = $res_710; |
|
4306
|
|
|
$this->pos = $pos_710; |
|
4307
|
|
|
$_727 = NULL; |
|
4308
|
|
|
do { |
|
4309
|
|
|
$res_712 = $result; |
|
4310
|
|
|
$pos_712 = $this->pos; |
|
4311
|
|
|
$matcher = 'match_'.'OpenBlock'; $key = $matcher; $pos = $this->pos; |
|
4312
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
4313
|
|
|
if ($subres !== FALSE) { |
|
4314
|
|
|
$this->store( $result, $subres ); |
|
4315
|
|
|
$_727 = TRUE; break; |
|
4316
|
|
|
} |
|
4317
|
|
|
$result = $res_712; |
|
4318
|
|
|
$this->pos = $pos_712; |
|
4319
|
|
|
$_725 = NULL; |
|
4320
|
|
|
do { |
|
4321
|
|
|
$res_714 = $result; |
|
4322
|
|
|
$pos_714 = $this->pos; |
|
4323
|
|
|
$matcher = 'match_'.'MalformedBlock'; $key = $matcher; $pos = $this->pos; |
|
4324
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
4325
|
|
|
if ($subres !== FALSE) { |
|
4326
|
|
|
$this->store( $result, $subres ); |
|
4327
|
|
|
$_725 = TRUE; break; |
|
4328
|
|
|
} |
|
4329
|
|
|
$result = $res_714; |
|
4330
|
|
|
$this->pos = $pos_714; |
|
4331
|
|
|
$_723 = NULL; |
|
4332
|
|
|
do { |
|
4333
|
|
|
$res_716 = $result; |
|
4334
|
|
|
$pos_716 = $this->pos; |
|
4335
|
|
|
$matcher = 'match_'.'MismatchedEndBlock'; $key = $matcher; $pos = $this->pos; |
|
4336
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
4337
|
|
|
if ($subres !== FALSE) { |
|
4338
|
|
|
$this->store( $result, $subres ); |
|
4339
|
|
|
$_723 = TRUE; break; |
|
4340
|
|
|
} |
|
4341
|
|
|
$result = $res_716; |
|
4342
|
|
|
$this->pos = $pos_716; |
|
4343
|
|
|
$_721 = NULL; |
|
4344
|
|
|
do { |
|
4345
|
|
|
$res_718 = $result; |
|
4346
|
|
|
$pos_718 = $this->pos; |
|
4347
|
|
|
$matcher = 'match_'.'Injection'; $key = $matcher; $pos = $this->pos; |
|
4348
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
4349
|
|
|
if ($subres !== FALSE) { |
|
4350
|
|
|
$this->store( $result, $subres ); |
|
4351
|
|
|
$_721 = TRUE; break; |
|
4352
|
|
|
} |
|
4353
|
|
|
$result = $res_718; |
|
4354
|
|
|
$this->pos = $pos_718; |
|
4355
|
|
|
$matcher = 'match_'.'Text'; $key = $matcher; $pos = $this->pos; |
|
4356
|
|
|
$subres = ( $this->packhas( $key, $pos ) ? $this->packread( $key, $pos ) : $this->packwrite( $key, $pos, $this->$matcher(array_merge($stack, array($result))) ) ); |
|
4357
|
|
|
if ($subres !== FALSE) { |
|
4358
|
|
|
$this->store( $result, $subres ); |
|
4359
|
|
|
$_721 = TRUE; break; |
|
4360
|
|
|
} |
|
4361
|
|
|
$result = $res_718; |
|
4362
|
|
|
$this->pos = $pos_718; |
|
4363
|
|
|
$_721 = FALSE; break; |
|
4364
|
|
|
} |
|
4365
|
|
|
while(0); |
|
4366
|
|
|
if( $_721 === TRUE ) { $_723 = TRUE; break; } |
|
4367
|
|
|
$result = $res_716; |
|
4368
|
|
|
$this->pos = $pos_716; |
|
4369
|
|
|
$_723 = FALSE; break; |
|
4370
|
|
|
} |
|
4371
|
|
|
while(0); |
|
4372
|
|
|
if( $_723 === TRUE ) { $_725 = TRUE; break; } |
|
4373
|
|
|
$result = $res_714; |
|
4374
|
|
|
$this->pos = $pos_714; |
|
4375
|
|
|
$_725 = FALSE; break; |
|
4376
|
|
|
} |
|
4377
|
|
|
while(0); |
|
4378
|
|
|
if( $_725 === TRUE ) { $_727 = TRUE; break; } |
|
4379
|
|
|
$result = $res_712; |
|
4380
|
|
|
$this->pos = $pos_712; |
|
4381
|
|
|
$_727 = FALSE; break; |
|
4382
|
|
|
} |
|
4383
|
|
|
while(0); |
|
4384
|
|
|
if( $_727 === TRUE ) { $_729 = TRUE; break; } |
|
4385
|
|
|
$result = $res_710; |
|
4386
|
|
|
$this->pos = $pos_710; |
|
4387
|
|
|
$_729 = FALSE; break; |
|
4388
|
|
|
} |
|
4389
|
|
|
while(0); |
|
4390
|
|
|
if( $_729 === TRUE ) { $_731 = TRUE; break; } |
|
4391
|
|
|
$result = $res_708; |
|
4392
|
|
|
$this->pos = $pos_708; |
|
4393
|
|
|
$_731 = FALSE; break; |
|
4394
|
|
|
} |
|
4395
|
|
|
while(0); |
|
4396
|
|
|
if( $_731 === TRUE ) { $_733 = TRUE; break; } |
|
4397
|
|
|
$result = $res_706; |
|
4398
|
|
|
$this->pos = $pos_706; |
|
4399
|
|
|
$_733 = FALSE; break; |
|
4400
|
|
|
} |
|
4401
|
|
|
while(0); |
|
4402
|
|
|
if( $_733 === TRUE ) { $_735 = TRUE; break; } |
|
4403
|
|
|
$result = $res_704; |
|
4404
|
|
|
$this->pos = $pos_704; |
|
4405
|
|
|
$_735 = FALSE; break; |
|
4406
|
|
|
} |
|
4407
|
|
|
while(0); |
|
4408
|
|
|
if( $_735 === TRUE ) { $_737 = TRUE; break; } |
|
4409
|
|
|
$result = $res_702; |
|
4410
|
|
|
$this->pos = $pos_702; |
|
4411
|
|
|
$_737 = FALSE; break; |
|
4412
|
|
|
} |
|
4413
|
|
|
while(0); |
|
4414
|
|
|
if( $_737 === TRUE ) { $_739 = TRUE; break; } |
|
4415
|
|
|
$result = $res_700; |
|
4416
|
|
|
$this->pos = $pos_700; |
|
4417
|
|
|
$_739 = FALSE; break; |
|
4418
|
|
|
} |
|
4419
|
|
|
while(0); |
|
4420
|
|
|
if( $_739 === TRUE ) { $_741 = TRUE; break; } |
|
4421
|
|
|
$result = $res_698; |
|
4422
|
|
|
$this->pos = $pos_698; |
|
4423
|
|
|
$_741 = FALSE; break; |
|
4424
|
|
|
} |
|
4425
|
|
|
while(0); |
|
4426
|
|
|
if( $_741 === TRUE ) { $_743 = TRUE; break; } |
|
4427
|
|
|
$result = $res_696; |
|
4428
|
|
|
$this->pos = $pos_696; |
|
4429
|
|
|
$_743 = FALSE; break; |
|
4430
|
|
|
} |
|
4431
|
|
|
while(0); |
|
4432
|
|
|
if( $_743 === TRUE ) { $_745 = TRUE; break; } |
|
4433
|
|
|
$result = $res_694; |
|
4434
|
|
|
$this->pos = $pos_694; |
|
4435
|
|
|
$_745 = FALSE; break; |
|
4436
|
|
|
} |
|
4437
|
|
|
while(0); |
|
4438
|
|
|
if( $_745 === FALSE) { $_747 = FALSE; break; } |
|
4439
|
|
|
$_747 = TRUE; break; |
|
4440
|
|
|
} |
|
4441
|
|
|
while(0); |
|
4442
|
|
|
if( $_747 === FALSE) { |
|
4443
|
|
|
$result = $res_748; |
|
4444
|
|
|
$this->pos = $pos_748; |
|
4445
|
|
|
unset( $res_748 ); |
|
4446
|
|
|
unset( $pos_748 ); |
|
4447
|
|
|
break; |
|
4448
|
|
|
} |
|
4449
|
|
|
$count += 1; |
|
4450
|
|
|
} |
|
4451
|
|
|
if ($count > 0) { return $this->finalise($result); } |
|
4452
|
|
|
else { return FALSE; } |
|
4453
|
|
|
} |
|
4454
|
|
|
|
|
4455
|
|
|
|
|
4456
|
|
|
|
|
4457
|
|
|
|
|
4458
|
|
|
/** |
|
4459
|
|
|
* The TopTemplate also includes the opening stanza to start off the template |
|
4460
|
|
|
*/ |
|
4461
|
|
|
function TopTemplate__construct(&$res) { |
|
4462
|
|
|
$res['php'] = "<?php" . PHP_EOL; |
|
4463
|
|
|
} |
|
4464
|
|
|
|
|
4465
|
|
|
/* Text: ( |
|
|
|
|
|
|
4466
|
|
|
/ [^<${\\]+ / | |
|
4467
|
|
|
/ (\\.) / | |
|
4468
|
|
|
'<' !'%' | |
|
4469
|
|
|
'$' !(/[A-Za-z_]/) | |
|
4470
|
|
|
'{' !'$' | |
|
4471
|
|
|
'{$' !(/[A-Za-z_]/) |
|
4472
|
|
|
)+ */ |
|
4473
|
|
|
protected $match_Text_typestack = array('Text'); |
|
4474
|
|
|
function match_Text ($stack = array()) { |
|
|
|
|
|
|
4475
|
|
|
$matchrule = "Text"; $result = $this->construct($matchrule, $matchrule, null); |
|
4476
|
|
|
$count = 0; |
|
4477
|
|
|
while (true) { |
|
4478
|
|
|
$res_787 = $result; |
|
4479
|
|
|
$pos_787 = $this->pos; |
|
4480
|
|
|
$_786 = NULL; |
|
4481
|
|
|
do { |
|
|
|
|
|
|
4482
|
|
|
$_784 = NULL; |
|
4483
|
|
|
do { |
|
4484
|
|
|
$res_749 = $result; |
|
4485
|
|
|
$pos_749 = $this->pos; |
|
4486
|
|
|
if (( $subres = $this->rx( '/ [^<${\\\\]+ /' ) ) !== FALSE) { |
|
4487
|
|
|
$result["text"] .= $subres; |
|
4488
|
|
|
$_784 = TRUE; break; |
|
4489
|
|
|
} |
|
4490
|
|
|
$result = $res_749; |
|
4491
|
|
|
$this->pos = $pos_749; |
|
4492
|
|
|
$_782 = NULL; |
|
4493
|
|
|
do { |
|
4494
|
|
|
$res_751 = $result; |
|
4495
|
|
|
$pos_751 = $this->pos; |
|
4496
|
|
|
if (( $subres = $this->rx( '/ (\\\\.) /' ) ) !== FALSE) { |
|
4497
|
|
|
$result["text"] .= $subres; |
|
4498
|
|
|
$_782 = TRUE; break; |
|
4499
|
|
|
} |
|
4500
|
|
|
$result = $res_751; |
|
4501
|
|
|
$this->pos = $pos_751; |
|
4502
|
|
|
$_780 = NULL; |
|
4503
|
|
|
do { |
|
4504
|
|
|
$res_753 = $result; |
|
4505
|
|
|
$pos_753 = $this->pos; |
|
4506
|
|
|
$_756 = NULL; |
|
4507
|
|
|
do { |
|
4508
|
|
|
if (substr($this->string,$this->pos,1) == '<') { |
|
|
|
|
|
|
4509
|
|
|
$this->pos += 1; |
|
4510
|
|
|
$result["text"] .= '<'; |
|
4511
|
|
|
} |
|
4512
|
|
|
else { $_756 = FALSE; break; } |
|
4513
|
|
|
$res_755 = $result; |
|
4514
|
|
|
$pos_755 = $this->pos; |
|
4515
|
|
|
if (substr($this->string,$this->pos,1) == '%') { |
|
|
|
|
|
|
4516
|
|
|
$this->pos += 1; |
|
4517
|
|
|
$result["text"] .= '%'; |
|
4518
|
|
|
$result = $res_755; |
|
4519
|
|
|
$this->pos = $pos_755; |
|
4520
|
|
|
$_756 = FALSE; break; |
|
4521
|
|
|
} |
|
4522
|
|
|
else { |
|
4523
|
|
|
$result = $res_755; |
|
4524
|
|
|
$this->pos = $pos_755; |
|
4525
|
|
|
} |
|
4526
|
|
|
$_756 = TRUE; break; |
|
4527
|
|
|
} |
|
4528
|
|
|
while(0); |
|
4529
|
|
|
if( $_756 === TRUE ) { $_780 = TRUE; break; } |
|
4530
|
|
|
$result = $res_753; |
|
4531
|
|
|
$this->pos = $pos_753; |
|
4532
|
|
|
$_778 = NULL; |
|
4533
|
|
|
do { |
|
4534
|
|
|
$res_758 = $result; |
|
4535
|
|
|
$pos_758 = $this->pos; |
|
4536
|
|
|
$_763 = NULL; |
|
4537
|
|
|
do { |
|
4538
|
|
|
if (substr($this->string,$this->pos,1) == '$') { |
|
|
|
|
|
|
4539
|
|
|
$this->pos += 1; |
|
4540
|
|
|
$result["text"] .= '$'; |
|
4541
|
|
|
} |
|
4542
|
|
|
else { $_763 = FALSE; break; } |
|
4543
|
|
|
$res_762 = $result; |
|
4544
|
|
|
$pos_762 = $this->pos; |
|
4545
|
|
|
$_761 = NULL; |
|
4546
|
|
|
do { |
|
4547
|
|
|
if (( $subres = $this->rx( '/[A-Za-z_]/' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
4548
|
|
|
else { $_761 = FALSE; break; } |
|
4549
|
|
|
$_761 = TRUE; break; |
|
4550
|
|
|
} |
|
4551
|
|
|
while(0); |
|
4552
|
|
|
if( $_761 === TRUE ) { |
|
4553
|
|
|
$result = $res_762; |
|
4554
|
|
|
$this->pos = $pos_762; |
|
4555
|
|
|
$_763 = FALSE; break; |
|
4556
|
|
|
} |
|
4557
|
|
|
if( $_761 === FALSE) { |
|
4558
|
|
|
$result = $res_762; |
|
4559
|
|
|
$this->pos = $pos_762; |
|
4560
|
|
|
} |
|
4561
|
|
|
$_763 = TRUE; break; |
|
4562
|
|
|
} |
|
4563
|
|
|
while(0); |
|
4564
|
|
|
if( $_763 === TRUE ) { $_778 = TRUE; break; } |
|
4565
|
|
|
$result = $res_758; |
|
4566
|
|
|
$this->pos = $pos_758; |
|
4567
|
|
|
$_776 = NULL; |
|
4568
|
|
|
do { |
|
4569
|
|
|
$res_765 = $result; |
|
4570
|
|
|
$pos_765 = $this->pos; |
|
4571
|
|
|
$_768 = NULL; |
|
4572
|
|
|
do { |
|
4573
|
|
|
if (substr($this->string,$this->pos,1) == '{') { |
|
|
|
|
|
|
4574
|
|
|
$this->pos += 1; |
|
4575
|
|
|
$result["text"] .= '{'; |
|
4576
|
|
|
} |
|
4577
|
|
|
else { $_768 = FALSE; break; } |
|
4578
|
|
|
$res_767 = $result; |
|
4579
|
|
|
$pos_767 = $this->pos; |
|
4580
|
|
|
if (substr($this->string,$this->pos,1) == '$') { |
|
|
|
|
|
|
4581
|
|
|
$this->pos += 1; |
|
4582
|
|
|
$result["text"] .= '$'; |
|
4583
|
|
|
$result = $res_767; |
|
4584
|
|
|
$this->pos = $pos_767; |
|
4585
|
|
|
$_768 = FALSE; break; |
|
4586
|
|
|
} |
|
4587
|
|
|
else { |
|
4588
|
|
|
$result = $res_767; |
|
4589
|
|
|
$this->pos = $pos_767; |
|
4590
|
|
|
} |
|
4591
|
|
|
$_768 = TRUE; break; |
|
4592
|
|
|
} |
|
4593
|
|
|
while(0); |
|
4594
|
|
|
if( $_768 === TRUE ) { $_776 = TRUE; break; } |
|
4595
|
|
|
$result = $res_765; |
|
4596
|
|
|
$this->pos = $pos_765; |
|
4597
|
|
|
$_774 = NULL; |
|
4598
|
|
|
do { |
|
4599
|
|
|
if (( $subres = $this->literal( '{$' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
4600
|
|
|
else { $_774 = FALSE; break; } |
|
4601
|
|
|
$res_773 = $result; |
|
4602
|
|
|
$pos_773 = $this->pos; |
|
4603
|
|
|
$_772 = NULL; |
|
4604
|
|
|
do { |
|
4605
|
|
|
if (( $subres = $this->rx( '/[A-Za-z_]/' ) ) !== FALSE) { $result["text"] .= $subres; } |
|
4606
|
|
|
else { $_772 = FALSE; break; } |
|
4607
|
|
|
$_772 = TRUE; break; |
|
4608
|
|
|
} |
|
4609
|
|
|
while(0); |
|
4610
|
|
|
if( $_772 === TRUE ) { |
|
4611
|
|
|
$result = $res_773; |
|
4612
|
|
|
$this->pos = $pos_773; |
|
4613
|
|
|
$_774 = FALSE; break; |
|
4614
|
|
|
} |
|
4615
|
|
|
if( $_772 === FALSE) { |
|
4616
|
|
|
$result = $res_773; |
|
4617
|
|
|
$this->pos = $pos_773; |
|
4618
|
|
|
} |
|
4619
|
|
|
$_774 = TRUE; break; |
|
4620
|
|
|
} |
|
4621
|
|
|
while(0); |
|
4622
|
|
|
if( $_774 === TRUE ) { $_776 = TRUE; break; } |
|
4623
|
|
|
$result = $res_765; |
|
4624
|
|
|
$this->pos = $pos_765; |
|
4625
|
|
|
$_776 = FALSE; break; |
|
4626
|
|
|
} |
|
4627
|
|
|
while(0); |
|
4628
|
|
|
if( $_776 === TRUE ) { $_778 = TRUE; break; } |
|
4629
|
|
|
$result = $res_758; |
|
4630
|
|
|
$this->pos = $pos_758; |
|
4631
|
|
|
$_778 = FALSE; break; |
|
4632
|
|
|
} |
|
4633
|
|
|
while(0); |
|
4634
|
|
|
if( $_778 === TRUE ) { $_780 = TRUE; break; } |
|
4635
|
|
|
$result = $res_753; |
|
4636
|
|
|
$this->pos = $pos_753; |
|
4637
|
|
|
$_780 = FALSE; break; |
|
4638
|
|
|
} |
|
4639
|
|
|
while(0); |
|
4640
|
|
|
if( $_780 === TRUE ) { $_782 = TRUE; break; } |
|
4641
|
|
|
$result = $res_751; |
|
4642
|
|
|
$this->pos = $pos_751; |
|
4643
|
|
|
$_782 = FALSE; break; |
|
4644
|
|
|
} |
|
4645
|
|
|
while(0); |
|
4646
|
|
|
if( $_782 === TRUE ) { $_784 = TRUE; break; } |
|
4647
|
|
|
$result = $res_749; |
|
4648
|
|
|
$this->pos = $pos_749; |
|
4649
|
|
|
$_784 = FALSE; break; |
|
4650
|
|
|
} |
|
4651
|
|
|
while(0); |
|
4652
|
|
|
if( $_784 === FALSE) { $_786 = FALSE; break; } |
|
4653
|
|
|
$_786 = TRUE; break; |
|
4654
|
|
|
} |
|
4655
|
|
|
while(0); |
|
4656
|
|
|
if( $_786 === FALSE) { |
|
4657
|
|
|
$result = $res_787; |
|
4658
|
|
|
$this->pos = $pos_787; |
|
4659
|
|
|
unset( $res_787 ); |
|
4660
|
|
|
unset( $pos_787 ); |
|
4661
|
|
|
break; |
|
4662
|
|
|
} |
|
4663
|
|
|
$count += 1; |
|
4664
|
|
|
} |
|
4665
|
|
|
if ($count > 0) { return $this->finalise($result); } |
|
4666
|
|
|
else { return FALSE; } |
|
4667
|
|
|
} |
|
4668
|
|
|
|
|
4669
|
|
|
|
|
4670
|
|
|
|
|
4671
|
|
|
|
|
4672
|
|
|
/** |
|
4673
|
|
|
* We convert text |
|
4674
|
|
|
*/ |
|
4675
|
|
|
function Text__finalise(&$res) { |
|
4676
|
|
|
$text = $res['text']; |
|
4677
|
|
|
|
|
4678
|
|
|
// Unescape any escaped characters in the text, then put back escapes for any single quotes and backslashes |
|
4679
|
|
|
$text = stripslashes($text); |
|
4680
|
|
|
$text = addcslashes($text, '\'\\'); |
|
4681
|
|
|
|
|
4682
|
|
|
// TODO: This is pretty ugly & gets applied on all files not just html. I wonder if we can make this |
|
4683
|
|
|
// non-dynamically calculated |
|
4684
|
|
|
$code = <<<'EOC' |
|
4685
|
|
|
(\Config::inst()->get('SSViewer', 'rewrite_hash_links') |
|
4686
|
|
|
? \Convert::raw2att( preg_replace("/^(\\/)+/", "/", $_SERVER['REQUEST_URI'] ) ) |
|
4687
|
|
|
: "") |
|
4688
|
|
|
EOC; |
|
4689
|
|
|
// Because preg_replace replacement requires escaped slashes, addcslashes here |
|
4690
|
|
|
$text = preg_replace( |
|
4691
|
|
|
'/(<a[^>]+href *= *)"#/i', |
|
4692
|
|
|
'\\1"\' . ' . addcslashes($code, '\\') . ' . \'#', |
|
4693
|
|
|
$text |
|
4694
|
|
|
); |
|
4695
|
|
|
|
|
4696
|
|
|
$res['php'] .= '$val .= \'' . $text . '\';' . PHP_EOL; |
|
4697
|
|
|
} |
|
4698
|
|
|
|
|
4699
|
|
|
/****************** |
|
4700
|
|
|
* Here ends the parser itself. Below are utility methods to use the parser |
|
4701
|
|
|
*/ |
|
4702
|
|
|
|
|
4703
|
|
|
/** |
|
4704
|
|
|
* Compiles some passed template source code into the php code that will execute as per the template source. |
|
4705
|
|
|
* |
|
4706
|
|
|
* @throws SSTemplateParseException |
|
4707
|
|
|
* @param $string The source of the template |
|
4708
|
|
|
* @param string $templateName The name of the template, normally the filename the template source was loaded from |
|
4709
|
|
|
* @param bool $includeDebuggingComments True is debugging comments should be included in the output |
|
4710
|
|
|
* @param bool $topTemplate True if this is a top template, false if it's just a template |
|
4711
|
|
|
* @return mixed|string The php that, when executed (via include or exec) will behave as per the template source |
|
4712
|
|
|
*/ |
|
4713
|
|
|
public function compileString($string, $templateName = "", $includeDebuggingComments=false, $topTemplate = true) { |
|
4714
|
|
|
if (!trim($string)) { |
|
4715
|
|
|
$code = ''; |
|
4716
|
|
|
} |
|
4717
|
|
|
else { |
|
4718
|
|
|
parent::__construct($string); |
|
|
|
|
|
|
4719
|
|
|
|
|
4720
|
|
|
$this->includeDebuggingComments = $includeDebuggingComments; |
|
4721
|
|
|
|
|
4722
|
|
|
// Ignore UTF8 BOM at begining of string. TODO: Confirm this is needed, make sure SSViewer handles UTF |
|
4723
|
|
|
// (and other encodings) properly |
|
4724
|
|
|
if(substr($string, 0,3) == pack("CCC", 0xef, 0xbb, 0xbf)) $this->pos = 3; |
|
4725
|
|
|
|
|
4726
|
|
|
// Match the source against the parser |
|
4727
|
|
|
if ($topTemplate) { |
|
4728
|
|
|
$result = $this->match_TopTemplate(); |
|
4729
|
|
|
} else { |
|
4730
|
|
|
$result = $this->match_Template(); |
|
4731
|
|
|
} |
|
4732
|
|
|
if(!$result) throw new SSTemplateParseException('Unexpected problem parsing template', $this); |
|
4733
|
|
|
|
|
4734
|
|
|
// Get the result |
|
4735
|
|
|
$code = $result['php']; |
|
4736
|
|
|
} |
|
4737
|
|
|
|
|
4738
|
|
|
// Include top level debugging comments if desired |
|
4739
|
|
|
if($includeDebuggingComments && $templateName && stripos($code, "<?xml") === false) { |
|
4740
|
|
|
$code = $this->includeDebuggingComments($code, $templateName); |
|
4741
|
|
|
} |
|
4742
|
|
|
|
|
4743
|
|
|
return $code; |
|
4744
|
|
|
} |
|
4745
|
|
|
|
|
4746
|
|
|
/** |
|
4747
|
|
|
* @param string $code |
|
4748
|
|
|
* @return string $code |
|
4749
|
|
|
*/ |
|
4750
|
|
|
protected function includeDebuggingComments($code, $templateName) { |
|
4751
|
|
|
// If this template contains a doctype, put it right after it, |
|
4752
|
|
|
// if not, put it after the <html> tag to avoid IE glitches |
|
4753
|
|
|
if(stripos($code, "<!doctype") !== false) { |
|
4754
|
|
|
$code = preg_replace('/(<!doctype[^>]*("[^"]")*[^>]*>)/im', "$1\r\n<!-- template $templateName -->", $code); |
|
4755
|
|
|
$code .= "\r\n" . '$val .= \'<!-- end template ' . $templateName . ' -->\';'; |
|
4756
|
|
|
} elseif(stripos($code, "<html") !== false) { |
|
4757
|
|
|
$code = preg_replace_callback('/(.*)(<html[^>]*>)(.*)/i', function($matches) use ($templateName) { |
|
4758
|
|
|
if (stripos($matches[3], '<!--') === false && stripos($matches[3], '-->') !== false) { |
|
4759
|
|
|
// after this <html> tag there is a comment close but no comment has been opened |
|
4760
|
|
|
// this most likely means that this <html> tag is inside a comment |
|
4761
|
|
|
// we should not add a comment inside a comment (invalid html) |
|
4762
|
|
|
// lets append it at the end of the comment |
|
4763
|
|
|
// an example case for this is the html5boilerplate: <!--[if IE]><html class="ie"><![endif]--> |
|
4764
|
|
|
return $matches[0]; |
|
4765
|
|
|
} else { |
|
4766
|
|
|
// all other cases, add the comment and return it |
|
4767
|
|
|
return "{$matches[1]}{$matches[2]}<!-- template $templateName -->{$matches[3]}"; |
|
4768
|
|
|
} |
|
4769
|
|
|
}, $code); |
|
4770
|
|
|
$code = preg_replace('/(<\/html[^>]*>)/i', "<!-- end template $templateName -->$1", $code); |
|
4771
|
|
|
} else { |
|
4772
|
|
|
$code = str_replace('<?php' . PHP_EOL, '<?php' . PHP_EOL . '$val .= \'<!-- template ' . $templateName . |
|
4773
|
|
|
' -->\';' . "\r\n", $code); |
|
4774
|
|
|
$code .= "\r\n" . '$val .= \'<!-- end template ' . $templateName . ' -->\';'; |
|
4775
|
|
|
} |
|
4776
|
|
|
return $code; |
|
4777
|
|
|
} |
|
4778
|
|
|
|
|
4779
|
|
|
/** |
|
4780
|
|
|
* Compiles some file that contains template source code, and returns the php code that will execute as per that |
|
4781
|
|
|
* source |
|
4782
|
|
|
* |
|
4783
|
|
|
* @static |
|
4784
|
|
|
* @param $template - A file path that contains template source code |
|
4785
|
|
|
* @return mixed|string - The php that, when executed (via include or exec) will behave as per the template source |
|
4786
|
|
|
*/ |
|
4787
|
|
|
public function compileFile($template) { |
|
4788
|
|
|
return $this->compileString(file_get_contents($template), $template); |
|
4789
|
|
|
} |
|
4790
|
|
|
} |
|
4791
|
|
|
|
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.