@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | /** |
300 | 300 | * method to compile a Smarty template |
301 | 301 | * |
302 | - * @param mixed $_content template source |
|
302 | + * @param string $_content template source |
|
303 | 303 | * @param bool $isTemplateSource |
304 | 304 | * |
305 | 305 | * @return bool true if compiling succeeded, false if it failed |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | * @param bool $nocache true is shall be compiled in nocache mode |
325 | 325 | * @param null|Smarty_Internal_TemplateCompilerBase $parent_compiler |
326 | 326 | * |
327 | - * @return bool true if compiling succeeded, false if it failed |
|
327 | + * @return string true if compiling succeeded, false if it failed |
|
328 | 328 | * @throws \Exception |
329 | 329 | */ |
330 | 330 | public function compileTemplate(Smarty_Internal_Template $template, $nocache = null, |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | * @param string $tag tag name |
842 | 842 | * @param array $args list of tag attributes |
843 | 843 | * @param mixed $param1 optional parameter |
844 | - * @param mixed $param2 optional parameter |
|
844 | + * @param string $param2 optional parameter |
|
845 | 845 | * @param mixed $param3 optional parameter |
846 | 846 | * |
847 | 847 | * @return string compiled code |
@@ -1052,7 +1052,7 @@ discard block |
||
1052 | 1052 | * |
1053 | 1053 | * @param string $input |
1054 | 1054 | * |
1055 | - * @return bool|string |
|
1055 | + * @return string|false |
|
1056 | 1056 | */ |
1057 | 1057 | public function getId($input) |
1058 | 1058 | { |
@@ -1067,7 +1067,7 @@ discard block |
||
1067 | 1067 | * |
1068 | 1068 | * @param string $input |
1069 | 1069 | * |
1070 | - * @return bool|string |
|
1070 | + * @return string|false |
|
1071 | 1071 | */ |
1072 | 1072 | public function getVariableName($input) |
1073 | 1073 | { |
@@ -23,1273 +23,1273 @@ |
||
23 | 23 | abstract class Smarty_Internal_TemplateCompilerBase |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * Smarty object |
|
28 | - * |
|
29 | - * @var Smarty |
|
30 | - */ |
|
31 | - public $smarty = null; |
|
32 | - |
|
33 | - /** |
|
34 | - * Parser object |
|
35 | - * |
|
36 | - * @var Smarty_Internal_Templateparser |
|
37 | - */ |
|
38 | - public $parser = null; |
|
39 | - |
|
40 | - /** |
|
41 | - * hash for nocache sections |
|
42 | - * |
|
43 | - * @var mixed |
|
44 | - */ |
|
45 | - public $nocache_hash = null; |
|
46 | - |
|
47 | - /** |
|
48 | - * suppress generation of nocache code |
|
49 | - * |
|
50 | - * @var bool |
|
51 | - */ |
|
52 | - public $suppressNocacheProcessing = false; |
|
53 | - |
|
54 | - /** |
|
55 | - * compile tag objects cache |
|
56 | - * |
|
57 | - * @var array |
|
58 | - */ |
|
59 | - static $_tag_objects = array(); |
|
60 | - |
|
61 | - /** |
|
62 | - * tag stack |
|
63 | - * |
|
64 | - * @var array |
|
65 | - */ |
|
66 | - public $_tag_stack = array(); |
|
67 | - |
|
68 | - /** |
|
69 | - * current template |
|
70 | - * |
|
71 | - * @var Smarty_Internal_Template |
|
72 | - */ |
|
73 | - public $template = null; |
|
74 | - |
|
75 | - /** |
|
76 | - * merged included sub template data |
|
77 | - * |
|
78 | - * @var array |
|
79 | - */ |
|
80 | - public $mergedSubTemplatesData = array(); |
|
81 | - |
|
82 | - /** |
|
83 | - * merged sub template code |
|
84 | - * |
|
85 | - * @var array |
|
86 | - */ |
|
87 | - public $mergedSubTemplatesCode = array(); |
|
88 | - |
|
89 | - /** |
|
90 | - * collected template properties during compilation |
|
91 | - * |
|
92 | - * @var array |
|
93 | - */ |
|
94 | - public $templateProperties = array(); |
|
95 | - |
|
96 | - /** |
|
97 | - * source line offset for error messages |
|
98 | - * |
|
99 | - * @var int |
|
100 | - */ |
|
101 | - public $trace_line_offset = 0; |
|
102 | - |
|
103 | - /** |
|
104 | - * trace uid |
|
105 | - * |
|
106 | - * @var string |
|
107 | - */ |
|
108 | - public $trace_uid = ''; |
|
109 | - |
|
110 | - /** |
|
111 | - * trace file path |
|
112 | - * |
|
113 | - * @var string |
|
114 | - */ |
|
115 | - public $trace_filepath = ''; |
|
116 | - |
|
117 | - /** |
|
118 | - * stack for tracing file and line of nested {block} tags |
|
119 | - * |
|
120 | - * @var array |
|
121 | - */ |
|
122 | - public $trace_stack = array(); |
|
123 | - |
|
124 | - /** |
|
125 | - * plugins loaded by default plugin handler |
|
126 | - * |
|
127 | - * @var array |
|
128 | - */ |
|
129 | - public $default_handler_plugins = array(); |
|
130 | - |
|
131 | - /** |
|
132 | - * saved preprocessed modifier list |
|
133 | - * |
|
134 | - * @var mixed |
|
135 | - */ |
|
136 | - public $default_modifier_list = null; |
|
137 | - |
|
138 | - /** |
|
139 | - * force compilation of complete template as nocache |
|
140 | - * |
|
141 | - * @var boolean |
|
142 | - */ |
|
143 | - public $forceNocache = false; |
|
144 | - |
|
145 | - /** |
|
146 | - * flag if compiled template file shall we written |
|
147 | - * |
|
148 | - * @var bool |
|
149 | - */ |
|
150 | - public $write_compiled_code = true; |
|
151 | - |
|
152 | - /** |
|
153 | - * Template functions |
|
154 | - * |
|
155 | - * @var array |
|
156 | - */ |
|
157 | - public $tpl_function = array(); |
|
158 | - |
|
159 | - /** |
|
160 | - * called sub functions from template function |
|
161 | - * |
|
162 | - * @var array |
|
163 | - */ |
|
164 | - public $called_functions = array(); |
|
165 | - |
|
166 | - /** |
|
167 | - * compiled template or block function code |
|
168 | - * |
|
169 | - * @var string |
|
170 | - */ |
|
171 | - public $blockOrFunctionCode = ''; |
|
172 | - |
|
173 | - /** |
|
174 | - * php_handling setting either from Smarty or security |
|
175 | - * |
|
176 | - * @var int |
|
177 | - */ |
|
178 | - public $php_handling = 0; |
|
179 | - |
|
180 | - /** |
|
181 | - * flags for used modifier plugins |
|
182 | - * |
|
183 | - * @var array |
|
184 | - */ |
|
185 | - public $modifier_plugins = array(); |
|
186 | - |
|
187 | - /** |
|
188 | - * type of already compiled modifier |
|
189 | - * |
|
190 | - * @var array |
|
191 | - */ |
|
192 | - public $known_modifier_type = array(); |
|
193 | - |
|
194 | - /** |
|
195 | - * parent compiler object for merged subtemplates and template functions |
|
196 | - * |
|
197 | - * @var Smarty_Internal_TemplateCompilerBase |
|
198 | - */ |
|
199 | - public $parent_compiler = null; |
|
200 | - |
|
201 | - /** |
|
202 | - * Flag true when compiling nocache section |
|
203 | - * |
|
204 | - * @var bool |
|
205 | - */ |
|
206 | - public $nocache = false; |
|
207 | - |
|
208 | - /** |
|
209 | - * Flag true when tag is compiled as nocache |
|
210 | - * |
|
211 | - * @var bool |
|
212 | - */ |
|
213 | - public $tag_nocache = false; |
|
214 | - |
|
215 | - /** |
|
216 | - * Compiled tag prefix code |
|
217 | - * |
|
218 | - * @var array |
|
219 | - */ |
|
220 | - public $prefix_code = array(); |
|
221 | - |
|
222 | - /** |
|
223 | - * Prefix code stack |
|
224 | - * |
|
225 | - * @var array |
|
226 | - */ |
|
227 | - public $prefixCodeStack = array(); |
|
228 | - |
|
229 | - /** |
|
230 | - * Tag has compiled code |
|
231 | - * |
|
232 | - * @var bool |
|
233 | - */ |
|
234 | - public $has_code = false; |
|
235 | - |
|
236 | - /** |
|
237 | - * A variable string was compiled |
|
238 | - * |
|
239 | - * @var bool |
|
240 | - */ |
|
241 | - public $has_variable_string = false; |
|
242 | - |
|
243 | - /** |
|
244 | - * Tag creates output |
|
245 | - * |
|
246 | - * @var bool |
|
247 | - */ |
|
248 | - public $has_output = false; |
|
249 | - |
|
250 | - /** |
|
251 | - * Stack for {setfilter} {/setfilter} |
|
252 | - * |
|
253 | - * @var array |
|
254 | - */ |
|
255 | - public $variable_filter_stack = array(); |
|
256 | - |
|
257 | - /** |
|
258 | - * variable filters for {setfilter} {/setfilter} |
|
259 | - * |
|
260 | - * @var array |
|
261 | - */ |
|
262 | - public $variable_filters = array(); |
|
263 | - |
|
264 | - /** |
|
265 | - * Nesting count of looping tags like {foreach}, {for}, {section}, {while} |
|
266 | - * |
|
267 | - * @var int |
|
268 | - */ |
|
269 | - public $loopNesting = 0; |
|
270 | - |
|
271 | - /** |
|
272 | - * Strip preg pattern |
|
273 | - * |
|
274 | - * @var string |
|
275 | - */ |
|
276 | - public $stripRegEx = '![\t ]*[\r\n]+[\t ]*!'; |
|
277 | - |
|
278 | - /** |
|
279 | - * plugin search order |
|
280 | - * |
|
281 | - * @var array |
|
282 | - */ |
|
283 | - public $plugin_search_order = array('function', 'block', 'compiler', 'class'); |
|
284 | - |
|
285 | - /** |
|
286 | - * General storage area for tag compiler plugins |
|
287 | - * |
|
288 | - * @var array |
|
289 | - */ |
|
290 | - public $_cache = array(); |
|
291 | - |
|
292 | - /** |
|
293 | - * counter for prefix variable number |
|
294 | - * |
|
295 | - * @var int |
|
296 | - */ |
|
297 | - public static $prefixVariableNumber = 0; |
|
298 | - |
|
299 | - /** |
|
300 | - * method to compile a Smarty template |
|
301 | - * |
|
302 | - * @param mixed $_content template source |
|
303 | - * @param bool $isTemplateSource |
|
304 | - * |
|
305 | - * @return bool true if compiling succeeded, false if it failed |
|
306 | - */ |
|
307 | - abstract protected function doCompile($_content, $isTemplateSource = false); |
|
308 | - |
|
309 | - /** |
|
310 | - * Initialize compiler |
|
311 | - * |
|
312 | - * @param Smarty $smarty global instance |
|
313 | - */ |
|
314 | - public function __construct(Smarty $smarty) |
|
315 | - { |
|
316 | - $this->smarty = $smarty; |
|
317 | - $this->nocache_hash = str_replace(array('.', ','), '_', uniqid(rand(), true)); |
|
318 | - } |
|
319 | - |
|
320 | - /** |
|
321 | - * Method to compile a Smarty template |
|
322 | - * |
|
323 | - * @param Smarty_Internal_Template $template template object to compile |
|
324 | - * @param bool $nocache true is shall be compiled in nocache mode |
|
325 | - * @param null|Smarty_Internal_TemplateCompilerBase $parent_compiler |
|
326 | - * |
|
327 | - * @return bool true if compiling succeeded, false if it failed |
|
328 | - * @throws \Exception |
|
329 | - */ |
|
330 | - public function compileTemplate(Smarty_Internal_Template $template, $nocache = null, |
|
331 | - Smarty_Internal_TemplateCompilerBase $parent_compiler = null) |
|
332 | - { |
|
333 | - // get code frame of compiled template |
|
334 | - $_compiled_code = $template->smarty->ext->_codeFrame->create($template, |
|
335 | - $this->compileTemplateSource($template, $nocache, |
|
336 | - $parent_compiler), |
|
337 | - $this->postFilter($this->blockOrFunctionCode) . |
|
338 | - join('', $this->mergedSubTemplatesCode), false, |
|
339 | - $this); |
|
340 | - return $_compiled_code; |
|
341 | - } |
|
342 | - |
|
343 | - /** |
|
344 | - * Compile template source and run optional post filter |
|
345 | - * |
|
346 | - * @param \Smarty_Internal_Template $template |
|
347 | - * @param null|bool $nocache flag if template must be compiled in nocache mode |
|
348 | - * @param \Smarty_Internal_TemplateCompilerBase $parent_compiler |
|
349 | - * |
|
350 | - * @return string |
|
351 | - * @throws \Exception |
|
352 | - */ |
|
353 | - public function compileTemplateSource(Smarty_Internal_Template $template, $nocache = null, |
|
354 | - Smarty_Internal_TemplateCompilerBase $parent_compiler = null) |
|
355 | - { |
|
356 | - try { |
|
357 | - // save template object in compiler class |
|
358 | - $this->template = $template; |
|
359 | - if (property_exists($this->template->smarty, 'plugin_search_order')) { |
|
360 | - $this->plugin_search_order = $this->template->smarty->plugin_search_order; |
|
361 | - } |
|
362 | - if ($this->smarty->debugging) { |
|
363 | - if (!isset($this->smarty->_debug)) { |
|
364 | - $this->smarty->_debug = new Smarty_Internal_Debug(); |
|
365 | - } |
|
366 | - $this->smarty->_debug->start_compile($this->template); |
|
367 | - } |
|
368 | - if (isset($this->template->smarty->security_policy)) { |
|
369 | - $this->php_handling = $this->template->smarty->security_policy->php_handling; |
|
370 | - } else { |
|
371 | - $this->php_handling = $this->template->smarty->php_handling; |
|
372 | - } |
|
373 | - $this->parent_compiler = $parent_compiler ? $parent_compiler : $this; |
|
374 | - $nocache = isset($nocache) ? $nocache : false; |
|
375 | - if (empty($template->compiled->nocache_hash)) { |
|
376 | - $template->compiled->nocache_hash = $this->nocache_hash; |
|
377 | - } else { |
|
378 | - $this->nocache_hash = $template->compiled->nocache_hash; |
|
379 | - } |
|
380 | - // flag for nocache sections |
|
381 | - $this->nocache = $nocache; |
|
382 | - $this->tag_nocache = false; |
|
383 | - // reset has nocache code flag |
|
384 | - $this->template->compiled->has_nocache_code = false; |
|
385 | - $this->has_variable_string = false; |
|
386 | - $this->prefix_code = array(); |
|
387 | - // add file dependency |
|
388 | - if ($this->smarty->merge_compiled_includes || $this->template->source->handler->checkTimestamps()) { |
|
389 | - $this->parent_compiler->template->compiled->file_dependency[ $this->template->source->uid ] = |
|
390 | - array($this->template->source->filepath, $this->template->source->getTimeStamp(), |
|
391 | - $this->template->source->type,); |
|
392 | - } |
|
393 | - $this->smarty->_current_file = $this->template->source->filepath; |
|
394 | - // get template source |
|
395 | - if (!empty($this->template->source->components)) { |
|
396 | - // we have array of inheritance templates by extends: resource |
|
397 | - // generate corresponding source code sequence |
|
398 | - $_content = |
|
399 | - Smarty_Internal_Compile_Extends::extendsSourceArrayCode($this->template->source->components); |
|
400 | - } else { |
|
401 | - // get template source |
|
402 | - $_content = $this->template->source->getContent(); |
|
403 | - } |
|
404 | - $_compiled_code = $this->postFilter($this->doCompile($this->preFilter($_content), true)); |
|
405 | - } |
|
406 | - catch (Exception $e) { |
|
407 | - if ($this->smarty->debugging) { |
|
408 | - $this->smarty->_debug->end_compile($this->template); |
|
409 | - } |
|
410 | - $this->_tag_stack = array(); |
|
411 | - // free memory |
|
412 | - $this->parent_compiler = null; |
|
413 | - $this->template = null; |
|
414 | - $this->parser = null; |
|
415 | - throw $e; |
|
416 | - } |
|
417 | - if ($this->smarty->debugging) { |
|
418 | - $this->smarty->_debug->end_compile($this->template); |
|
419 | - } |
|
420 | - $this->parent_compiler = null; |
|
421 | - $this->parser = null; |
|
422 | - return $_compiled_code; |
|
423 | - } |
|
424 | - |
|
425 | - /** |
|
426 | - * Optionally process compiled code by post filter |
|
427 | - * |
|
428 | - * @param string $code compiled code |
|
429 | - * |
|
430 | - * @return string |
|
431 | - * @throws \SmartyException |
|
432 | - */ |
|
433 | - public function postFilter($code) |
|
434 | - { |
|
435 | - // run post filter if on code |
|
436 | - if (!empty($code) && |
|
437 | - (isset($this->smarty->autoload_filters[ 'post' ]) || isset($this->smarty->registered_filters[ 'post' ])) |
|
438 | - ) { |
|
439 | - return $this->smarty->ext->_filterHandler->runFilter('post', $code, $this->template); |
|
440 | - } else { |
|
441 | - return $code; |
|
442 | - } |
|
443 | - } |
|
444 | - |
|
445 | - /** |
|
446 | - * Run optional prefilter |
|
447 | - * |
|
448 | - * @param string $_content template source |
|
449 | - * |
|
450 | - * @return string |
|
451 | - * @throws \SmartyException |
|
452 | - */ |
|
453 | - public function preFilter($_content) |
|
454 | - { |
|
455 | - // run pre filter if required |
|
456 | - if ($_content != '' && |
|
457 | - ((isset($this->smarty->autoload_filters[ 'pre' ]) || isset($this->smarty->registered_filters[ 'pre' ]))) |
|
458 | - ) { |
|
459 | - return $this->smarty->ext->_filterHandler->runFilter('pre', $_content, $this->template); |
|
460 | - } else { |
|
461 | - return $_content; |
|
462 | - } |
|
463 | - } |
|
464 | - |
|
465 | - /** |
|
466 | - * Compile Tag |
|
467 | - * This is a call back from the lexer/parser |
|
468 | - * |
|
469 | - * Save current prefix code |
|
470 | - * Compile tag |
|
471 | - * Merge tag prefix code with saved one |
|
472 | - * (required nested tags in attributes) |
|
473 | - * |
|
474 | - * @param string $tag tag name |
|
475 | - * @param array $args array with tag attributes |
|
476 | - * @param array $parameter array with compilation parameter |
|
477 | - * |
|
478 | - * @throws SmartyCompilerException |
|
479 | - * @throws SmartyException |
|
480 | - * @return string compiled code |
|
481 | - */ |
|
482 | - public function compileTag($tag, $args, $parameter = array()) |
|
483 | - { |
|
484 | - $this->prefixCodeStack[] = $this->prefix_code; |
|
485 | - $this->prefix_code = array(); |
|
486 | - $result = $this->compileTag2($tag, $args, $parameter); |
|
487 | - $this->prefix_code = array_merge($this->prefix_code, array_pop($this->prefixCodeStack)); |
|
488 | - return $result; |
|
489 | - } |
|
490 | - |
|
491 | - /** |
|
492 | - * Compile Tag |
|
493 | - * |
|
494 | - * @param string $tag tag name |
|
495 | - * @param array $args array with tag attributes |
|
496 | - * @param array $parameter array with compilation parameter |
|
497 | - * |
|
498 | - * @throws SmartyCompilerException |
|
499 | - * @throws SmartyException |
|
500 | - * @return string compiled code |
|
501 | - */ |
|
502 | - private function compileTag2($tag, $args, $parameter) |
|
503 | - { |
|
504 | - $plugin_type = ''; |
|
505 | - // $args contains the attributes parsed and compiled by the lexer/parser |
|
506 | - // assume that tag does compile into code, but creates no HTML output |
|
507 | - $this->has_code = true; |
|
508 | - $this->has_output = false; |
|
509 | - // log tag/attributes |
|
510 | - if (isset($this->smarty->_cache[ 'get_used_tags' ])) { |
|
511 | - $this->template->_cache[ 'used_tags' ][] = array($tag, $args); |
|
512 | - } |
|
513 | - // check nocache option flag |
|
514 | - foreach ($args as $arg) { |
|
515 | - if (!is_array($arg)) { |
|
516 | - if ($arg == "'nocache'") { |
|
517 | - $this->tag_nocache = true; |
|
518 | - } |
|
519 | - } else { |
|
520 | - foreach ($arg as $k => $v) { |
|
521 | - if ($k == "'nocache'" && (trim($v, "'\" ") == 'true')) { |
|
522 | - $this->tag_nocache = true; |
|
523 | - } |
|
524 | - } |
|
525 | - } |
|
526 | - } |
|
527 | - // compile the smarty tag (required compile classes to compile the tag are auto loaded) |
|
528 | - if (($_output = $this->callTagCompiler($tag, $args, $parameter)) === false) { |
|
529 | - if (isset($this->parent_compiler->tpl_function[ $tag ])) { |
|
530 | - // template defined by {template} tag |
|
531 | - $args[ '_attr' ][ 'name' ] = "'" . $tag . "'"; |
|
532 | - $_output = $this->callTagCompiler('call', $args, $parameter); |
|
533 | - } |
|
534 | - } |
|
535 | - if ($_output !== false) { |
|
536 | - if ($_output !== true) { |
|
537 | - // did we get compiled code |
|
538 | - if ($this->has_code) { |
|
539 | - // Does it create output? |
|
540 | - if ($this->has_output) { |
|
541 | - $_output .= "\n"; |
|
542 | - } |
|
543 | - // return compiled code |
|
544 | - return $_output; |
|
545 | - } |
|
546 | - } |
|
547 | - // tag did not produce compiled code |
|
548 | - return null; |
|
549 | - } else { |
|
550 | - // map_named attributes |
|
551 | - if (isset($args[ '_attr' ])) { |
|
552 | - foreach ($args[ '_attr' ] as $key => $attribute) { |
|
553 | - if (is_array($attribute)) { |
|
554 | - $args = array_merge($args, $attribute); |
|
555 | - } |
|
556 | - } |
|
557 | - } |
|
558 | - // not an internal compiler tag |
|
559 | - if (strlen($tag) < 6 || substr($tag, - 5) != 'close') { |
|
560 | - // check if tag is a registered object |
|
561 | - if (isset($this->smarty->registered_objects[ $tag ]) && isset($parameter[ 'object_method' ])) { |
|
562 | - $method = $parameter[ 'object_method' ]; |
|
563 | - if (!in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ]) && |
|
564 | - (empty($this->smarty->registered_objects[ $tag ][ 1 ]) || |
|
565 | - in_array($method, $this->smarty->registered_objects[ $tag ][ 1 ])) |
|
566 | - ) { |
|
567 | - return $this->callTagCompiler('private_object_function', $args, $parameter, $tag, $method); |
|
568 | - } elseif (in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ])) { |
|
569 | - return $this->callTagCompiler('private_object_block_function', $args, $parameter, $tag, |
|
570 | - $method); |
|
571 | - } else { |
|
572 | - // throw exception |
|
573 | - $this->trigger_template_error('not allowed method "' . $method . '" in registered object "' . |
|
574 | - $tag . '"', null, true); |
|
575 | - } |
|
576 | - } |
|
577 | - // check if tag is registered |
|
578 | - foreach (array(Smarty::PLUGIN_COMPILER, Smarty::PLUGIN_FUNCTION, Smarty::PLUGIN_BLOCK,) as $plugin_type) |
|
579 | - { |
|
580 | - if (isset($this->smarty->registered_plugins[ $plugin_type ][ $tag ])) { |
|
581 | - // if compiler function plugin call it now |
|
582 | - if ($plugin_type == Smarty::PLUGIN_COMPILER) { |
|
583 | - $new_args = array(); |
|
584 | - foreach ($args as $key => $mixed) { |
|
585 | - if (is_array($mixed)) { |
|
586 | - $new_args = array_merge($new_args, $mixed); |
|
587 | - } else { |
|
588 | - $new_args[ $key ] = $mixed; |
|
589 | - } |
|
590 | - } |
|
591 | - if (!$this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 1 ]) { |
|
592 | - $this->tag_nocache = true; |
|
593 | - } |
|
594 | - return call_user_func_array($this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 0 ], |
|
595 | - array($new_args, $this)); |
|
596 | - } |
|
597 | - // compile registered function or block function |
|
598 | - if ($plugin_type == Smarty::PLUGIN_FUNCTION || $plugin_type == Smarty::PLUGIN_BLOCK) { |
|
599 | - return $this->callTagCompiler('private_registered_' . $plugin_type, $args, $parameter, |
|
600 | - $tag); |
|
601 | - } |
|
602 | - } |
|
603 | - } |
|
604 | - // check plugins from plugins folder |
|
605 | - foreach ($this->plugin_search_order as $plugin_type) { |
|
606 | - if ($plugin_type == Smarty::PLUGIN_COMPILER && |
|
607 | - $this->smarty->loadPlugin('smarty_compiler_' . $tag) && |
|
608 | - (!isset($this->smarty->security_policy) || |
|
609 | - $this->smarty->security_policy->isTrustedTag($tag, $this)) |
|
610 | - ) { |
|
611 | - $plugin = 'smarty_compiler_' . $tag; |
|
612 | - if (is_callable($plugin)) { |
|
613 | - // convert arguments format for old compiler plugins |
|
614 | - $new_args = array(); |
|
615 | - foreach ($args as $key => $mixed) { |
|
616 | - if (is_array($mixed)) { |
|
617 | - $new_args = array_merge($new_args, $mixed); |
|
618 | - } else { |
|
619 | - $new_args[ $key ] = $mixed; |
|
620 | - } |
|
621 | - } |
|
622 | - |
|
623 | - return $plugin($new_args, $this->smarty); |
|
624 | - } |
|
625 | - if (class_exists($plugin, false)) { |
|
626 | - $plugin_object = new $plugin; |
|
627 | - if (method_exists($plugin_object, 'compile')) { |
|
628 | - return $plugin_object->compile($args, $this); |
|
629 | - } |
|
630 | - } |
|
631 | - throw new SmartyException("Plugin \"{$tag}\" not callable"); |
|
632 | - } else { |
|
633 | - if ($function = $this->getPlugin($tag, $plugin_type)) { |
|
634 | - if (!isset($this->smarty->security_policy) || |
|
635 | - $this->smarty->security_policy->isTrustedTag($tag, $this) |
|
636 | - ) { |
|
637 | - return $this->callTagCompiler('private_' . $plugin_type . '_plugin', $args, $parameter, |
|
638 | - $tag, $function); |
|
639 | - } |
|
640 | - } |
|
641 | - } |
|
642 | - } |
|
643 | - if (is_callable($this->smarty->default_plugin_handler_func)) { |
|
644 | - $found = false; |
|
645 | - // look for already resolved tags |
|
646 | - foreach ($this->plugin_search_order as $plugin_type) { |
|
647 | - if (isset($this->default_handler_plugins[ $plugin_type ][ $tag ])) { |
|
648 | - $found = true; |
|
649 | - break; |
|
650 | - } |
|
651 | - } |
|
652 | - if (!$found) { |
|
653 | - // call default handler |
|
654 | - foreach ($this->plugin_search_order as $plugin_type) { |
|
655 | - if ($this->getPluginFromDefaultHandler($tag, $plugin_type)) { |
|
656 | - $found = true; |
|
657 | - break; |
|
658 | - } |
|
659 | - } |
|
660 | - } |
|
661 | - if ($found) { |
|
662 | - // if compiler function plugin call it now |
|
663 | - if ($plugin_type == Smarty::PLUGIN_COMPILER) { |
|
664 | - $new_args = array(); |
|
665 | - foreach ($args as $mixed) { |
|
666 | - $new_args = array_merge($new_args, $mixed); |
|
667 | - } |
|
668 | - return call_user_func_array($this->default_handler_plugins[ $plugin_type ][ $tag ][ 0 ], |
|
669 | - array($new_args, $this)); |
|
670 | - } else { |
|
671 | - return $this->callTagCompiler('private_registered_' . $plugin_type, $args, $parameter, |
|
672 | - $tag); |
|
673 | - } |
|
674 | - } |
|
675 | - } |
|
676 | - } else { |
|
677 | - // compile closing tag of block function |
|
678 | - $base_tag = substr($tag, 0, - 5); |
|
679 | - // check if closing tag is a registered object |
|
680 | - if (isset($this->smarty->registered_objects[ $base_tag ]) && isset($parameter[ 'object_method' ])) { |
|
681 | - $method = $parameter[ 'object_method' ]; |
|
682 | - if (in_array($method, $this->smarty->registered_objects[ $base_tag ][ 3 ])) { |
|
683 | - return $this->callTagCompiler('private_object_block_function', $args, $parameter, $tag, |
|
684 | - $method); |
|
685 | - } else { |
|
686 | - // throw exception |
|
687 | - $this->trigger_template_error('not allowed closing tag method "' . $method . |
|
688 | - '" in registered object "' . $base_tag . '"', null, true); |
|
689 | - } |
|
690 | - } |
|
691 | - // registered block tag ? |
|
692 | - if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ]) || |
|
693 | - isset($this->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ]) |
|
694 | - ) { |
|
695 | - return $this->callTagCompiler('private_registered_block', $args, $parameter, $tag); |
|
696 | - } |
|
697 | - // registered function tag ? |
|
698 | - if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ])) { |
|
699 | - return $this->callTagCompiler('private_registered_function', $args, $parameter, $tag); |
|
700 | - } |
|
701 | - // block plugin? |
|
702 | - if ($function = $this->getPlugin($base_tag, Smarty::PLUGIN_BLOCK)) { |
|
703 | - return $this->callTagCompiler('private_block_plugin', $args, $parameter, $tag, $function); |
|
704 | - } |
|
705 | - // function plugin? |
|
706 | - if ($function = $this->getPlugin($tag, Smarty::PLUGIN_FUNCTION)) { |
|
707 | - if (!isset($this->smarty->security_policy) || |
|
708 | - $this->smarty->security_policy->isTrustedTag($tag, $this) |
|
709 | - ) { |
|
710 | - return $this->callTagCompiler('private_function_plugin', $args, $parameter, $tag, $function); |
|
711 | - } |
|
712 | - } |
|
713 | - // registered compiler plugin ? |
|
714 | - if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ])) { |
|
715 | - // if compiler function plugin call it now |
|
716 | - $args = array(); |
|
717 | - if (!$this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 1 ]) { |
|
718 | - $this->tag_nocache = true; |
|
719 | - } |
|
720 | - return call_user_func_array($this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 0 ], |
|
721 | - array($args, $this)); |
|
722 | - } |
|
723 | - if ($this->smarty->loadPlugin('smarty_compiler_' . $tag)) { |
|
724 | - $plugin = 'smarty_compiler_' . $tag; |
|
725 | - if (is_callable($plugin)) { |
|
726 | - return $plugin($args, $this->smarty); |
|
727 | - } |
|
728 | - if (class_exists($plugin, false)) { |
|
729 | - $plugin_object = new $plugin; |
|
730 | - if (method_exists($plugin_object, 'compile')) { |
|
731 | - return $plugin_object->compile($args, $this); |
|
732 | - } |
|
733 | - } |
|
734 | - throw new SmartyException("Plugin \"{$tag}\" not callable"); |
|
735 | - } |
|
736 | - } |
|
737 | - $this->trigger_template_error("unknown tag \"" . $tag . "\"", null, true); |
|
738 | - } |
|
739 | - } |
|
740 | - |
|
741 | - /** |
|
742 | - * compile variable |
|
743 | - * |
|
744 | - * @param string $variable |
|
745 | - * |
|
746 | - * @return string |
|
747 | - */ |
|
748 | - public function compileVariable($variable) |
|
749 | - { |
|
750 | - if (strpos($variable, '(') == 0) { |
|
751 | - // not a variable variable |
|
752 | - $var = trim($variable, '\''); |
|
753 | - $this->tag_nocache = $this->tag_nocache | |
|
754 | - $this->template->ext->getTemplateVars->_getVariable($this->template, $var, null, true, |
|
755 | - false)->nocache; |
|
756 | - // todo $this->template->compiled->properties['variables'][$var] = $this->tag_nocache | $this->nocache; |
|
757 | - } |
|
758 | - return '$_smarty_tpl->tpl_vars[' . $variable . ']->value'; |
|
759 | - } |
|
760 | - |
|
761 | - /** |
|
762 | - * compile config variable |
|
763 | - * |
|
764 | - * @param string $variable |
|
765 | - * |
|
766 | - * @return string |
|
767 | - */ |
|
768 | - public function compileConfigVariable($variable) |
|
769 | - { |
|
770 | - // return '$_smarty_tpl->config_vars[' . $variable . ']'; |
|
771 | - return '$_smarty_tpl->smarty->ext->configLoad->_getConfigVariable($_smarty_tpl, ' . $variable . ')'; |
|
772 | - } |
|
773 | - |
|
774 | - /** |
|
775 | - * This method is called from parser to process a text content section |
|
776 | - * - remove text from inheritance child templates as they may generate output |
|
777 | - * - strip text if strip is enabled |
|
778 | - * |
|
779 | - * @param string $text |
|
780 | - * |
|
781 | - * @return null|\Smarty_Internal_ParseTree_Text |
|
782 | - */ |
|
783 | - public function processText($text) |
|
784 | - { |
|
785 | - if ((string) $text != '') { |
|
786 | - $store = array(); |
|
787 | - $_store = 0; |
|
788 | - if ($this->parser->strip) { |
|
789 | - if (strpos($text, '<') !== false) { |
|
790 | - // capture html elements not to be messed with |
|
791 | - $_offset = 0; |
|
792 | - if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is', |
|
793 | - $text, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
794 | - foreach ($matches as $match) { |
|
795 | - $store[] = $match[ 0 ][ 0 ]; |
|
796 | - $_length = strlen($match[ 0 ][ 0 ]); |
|
797 | - $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; |
|
798 | - $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); |
|
799 | - |
|
800 | - $_offset += $_length - strlen($replace); |
|
801 | - $_store ++; |
|
802 | - } |
|
803 | - } |
|
804 | - $expressions = array(// replace multiple spaces between tags by a single space |
|
805 | - '#(:SMARTY@!@|>)[\040\011]+(?=@!@SMARTY:|<)#s' => '\1 \2', |
|
806 | - // remove newline between tags |
|
807 | - '#(:SMARTY@!@|>)[\040\011]*[\n]\s*(?=@!@SMARTY:|<)#s' => '\1\2', |
|
808 | - // remove multiple spaces between attributes (but not in attribute values!) |
|
809 | - '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5', |
|
810 | - '#>[\040\011]+$#Ss' => '> ', '#>[\040\011]*[\n]\s*$#Ss' => '>', |
|
811 | - $this->stripRegEx => '',); |
|
812 | - |
|
813 | - $text = preg_replace(array_keys($expressions), array_values($expressions), $text); |
|
814 | - $_offset = 0; |
|
815 | - if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $text, $matches, |
|
816 | - PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
817 | - foreach ($matches as $match) { |
|
818 | - $_length = strlen($match[ 0 ][ 0 ]); |
|
819 | - $replace = $store[ $match[ 1 ][ 0 ] ]; |
|
820 | - $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] + $_offset, $_length); |
|
821 | - |
|
822 | - $_offset += strlen($replace) - $_length; |
|
823 | - $_store ++; |
|
824 | - } |
|
825 | - } |
|
826 | - } else { |
|
827 | - $text = preg_replace($this->stripRegEx, '', $text); |
|
828 | - } |
|
829 | - } |
|
830 | - return new Smarty_Internal_ParseTree_Text($text); |
|
831 | - } |
|
832 | - return null; |
|
833 | - } |
|
834 | - |
|
835 | - /** |
|
836 | - * lazy loads internal compile plugin for tag and calls the compile method |
|
837 | - * compile objects cached for reuse. |
|
838 | - * class name format: Smarty_Internal_Compile_TagName |
|
839 | - * plugin filename format: Smarty_Internal_TagName.php |
|
840 | - * |
|
841 | - * @param string $tag tag name |
|
842 | - * @param array $args list of tag attributes |
|
843 | - * @param mixed $param1 optional parameter |
|
844 | - * @param mixed $param2 optional parameter |
|
845 | - * @param mixed $param3 optional parameter |
|
846 | - * |
|
847 | - * @return string compiled code |
|
848 | - */ |
|
849 | - public function callTagCompiler($tag, $args, $param1 = null, $param2 = null, $param3 = null) |
|
850 | - { |
|
851 | - // re-use object if already exists |
|
852 | - if (!isset(self::$_tag_objects[ $tag ])) { |
|
853 | - // lazy load internal compiler plugin |
|
854 | - $_tag = explode('_', $tag); |
|
855 | - $_tag = array_map('ucfirst', $_tag); |
|
856 | - $class_name = 'Smarty_Internal_Compile_' . implode('_', $_tag); |
|
857 | - if (class_exists($class_name) && |
|
858 | - (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this)) |
|
859 | - ) { |
|
860 | - self::$_tag_objects[ $tag ] = new $class_name; |
|
861 | - } else { |
|
862 | - self::$_tag_objects[ $tag ] = false; |
|
863 | - return false; |
|
864 | - } |
|
865 | - } |
|
866 | - // compile this tag |
|
867 | - return self::$_tag_objects[ $tag ] === false ? false : |
|
868 | - self::$_tag_objects[ $tag ]->compile($args, $this, $param1, $param2, $param3); |
|
869 | - } |
|
870 | - |
|
871 | - /** |
|
872 | - * Check for plugins and return function name |
|
873 | - * |
|
874 | - * @param $plugin_name |
|
875 | - * @param string $plugin_type type of plugin |
|
876 | - * |
|
877 | - * @return string call name of function |
|
878 | - */ |
|
879 | - public function getPlugin($plugin_name, $plugin_type) |
|
880 | - { |
|
881 | - $function = null; |
|
882 | - if ($this->template->caching && ($this->nocache || $this->tag_nocache)) { |
|
883 | - if (isset($this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ])) { |
|
884 | - $function = |
|
885 | - $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ]; |
|
886 | - } elseif (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ])) { |
|
887 | - $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ] = |
|
888 | - $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ]; |
|
889 | - $function = |
|
890 | - $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ]; |
|
891 | - } |
|
892 | - } else { |
|
893 | - if (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ])) { |
|
894 | - $function = |
|
895 | - $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ]; |
|
896 | - } elseif (isset($this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ])) { |
|
897 | - $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ] = |
|
898 | - $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ]; |
|
899 | - $function = |
|
900 | - $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ]; |
|
901 | - } |
|
902 | - } |
|
903 | - if (isset($function)) { |
|
904 | - if ($plugin_type == 'modifier') { |
|
905 | - $this->modifier_plugins[ $plugin_name ] = true; |
|
906 | - } |
|
907 | - |
|
908 | - return $function; |
|
909 | - } |
|
910 | - // loop through plugin dirs and find the plugin |
|
911 | - $function = 'smarty_' . $plugin_type . '_' . $plugin_name; |
|
912 | - $file = $this->smarty->loadPlugin($function, false); |
|
913 | - |
|
914 | - if (is_string($file)) { |
|
915 | - if ($this->template->caching && ($this->nocache || $this->tag_nocache)) { |
|
916 | - $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'file' ] = |
|
917 | - $file; |
|
918 | - $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ] = |
|
919 | - $function; |
|
920 | - } else { |
|
921 | - $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'file' ] = |
|
922 | - $file; |
|
923 | - $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ] = |
|
924 | - $function; |
|
925 | - } |
|
926 | - if ($plugin_type == 'modifier') { |
|
927 | - $this->modifier_plugins[ $plugin_name ] = true; |
|
928 | - } |
|
929 | - |
|
930 | - return $function; |
|
931 | - } |
|
932 | - if (is_callable($function)) { |
|
933 | - // plugin function is defined in the script |
|
934 | - return $function; |
|
935 | - } |
|
936 | - |
|
937 | - return false; |
|
938 | - } |
|
939 | - |
|
940 | - /** |
|
941 | - * Check for plugins by default plugin handler |
|
942 | - * |
|
943 | - * @param string $tag name of tag |
|
944 | - * @param string $plugin_type type of plugin |
|
945 | - * |
|
946 | - * @return boolean true if found |
|
947 | - */ |
|
948 | - public function getPluginFromDefaultHandler($tag, $plugin_type) |
|
949 | - { |
|
950 | - $callback = null; |
|
951 | - $script = null; |
|
952 | - $cacheable = true; |
|
953 | - $result = call_user_func_array($this->smarty->default_plugin_handler_func, |
|
954 | - array($tag, $plugin_type, $this->template, &$callback, &$script, &$cacheable,)); |
|
955 | - if ($result) { |
|
956 | - $this->tag_nocache = $this->tag_nocache || !$cacheable; |
|
957 | - if ($script !== null) { |
|
958 | - if (is_file($script)) { |
|
959 | - if ($this->template->caching && ($this->nocache || $this->tag_nocache)) { |
|
960 | - $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $tag ][ $plugin_type ][ 'file' ] = |
|
961 | - $script; |
|
962 | - $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $tag ][ $plugin_type ][ 'function' ] = |
|
963 | - $callback; |
|
964 | - } else { |
|
965 | - $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $tag ][ $plugin_type ][ 'file' ] = |
|
966 | - $script; |
|
967 | - $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $tag ][ $plugin_type ][ 'function' ] = |
|
968 | - $callback; |
|
969 | - } |
|
970 | - require_once $script; |
|
971 | - } else { |
|
972 | - $this->trigger_template_error("Default plugin handler: Returned script file \"{$script}\" for \"{$tag}\" not found"); |
|
973 | - } |
|
974 | - } |
|
975 | - if (is_callable($callback)) { |
|
976 | - $this->default_handler_plugins[ $plugin_type ][ $tag ] = array($callback, true, array()); |
|
977 | - |
|
978 | - return true; |
|
979 | - } else { |
|
980 | - $this->trigger_template_error("Default plugin handler: Returned callback for \"{$tag}\" not callable"); |
|
981 | - } |
|
982 | - } |
|
983 | - |
|
984 | - return false; |
|
985 | - } |
|
986 | - |
|
987 | - /** |
|
988 | - * Append code segments and remove unneeded ?> <?php transitions |
|
989 | - * |
|
990 | - * @param string $left |
|
991 | - * @param string $right |
|
992 | - * |
|
993 | - * @return string |
|
994 | - */ |
|
995 | - public function appendCode($left, $right) |
|
996 | - { |
|
997 | - if (preg_match('/\s*\?>\s*$/', $left) && preg_match('/^\s*<\?php\s+/', $right)) { |
|
998 | - $left = preg_replace('/\s*\?>\s*$/', "\n", $left); |
|
999 | - $left .= preg_replace('/^\s*<\?php\s+/', '', $right); |
|
1000 | - } else { |
|
1001 | - $left .= $right; |
|
1002 | - } |
|
1003 | - return $left; |
|
1004 | - } |
|
1005 | - |
|
1006 | - /** |
|
1007 | - * Inject inline code for nocache template sections |
|
1008 | - * This method gets the content of each template element from the parser. |
|
1009 | - * If the content is compiled code and it should be not cached the code is injected |
|
1010 | - * into the rendered output. |
|
1011 | - * |
|
1012 | - * @param string $content content of template element |
|
1013 | - * @param boolean $is_code true if content is compiled code |
|
1014 | - * |
|
1015 | - * @return string content |
|
1016 | - */ |
|
1017 | - public function processNocacheCode($content, $is_code) |
|
1018 | - { |
|
1019 | - // If the template is not evaluated and we have a nocache section and or a nocache tag |
|
1020 | - if ($is_code && !empty($content)) { |
|
1021 | - // generate replacement code |
|
1022 | - if ((!($this->template->source->handler->recompiled) || $this->forceNocache) && $this->template->caching && |
|
1023 | - !$this->suppressNocacheProcessing && ($this->nocache || $this->tag_nocache) |
|
1024 | - ) { |
|
1025 | - $this->template->compiled->has_nocache_code = true; |
|
1026 | - $_output = addcslashes($content, '\'\\'); |
|
1027 | - $_output = str_replace("^#^", "'", $_output); |
|
1028 | - $_output = "<?php echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/" . $_output . |
|
1029 | - "/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>\n"; |
|
1030 | - // make sure we include modifier plugins for nocache code |
|
1031 | - foreach ($this->modifier_plugins as $plugin_name => $dummy) { |
|
1032 | - if (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ])) { |
|
1033 | - $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ 'modifier' ] = |
|
1034 | - $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ]; |
|
1035 | - } |
|
1036 | - } |
|
1037 | - } else { |
|
1038 | - $_output = $content; |
|
1039 | - } |
|
1040 | - } else { |
|
1041 | - $_output = $content; |
|
1042 | - } |
|
1043 | - $this->modifier_plugins = array(); |
|
1044 | - $this->suppressNocacheProcessing = false; |
|
1045 | - $this->tag_nocache = false; |
|
1046 | - |
|
1047 | - return $_output; |
|
1048 | - } |
|
1049 | - |
|
1050 | - /** |
|
1051 | - * Get Id |
|
1052 | - * |
|
1053 | - * @param string $input |
|
1054 | - * |
|
1055 | - * @return bool|string |
|
1056 | - */ |
|
1057 | - public function getId($input) |
|
1058 | - { |
|
1059 | - if (preg_match('~^([\'"]*)([0-9]*[a-zA-Z_]\w*)\1$~', $input, $match)) { |
|
1060 | - return $match[ 2 ]; |
|
1061 | - } |
|
1062 | - return false; |
|
1063 | - } |
|
1064 | - |
|
1065 | - /** |
|
1066 | - * Get variable name from string |
|
1067 | - * |
|
1068 | - * @param string $input |
|
1069 | - * |
|
1070 | - * @return bool|string |
|
1071 | - */ |
|
1072 | - public function getVariableName($input) |
|
1073 | - { |
|
1074 | - if (preg_match('~^[$]_smarty_tpl->tpl_vars\[[\'"]*([0-9]*[a-zA-Z_]\w*)[\'"]*\]->value$~', $input, $match)) { |
|
1075 | - return $match[ 1 ]; |
|
1076 | - } |
|
1077 | - return false; |
|
1078 | - } |
|
1079 | - |
|
1080 | - /** |
|
1081 | - * Set nocache flag in variable or create new variable |
|
1082 | - * |
|
1083 | - * @param string $varName |
|
1084 | - */ |
|
1085 | - public function setNocacheInVariable($varName) |
|
1086 | - { |
|
1087 | - // create nocache var to make it know for further compiling |
|
1088 | - if ($_var = $this->getId($varName)) { |
|
1089 | - if (isset($this->template->tpl_vars[ $_var ])) { |
|
1090 | - $this->template->tpl_vars[ $_var ] = clone $this->template->tpl_vars[ $_var ]; |
|
1091 | - $this->template->tpl_vars[ $_var ]->nocache = true; |
|
1092 | - } else { |
|
1093 | - $this->template->tpl_vars[ $_var ] = new Smarty_Variable(null, true); |
|
1094 | - } |
|
1095 | - } |
|
1096 | - } |
|
1097 | - |
|
1098 | - /** |
|
1099 | - * @param array $_attr tag attributes |
|
1100 | - * @param array $validScopes |
|
1101 | - * |
|
1102 | - * @return int|string |
|
1103 | - * @throws \SmartyCompilerException |
|
1104 | - */ |
|
1105 | - public function convertScope($_attr, $validScopes) |
|
1106 | - { |
|
1107 | - $_scope = 0; |
|
1108 | - if (isset($_attr[ 'scope' ])) { |
|
1109 | - $_scopeName = trim($_attr[ 'scope' ], "'\""); |
|
1110 | - if (is_numeric($_scopeName) && in_array($_scopeName, $validScopes)) { |
|
1111 | - $_scope = $_scopeName; |
|
1112 | - } elseif (is_string($_scopeName)) { |
|
1113 | - $_scopeName = trim($_scopeName, "'\""); |
|
1114 | - $_scope = isset($validScopes[ $_scopeName ]) ? $validScopes[ $_scopeName ] : false; |
|
1115 | - } else { |
|
1116 | - $_scope = false; |
|
1117 | - } |
|
1118 | - if ($_scope === false) { |
|
1119 | - $err = var_export($_scopeName, true); |
|
1120 | - $this->trigger_template_error("illegal value '{$err}' for \"scope\" attribute", null, true); |
|
1121 | - } |
|
1122 | - } |
|
1123 | - return $_scope; |
|
1124 | - } |
|
1125 | - |
|
1126 | - /** |
|
1127 | - * Generate nocache code string |
|
1128 | - * |
|
1129 | - * @param string $code PHP code |
|
1130 | - * |
|
1131 | - * @return string |
|
1132 | - */ |
|
1133 | - public function makeNocacheCode($code) |
|
1134 | - { |
|
1135 | - return "echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/<?php " . |
|
1136 | - str_replace("^#^", "'", addcslashes($code, '\'\\')) . |
|
1137 | - "?>/*/%%SmartyNocache:{$this->nocache_hash}%%*/';\n"; |
|
1138 | - } |
|
1139 | - |
|
1140 | - /** |
|
1141 | - * display compiler error messages without dying |
|
1142 | - * If parameter $args is empty it is a parser detected syntax error. |
|
1143 | - * In this case the parser is called to obtain information about expected tokens. |
|
1144 | - * If parameter $args contains a string this is used as error message |
|
1145 | - * |
|
1146 | - * @param string $args individual error message or null |
|
1147 | - * @param string $line line-number |
|
1148 | - * @param null|bool $tagline if true the line number of last tag |
|
1149 | - * |
|
1150 | - * @throws \SmartyCompilerException when an unexpected token is found |
|
1151 | - */ |
|
1152 | - public function trigger_template_error($args = null, $line = null, $tagline = null) |
|
1153 | - { |
|
1154 | - $lex = $this->parser->lex; |
|
1155 | - if ($tagline === true) { |
|
1156 | - // get line number of Tag |
|
1157 | - $line = $lex->taglineno; |
|
1158 | - } elseif (!isset($line)) { |
|
1159 | - // get template source line which has error |
|
1160 | - $line = $lex->line; |
|
1161 | - } else { |
|
1162 | - $line = (int) $line; |
|
1163 | - } |
|
1164 | - |
|
1165 | - if (in_array($this->template->source->type, array('eval', 'string'))) { |
|
1166 | - $templateName = $this->template->source->type . ':' . trim(preg_replace('![\t\r\n]+!', ' ', |
|
1167 | - strlen($lex->data) > 40 ? |
|
1168 | - substr($lex->data, 0, 40) . |
|
1169 | - '...' : $lex->data)); |
|
1170 | - } else { |
|
1171 | - $templateName = $this->template->source->type . ':' . $this->template->source->filepath; |
|
1172 | - } |
|
1173 | - |
|
1174 | - // $line += $this->trace_line_offset; |
|
1175 | - $match = preg_split("/\n/", $lex->data); |
|
1176 | - $error_text = |
|
1177 | - 'Syntax error in template "' . (empty($this->trace_filepath) ? $templateName : $this->trace_filepath) . |
|
1178 | - '" on line ' . ($line + $this->trace_line_offset) . ' "' . |
|
1179 | - trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ])) . '" '; |
|
1180 | - if (isset($args)) { |
|
1181 | - // individual error message |
|
1182 | - $error_text .= $args; |
|
1183 | - } else { |
|
1184 | - $expect = array(); |
|
1185 | - // expected token from parser |
|
1186 | - $error_text .= ' - Unexpected "' . $lex->value . '"'; |
|
1187 | - if (count($this->parser->yy_get_expected_tokens($this->parser->yymajor)) <= 4) { |
|
1188 | - foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) { |
|
1189 | - $exp_token = $this->parser->yyTokenName[ $token ]; |
|
1190 | - if (isset($lex->smarty_token_names[ $exp_token ])) { |
|
1191 | - // token type from lexer |
|
1192 | - $expect[] = '"' . $lex->smarty_token_names[ $exp_token ] . '"'; |
|
1193 | - } else { |
|
1194 | - // otherwise internal token name |
|
1195 | - $expect[] = $this->parser->yyTokenName[ $token ]; |
|
1196 | - } |
|
1197 | - } |
|
1198 | - $error_text .= ', expected one of: ' . implode(' , ', $expect); |
|
1199 | - } |
|
1200 | - } |
|
1201 | - $e = new SmartyCompilerException($error_text); |
|
1202 | - $e->line = $line; |
|
1203 | - $e->source = trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ])); |
|
1204 | - $e->desc = $args; |
|
1205 | - $e->template = $this->template->source->filepath; |
|
1206 | - throw $e; |
|
1207 | - } |
|
1208 | - |
|
1209 | - /** |
|
1210 | - * Return var_export() value with all white spaces removed |
|
1211 | - * |
|
1212 | - * @param mixed $value |
|
1213 | - * |
|
1214 | - * @return string |
|
1215 | - */ |
|
1216 | - public function getVarExport($value) |
|
1217 | - { |
|
1218 | - return preg_replace('/\s/', '', var_export($value, true)); |
|
1219 | - } |
|
1220 | - |
|
1221 | - /** |
|
1222 | - * Check if $value contains variable elements |
|
1223 | - * |
|
1224 | - * @param mixed $value |
|
1225 | - * |
|
1226 | - * @return bool|int |
|
1227 | - */ |
|
1228 | - public function isVariable($value) |
|
1229 | - { |
|
1230 | - if (is_string($value)) { |
|
1231 | - return preg_match('/[$(]/', $value); |
|
1232 | - } |
|
1233 | - if (is_bool($value) || is_numeric($value)) { |
|
1234 | - return false; |
|
1235 | - } |
|
1236 | - if (is_array($value)) { |
|
1237 | - foreach ($value as $k => $v) { |
|
1238 | - if ($this->isVariable($k) || $this->isVariable($v)) { |
|
1239 | - return true; |
|
1240 | - } |
|
1241 | - } |
|
1242 | - return false; |
|
1243 | - } |
|
1244 | - return false; |
|
1245 | - } |
|
1246 | - |
|
1247 | - /** |
|
1248 | - * Get new prefix variable name |
|
1249 | - * |
|
1250 | - * @return string |
|
1251 | - */ |
|
1252 | - public function getNewPrefixVariable() |
|
1253 | - { |
|
1254 | - self::$prefixVariableNumber ++; |
|
1255 | - return $this->getPrefixVariable(); |
|
1256 | - } |
|
1257 | - |
|
1258 | - /** |
|
1259 | - * Get current prefix variable name |
|
1260 | - * |
|
1261 | - * @return string |
|
1262 | - */ |
|
1263 | - public function getPrefixVariable() |
|
1264 | - { |
|
1265 | - return '$_prefixVariable' . self::$prefixVariableNumber; |
|
1266 | - } |
|
1267 | - |
|
1268 | - /** |
|
1269 | - * append code to prefix buffer |
|
1270 | - * |
|
1271 | - * @param string $code |
|
1272 | - */ |
|
1273 | - public function appendPrefixCode($code) |
|
1274 | - { |
|
1275 | - $this->prefix_code[] = $code; |
|
1276 | - } |
|
1277 | - |
|
1278 | - /** |
|
1279 | - * get prefix code string |
|
1280 | - * |
|
1281 | - * @return string |
|
1282 | - */ |
|
1283 | - public function getPrefixCode() |
|
1284 | - { |
|
1285 | - $code = ''; |
|
1286 | - $prefixArray = array_merge($this->prefix_code, array_pop($this->prefixCodeStack)); |
|
1287 | - $this->prefixCodeStack[] = array(); |
|
1288 | - foreach ($prefixArray as $c) { |
|
1289 | - $code = $this->appendCode($code, $c); |
|
1290 | - } |
|
1291 | - $this->prefix_code = array(); |
|
1292 | - return $code; |
|
1293 | - } |
|
26 | + /** |
|
27 | + * Smarty object |
|
28 | + * |
|
29 | + * @var Smarty |
|
30 | + */ |
|
31 | + public $smarty = null; |
|
32 | + |
|
33 | + /** |
|
34 | + * Parser object |
|
35 | + * |
|
36 | + * @var Smarty_Internal_Templateparser |
|
37 | + */ |
|
38 | + public $parser = null; |
|
39 | + |
|
40 | + /** |
|
41 | + * hash for nocache sections |
|
42 | + * |
|
43 | + * @var mixed |
|
44 | + */ |
|
45 | + public $nocache_hash = null; |
|
46 | + |
|
47 | + /** |
|
48 | + * suppress generation of nocache code |
|
49 | + * |
|
50 | + * @var bool |
|
51 | + */ |
|
52 | + public $suppressNocacheProcessing = false; |
|
53 | + |
|
54 | + /** |
|
55 | + * compile tag objects cache |
|
56 | + * |
|
57 | + * @var array |
|
58 | + */ |
|
59 | + static $_tag_objects = array(); |
|
60 | + |
|
61 | + /** |
|
62 | + * tag stack |
|
63 | + * |
|
64 | + * @var array |
|
65 | + */ |
|
66 | + public $_tag_stack = array(); |
|
67 | + |
|
68 | + /** |
|
69 | + * current template |
|
70 | + * |
|
71 | + * @var Smarty_Internal_Template |
|
72 | + */ |
|
73 | + public $template = null; |
|
74 | + |
|
75 | + /** |
|
76 | + * merged included sub template data |
|
77 | + * |
|
78 | + * @var array |
|
79 | + */ |
|
80 | + public $mergedSubTemplatesData = array(); |
|
81 | + |
|
82 | + /** |
|
83 | + * merged sub template code |
|
84 | + * |
|
85 | + * @var array |
|
86 | + */ |
|
87 | + public $mergedSubTemplatesCode = array(); |
|
88 | + |
|
89 | + /** |
|
90 | + * collected template properties during compilation |
|
91 | + * |
|
92 | + * @var array |
|
93 | + */ |
|
94 | + public $templateProperties = array(); |
|
95 | + |
|
96 | + /** |
|
97 | + * source line offset for error messages |
|
98 | + * |
|
99 | + * @var int |
|
100 | + */ |
|
101 | + public $trace_line_offset = 0; |
|
102 | + |
|
103 | + /** |
|
104 | + * trace uid |
|
105 | + * |
|
106 | + * @var string |
|
107 | + */ |
|
108 | + public $trace_uid = ''; |
|
109 | + |
|
110 | + /** |
|
111 | + * trace file path |
|
112 | + * |
|
113 | + * @var string |
|
114 | + */ |
|
115 | + public $trace_filepath = ''; |
|
116 | + |
|
117 | + /** |
|
118 | + * stack for tracing file and line of nested {block} tags |
|
119 | + * |
|
120 | + * @var array |
|
121 | + */ |
|
122 | + public $trace_stack = array(); |
|
123 | + |
|
124 | + /** |
|
125 | + * plugins loaded by default plugin handler |
|
126 | + * |
|
127 | + * @var array |
|
128 | + */ |
|
129 | + public $default_handler_plugins = array(); |
|
130 | + |
|
131 | + /** |
|
132 | + * saved preprocessed modifier list |
|
133 | + * |
|
134 | + * @var mixed |
|
135 | + */ |
|
136 | + public $default_modifier_list = null; |
|
137 | + |
|
138 | + /** |
|
139 | + * force compilation of complete template as nocache |
|
140 | + * |
|
141 | + * @var boolean |
|
142 | + */ |
|
143 | + public $forceNocache = false; |
|
144 | + |
|
145 | + /** |
|
146 | + * flag if compiled template file shall we written |
|
147 | + * |
|
148 | + * @var bool |
|
149 | + */ |
|
150 | + public $write_compiled_code = true; |
|
151 | + |
|
152 | + /** |
|
153 | + * Template functions |
|
154 | + * |
|
155 | + * @var array |
|
156 | + */ |
|
157 | + public $tpl_function = array(); |
|
158 | + |
|
159 | + /** |
|
160 | + * called sub functions from template function |
|
161 | + * |
|
162 | + * @var array |
|
163 | + */ |
|
164 | + public $called_functions = array(); |
|
165 | + |
|
166 | + /** |
|
167 | + * compiled template or block function code |
|
168 | + * |
|
169 | + * @var string |
|
170 | + */ |
|
171 | + public $blockOrFunctionCode = ''; |
|
172 | + |
|
173 | + /** |
|
174 | + * php_handling setting either from Smarty or security |
|
175 | + * |
|
176 | + * @var int |
|
177 | + */ |
|
178 | + public $php_handling = 0; |
|
179 | + |
|
180 | + /** |
|
181 | + * flags for used modifier plugins |
|
182 | + * |
|
183 | + * @var array |
|
184 | + */ |
|
185 | + public $modifier_plugins = array(); |
|
186 | + |
|
187 | + /** |
|
188 | + * type of already compiled modifier |
|
189 | + * |
|
190 | + * @var array |
|
191 | + */ |
|
192 | + public $known_modifier_type = array(); |
|
193 | + |
|
194 | + /** |
|
195 | + * parent compiler object for merged subtemplates and template functions |
|
196 | + * |
|
197 | + * @var Smarty_Internal_TemplateCompilerBase |
|
198 | + */ |
|
199 | + public $parent_compiler = null; |
|
200 | + |
|
201 | + /** |
|
202 | + * Flag true when compiling nocache section |
|
203 | + * |
|
204 | + * @var bool |
|
205 | + */ |
|
206 | + public $nocache = false; |
|
207 | + |
|
208 | + /** |
|
209 | + * Flag true when tag is compiled as nocache |
|
210 | + * |
|
211 | + * @var bool |
|
212 | + */ |
|
213 | + public $tag_nocache = false; |
|
214 | + |
|
215 | + /** |
|
216 | + * Compiled tag prefix code |
|
217 | + * |
|
218 | + * @var array |
|
219 | + */ |
|
220 | + public $prefix_code = array(); |
|
221 | + |
|
222 | + /** |
|
223 | + * Prefix code stack |
|
224 | + * |
|
225 | + * @var array |
|
226 | + */ |
|
227 | + public $prefixCodeStack = array(); |
|
228 | + |
|
229 | + /** |
|
230 | + * Tag has compiled code |
|
231 | + * |
|
232 | + * @var bool |
|
233 | + */ |
|
234 | + public $has_code = false; |
|
235 | + |
|
236 | + /** |
|
237 | + * A variable string was compiled |
|
238 | + * |
|
239 | + * @var bool |
|
240 | + */ |
|
241 | + public $has_variable_string = false; |
|
242 | + |
|
243 | + /** |
|
244 | + * Tag creates output |
|
245 | + * |
|
246 | + * @var bool |
|
247 | + */ |
|
248 | + public $has_output = false; |
|
249 | + |
|
250 | + /** |
|
251 | + * Stack for {setfilter} {/setfilter} |
|
252 | + * |
|
253 | + * @var array |
|
254 | + */ |
|
255 | + public $variable_filter_stack = array(); |
|
256 | + |
|
257 | + /** |
|
258 | + * variable filters for {setfilter} {/setfilter} |
|
259 | + * |
|
260 | + * @var array |
|
261 | + */ |
|
262 | + public $variable_filters = array(); |
|
263 | + |
|
264 | + /** |
|
265 | + * Nesting count of looping tags like {foreach}, {for}, {section}, {while} |
|
266 | + * |
|
267 | + * @var int |
|
268 | + */ |
|
269 | + public $loopNesting = 0; |
|
270 | + |
|
271 | + /** |
|
272 | + * Strip preg pattern |
|
273 | + * |
|
274 | + * @var string |
|
275 | + */ |
|
276 | + public $stripRegEx = '![\t ]*[\r\n]+[\t ]*!'; |
|
277 | + |
|
278 | + /** |
|
279 | + * plugin search order |
|
280 | + * |
|
281 | + * @var array |
|
282 | + */ |
|
283 | + public $plugin_search_order = array('function', 'block', 'compiler', 'class'); |
|
284 | + |
|
285 | + /** |
|
286 | + * General storage area for tag compiler plugins |
|
287 | + * |
|
288 | + * @var array |
|
289 | + */ |
|
290 | + public $_cache = array(); |
|
291 | + |
|
292 | + /** |
|
293 | + * counter for prefix variable number |
|
294 | + * |
|
295 | + * @var int |
|
296 | + */ |
|
297 | + public static $prefixVariableNumber = 0; |
|
298 | + |
|
299 | + /** |
|
300 | + * method to compile a Smarty template |
|
301 | + * |
|
302 | + * @param mixed $_content template source |
|
303 | + * @param bool $isTemplateSource |
|
304 | + * |
|
305 | + * @return bool true if compiling succeeded, false if it failed |
|
306 | + */ |
|
307 | + abstract protected function doCompile($_content, $isTemplateSource = false); |
|
308 | + |
|
309 | + /** |
|
310 | + * Initialize compiler |
|
311 | + * |
|
312 | + * @param Smarty $smarty global instance |
|
313 | + */ |
|
314 | + public function __construct(Smarty $smarty) |
|
315 | + { |
|
316 | + $this->smarty = $smarty; |
|
317 | + $this->nocache_hash = str_replace(array('.', ','), '_', uniqid(rand(), true)); |
|
318 | + } |
|
319 | + |
|
320 | + /** |
|
321 | + * Method to compile a Smarty template |
|
322 | + * |
|
323 | + * @param Smarty_Internal_Template $template template object to compile |
|
324 | + * @param bool $nocache true is shall be compiled in nocache mode |
|
325 | + * @param null|Smarty_Internal_TemplateCompilerBase $parent_compiler |
|
326 | + * |
|
327 | + * @return bool true if compiling succeeded, false if it failed |
|
328 | + * @throws \Exception |
|
329 | + */ |
|
330 | + public function compileTemplate(Smarty_Internal_Template $template, $nocache = null, |
|
331 | + Smarty_Internal_TemplateCompilerBase $parent_compiler = null) |
|
332 | + { |
|
333 | + // get code frame of compiled template |
|
334 | + $_compiled_code = $template->smarty->ext->_codeFrame->create($template, |
|
335 | + $this->compileTemplateSource($template, $nocache, |
|
336 | + $parent_compiler), |
|
337 | + $this->postFilter($this->blockOrFunctionCode) . |
|
338 | + join('', $this->mergedSubTemplatesCode), false, |
|
339 | + $this); |
|
340 | + return $_compiled_code; |
|
341 | + } |
|
342 | + |
|
343 | + /** |
|
344 | + * Compile template source and run optional post filter |
|
345 | + * |
|
346 | + * @param \Smarty_Internal_Template $template |
|
347 | + * @param null|bool $nocache flag if template must be compiled in nocache mode |
|
348 | + * @param \Smarty_Internal_TemplateCompilerBase $parent_compiler |
|
349 | + * |
|
350 | + * @return string |
|
351 | + * @throws \Exception |
|
352 | + */ |
|
353 | + public function compileTemplateSource(Smarty_Internal_Template $template, $nocache = null, |
|
354 | + Smarty_Internal_TemplateCompilerBase $parent_compiler = null) |
|
355 | + { |
|
356 | + try { |
|
357 | + // save template object in compiler class |
|
358 | + $this->template = $template; |
|
359 | + if (property_exists($this->template->smarty, 'plugin_search_order')) { |
|
360 | + $this->plugin_search_order = $this->template->smarty->plugin_search_order; |
|
361 | + } |
|
362 | + if ($this->smarty->debugging) { |
|
363 | + if (!isset($this->smarty->_debug)) { |
|
364 | + $this->smarty->_debug = new Smarty_Internal_Debug(); |
|
365 | + } |
|
366 | + $this->smarty->_debug->start_compile($this->template); |
|
367 | + } |
|
368 | + if (isset($this->template->smarty->security_policy)) { |
|
369 | + $this->php_handling = $this->template->smarty->security_policy->php_handling; |
|
370 | + } else { |
|
371 | + $this->php_handling = $this->template->smarty->php_handling; |
|
372 | + } |
|
373 | + $this->parent_compiler = $parent_compiler ? $parent_compiler : $this; |
|
374 | + $nocache = isset($nocache) ? $nocache : false; |
|
375 | + if (empty($template->compiled->nocache_hash)) { |
|
376 | + $template->compiled->nocache_hash = $this->nocache_hash; |
|
377 | + } else { |
|
378 | + $this->nocache_hash = $template->compiled->nocache_hash; |
|
379 | + } |
|
380 | + // flag for nocache sections |
|
381 | + $this->nocache = $nocache; |
|
382 | + $this->tag_nocache = false; |
|
383 | + // reset has nocache code flag |
|
384 | + $this->template->compiled->has_nocache_code = false; |
|
385 | + $this->has_variable_string = false; |
|
386 | + $this->prefix_code = array(); |
|
387 | + // add file dependency |
|
388 | + if ($this->smarty->merge_compiled_includes || $this->template->source->handler->checkTimestamps()) { |
|
389 | + $this->parent_compiler->template->compiled->file_dependency[ $this->template->source->uid ] = |
|
390 | + array($this->template->source->filepath, $this->template->source->getTimeStamp(), |
|
391 | + $this->template->source->type,); |
|
392 | + } |
|
393 | + $this->smarty->_current_file = $this->template->source->filepath; |
|
394 | + // get template source |
|
395 | + if (!empty($this->template->source->components)) { |
|
396 | + // we have array of inheritance templates by extends: resource |
|
397 | + // generate corresponding source code sequence |
|
398 | + $_content = |
|
399 | + Smarty_Internal_Compile_Extends::extendsSourceArrayCode($this->template->source->components); |
|
400 | + } else { |
|
401 | + // get template source |
|
402 | + $_content = $this->template->source->getContent(); |
|
403 | + } |
|
404 | + $_compiled_code = $this->postFilter($this->doCompile($this->preFilter($_content), true)); |
|
405 | + } |
|
406 | + catch (Exception $e) { |
|
407 | + if ($this->smarty->debugging) { |
|
408 | + $this->smarty->_debug->end_compile($this->template); |
|
409 | + } |
|
410 | + $this->_tag_stack = array(); |
|
411 | + // free memory |
|
412 | + $this->parent_compiler = null; |
|
413 | + $this->template = null; |
|
414 | + $this->parser = null; |
|
415 | + throw $e; |
|
416 | + } |
|
417 | + if ($this->smarty->debugging) { |
|
418 | + $this->smarty->_debug->end_compile($this->template); |
|
419 | + } |
|
420 | + $this->parent_compiler = null; |
|
421 | + $this->parser = null; |
|
422 | + return $_compiled_code; |
|
423 | + } |
|
424 | + |
|
425 | + /** |
|
426 | + * Optionally process compiled code by post filter |
|
427 | + * |
|
428 | + * @param string $code compiled code |
|
429 | + * |
|
430 | + * @return string |
|
431 | + * @throws \SmartyException |
|
432 | + */ |
|
433 | + public function postFilter($code) |
|
434 | + { |
|
435 | + // run post filter if on code |
|
436 | + if (!empty($code) && |
|
437 | + (isset($this->smarty->autoload_filters[ 'post' ]) || isset($this->smarty->registered_filters[ 'post' ])) |
|
438 | + ) { |
|
439 | + return $this->smarty->ext->_filterHandler->runFilter('post', $code, $this->template); |
|
440 | + } else { |
|
441 | + return $code; |
|
442 | + } |
|
443 | + } |
|
444 | + |
|
445 | + /** |
|
446 | + * Run optional prefilter |
|
447 | + * |
|
448 | + * @param string $_content template source |
|
449 | + * |
|
450 | + * @return string |
|
451 | + * @throws \SmartyException |
|
452 | + */ |
|
453 | + public function preFilter($_content) |
|
454 | + { |
|
455 | + // run pre filter if required |
|
456 | + if ($_content != '' && |
|
457 | + ((isset($this->smarty->autoload_filters[ 'pre' ]) || isset($this->smarty->registered_filters[ 'pre' ]))) |
|
458 | + ) { |
|
459 | + return $this->smarty->ext->_filterHandler->runFilter('pre', $_content, $this->template); |
|
460 | + } else { |
|
461 | + return $_content; |
|
462 | + } |
|
463 | + } |
|
464 | + |
|
465 | + /** |
|
466 | + * Compile Tag |
|
467 | + * This is a call back from the lexer/parser |
|
468 | + * |
|
469 | + * Save current prefix code |
|
470 | + * Compile tag |
|
471 | + * Merge tag prefix code with saved one |
|
472 | + * (required nested tags in attributes) |
|
473 | + * |
|
474 | + * @param string $tag tag name |
|
475 | + * @param array $args array with tag attributes |
|
476 | + * @param array $parameter array with compilation parameter |
|
477 | + * |
|
478 | + * @throws SmartyCompilerException |
|
479 | + * @throws SmartyException |
|
480 | + * @return string compiled code |
|
481 | + */ |
|
482 | + public function compileTag($tag, $args, $parameter = array()) |
|
483 | + { |
|
484 | + $this->prefixCodeStack[] = $this->prefix_code; |
|
485 | + $this->prefix_code = array(); |
|
486 | + $result = $this->compileTag2($tag, $args, $parameter); |
|
487 | + $this->prefix_code = array_merge($this->prefix_code, array_pop($this->prefixCodeStack)); |
|
488 | + return $result; |
|
489 | + } |
|
490 | + |
|
491 | + /** |
|
492 | + * Compile Tag |
|
493 | + * |
|
494 | + * @param string $tag tag name |
|
495 | + * @param array $args array with tag attributes |
|
496 | + * @param array $parameter array with compilation parameter |
|
497 | + * |
|
498 | + * @throws SmartyCompilerException |
|
499 | + * @throws SmartyException |
|
500 | + * @return string compiled code |
|
501 | + */ |
|
502 | + private function compileTag2($tag, $args, $parameter) |
|
503 | + { |
|
504 | + $plugin_type = ''; |
|
505 | + // $args contains the attributes parsed and compiled by the lexer/parser |
|
506 | + // assume that tag does compile into code, but creates no HTML output |
|
507 | + $this->has_code = true; |
|
508 | + $this->has_output = false; |
|
509 | + // log tag/attributes |
|
510 | + if (isset($this->smarty->_cache[ 'get_used_tags' ])) { |
|
511 | + $this->template->_cache[ 'used_tags' ][] = array($tag, $args); |
|
512 | + } |
|
513 | + // check nocache option flag |
|
514 | + foreach ($args as $arg) { |
|
515 | + if (!is_array($arg)) { |
|
516 | + if ($arg == "'nocache'") { |
|
517 | + $this->tag_nocache = true; |
|
518 | + } |
|
519 | + } else { |
|
520 | + foreach ($arg as $k => $v) { |
|
521 | + if ($k == "'nocache'" && (trim($v, "'\" ") == 'true')) { |
|
522 | + $this->tag_nocache = true; |
|
523 | + } |
|
524 | + } |
|
525 | + } |
|
526 | + } |
|
527 | + // compile the smarty tag (required compile classes to compile the tag are auto loaded) |
|
528 | + if (($_output = $this->callTagCompiler($tag, $args, $parameter)) === false) { |
|
529 | + if (isset($this->parent_compiler->tpl_function[ $tag ])) { |
|
530 | + // template defined by {template} tag |
|
531 | + $args[ '_attr' ][ 'name' ] = "'" . $tag . "'"; |
|
532 | + $_output = $this->callTagCompiler('call', $args, $parameter); |
|
533 | + } |
|
534 | + } |
|
535 | + if ($_output !== false) { |
|
536 | + if ($_output !== true) { |
|
537 | + // did we get compiled code |
|
538 | + if ($this->has_code) { |
|
539 | + // Does it create output? |
|
540 | + if ($this->has_output) { |
|
541 | + $_output .= "\n"; |
|
542 | + } |
|
543 | + // return compiled code |
|
544 | + return $_output; |
|
545 | + } |
|
546 | + } |
|
547 | + // tag did not produce compiled code |
|
548 | + return null; |
|
549 | + } else { |
|
550 | + // map_named attributes |
|
551 | + if (isset($args[ '_attr' ])) { |
|
552 | + foreach ($args[ '_attr' ] as $key => $attribute) { |
|
553 | + if (is_array($attribute)) { |
|
554 | + $args = array_merge($args, $attribute); |
|
555 | + } |
|
556 | + } |
|
557 | + } |
|
558 | + // not an internal compiler tag |
|
559 | + if (strlen($tag) < 6 || substr($tag, - 5) != 'close') { |
|
560 | + // check if tag is a registered object |
|
561 | + if (isset($this->smarty->registered_objects[ $tag ]) && isset($parameter[ 'object_method' ])) { |
|
562 | + $method = $parameter[ 'object_method' ]; |
|
563 | + if (!in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ]) && |
|
564 | + (empty($this->smarty->registered_objects[ $tag ][ 1 ]) || |
|
565 | + in_array($method, $this->smarty->registered_objects[ $tag ][ 1 ])) |
|
566 | + ) { |
|
567 | + return $this->callTagCompiler('private_object_function', $args, $parameter, $tag, $method); |
|
568 | + } elseif (in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ])) { |
|
569 | + return $this->callTagCompiler('private_object_block_function', $args, $parameter, $tag, |
|
570 | + $method); |
|
571 | + } else { |
|
572 | + // throw exception |
|
573 | + $this->trigger_template_error('not allowed method "' . $method . '" in registered object "' . |
|
574 | + $tag . '"', null, true); |
|
575 | + } |
|
576 | + } |
|
577 | + // check if tag is registered |
|
578 | + foreach (array(Smarty::PLUGIN_COMPILER, Smarty::PLUGIN_FUNCTION, Smarty::PLUGIN_BLOCK,) as $plugin_type) |
|
579 | + { |
|
580 | + if (isset($this->smarty->registered_plugins[ $plugin_type ][ $tag ])) { |
|
581 | + // if compiler function plugin call it now |
|
582 | + if ($plugin_type == Smarty::PLUGIN_COMPILER) { |
|
583 | + $new_args = array(); |
|
584 | + foreach ($args as $key => $mixed) { |
|
585 | + if (is_array($mixed)) { |
|
586 | + $new_args = array_merge($new_args, $mixed); |
|
587 | + } else { |
|
588 | + $new_args[ $key ] = $mixed; |
|
589 | + } |
|
590 | + } |
|
591 | + if (!$this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 1 ]) { |
|
592 | + $this->tag_nocache = true; |
|
593 | + } |
|
594 | + return call_user_func_array($this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 0 ], |
|
595 | + array($new_args, $this)); |
|
596 | + } |
|
597 | + // compile registered function or block function |
|
598 | + if ($plugin_type == Smarty::PLUGIN_FUNCTION || $plugin_type == Smarty::PLUGIN_BLOCK) { |
|
599 | + return $this->callTagCompiler('private_registered_' . $plugin_type, $args, $parameter, |
|
600 | + $tag); |
|
601 | + } |
|
602 | + } |
|
603 | + } |
|
604 | + // check plugins from plugins folder |
|
605 | + foreach ($this->plugin_search_order as $plugin_type) { |
|
606 | + if ($plugin_type == Smarty::PLUGIN_COMPILER && |
|
607 | + $this->smarty->loadPlugin('smarty_compiler_' . $tag) && |
|
608 | + (!isset($this->smarty->security_policy) || |
|
609 | + $this->smarty->security_policy->isTrustedTag($tag, $this)) |
|
610 | + ) { |
|
611 | + $plugin = 'smarty_compiler_' . $tag; |
|
612 | + if (is_callable($plugin)) { |
|
613 | + // convert arguments format for old compiler plugins |
|
614 | + $new_args = array(); |
|
615 | + foreach ($args as $key => $mixed) { |
|
616 | + if (is_array($mixed)) { |
|
617 | + $new_args = array_merge($new_args, $mixed); |
|
618 | + } else { |
|
619 | + $new_args[ $key ] = $mixed; |
|
620 | + } |
|
621 | + } |
|
622 | + |
|
623 | + return $plugin($new_args, $this->smarty); |
|
624 | + } |
|
625 | + if (class_exists($plugin, false)) { |
|
626 | + $plugin_object = new $plugin; |
|
627 | + if (method_exists($plugin_object, 'compile')) { |
|
628 | + return $plugin_object->compile($args, $this); |
|
629 | + } |
|
630 | + } |
|
631 | + throw new SmartyException("Plugin \"{$tag}\" not callable"); |
|
632 | + } else { |
|
633 | + if ($function = $this->getPlugin($tag, $plugin_type)) { |
|
634 | + if (!isset($this->smarty->security_policy) || |
|
635 | + $this->smarty->security_policy->isTrustedTag($tag, $this) |
|
636 | + ) { |
|
637 | + return $this->callTagCompiler('private_' . $plugin_type . '_plugin', $args, $parameter, |
|
638 | + $tag, $function); |
|
639 | + } |
|
640 | + } |
|
641 | + } |
|
642 | + } |
|
643 | + if (is_callable($this->smarty->default_plugin_handler_func)) { |
|
644 | + $found = false; |
|
645 | + // look for already resolved tags |
|
646 | + foreach ($this->plugin_search_order as $plugin_type) { |
|
647 | + if (isset($this->default_handler_plugins[ $plugin_type ][ $tag ])) { |
|
648 | + $found = true; |
|
649 | + break; |
|
650 | + } |
|
651 | + } |
|
652 | + if (!$found) { |
|
653 | + // call default handler |
|
654 | + foreach ($this->plugin_search_order as $plugin_type) { |
|
655 | + if ($this->getPluginFromDefaultHandler($tag, $plugin_type)) { |
|
656 | + $found = true; |
|
657 | + break; |
|
658 | + } |
|
659 | + } |
|
660 | + } |
|
661 | + if ($found) { |
|
662 | + // if compiler function plugin call it now |
|
663 | + if ($plugin_type == Smarty::PLUGIN_COMPILER) { |
|
664 | + $new_args = array(); |
|
665 | + foreach ($args as $mixed) { |
|
666 | + $new_args = array_merge($new_args, $mixed); |
|
667 | + } |
|
668 | + return call_user_func_array($this->default_handler_plugins[ $plugin_type ][ $tag ][ 0 ], |
|
669 | + array($new_args, $this)); |
|
670 | + } else { |
|
671 | + return $this->callTagCompiler('private_registered_' . $plugin_type, $args, $parameter, |
|
672 | + $tag); |
|
673 | + } |
|
674 | + } |
|
675 | + } |
|
676 | + } else { |
|
677 | + // compile closing tag of block function |
|
678 | + $base_tag = substr($tag, 0, - 5); |
|
679 | + // check if closing tag is a registered object |
|
680 | + if (isset($this->smarty->registered_objects[ $base_tag ]) && isset($parameter[ 'object_method' ])) { |
|
681 | + $method = $parameter[ 'object_method' ]; |
|
682 | + if (in_array($method, $this->smarty->registered_objects[ $base_tag ][ 3 ])) { |
|
683 | + return $this->callTagCompiler('private_object_block_function', $args, $parameter, $tag, |
|
684 | + $method); |
|
685 | + } else { |
|
686 | + // throw exception |
|
687 | + $this->trigger_template_error('not allowed closing tag method "' . $method . |
|
688 | + '" in registered object "' . $base_tag . '"', null, true); |
|
689 | + } |
|
690 | + } |
|
691 | + // registered block tag ? |
|
692 | + if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ]) || |
|
693 | + isset($this->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ]) |
|
694 | + ) { |
|
695 | + return $this->callTagCompiler('private_registered_block', $args, $parameter, $tag); |
|
696 | + } |
|
697 | + // registered function tag ? |
|
698 | + if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ])) { |
|
699 | + return $this->callTagCompiler('private_registered_function', $args, $parameter, $tag); |
|
700 | + } |
|
701 | + // block plugin? |
|
702 | + if ($function = $this->getPlugin($base_tag, Smarty::PLUGIN_BLOCK)) { |
|
703 | + return $this->callTagCompiler('private_block_plugin', $args, $parameter, $tag, $function); |
|
704 | + } |
|
705 | + // function plugin? |
|
706 | + if ($function = $this->getPlugin($tag, Smarty::PLUGIN_FUNCTION)) { |
|
707 | + if (!isset($this->smarty->security_policy) || |
|
708 | + $this->smarty->security_policy->isTrustedTag($tag, $this) |
|
709 | + ) { |
|
710 | + return $this->callTagCompiler('private_function_plugin', $args, $parameter, $tag, $function); |
|
711 | + } |
|
712 | + } |
|
713 | + // registered compiler plugin ? |
|
714 | + if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ])) { |
|
715 | + // if compiler function plugin call it now |
|
716 | + $args = array(); |
|
717 | + if (!$this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 1 ]) { |
|
718 | + $this->tag_nocache = true; |
|
719 | + } |
|
720 | + return call_user_func_array($this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 0 ], |
|
721 | + array($args, $this)); |
|
722 | + } |
|
723 | + if ($this->smarty->loadPlugin('smarty_compiler_' . $tag)) { |
|
724 | + $plugin = 'smarty_compiler_' . $tag; |
|
725 | + if (is_callable($plugin)) { |
|
726 | + return $plugin($args, $this->smarty); |
|
727 | + } |
|
728 | + if (class_exists($plugin, false)) { |
|
729 | + $plugin_object = new $plugin; |
|
730 | + if (method_exists($plugin_object, 'compile')) { |
|
731 | + return $plugin_object->compile($args, $this); |
|
732 | + } |
|
733 | + } |
|
734 | + throw new SmartyException("Plugin \"{$tag}\" not callable"); |
|
735 | + } |
|
736 | + } |
|
737 | + $this->trigger_template_error("unknown tag \"" . $tag . "\"", null, true); |
|
738 | + } |
|
739 | + } |
|
740 | + |
|
741 | + /** |
|
742 | + * compile variable |
|
743 | + * |
|
744 | + * @param string $variable |
|
745 | + * |
|
746 | + * @return string |
|
747 | + */ |
|
748 | + public function compileVariable($variable) |
|
749 | + { |
|
750 | + if (strpos($variable, '(') == 0) { |
|
751 | + // not a variable variable |
|
752 | + $var = trim($variable, '\''); |
|
753 | + $this->tag_nocache = $this->tag_nocache | |
|
754 | + $this->template->ext->getTemplateVars->_getVariable($this->template, $var, null, true, |
|
755 | + false)->nocache; |
|
756 | + // todo $this->template->compiled->properties['variables'][$var] = $this->tag_nocache | $this->nocache; |
|
757 | + } |
|
758 | + return '$_smarty_tpl->tpl_vars[' . $variable . ']->value'; |
|
759 | + } |
|
760 | + |
|
761 | + /** |
|
762 | + * compile config variable |
|
763 | + * |
|
764 | + * @param string $variable |
|
765 | + * |
|
766 | + * @return string |
|
767 | + */ |
|
768 | + public function compileConfigVariable($variable) |
|
769 | + { |
|
770 | + // return '$_smarty_tpl->config_vars[' . $variable . ']'; |
|
771 | + return '$_smarty_tpl->smarty->ext->configLoad->_getConfigVariable($_smarty_tpl, ' . $variable . ')'; |
|
772 | + } |
|
773 | + |
|
774 | + /** |
|
775 | + * This method is called from parser to process a text content section |
|
776 | + * - remove text from inheritance child templates as they may generate output |
|
777 | + * - strip text if strip is enabled |
|
778 | + * |
|
779 | + * @param string $text |
|
780 | + * |
|
781 | + * @return null|\Smarty_Internal_ParseTree_Text |
|
782 | + */ |
|
783 | + public function processText($text) |
|
784 | + { |
|
785 | + if ((string) $text != '') { |
|
786 | + $store = array(); |
|
787 | + $_store = 0; |
|
788 | + if ($this->parser->strip) { |
|
789 | + if (strpos($text, '<') !== false) { |
|
790 | + // capture html elements not to be messed with |
|
791 | + $_offset = 0; |
|
792 | + if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is', |
|
793 | + $text, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
794 | + foreach ($matches as $match) { |
|
795 | + $store[] = $match[ 0 ][ 0 ]; |
|
796 | + $_length = strlen($match[ 0 ][ 0 ]); |
|
797 | + $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; |
|
798 | + $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); |
|
799 | + |
|
800 | + $_offset += $_length - strlen($replace); |
|
801 | + $_store ++; |
|
802 | + } |
|
803 | + } |
|
804 | + $expressions = array(// replace multiple spaces between tags by a single space |
|
805 | + '#(:SMARTY@!@|>)[\040\011]+(?=@!@SMARTY:|<)#s' => '\1 \2', |
|
806 | + // remove newline between tags |
|
807 | + '#(:SMARTY@!@|>)[\040\011]*[\n]\s*(?=@!@SMARTY:|<)#s' => '\1\2', |
|
808 | + // remove multiple spaces between attributes (but not in attribute values!) |
|
809 | + '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5', |
|
810 | + '#>[\040\011]+$#Ss' => '> ', '#>[\040\011]*[\n]\s*$#Ss' => '>', |
|
811 | + $this->stripRegEx => '',); |
|
812 | + |
|
813 | + $text = preg_replace(array_keys($expressions), array_values($expressions), $text); |
|
814 | + $_offset = 0; |
|
815 | + if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $text, $matches, |
|
816 | + PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
|
817 | + foreach ($matches as $match) { |
|
818 | + $_length = strlen($match[ 0 ][ 0 ]); |
|
819 | + $replace = $store[ $match[ 1 ][ 0 ] ]; |
|
820 | + $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] + $_offset, $_length); |
|
821 | + |
|
822 | + $_offset += strlen($replace) - $_length; |
|
823 | + $_store ++; |
|
824 | + } |
|
825 | + } |
|
826 | + } else { |
|
827 | + $text = preg_replace($this->stripRegEx, '', $text); |
|
828 | + } |
|
829 | + } |
|
830 | + return new Smarty_Internal_ParseTree_Text($text); |
|
831 | + } |
|
832 | + return null; |
|
833 | + } |
|
834 | + |
|
835 | + /** |
|
836 | + * lazy loads internal compile plugin for tag and calls the compile method |
|
837 | + * compile objects cached for reuse. |
|
838 | + * class name format: Smarty_Internal_Compile_TagName |
|
839 | + * plugin filename format: Smarty_Internal_TagName.php |
|
840 | + * |
|
841 | + * @param string $tag tag name |
|
842 | + * @param array $args list of tag attributes |
|
843 | + * @param mixed $param1 optional parameter |
|
844 | + * @param mixed $param2 optional parameter |
|
845 | + * @param mixed $param3 optional parameter |
|
846 | + * |
|
847 | + * @return string compiled code |
|
848 | + */ |
|
849 | + public function callTagCompiler($tag, $args, $param1 = null, $param2 = null, $param3 = null) |
|
850 | + { |
|
851 | + // re-use object if already exists |
|
852 | + if (!isset(self::$_tag_objects[ $tag ])) { |
|
853 | + // lazy load internal compiler plugin |
|
854 | + $_tag = explode('_', $tag); |
|
855 | + $_tag = array_map('ucfirst', $_tag); |
|
856 | + $class_name = 'Smarty_Internal_Compile_' . implode('_', $_tag); |
|
857 | + if (class_exists($class_name) && |
|
858 | + (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this)) |
|
859 | + ) { |
|
860 | + self::$_tag_objects[ $tag ] = new $class_name; |
|
861 | + } else { |
|
862 | + self::$_tag_objects[ $tag ] = false; |
|
863 | + return false; |
|
864 | + } |
|
865 | + } |
|
866 | + // compile this tag |
|
867 | + return self::$_tag_objects[ $tag ] === false ? false : |
|
868 | + self::$_tag_objects[ $tag ]->compile($args, $this, $param1, $param2, $param3); |
|
869 | + } |
|
870 | + |
|
871 | + /** |
|
872 | + * Check for plugins and return function name |
|
873 | + * |
|
874 | + * @param $plugin_name |
|
875 | + * @param string $plugin_type type of plugin |
|
876 | + * |
|
877 | + * @return string call name of function |
|
878 | + */ |
|
879 | + public function getPlugin($plugin_name, $plugin_type) |
|
880 | + { |
|
881 | + $function = null; |
|
882 | + if ($this->template->caching && ($this->nocache || $this->tag_nocache)) { |
|
883 | + if (isset($this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ])) { |
|
884 | + $function = |
|
885 | + $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ]; |
|
886 | + } elseif (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ])) { |
|
887 | + $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ] = |
|
888 | + $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ]; |
|
889 | + $function = |
|
890 | + $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ]; |
|
891 | + } |
|
892 | + } else { |
|
893 | + if (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ])) { |
|
894 | + $function = |
|
895 | + $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ]; |
|
896 | + } elseif (isset($this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ])) { |
|
897 | + $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ] = |
|
898 | + $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ]; |
|
899 | + $function = |
|
900 | + $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ]; |
|
901 | + } |
|
902 | + } |
|
903 | + if (isset($function)) { |
|
904 | + if ($plugin_type == 'modifier') { |
|
905 | + $this->modifier_plugins[ $plugin_name ] = true; |
|
906 | + } |
|
907 | + |
|
908 | + return $function; |
|
909 | + } |
|
910 | + // loop through plugin dirs and find the plugin |
|
911 | + $function = 'smarty_' . $plugin_type . '_' . $plugin_name; |
|
912 | + $file = $this->smarty->loadPlugin($function, false); |
|
913 | + |
|
914 | + if (is_string($file)) { |
|
915 | + if ($this->template->caching && ($this->nocache || $this->tag_nocache)) { |
|
916 | + $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'file' ] = |
|
917 | + $file; |
|
918 | + $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ] = |
|
919 | + $function; |
|
920 | + } else { |
|
921 | + $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'file' ] = |
|
922 | + $file; |
|
923 | + $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ] = |
|
924 | + $function; |
|
925 | + } |
|
926 | + if ($plugin_type == 'modifier') { |
|
927 | + $this->modifier_plugins[ $plugin_name ] = true; |
|
928 | + } |
|
929 | + |
|
930 | + return $function; |
|
931 | + } |
|
932 | + if (is_callable($function)) { |
|
933 | + // plugin function is defined in the script |
|
934 | + return $function; |
|
935 | + } |
|
936 | + |
|
937 | + return false; |
|
938 | + } |
|
939 | + |
|
940 | + /** |
|
941 | + * Check for plugins by default plugin handler |
|
942 | + * |
|
943 | + * @param string $tag name of tag |
|
944 | + * @param string $plugin_type type of plugin |
|
945 | + * |
|
946 | + * @return boolean true if found |
|
947 | + */ |
|
948 | + public function getPluginFromDefaultHandler($tag, $plugin_type) |
|
949 | + { |
|
950 | + $callback = null; |
|
951 | + $script = null; |
|
952 | + $cacheable = true; |
|
953 | + $result = call_user_func_array($this->smarty->default_plugin_handler_func, |
|
954 | + array($tag, $plugin_type, $this->template, &$callback, &$script, &$cacheable,)); |
|
955 | + if ($result) { |
|
956 | + $this->tag_nocache = $this->tag_nocache || !$cacheable; |
|
957 | + if ($script !== null) { |
|
958 | + if (is_file($script)) { |
|
959 | + if ($this->template->caching && ($this->nocache || $this->tag_nocache)) { |
|
960 | + $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $tag ][ $plugin_type ][ 'file' ] = |
|
961 | + $script; |
|
962 | + $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $tag ][ $plugin_type ][ 'function' ] = |
|
963 | + $callback; |
|
964 | + } else { |
|
965 | + $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $tag ][ $plugin_type ][ 'file' ] = |
|
966 | + $script; |
|
967 | + $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $tag ][ $plugin_type ][ 'function' ] = |
|
968 | + $callback; |
|
969 | + } |
|
970 | + require_once $script; |
|
971 | + } else { |
|
972 | + $this->trigger_template_error("Default plugin handler: Returned script file \"{$script}\" for \"{$tag}\" not found"); |
|
973 | + } |
|
974 | + } |
|
975 | + if (is_callable($callback)) { |
|
976 | + $this->default_handler_plugins[ $plugin_type ][ $tag ] = array($callback, true, array()); |
|
977 | + |
|
978 | + return true; |
|
979 | + } else { |
|
980 | + $this->trigger_template_error("Default plugin handler: Returned callback for \"{$tag}\" not callable"); |
|
981 | + } |
|
982 | + } |
|
983 | + |
|
984 | + return false; |
|
985 | + } |
|
986 | + |
|
987 | + /** |
|
988 | + * Append code segments and remove unneeded ?> <?php transitions |
|
989 | + * |
|
990 | + * @param string $left |
|
991 | + * @param string $right |
|
992 | + * |
|
993 | + * @return string |
|
994 | + */ |
|
995 | + public function appendCode($left, $right) |
|
996 | + { |
|
997 | + if (preg_match('/\s*\?>\s*$/', $left) && preg_match('/^\s*<\?php\s+/', $right)) { |
|
998 | + $left = preg_replace('/\s*\?>\s*$/', "\n", $left); |
|
999 | + $left .= preg_replace('/^\s*<\?php\s+/', '', $right); |
|
1000 | + } else { |
|
1001 | + $left .= $right; |
|
1002 | + } |
|
1003 | + return $left; |
|
1004 | + } |
|
1005 | + |
|
1006 | + /** |
|
1007 | + * Inject inline code for nocache template sections |
|
1008 | + * This method gets the content of each template element from the parser. |
|
1009 | + * If the content is compiled code and it should be not cached the code is injected |
|
1010 | + * into the rendered output. |
|
1011 | + * |
|
1012 | + * @param string $content content of template element |
|
1013 | + * @param boolean $is_code true if content is compiled code |
|
1014 | + * |
|
1015 | + * @return string content |
|
1016 | + */ |
|
1017 | + public function processNocacheCode($content, $is_code) |
|
1018 | + { |
|
1019 | + // If the template is not evaluated and we have a nocache section and or a nocache tag |
|
1020 | + if ($is_code && !empty($content)) { |
|
1021 | + // generate replacement code |
|
1022 | + if ((!($this->template->source->handler->recompiled) || $this->forceNocache) && $this->template->caching && |
|
1023 | + !$this->suppressNocacheProcessing && ($this->nocache || $this->tag_nocache) |
|
1024 | + ) { |
|
1025 | + $this->template->compiled->has_nocache_code = true; |
|
1026 | + $_output = addcslashes($content, '\'\\'); |
|
1027 | + $_output = str_replace("^#^", "'", $_output); |
|
1028 | + $_output = "<?php echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/" . $_output . |
|
1029 | + "/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>\n"; |
|
1030 | + // make sure we include modifier plugins for nocache code |
|
1031 | + foreach ($this->modifier_plugins as $plugin_name => $dummy) { |
|
1032 | + if (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ])) { |
|
1033 | + $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ 'modifier' ] = |
|
1034 | + $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ]; |
|
1035 | + } |
|
1036 | + } |
|
1037 | + } else { |
|
1038 | + $_output = $content; |
|
1039 | + } |
|
1040 | + } else { |
|
1041 | + $_output = $content; |
|
1042 | + } |
|
1043 | + $this->modifier_plugins = array(); |
|
1044 | + $this->suppressNocacheProcessing = false; |
|
1045 | + $this->tag_nocache = false; |
|
1046 | + |
|
1047 | + return $_output; |
|
1048 | + } |
|
1049 | + |
|
1050 | + /** |
|
1051 | + * Get Id |
|
1052 | + * |
|
1053 | + * @param string $input |
|
1054 | + * |
|
1055 | + * @return bool|string |
|
1056 | + */ |
|
1057 | + public function getId($input) |
|
1058 | + { |
|
1059 | + if (preg_match('~^([\'"]*)([0-9]*[a-zA-Z_]\w*)\1$~', $input, $match)) { |
|
1060 | + return $match[ 2 ]; |
|
1061 | + } |
|
1062 | + return false; |
|
1063 | + } |
|
1064 | + |
|
1065 | + /** |
|
1066 | + * Get variable name from string |
|
1067 | + * |
|
1068 | + * @param string $input |
|
1069 | + * |
|
1070 | + * @return bool|string |
|
1071 | + */ |
|
1072 | + public function getVariableName($input) |
|
1073 | + { |
|
1074 | + if (preg_match('~^[$]_smarty_tpl->tpl_vars\[[\'"]*([0-9]*[a-zA-Z_]\w*)[\'"]*\]->value$~', $input, $match)) { |
|
1075 | + return $match[ 1 ]; |
|
1076 | + } |
|
1077 | + return false; |
|
1078 | + } |
|
1079 | + |
|
1080 | + /** |
|
1081 | + * Set nocache flag in variable or create new variable |
|
1082 | + * |
|
1083 | + * @param string $varName |
|
1084 | + */ |
|
1085 | + public function setNocacheInVariable($varName) |
|
1086 | + { |
|
1087 | + // create nocache var to make it know for further compiling |
|
1088 | + if ($_var = $this->getId($varName)) { |
|
1089 | + if (isset($this->template->tpl_vars[ $_var ])) { |
|
1090 | + $this->template->tpl_vars[ $_var ] = clone $this->template->tpl_vars[ $_var ]; |
|
1091 | + $this->template->tpl_vars[ $_var ]->nocache = true; |
|
1092 | + } else { |
|
1093 | + $this->template->tpl_vars[ $_var ] = new Smarty_Variable(null, true); |
|
1094 | + } |
|
1095 | + } |
|
1096 | + } |
|
1097 | + |
|
1098 | + /** |
|
1099 | + * @param array $_attr tag attributes |
|
1100 | + * @param array $validScopes |
|
1101 | + * |
|
1102 | + * @return int|string |
|
1103 | + * @throws \SmartyCompilerException |
|
1104 | + */ |
|
1105 | + public function convertScope($_attr, $validScopes) |
|
1106 | + { |
|
1107 | + $_scope = 0; |
|
1108 | + if (isset($_attr[ 'scope' ])) { |
|
1109 | + $_scopeName = trim($_attr[ 'scope' ], "'\""); |
|
1110 | + if (is_numeric($_scopeName) && in_array($_scopeName, $validScopes)) { |
|
1111 | + $_scope = $_scopeName; |
|
1112 | + } elseif (is_string($_scopeName)) { |
|
1113 | + $_scopeName = trim($_scopeName, "'\""); |
|
1114 | + $_scope = isset($validScopes[ $_scopeName ]) ? $validScopes[ $_scopeName ] : false; |
|
1115 | + } else { |
|
1116 | + $_scope = false; |
|
1117 | + } |
|
1118 | + if ($_scope === false) { |
|
1119 | + $err = var_export($_scopeName, true); |
|
1120 | + $this->trigger_template_error("illegal value '{$err}' for \"scope\" attribute", null, true); |
|
1121 | + } |
|
1122 | + } |
|
1123 | + return $_scope; |
|
1124 | + } |
|
1125 | + |
|
1126 | + /** |
|
1127 | + * Generate nocache code string |
|
1128 | + * |
|
1129 | + * @param string $code PHP code |
|
1130 | + * |
|
1131 | + * @return string |
|
1132 | + */ |
|
1133 | + public function makeNocacheCode($code) |
|
1134 | + { |
|
1135 | + return "echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/<?php " . |
|
1136 | + str_replace("^#^", "'", addcslashes($code, '\'\\')) . |
|
1137 | + "?>/*/%%SmartyNocache:{$this->nocache_hash}%%*/';\n"; |
|
1138 | + } |
|
1139 | + |
|
1140 | + /** |
|
1141 | + * display compiler error messages without dying |
|
1142 | + * If parameter $args is empty it is a parser detected syntax error. |
|
1143 | + * In this case the parser is called to obtain information about expected tokens. |
|
1144 | + * If parameter $args contains a string this is used as error message |
|
1145 | + * |
|
1146 | + * @param string $args individual error message or null |
|
1147 | + * @param string $line line-number |
|
1148 | + * @param null|bool $tagline if true the line number of last tag |
|
1149 | + * |
|
1150 | + * @throws \SmartyCompilerException when an unexpected token is found |
|
1151 | + */ |
|
1152 | + public function trigger_template_error($args = null, $line = null, $tagline = null) |
|
1153 | + { |
|
1154 | + $lex = $this->parser->lex; |
|
1155 | + if ($tagline === true) { |
|
1156 | + // get line number of Tag |
|
1157 | + $line = $lex->taglineno; |
|
1158 | + } elseif (!isset($line)) { |
|
1159 | + // get template source line which has error |
|
1160 | + $line = $lex->line; |
|
1161 | + } else { |
|
1162 | + $line = (int) $line; |
|
1163 | + } |
|
1164 | + |
|
1165 | + if (in_array($this->template->source->type, array('eval', 'string'))) { |
|
1166 | + $templateName = $this->template->source->type . ':' . trim(preg_replace('![\t\r\n]+!', ' ', |
|
1167 | + strlen($lex->data) > 40 ? |
|
1168 | + substr($lex->data, 0, 40) . |
|
1169 | + '...' : $lex->data)); |
|
1170 | + } else { |
|
1171 | + $templateName = $this->template->source->type . ':' . $this->template->source->filepath; |
|
1172 | + } |
|
1173 | + |
|
1174 | + // $line += $this->trace_line_offset; |
|
1175 | + $match = preg_split("/\n/", $lex->data); |
|
1176 | + $error_text = |
|
1177 | + 'Syntax error in template "' . (empty($this->trace_filepath) ? $templateName : $this->trace_filepath) . |
|
1178 | + '" on line ' . ($line + $this->trace_line_offset) . ' "' . |
|
1179 | + trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ])) . '" '; |
|
1180 | + if (isset($args)) { |
|
1181 | + // individual error message |
|
1182 | + $error_text .= $args; |
|
1183 | + } else { |
|
1184 | + $expect = array(); |
|
1185 | + // expected token from parser |
|
1186 | + $error_text .= ' - Unexpected "' . $lex->value . '"'; |
|
1187 | + if (count($this->parser->yy_get_expected_tokens($this->parser->yymajor)) <= 4) { |
|
1188 | + foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) { |
|
1189 | + $exp_token = $this->parser->yyTokenName[ $token ]; |
|
1190 | + if (isset($lex->smarty_token_names[ $exp_token ])) { |
|
1191 | + // token type from lexer |
|
1192 | + $expect[] = '"' . $lex->smarty_token_names[ $exp_token ] . '"'; |
|
1193 | + } else { |
|
1194 | + // otherwise internal token name |
|
1195 | + $expect[] = $this->parser->yyTokenName[ $token ]; |
|
1196 | + } |
|
1197 | + } |
|
1198 | + $error_text .= ', expected one of: ' . implode(' , ', $expect); |
|
1199 | + } |
|
1200 | + } |
|
1201 | + $e = new SmartyCompilerException($error_text); |
|
1202 | + $e->line = $line; |
|
1203 | + $e->source = trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ])); |
|
1204 | + $e->desc = $args; |
|
1205 | + $e->template = $this->template->source->filepath; |
|
1206 | + throw $e; |
|
1207 | + } |
|
1208 | + |
|
1209 | + /** |
|
1210 | + * Return var_export() value with all white spaces removed |
|
1211 | + * |
|
1212 | + * @param mixed $value |
|
1213 | + * |
|
1214 | + * @return string |
|
1215 | + */ |
|
1216 | + public function getVarExport($value) |
|
1217 | + { |
|
1218 | + return preg_replace('/\s/', '', var_export($value, true)); |
|
1219 | + } |
|
1220 | + |
|
1221 | + /** |
|
1222 | + * Check if $value contains variable elements |
|
1223 | + * |
|
1224 | + * @param mixed $value |
|
1225 | + * |
|
1226 | + * @return bool|int |
|
1227 | + */ |
|
1228 | + public function isVariable($value) |
|
1229 | + { |
|
1230 | + if (is_string($value)) { |
|
1231 | + return preg_match('/[$(]/', $value); |
|
1232 | + } |
|
1233 | + if (is_bool($value) || is_numeric($value)) { |
|
1234 | + return false; |
|
1235 | + } |
|
1236 | + if (is_array($value)) { |
|
1237 | + foreach ($value as $k => $v) { |
|
1238 | + if ($this->isVariable($k) || $this->isVariable($v)) { |
|
1239 | + return true; |
|
1240 | + } |
|
1241 | + } |
|
1242 | + return false; |
|
1243 | + } |
|
1244 | + return false; |
|
1245 | + } |
|
1246 | + |
|
1247 | + /** |
|
1248 | + * Get new prefix variable name |
|
1249 | + * |
|
1250 | + * @return string |
|
1251 | + */ |
|
1252 | + public function getNewPrefixVariable() |
|
1253 | + { |
|
1254 | + self::$prefixVariableNumber ++; |
|
1255 | + return $this->getPrefixVariable(); |
|
1256 | + } |
|
1257 | + |
|
1258 | + /** |
|
1259 | + * Get current prefix variable name |
|
1260 | + * |
|
1261 | + * @return string |
|
1262 | + */ |
|
1263 | + public function getPrefixVariable() |
|
1264 | + { |
|
1265 | + return '$_prefixVariable' . self::$prefixVariableNumber; |
|
1266 | + } |
|
1267 | + |
|
1268 | + /** |
|
1269 | + * append code to prefix buffer |
|
1270 | + * |
|
1271 | + * @param string $code |
|
1272 | + */ |
|
1273 | + public function appendPrefixCode($code) |
|
1274 | + { |
|
1275 | + $this->prefix_code[] = $code; |
|
1276 | + } |
|
1277 | + |
|
1278 | + /** |
|
1279 | + * get prefix code string |
|
1280 | + * |
|
1281 | + * @return string |
|
1282 | + */ |
|
1283 | + public function getPrefixCode() |
|
1284 | + { |
|
1285 | + $code = ''; |
|
1286 | + $prefixArray = array_merge($this->prefix_code, array_pop($this->prefixCodeStack)); |
|
1287 | + $this->prefixCodeStack[] = array(); |
|
1288 | + foreach ($prefixArray as $c) { |
|
1289 | + $code = $this->appendCode($code, $c); |
|
1290 | + } |
|
1291 | + $this->prefix_code = array(); |
|
1292 | + return $code; |
|
1293 | + } |
|
1294 | 1294 | |
1295 | 1295 | } |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | $this->prefix_code = array(); |
387 | 387 | // add file dependency |
388 | 388 | if ($this->smarty->merge_compiled_includes || $this->template->source->handler->checkTimestamps()) { |
389 | - $this->parent_compiler->template->compiled->file_dependency[ $this->template->source->uid ] = |
|
389 | + $this->parent_compiler->template->compiled->file_dependency[$this->template->source->uid] = |
|
390 | 390 | array($this->template->source->filepath, $this->template->source->getTimeStamp(), |
391 | 391 | $this->template->source->type,); |
392 | 392 | } |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | { |
435 | 435 | // run post filter if on code |
436 | 436 | if (!empty($code) && |
437 | - (isset($this->smarty->autoload_filters[ 'post' ]) || isset($this->smarty->registered_filters[ 'post' ])) |
|
437 | + (isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) |
|
438 | 438 | ) { |
439 | 439 | return $this->smarty->ext->_filterHandler->runFilter('post', $code, $this->template); |
440 | 440 | } else { |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | { |
455 | 455 | // run pre filter if required |
456 | 456 | if ($_content != '' && |
457 | - ((isset($this->smarty->autoload_filters[ 'pre' ]) || isset($this->smarty->registered_filters[ 'pre' ]))) |
|
457 | + ((isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre']))) |
|
458 | 458 | ) { |
459 | 459 | return $this->smarty->ext->_filterHandler->runFilter('pre', $_content, $this->template); |
460 | 460 | } else { |
@@ -507,8 +507,8 @@ discard block |
||
507 | 507 | $this->has_code = true; |
508 | 508 | $this->has_output = false; |
509 | 509 | // log tag/attributes |
510 | - if (isset($this->smarty->_cache[ 'get_used_tags' ])) { |
|
511 | - $this->template->_cache[ 'used_tags' ][] = array($tag, $args); |
|
510 | + if (isset($this->smarty->_cache['get_used_tags'])) { |
|
511 | + $this->template->_cache['used_tags'][] = array($tag, $args); |
|
512 | 512 | } |
513 | 513 | // check nocache option flag |
514 | 514 | foreach ($args as $arg) { |
@@ -526,9 +526,9 @@ discard block |
||
526 | 526 | } |
527 | 527 | // compile the smarty tag (required compile classes to compile the tag are auto loaded) |
528 | 528 | if (($_output = $this->callTagCompiler($tag, $args, $parameter)) === false) { |
529 | - if (isset($this->parent_compiler->tpl_function[ $tag ])) { |
|
529 | + if (isset($this->parent_compiler->tpl_function[$tag])) { |
|
530 | 530 | // template defined by {template} tag |
531 | - $args[ '_attr' ][ 'name' ] = "'" . $tag . "'"; |
|
531 | + $args['_attr']['name'] = "'" . $tag . "'"; |
|
532 | 532 | $_output = $this->callTagCompiler('call', $args, $parameter); |
533 | 533 | } |
534 | 534 | } |
@@ -548,8 +548,8 @@ discard block |
||
548 | 548 | return null; |
549 | 549 | } else { |
550 | 550 | // map_named attributes |
551 | - if (isset($args[ '_attr' ])) { |
|
552 | - foreach ($args[ '_attr' ] as $key => $attribute) { |
|
551 | + if (isset($args['_attr'])) { |
|
552 | + foreach ($args['_attr'] as $key => $attribute) { |
|
553 | 553 | if (is_array($attribute)) { |
554 | 554 | $args = array_merge($args, $attribute); |
555 | 555 | } |
@@ -558,14 +558,14 @@ discard block |
||
558 | 558 | // not an internal compiler tag |
559 | 559 | if (strlen($tag) < 6 || substr($tag, - 5) != 'close') { |
560 | 560 | // check if tag is a registered object |
561 | - if (isset($this->smarty->registered_objects[ $tag ]) && isset($parameter[ 'object_method' ])) { |
|
562 | - $method = $parameter[ 'object_method' ]; |
|
563 | - if (!in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ]) && |
|
564 | - (empty($this->smarty->registered_objects[ $tag ][ 1 ]) || |
|
565 | - in_array($method, $this->smarty->registered_objects[ $tag ][ 1 ])) |
|
561 | + if (isset($this->smarty->registered_objects[$tag]) && isset($parameter['object_method'])) { |
|
562 | + $method = $parameter['object_method']; |
|
563 | + if (!in_array($method, $this->smarty->registered_objects[$tag][3]) && |
|
564 | + (empty($this->smarty->registered_objects[$tag][1]) || |
|
565 | + in_array($method, $this->smarty->registered_objects[$tag][1])) |
|
566 | 566 | ) { |
567 | 567 | return $this->callTagCompiler('private_object_function', $args, $parameter, $tag, $method); |
568 | - } elseif (in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ])) { |
|
568 | + } elseif (in_array($method, $this->smarty->registered_objects[$tag][3])) { |
|
569 | 569 | return $this->callTagCompiler('private_object_block_function', $args, $parameter, $tag, |
570 | 570 | $method); |
571 | 571 | } else { |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | // check if tag is registered |
578 | 578 | foreach (array(Smarty::PLUGIN_COMPILER, Smarty::PLUGIN_FUNCTION, Smarty::PLUGIN_BLOCK,) as $plugin_type) |
579 | 579 | { |
580 | - if (isset($this->smarty->registered_plugins[ $plugin_type ][ $tag ])) { |
|
580 | + if (isset($this->smarty->registered_plugins[$plugin_type][$tag])) { |
|
581 | 581 | // if compiler function plugin call it now |
582 | 582 | if ($plugin_type == Smarty::PLUGIN_COMPILER) { |
583 | 583 | $new_args = array(); |
@@ -585,13 +585,13 @@ discard block |
||
585 | 585 | if (is_array($mixed)) { |
586 | 586 | $new_args = array_merge($new_args, $mixed); |
587 | 587 | } else { |
588 | - $new_args[ $key ] = $mixed; |
|
588 | + $new_args[$key] = $mixed; |
|
589 | 589 | } |
590 | 590 | } |
591 | - if (!$this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 1 ]) { |
|
591 | + if (!$this->smarty->registered_plugins[$plugin_type][$tag][1]) { |
|
592 | 592 | $this->tag_nocache = true; |
593 | 593 | } |
594 | - return call_user_func_array($this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 0 ], |
|
594 | + return call_user_func_array($this->smarty->registered_plugins[$plugin_type][$tag][0], |
|
595 | 595 | array($new_args, $this)); |
596 | 596 | } |
597 | 597 | // compile registered function or block function |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | if (is_array($mixed)) { |
617 | 617 | $new_args = array_merge($new_args, $mixed); |
618 | 618 | } else { |
619 | - $new_args[ $key ] = $mixed; |
|
619 | + $new_args[$key] = $mixed; |
|
620 | 620 | } |
621 | 621 | } |
622 | 622 | |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | $found = false; |
645 | 645 | // look for already resolved tags |
646 | 646 | foreach ($this->plugin_search_order as $plugin_type) { |
647 | - if (isset($this->default_handler_plugins[ $plugin_type ][ $tag ])) { |
|
647 | + if (isset($this->default_handler_plugins[$plugin_type][$tag])) { |
|
648 | 648 | $found = true; |
649 | 649 | break; |
650 | 650 | } |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | foreach ($args as $mixed) { |
666 | 666 | $new_args = array_merge($new_args, $mixed); |
667 | 667 | } |
668 | - return call_user_func_array($this->default_handler_plugins[ $plugin_type ][ $tag ][ 0 ], |
|
668 | + return call_user_func_array($this->default_handler_plugins[$plugin_type][$tag][0], |
|
669 | 669 | array($new_args, $this)); |
670 | 670 | } else { |
671 | 671 | return $this->callTagCompiler('private_registered_' . $plugin_type, $args, $parameter, |
@@ -677,9 +677,9 @@ discard block |
||
677 | 677 | // compile closing tag of block function |
678 | 678 | $base_tag = substr($tag, 0, - 5); |
679 | 679 | // check if closing tag is a registered object |
680 | - if (isset($this->smarty->registered_objects[ $base_tag ]) && isset($parameter[ 'object_method' ])) { |
|
681 | - $method = $parameter[ 'object_method' ]; |
|
682 | - if (in_array($method, $this->smarty->registered_objects[ $base_tag ][ 3 ])) { |
|
680 | + if (isset($this->smarty->registered_objects[$base_tag]) && isset($parameter['object_method'])) { |
|
681 | + $method = $parameter['object_method']; |
|
682 | + if (in_array($method, $this->smarty->registered_objects[$base_tag][3])) { |
|
683 | 683 | return $this->callTagCompiler('private_object_block_function', $args, $parameter, $tag, |
684 | 684 | $method); |
685 | 685 | } else { |
@@ -689,13 +689,13 @@ discard block |
||
689 | 689 | } |
690 | 690 | } |
691 | 691 | // registered block tag ? |
692 | - if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ]) || |
|
693 | - isset($this->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ]) |
|
692 | + if (isset($this->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$base_tag]) || |
|
693 | + isset($this->default_handler_plugins[Smarty::PLUGIN_BLOCK][$base_tag]) |
|
694 | 694 | ) { |
695 | 695 | return $this->callTagCompiler('private_registered_block', $args, $parameter, $tag); |
696 | 696 | } |
697 | 697 | // registered function tag ? |
698 | - if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ])) { |
|
698 | + if (isset($this->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag])) { |
|
699 | 699 | return $this->callTagCompiler('private_registered_function', $args, $parameter, $tag); |
700 | 700 | } |
701 | 701 | // block plugin? |
@@ -711,13 +711,13 @@ discard block |
||
711 | 711 | } |
712 | 712 | } |
713 | 713 | // registered compiler plugin ? |
714 | - if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ])) { |
|
714 | + if (isset($this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER][$tag])) { |
|
715 | 715 | // if compiler function plugin call it now |
716 | 716 | $args = array(); |
717 | - if (!$this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 1 ]) { |
|
717 | + if (!$this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER][$tag][1]) { |
|
718 | 718 | $this->tag_nocache = true; |
719 | 719 | } |
720 | - return call_user_func_array($this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 0 ], |
|
720 | + return call_user_func_array($this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER][$tag][0], |
|
721 | 721 | array($args, $this)); |
722 | 722 | } |
723 | 723 | if ($this->smarty->loadPlugin('smarty_compiler_' . $tag)) { |
@@ -792,13 +792,13 @@ discard block |
||
792 | 792 | if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is', |
793 | 793 | $text, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
794 | 794 | foreach ($matches as $match) { |
795 | - $store[] = $match[ 0 ][ 0 ]; |
|
796 | - $_length = strlen($match[ 0 ][ 0 ]); |
|
795 | + $store[] = $match[0][0]; |
|
796 | + $_length = strlen($match[0][0]); |
|
797 | 797 | $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; |
798 | - $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); |
|
798 | + $text = substr_replace($text, $replace, $match[0][1] - $_offset, $_length); |
|
799 | 799 | |
800 | 800 | $_offset += $_length - strlen($replace); |
801 | - $_store ++; |
|
801 | + $_store++; |
|
802 | 802 | } |
803 | 803 | } |
804 | 804 | $expressions = array(// replace multiple spaces between tags by a single space |
@@ -815,12 +815,12 @@ discard block |
||
815 | 815 | if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $text, $matches, |
816 | 816 | PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { |
817 | 817 | foreach ($matches as $match) { |
818 | - $_length = strlen($match[ 0 ][ 0 ]); |
|
819 | - $replace = $store[ $match[ 1 ][ 0 ] ]; |
|
820 | - $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] + $_offset, $_length); |
|
818 | + $_length = strlen($match[0][0]); |
|
819 | + $replace = $store[$match[1][0]]; |
|
820 | + $text = substr_replace($text, $replace, $match[0][1] + $_offset, $_length); |
|
821 | 821 | |
822 | 822 | $_offset += strlen($replace) - $_length; |
823 | - $_store ++; |
|
823 | + $_store++; |
|
824 | 824 | } |
825 | 825 | } |
826 | 826 | } else { |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | public function callTagCompiler($tag, $args, $param1 = null, $param2 = null, $param3 = null) |
850 | 850 | { |
851 | 851 | // re-use object if already exists |
852 | - if (!isset(self::$_tag_objects[ $tag ])) { |
|
852 | + if (!isset(self::$_tag_objects[$tag])) { |
|
853 | 853 | // lazy load internal compiler plugin |
854 | 854 | $_tag = explode('_', $tag); |
855 | 855 | $_tag = array_map('ucfirst', $_tag); |
@@ -857,15 +857,14 @@ discard block |
||
857 | 857 | if (class_exists($class_name) && |
858 | 858 | (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this)) |
859 | 859 | ) { |
860 | - self::$_tag_objects[ $tag ] = new $class_name; |
|
860 | + self::$_tag_objects[$tag] = new $class_name; |
|
861 | 861 | } else { |
862 | - self::$_tag_objects[ $tag ] = false; |
|
862 | + self::$_tag_objects[$tag] = false; |
|
863 | 863 | return false; |
864 | 864 | } |
865 | 865 | } |
866 | 866 | // compile this tag |
867 | - return self::$_tag_objects[ $tag ] === false ? false : |
|
868 | - self::$_tag_objects[ $tag ]->compile($args, $this, $param1, $param2, $param3); |
|
867 | + return self::$_tag_objects[$tag] === false ? false : self::$_tag_objects[$tag]->compile($args, $this, $param1, $param2, $param3); |
|
869 | 868 | } |
870 | 869 | |
871 | 870 | /** |
@@ -880,29 +879,29 @@ discard block |
||
880 | 879 | { |
881 | 880 | $function = null; |
882 | 881 | if ($this->template->caching && ($this->nocache || $this->tag_nocache)) { |
883 | - if (isset($this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ])) { |
|
882 | + if (isset($this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type])) { |
|
884 | 883 | $function = |
885 | - $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ]; |
|
886 | - } elseif (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ])) { |
|
887 | - $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ] = |
|
888 | - $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ]; |
|
884 | + $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['function']; |
|
885 | + } elseif (isset($this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type])) { |
|
886 | + $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type] = |
|
887 | + $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]; |
|
889 | 888 | $function = |
890 | - $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ]; |
|
889 | + $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['function']; |
|
891 | 890 | } |
892 | 891 | } else { |
893 | - if (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ])) { |
|
892 | + if (isset($this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type])) { |
|
894 | 893 | $function = |
895 | - $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ]; |
|
896 | - } elseif (isset($this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ])) { |
|
897 | - $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ] = |
|
898 | - $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ]; |
|
894 | + $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['function']; |
|
895 | + } elseif (isset($this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type])) { |
|
896 | + $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type] = |
|
897 | + $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]; |
|
899 | 898 | $function = |
900 | - $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ]; |
|
899 | + $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['function']; |
|
901 | 900 | } |
902 | 901 | } |
903 | 902 | if (isset($function)) { |
904 | 903 | if ($plugin_type == 'modifier') { |
905 | - $this->modifier_plugins[ $plugin_name ] = true; |
|
904 | + $this->modifier_plugins[$plugin_name] = true; |
|
906 | 905 | } |
907 | 906 | |
908 | 907 | return $function; |
@@ -913,18 +912,18 @@ discard block |
||
913 | 912 | |
914 | 913 | if (is_string($file)) { |
915 | 914 | if ($this->template->caching && ($this->nocache || $this->tag_nocache)) { |
916 | - $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'file' ] = |
|
915 | + $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['file'] = |
|
917 | 916 | $file; |
918 | - $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ] = |
|
917 | + $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['function'] = |
|
919 | 918 | $function; |
920 | 919 | } else { |
921 | - $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'file' ] = |
|
920 | + $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['file'] = |
|
922 | 921 | $file; |
923 | - $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ] = |
|
922 | + $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['function'] = |
|
924 | 923 | $function; |
925 | 924 | } |
926 | 925 | if ($plugin_type == 'modifier') { |
927 | - $this->modifier_plugins[ $plugin_name ] = true; |
|
926 | + $this->modifier_plugins[$plugin_name] = true; |
|
928 | 927 | } |
929 | 928 | |
930 | 929 | return $function; |
@@ -957,14 +956,14 @@ discard block |
||
957 | 956 | if ($script !== null) { |
958 | 957 | if (is_file($script)) { |
959 | 958 | if ($this->template->caching && ($this->nocache || $this->tag_nocache)) { |
960 | - $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $tag ][ $plugin_type ][ 'file' ] = |
|
959 | + $this->parent_compiler->template->compiled->required_plugins['nocache'][$tag][$plugin_type]['file'] = |
|
961 | 960 | $script; |
962 | - $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $tag ][ $plugin_type ][ 'function' ] = |
|
961 | + $this->parent_compiler->template->compiled->required_plugins['nocache'][$tag][$plugin_type]['function'] = |
|
963 | 962 | $callback; |
964 | 963 | } else { |
965 | - $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $tag ][ $plugin_type ][ 'file' ] = |
|
964 | + $this->parent_compiler->template->compiled->required_plugins['compiled'][$tag][$plugin_type]['file'] = |
|
966 | 965 | $script; |
967 | - $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $tag ][ $plugin_type ][ 'function' ] = |
|
966 | + $this->parent_compiler->template->compiled->required_plugins['compiled'][$tag][$plugin_type]['function'] = |
|
968 | 967 | $callback; |
969 | 968 | } |
970 | 969 | require_once $script; |
@@ -973,7 +972,7 @@ discard block |
||
973 | 972 | } |
974 | 973 | } |
975 | 974 | if (is_callable($callback)) { |
976 | - $this->default_handler_plugins[ $plugin_type ][ $tag ] = array($callback, true, array()); |
|
975 | + $this->default_handler_plugins[$plugin_type][$tag] = array($callback, true, array()); |
|
977 | 976 | |
978 | 977 | return true; |
979 | 978 | } else { |
@@ -1029,9 +1028,9 @@ discard block |
||
1029 | 1028 | "/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>\n"; |
1030 | 1029 | // make sure we include modifier plugins for nocache code |
1031 | 1030 | foreach ($this->modifier_plugins as $plugin_name => $dummy) { |
1032 | - if (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ])) { |
|
1033 | - $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ 'modifier' ] = |
|
1034 | - $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ]; |
|
1031 | + if (isset($this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name]['modifier'])) { |
|
1032 | + $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name]['modifier'] = |
|
1033 | + $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name]['modifier']; |
|
1035 | 1034 | } |
1036 | 1035 | } |
1037 | 1036 | } else { |
@@ -1057,7 +1056,7 @@ discard block |
||
1057 | 1056 | public function getId($input) |
1058 | 1057 | { |
1059 | 1058 | if (preg_match('~^([\'"]*)([0-9]*[a-zA-Z_]\w*)\1$~', $input, $match)) { |
1060 | - return $match[ 2 ]; |
|
1059 | + return $match[2]; |
|
1061 | 1060 | } |
1062 | 1061 | return false; |
1063 | 1062 | } |
@@ -1072,7 +1071,7 @@ discard block |
||
1072 | 1071 | public function getVariableName($input) |
1073 | 1072 | { |
1074 | 1073 | if (preg_match('~^[$]_smarty_tpl->tpl_vars\[[\'"]*([0-9]*[a-zA-Z_]\w*)[\'"]*\]->value$~', $input, $match)) { |
1075 | - return $match[ 1 ]; |
|
1074 | + return $match[1]; |
|
1076 | 1075 | } |
1077 | 1076 | return false; |
1078 | 1077 | } |
@@ -1086,11 +1085,11 @@ discard block |
||
1086 | 1085 | { |
1087 | 1086 | // create nocache var to make it know for further compiling |
1088 | 1087 | if ($_var = $this->getId($varName)) { |
1089 | - if (isset($this->template->tpl_vars[ $_var ])) { |
|
1090 | - $this->template->tpl_vars[ $_var ] = clone $this->template->tpl_vars[ $_var ]; |
|
1091 | - $this->template->tpl_vars[ $_var ]->nocache = true; |
|
1088 | + if (isset($this->template->tpl_vars[$_var])) { |
|
1089 | + $this->template->tpl_vars[$_var] = clone $this->template->tpl_vars[$_var]; |
|
1090 | + $this->template->tpl_vars[$_var]->nocache = true; |
|
1092 | 1091 | } else { |
1093 | - $this->template->tpl_vars[ $_var ] = new Smarty_Variable(null, true); |
|
1092 | + $this->template->tpl_vars[$_var] = new Smarty_Variable(null, true); |
|
1094 | 1093 | } |
1095 | 1094 | } |
1096 | 1095 | } |
@@ -1105,13 +1104,13 @@ discard block |
||
1105 | 1104 | public function convertScope($_attr, $validScopes) |
1106 | 1105 | { |
1107 | 1106 | $_scope = 0; |
1108 | - if (isset($_attr[ 'scope' ])) { |
|
1109 | - $_scopeName = trim($_attr[ 'scope' ], "'\""); |
|
1107 | + if (isset($_attr['scope'])) { |
|
1108 | + $_scopeName = trim($_attr['scope'], "'\""); |
|
1110 | 1109 | if (is_numeric($_scopeName) && in_array($_scopeName, $validScopes)) { |
1111 | 1110 | $_scope = $_scopeName; |
1112 | 1111 | } elseif (is_string($_scopeName)) { |
1113 | 1112 | $_scopeName = trim($_scopeName, "'\""); |
1114 | - $_scope = isset($validScopes[ $_scopeName ]) ? $validScopes[ $_scopeName ] : false; |
|
1113 | + $_scope = isset($validScopes[$_scopeName]) ? $validScopes[$_scopeName] : false; |
|
1115 | 1114 | } else { |
1116 | 1115 | $_scope = false; |
1117 | 1116 | } |
@@ -1176,7 +1175,7 @@ discard block |
||
1176 | 1175 | $error_text = |
1177 | 1176 | 'Syntax error in template "' . (empty($this->trace_filepath) ? $templateName : $this->trace_filepath) . |
1178 | 1177 | '" on line ' . ($line + $this->trace_line_offset) . ' "' . |
1179 | - trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ])) . '" '; |
|
1178 | + trim(preg_replace('![\t\r\n]+!', ' ', $match[$line - 1])) . '" '; |
|
1180 | 1179 | if (isset($args)) { |
1181 | 1180 | // individual error message |
1182 | 1181 | $error_text .= $args; |
@@ -1186,13 +1185,13 @@ discard block |
||
1186 | 1185 | $error_text .= ' - Unexpected "' . $lex->value . '"'; |
1187 | 1186 | if (count($this->parser->yy_get_expected_tokens($this->parser->yymajor)) <= 4) { |
1188 | 1187 | foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) { |
1189 | - $exp_token = $this->parser->yyTokenName[ $token ]; |
|
1190 | - if (isset($lex->smarty_token_names[ $exp_token ])) { |
|
1188 | + $exp_token = $this->parser->yyTokenName[$token]; |
|
1189 | + if (isset($lex->smarty_token_names[$exp_token])) { |
|
1191 | 1190 | // token type from lexer |
1192 | - $expect[] = '"' . $lex->smarty_token_names[ $exp_token ] . '"'; |
|
1191 | + $expect[] = '"' . $lex->smarty_token_names[$exp_token] . '"'; |
|
1193 | 1192 | } else { |
1194 | 1193 | // otherwise internal token name |
1195 | - $expect[] = $this->parser->yyTokenName[ $token ]; |
|
1194 | + $expect[] = $this->parser->yyTokenName[$token]; |
|
1196 | 1195 | } |
1197 | 1196 | } |
1198 | 1197 | $error_text .= ', expected one of: ' . implode(' , ', $expect); |
@@ -1200,7 +1199,7 @@ discard block |
||
1200 | 1199 | } |
1201 | 1200 | $e = new SmartyCompilerException($error_text); |
1202 | 1201 | $e->line = $line; |
1203 | - $e->source = trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ])); |
|
1202 | + $e->source = trim(preg_replace('![\t\r\n]+!', ' ', $match[$line - 1])); |
|
1204 | 1203 | $e->desc = $args; |
1205 | 1204 | $e->template = $this->template->source->filepath; |
1206 | 1205 | throw $e; |
@@ -1251,7 +1250,7 @@ discard block |
||
1251 | 1250 | */ |
1252 | 1251 | public function getNewPrefixVariable() |
1253 | 1252 | { |
1254 | - self::$prefixVariableNumber ++; |
|
1253 | + self::$prefixVariableNumber++; |
|
1255 | 1254 | return $this->getPrefixVariable(); |
1256 | 1255 | } |
1257 | 1256 |
@@ -213,8 +213,7 @@ |
||
213 | 213 | error_reporting($_smarty_old_error_level); |
214 | 214 | } |
215 | 215 | return $result; |
216 | - } |
|
217 | - catch (Exception $e) { |
|
216 | + } catch (Exception $e) { |
|
218 | 217 | while (ob_get_level() > $level) { |
219 | 218 | ob_end_clean(); |
220 | 219 | } |
@@ -241,6 +241,9 @@ discard block |
||
241 | 241 | return $this->{'yylex' . $this->_yy_state}(); |
242 | 242 | } |
243 | 243 | |
244 | + /** |
|
245 | + * @param integer $state |
|
246 | + */ |
|
244 | 247 | public function yypushstate($state) |
245 | 248 | { |
246 | 249 | if ($this->yyTraceFILE) { |
@@ -272,6 +275,9 @@ discard block |
||
272 | 275 | } |
273 | 276 | } |
274 | 277 | |
278 | + /** |
|
279 | + * @param integer $state |
|
280 | + */ |
|
275 | 281 | public function yybegin($state) |
276 | 282 | { |
277 | 283 | $this->_yy_state = $state; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $this->data = $data; |
205 | 205 | $this->counter = 0; |
206 | 206 | if (preg_match('/^\xEF\xBB\xBF/i', $this->data, $match)) { |
207 | - $this->counter += strlen($match[ 0 ]); |
|
207 | + $this->counter += strlen($match[0]); |
|
208 | 208 | } |
209 | 209 | $this->line = 1; |
210 | 210 | $this->smarty = $compiler->smarty; |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | $this->ldel_length = strlen($this->smarty->left_delimiter); |
214 | 214 | $this->rdel = preg_quote($this->smarty->right_delimiter, '/'); |
215 | 215 | $this->rdel_length = strlen($this->smarty->right_delimiter); |
216 | - $this->smarty_token_names[ 'LDEL' ] = $this->smarty->left_delimiter; |
|
217 | - $this->smarty_token_names[ 'RDEL' ] = $this->smarty->right_delimiter; |
|
216 | + $this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter; |
|
217 | + $this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter; |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | public function PrintTrace() |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function isAutoLiteral() |
230 | 230 | { |
231 | - return $this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
232 | - strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false; |
|
231 | + return $this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? |
|
232 | + strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false; |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | private $_yy_state = 1; |
@@ -245,15 +245,13 @@ discard block |
||
245 | 245 | { |
246 | 246 | if ($this->yyTraceFILE) { |
247 | 247 | fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt, |
248 | - isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : |
|
249 | - $this->_yy_state); |
|
248 | + isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state); |
|
250 | 249 | } |
251 | 250 | array_push($this->_yy_stack, $this->_yy_state); |
252 | 251 | $this->_yy_state = $state; |
253 | 252 | if ($this->yyTraceFILE) { |
254 | 253 | fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, |
255 | - isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : |
|
256 | - $this->_yy_state); |
|
254 | + isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state); |
|
257 | 255 | } |
258 | 256 | } |
259 | 257 | |
@@ -261,14 +259,12 @@ discard block |
||
261 | 259 | { |
262 | 260 | if ($this->yyTraceFILE) { |
263 | 261 | fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt, |
264 | - isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : |
|
265 | - $this->_yy_state); |
|
262 | + isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state); |
|
266 | 263 | } |
267 | 264 | $this->_yy_state = array_pop($this->_yy_stack); |
268 | 265 | if ($this->yyTraceFILE) { |
269 | 266 | fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, |
270 | - isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : |
|
271 | - $this->_yy_state); |
|
267 | + isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state); |
|
272 | 268 | } |
273 | 269 | } |
274 | 270 | |
@@ -277,8 +273,7 @@ discard block |
||
277 | 273 | $this->_yy_state = $state; |
278 | 274 | if ($this->yyTraceFILE) { |
279 | 275 | fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt, |
280 | - isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : |
|
281 | - $this->_yy_state); |
|
276 | + isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state); |
|
282 | 277 | } |
283 | 278 | } |
284 | 279 | |
@@ -298,7 +293,7 @@ discard block |
||
298 | 293 | do { |
299 | 294 | if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, null, $this->counter)) { |
300 | 295 | $yysubmatches = $yymatches; |
301 | - if (strlen($yysubmatches[ 0 ]) < 200) { |
|
296 | + if (strlen($yysubmatches[0]) < 200) { |
|
302 | 297 | $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
303 | 298 | } else { |
304 | 299 | $yymatches = array_filter($yymatches, 'strlen'); |
@@ -330,7 +325,7 @@ discard block |
||
330 | 325 | continue; |
331 | 326 | } |
332 | 327 | } else { |
333 | - throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]); |
|
328 | + throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]); |
|
334 | 329 | } |
335 | 330 | break; |
336 | 331 | } |
@@ -349,8 +344,8 @@ discard block |
||
349 | 344 | { |
350 | 345 | |
351 | 346 | preg_match("/[*]{$this->rdel}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); |
352 | - if (isset($match[ 0 ][ 1 ])) { |
|
353 | - $to = $match[ 0 ][ 1 ] + strlen($match[ 0 ][ 0 ]); |
|
347 | + if (isset($match[0][1])) { |
|
348 | + $to = $match[0][1] + strlen($match[0][0]); |
|
354 | 349 | } else { |
355 | 350 | $this->compiler->trigger_template_error("missing or misspelled comment closing tag '*{$this->smarty->right_delimiter}'"); |
356 | 351 | } |
@@ -368,8 +363,8 @@ discard block |
||
368 | 363 | function yy_r1_7() |
369 | 364 | { |
370 | 365 | |
371 | - if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
372 | - strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false |
|
366 | + if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? |
|
367 | + strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false |
|
373 | 368 | ) { |
374 | 369 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
375 | 370 | } else { |
@@ -381,8 +376,8 @@ discard block |
||
381 | 376 | function yy_r1_8() |
382 | 377 | { |
383 | 378 | |
384 | - if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
385 | - strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false |
|
379 | + if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? |
|
380 | + strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false |
|
386 | 381 | ) { |
387 | 382 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
388 | 383 | } else { |
@@ -410,8 +405,8 @@ discard block |
||
410 | 405 | $to = strlen($this->data); |
411 | 406 | preg_match("/($this->ldel)|(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*[\"']?\s*php\s*[\"']?\s*>)|([?][>])|([%][>])/i", |
412 | 407 | $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); |
413 | - if (isset($match[ 0 ][ 1 ])) { |
|
414 | - $to = $match[ 0 ][ 1 ]; |
|
408 | + if (isset($match[0][1])) { |
|
409 | + $to = $match[0][1]; |
|
415 | 410 | } |
416 | 411 | $this->value = substr($this->data, $this->counter, $to - $this->counter); |
417 | 412 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
@@ -435,7 +430,7 @@ discard block |
||
435 | 430 | do { |
436 | 431 | if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, null, $this->counter)) { |
437 | 432 | $yysubmatches = $yymatches; |
438 | - if (strlen($yysubmatches[ 0 ]) < 200) { |
|
433 | + if (strlen($yysubmatches[0]) < 200) { |
|
439 | 434 | $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
440 | 435 | } else { |
441 | 436 | $yymatches = array_filter($yymatches, 'strlen'); |
@@ -467,7 +462,7 @@ discard block |
||
467 | 462 | continue; |
468 | 463 | } |
469 | 464 | } else { |
470 | - throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]); |
|
465 | + throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]); |
|
471 | 466 | } |
472 | 467 | break; |
473 | 468 | } |
@@ -535,7 +530,7 @@ discard block |
||
535 | 530 | function yy_r2_10() |
536 | 531 | { |
537 | 532 | |
538 | - if ($this->_yy_stack[ count($this->_yy_stack) - 1 ] == self::TEXT) { |
|
533 | + if ($this->_yy_stack[count($this->_yy_stack) - 1] == self::TEXT) { |
|
539 | 534 | $this->yypopstate(); |
540 | 535 | $this->token = Smarty_Internal_Templateparser::TP_SIMPELOUTPUT; |
541 | 536 | $this->taglineno = $this->line; |
@@ -576,7 +571,7 @@ discard block |
||
576 | 571 | do { |
577 | 572 | if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, null, $this->counter)) { |
578 | 573 | $yysubmatches = $yymatches; |
579 | - if (strlen($yysubmatches[ 0 ]) < 200) { |
|
574 | + if (strlen($yysubmatches[0]) < 200) { |
|
580 | 575 | $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
581 | 576 | } else { |
582 | 577 | $yymatches = array_filter($yymatches, 'strlen'); |
@@ -608,7 +603,7 @@ discard block |
||
608 | 603 | continue; |
609 | 604 | } |
610 | 605 | } else { |
611 | - throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]); |
|
606 | + throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]); |
|
612 | 607 | } |
613 | 608 | break; |
614 | 609 | } |
@@ -627,8 +622,8 @@ discard block |
||
627 | 622 | function yy_r3_2() |
628 | 623 | { |
629 | 624 | |
630 | - if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
631 | - strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false |
|
625 | + if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? |
|
626 | + strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false |
|
632 | 627 | ) { |
633 | 628 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
634 | 629 | } else { |
@@ -815,7 +810,7 @@ discard block |
||
815 | 810 | $this->smarty->right_delimiter |
816 | 811 | ) { |
817 | 812 | preg_match("/\s+/", $this->value, $match); |
818 | - $this->value = $match[ 0 ]; |
|
813 | + $this->value = $match[0]; |
|
819 | 814 | $this->token = Smarty_Internal_Templateparser::TP_SPACE; |
820 | 815 | } else { |
821 | 816 | $this->token = Smarty_Internal_Templateparser::TP_ATTR; |
@@ -921,7 +916,7 @@ discard block |
||
921 | 916 | do { |
922 | 917 | if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, null, $this->counter)) { |
923 | 918 | $yysubmatches = $yymatches; |
924 | - if (strlen($yysubmatches[ 0 ]) < 200) { |
|
919 | + if (strlen($yysubmatches[0]) < 200) { |
|
925 | 920 | $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
926 | 921 | } else { |
927 | 922 | $yymatches = array_filter($yymatches, 'strlen'); |
@@ -953,7 +948,7 @@ discard block |
||
953 | 948 | continue; |
954 | 949 | } |
955 | 950 | } else { |
956 | - throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]); |
|
951 | + throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]); |
|
957 | 952 | } |
958 | 953 | break; |
959 | 954 | } |
@@ -965,7 +960,7 @@ discard block |
||
965 | 960 | function yy_r4_1() |
966 | 961 | { |
967 | 962 | |
968 | - $this->literal_cnt ++; |
|
963 | + $this->literal_cnt++; |
|
969 | 964 | $this->token = Smarty_Internal_Templateparser::TP_LITERAL; |
970 | 965 | } |
971 | 966 | |
@@ -973,7 +968,7 @@ discard block |
||
973 | 968 | { |
974 | 969 | |
975 | 970 | if ($this->literal_cnt) { |
976 | - $this->literal_cnt --; |
|
971 | + $this->literal_cnt--; |
|
977 | 972 | $this->token = Smarty_Internal_Templateparser::TP_LITERAL; |
978 | 973 | } else { |
979 | 974 | $this->token = Smarty_Internal_Templateparser::TP_LITERALEND; |
@@ -987,8 +982,8 @@ discard block |
||
987 | 982 | $to = strlen($this->data); |
988 | 983 | preg_match("/{$this->ldel}[\/]?literal{$this->rdel}/i", $this->data, $match, PREG_OFFSET_CAPTURE, |
989 | 984 | $this->counter); |
990 | - if (isset($match[ 0 ][ 1 ])) { |
|
991 | - $to = $match[ 0 ][ 1 ]; |
|
985 | + if (isset($match[0][1])) { |
|
986 | + $to = $match[0][1]; |
|
992 | 987 | } else { |
993 | 988 | $this->compiler->trigger_template_error("missing or misspelled literal closing tag"); |
994 | 989 | } |
@@ -1013,7 +1008,7 @@ discard block |
||
1013 | 1008 | do { |
1014 | 1009 | if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, null, $this->counter)) { |
1015 | 1010 | $yysubmatches = $yymatches; |
1016 | - if (strlen($yysubmatches[ 0 ]) < 200) { |
|
1011 | + if (strlen($yysubmatches[0]) < 200) { |
|
1017 | 1012 | $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
1018 | 1013 | } else { |
1019 | 1014 | $yymatches = array_filter($yymatches, 'strlen'); |
@@ -1045,7 +1040,7 @@ discard block |
||
1045 | 1040 | continue; |
1046 | 1041 | } |
1047 | 1042 | } else { |
1048 | - throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]); |
|
1043 | + throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]); |
|
1049 | 1044 | } |
1050 | 1045 | break; |
1051 | 1046 | } |
@@ -1069,8 +1064,8 @@ discard block |
||
1069 | 1064 | function yy_r5_3() |
1070 | 1065 | { |
1071 | 1066 | |
1072 | - if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
1073 | - strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false |
|
1067 | + if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? |
|
1068 | + strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false |
|
1074 | 1069 | ) { |
1075 | 1070 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
1076 | 1071 | } else { |
@@ -1082,8 +1077,8 @@ discard block |
||
1082 | 1077 | function yy_r5_4() |
1083 | 1078 | { |
1084 | 1079 | |
1085 | - if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
1086 | - strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false |
|
1080 | + if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? |
|
1081 | + strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false |
|
1087 | 1082 | ) { |
1088 | 1083 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
1089 | 1084 | } else { |
@@ -1095,8 +1090,8 @@ discard block |
||
1095 | 1090 | function yy_r5_5() |
1096 | 1091 | { |
1097 | 1092 | |
1098 | - if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
1099 | - strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false |
|
1093 | + if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? |
|
1094 | + strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false |
|
1100 | 1095 | ) { |
1101 | 1096 | $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
1102 | 1097 | } else { |
@@ -18,1136 +18,1136 @@ |
||
18 | 18 | */ |
19 | 19 | class Smarty_Internal_Templatelexer |
20 | 20 | { |
21 | - /** |
|
22 | - * Source |
|
23 | - * |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - public $data; |
|
27 | - |
|
28 | - /** |
|
29 | - * byte counter |
|
30 | - * |
|
31 | - * @var int |
|
32 | - */ |
|
33 | - public $counter; |
|
34 | - |
|
35 | - /** |
|
36 | - * token number |
|
37 | - * |
|
38 | - * @var int |
|
39 | - */ |
|
40 | - public $token; |
|
41 | - |
|
42 | - /** |
|
43 | - * token value |
|
44 | - * |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - public $value; |
|
48 | - |
|
49 | - /** |
|
50 | - * current line |
|
51 | - * |
|
52 | - * @var int |
|
53 | - */ |
|
54 | - public $line; |
|
55 | - |
|
56 | - /** |
|
57 | - * tag start line |
|
58 | - * |
|
59 | - * @var |
|
60 | - */ |
|
61 | - public $taglineno; |
|
62 | - |
|
63 | - /** |
|
64 | - * php code type |
|
65 | - * |
|
66 | - * @var string |
|
67 | - */ |
|
68 | - public $phpType = ''; |
|
69 | - |
|
70 | - /** |
|
71 | - * escaped left delimiter |
|
72 | - * |
|
73 | - * @var string |
|
74 | - */ |
|
75 | - public $ldel = ''; |
|
76 | - |
|
77 | - /** |
|
78 | - * escaped left delimiter length |
|
79 | - * |
|
80 | - * @var int |
|
81 | - */ |
|
82 | - public $ldel_length = 0; |
|
83 | - |
|
84 | - /** |
|
85 | - * escaped right delimiter |
|
86 | - * |
|
87 | - * @var string |
|
88 | - */ |
|
89 | - public $rdel = ''; |
|
90 | - |
|
91 | - /** |
|
92 | - * escaped right delimiter length |
|
93 | - * |
|
94 | - * @var int |
|
95 | - */ |
|
96 | - public $rdel_length = 0; |
|
97 | - |
|
98 | - /** |
|
99 | - * state number |
|
100 | - * |
|
101 | - * @var int |
|
102 | - */ |
|
103 | - public $state = 1; |
|
104 | - |
|
105 | - /** |
|
106 | - * Smarty object |
|
107 | - * |
|
108 | - * @var Smarty |
|
109 | - */ |
|
110 | - public $smarty = null; |
|
111 | - |
|
112 | - /** |
|
113 | - * compiler object |
|
114 | - * |
|
115 | - * @var Smarty_Internal_TemplateCompilerBase |
|
116 | - */ |
|
117 | - public $compiler = null; |
|
118 | - |
|
119 | - /** |
|
120 | - * literal tag nesting level |
|
121 | - * |
|
122 | - * @var int |
|
123 | - */ |
|
124 | - private $literal_cnt = 0; |
|
125 | - |
|
126 | - /** |
|
127 | - * PHP start tag string |
|
128 | - * |
|
129 | - * @var string |
|
130 | - */ |
|
131 | - |
|
132 | - /** |
|
133 | - * trace file |
|
134 | - * |
|
135 | - * @var resource |
|
136 | - */ |
|
137 | - public $yyTraceFILE; |
|
138 | - |
|
139 | - /** |
|
140 | - * trace prompt |
|
141 | - * |
|
142 | - * @var string |
|
143 | - */ |
|
144 | - public $yyTracePrompt; |
|
145 | - |
|
146 | - /** |
|
147 | - * XML flag true while processing xml |
|
148 | - * |
|
149 | - * @var bool |
|
150 | - */ |
|
151 | - public $is_xml = false; |
|
152 | - |
|
153 | - /** |
|
154 | - * state names |
|
155 | - * |
|
156 | - * @var array |
|
157 | - */ |
|
158 | - public $state_name = array(1 => 'TEXT', 2 => 'TAG', 3 => 'TAGBODY', 4 => 'LITERAL', 5 => 'DOUBLEQUOTEDSTRING',); |
|
159 | - |
|
160 | - /** |
|
161 | - * storage for assembled token patterns |
|
162 | - * |
|
163 | - * @var string |
|
164 | - */ |
|
165 | - private $yy_global_pattern1 = null; |
|
166 | - |
|
167 | - private $yy_global_pattern2 = null; |
|
168 | - |
|
169 | - private $yy_global_pattern3 = null; |
|
170 | - |
|
171 | - private $yy_global_pattern4 = null; |
|
172 | - |
|
173 | - private $yy_global_pattern5 = null; |
|
174 | - |
|
175 | - /** |
|
176 | - * token names |
|
177 | - * |
|
178 | - * @var array |
|
179 | - */ |
|
180 | - public $smarty_token_names = array( // Text for parser error messages |
|
181 | - 'NOT' => '(!,not)', 'OPENP' => '(', 'CLOSEP' => ')', 'OPENB' => '[', |
|
182 | - 'CLOSEB' => ']', 'PTR' => '->', 'APTR' => '=>', 'EQUAL' => '=', |
|
183 | - 'NUMBER' => 'number', 'UNIMATH' => '+" , "-', 'MATH' => '*" , "/" , "%', |
|
184 | - 'INCDEC' => '++" , "--', 'SPACE' => ' ', 'DOLLAR' => '$', |
|
185 | - 'SEMICOLON' => ';', 'COLON' => ':', 'DOUBLECOLON' => '::', 'AT' => '@', |
|
186 | - 'HATCH' => '#', 'QUOTE' => '"', 'BACKTICK' => '`', |
|
187 | - 'VERT' => '"|" modifier', 'DOT' => '.', 'COMMA' => '","', |
|
188 | - 'QMARK' => '"?"', 'ID' => 'id, name', 'TEXT' => 'text', |
|
189 | - 'LDELSLASH' => '{/..} closing tag', 'LDEL' => '{...} Smarty tag', |
|
190 | - 'COMMENT' => 'comment', 'AS' => 'as', 'TO' => 'to', |
|
191 | - 'PHP' => '"<?php", "<%", "{php}" tag', |
|
192 | - 'LOGOP' => '"<", "==" ... logical operator', |
|
193 | - 'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition', |
|
194 | - 'SCOND' => '"is even" ... if condition',); |
|
195 | - |
|
196 | - /** |
|
197 | - * constructor |
|
198 | - * |
|
199 | - * @param string $data template source |
|
200 | - * @param Smarty_Internal_TemplateCompilerBase $compiler |
|
201 | - */ |
|
202 | - public function __construct($data, Smarty_Internal_TemplateCompilerBase $compiler) |
|
203 | - { |
|
204 | - $this->data = $data; |
|
205 | - $this->counter = 0; |
|
206 | - if (preg_match('/^\xEF\xBB\xBF/i', $this->data, $match)) { |
|
207 | - $this->counter += strlen($match[ 0 ]); |
|
208 | - } |
|
209 | - $this->line = 1; |
|
210 | - $this->smarty = $compiler->smarty; |
|
211 | - $this->compiler = $compiler; |
|
212 | - $this->ldel = preg_quote($this->smarty->left_delimiter, '/'); |
|
213 | - $this->ldel_length = strlen($this->smarty->left_delimiter); |
|
214 | - $this->rdel = preg_quote($this->smarty->right_delimiter, '/'); |
|
215 | - $this->rdel_length = strlen($this->smarty->right_delimiter); |
|
216 | - $this->smarty_token_names[ 'LDEL' ] = $this->smarty->left_delimiter; |
|
217 | - $this->smarty_token_names[ 'RDEL' ] = $this->smarty->right_delimiter; |
|
218 | - } |
|
219 | - |
|
220 | - public function PrintTrace() |
|
221 | - { |
|
222 | - $this->yyTraceFILE = fopen('php://output', 'w'); |
|
223 | - $this->yyTracePrompt = '<br>'; |
|
224 | - } |
|
225 | - |
|
226 | - /* |
|
21 | + /** |
|
22 | + * Source |
|
23 | + * |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + public $data; |
|
27 | + |
|
28 | + /** |
|
29 | + * byte counter |
|
30 | + * |
|
31 | + * @var int |
|
32 | + */ |
|
33 | + public $counter; |
|
34 | + |
|
35 | + /** |
|
36 | + * token number |
|
37 | + * |
|
38 | + * @var int |
|
39 | + */ |
|
40 | + public $token; |
|
41 | + |
|
42 | + /** |
|
43 | + * token value |
|
44 | + * |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + public $value; |
|
48 | + |
|
49 | + /** |
|
50 | + * current line |
|
51 | + * |
|
52 | + * @var int |
|
53 | + */ |
|
54 | + public $line; |
|
55 | + |
|
56 | + /** |
|
57 | + * tag start line |
|
58 | + * |
|
59 | + * @var |
|
60 | + */ |
|
61 | + public $taglineno; |
|
62 | + |
|
63 | + /** |
|
64 | + * php code type |
|
65 | + * |
|
66 | + * @var string |
|
67 | + */ |
|
68 | + public $phpType = ''; |
|
69 | + |
|
70 | + /** |
|
71 | + * escaped left delimiter |
|
72 | + * |
|
73 | + * @var string |
|
74 | + */ |
|
75 | + public $ldel = ''; |
|
76 | + |
|
77 | + /** |
|
78 | + * escaped left delimiter length |
|
79 | + * |
|
80 | + * @var int |
|
81 | + */ |
|
82 | + public $ldel_length = 0; |
|
83 | + |
|
84 | + /** |
|
85 | + * escaped right delimiter |
|
86 | + * |
|
87 | + * @var string |
|
88 | + */ |
|
89 | + public $rdel = ''; |
|
90 | + |
|
91 | + /** |
|
92 | + * escaped right delimiter length |
|
93 | + * |
|
94 | + * @var int |
|
95 | + */ |
|
96 | + public $rdel_length = 0; |
|
97 | + |
|
98 | + /** |
|
99 | + * state number |
|
100 | + * |
|
101 | + * @var int |
|
102 | + */ |
|
103 | + public $state = 1; |
|
104 | + |
|
105 | + /** |
|
106 | + * Smarty object |
|
107 | + * |
|
108 | + * @var Smarty |
|
109 | + */ |
|
110 | + public $smarty = null; |
|
111 | + |
|
112 | + /** |
|
113 | + * compiler object |
|
114 | + * |
|
115 | + * @var Smarty_Internal_TemplateCompilerBase |
|
116 | + */ |
|
117 | + public $compiler = null; |
|
118 | + |
|
119 | + /** |
|
120 | + * literal tag nesting level |
|
121 | + * |
|
122 | + * @var int |
|
123 | + */ |
|
124 | + private $literal_cnt = 0; |
|
125 | + |
|
126 | + /** |
|
127 | + * PHP start tag string |
|
128 | + * |
|
129 | + * @var string |
|
130 | + */ |
|
131 | + |
|
132 | + /** |
|
133 | + * trace file |
|
134 | + * |
|
135 | + * @var resource |
|
136 | + */ |
|
137 | + public $yyTraceFILE; |
|
138 | + |
|
139 | + /** |
|
140 | + * trace prompt |
|
141 | + * |
|
142 | + * @var string |
|
143 | + */ |
|
144 | + public $yyTracePrompt; |
|
145 | + |
|
146 | + /** |
|
147 | + * XML flag true while processing xml |
|
148 | + * |
|
149 | + * @var bool |
|
150 | + */ |
|
151 | + public $is_xml = false; |
|
152 | + |
|
153 | + /** |
|
154 | + * state names |
|
155 | + * |
|
156 | + * @var array |
|
157 | + */ |
|
158 | + public $state_name = array(1 => 'TEXT', 2 => 'TAG', 3 => 'TAGBODY', 4 => 'LITERAL', 5 => 'DOUBLEQUOTEDSTRING',); |
|
159 | + |
|
160 | + /** |
|
161 | + * storage for assembled token patterns |
|
162 | + * |
|
163 | + * @var string |
|
164 | + */ |
|
165 | + private $yy_global_pattern1 = null; |
|
166 | + |
|
167 | + private $yy_global_pattern2 = null; |
|
168 | + |
|
169 | + private $yy_global_pattern3 = null; |
|
170 | + |
|
171 | + private $yy_global_pattern4 = null; |
|
172 | + |
|
173 | + private $yy_global_pattern5 = null; |
|
174 | + |
|
175 | + /** |
|
176 | + * token names |
|
177 | + * |
|
178 | + * @var array |
|
179 | + */ |
|
180 | + public $smarty_token_names = array( // Text for parser error messages |
|
181 | + 'NOT' => '(!,not)', 'OPENP' => '(', 'CLOSEP' => ')', 'OPENB' => '[', |
|
182 | + 'CLOSEB' => ']', 'PTR' => '->', 'APTR' => '=>', 'EQUAL' => '=', |
|
183 | + 'NUMBER' => 'number', 'UNIMATH' => '+" , "-', 'MATH' => '*" , "/" , "%', |
|
184 | + 'INCDEC' => '++" , "--', 'SPACE' => ' ', 'DOLLAR' => '$', |
|
185 | + 'SEMICOLON' => ';', 'COLON' => ':', 'DOUBLECOLON' => '::', 'AT' => '@', |
|
186 | + 'HATCH' => '#', 'QUOTE' => '"', 'BACKTICK' => '`', |
|
187 | + 'VERT' => '"|" modifier', 'DOT' => '.', 'COMMA' => '","', |
|
188 | + 'QMARK' => '"?"', 'ID' => 'id, name', 'TEXT' => 'text', |
|
189 | + 'LDELSLASH' => '{/..} closing tag', 'LDEL' => '{...} Smarty tag', |
|
190 | + 'COMMENT' => 'comment', 'AS' => 'as', 'TO' => 'to', |
|
191 | + 'PHP' => '"<?php", "<%", "{php}" tag', |
|
192 | + 'LOGOP' => '"<", "==" ... logical operator', |
|
193 | + 'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition', |
|
194 | + 'SCOND' => '"is even" ... if condition',); |
|
195 | + |
|
196 | + /** |
|
197 | + * constructor |
|
198 | + * |
|
199 | + * @param string $data template source |
|
200 | + * @param Smarty_Internal_TemplateCompilerBase $compiler |
|
201 | + */ |
|
202 | + public function __construct($data, Smarty_Internal_TemplateCompilerBase $compiler) |
|
203 | + { |
|
204 | + $this->data = $data; |
|
205 | + $this->counter = 0; |
|
206 | + if (preg_match('/^\xEF\xBB\xBF/i', $this->data, $match)) { |
|
207 | + $this->counter += strlen($match[ 0 ]); |
|
208 | + } |
|
209 | + $this->line = 1; |
|
210 | + $this->smarty = $compiler->smarty; |
|
211 | + $this->compiler = $compiler; |
|
212 | + $this->ldel = preg_quote($this->smarty->left_delimiter, '/'); |
|
213 | + $this->ldel_length = strlen($this->smarty->left_delimiter); |
|
214 | + $this->rdel = preg_quote($this->smarty->right_delimiter, '/'); |
|
215 | + $this->rdel_length = strlen($this->smarty->right_delimiter); |
|
216 | + $this->smarty_token_names[ 'LDEL' ] = $this->smarty->left_delimiter; |
|
217 | + $this->smarty_token_names[ 'RDEL' ] = $this->smarty->right_delimiter; |
|
218 | + } |
|
219 | + |
|
220 | + public function PrintTrace() |
|
221 | + { |
|
222 | + $this->yyTraceFILE = fopen('php://output', 'w'); |
|
223 | + $this->yyTracePrompt = '<br>'; |
|
224 | + } |
|
225 | + |
|
226 | + /* |
|
227 | 227 | * Check if this tag is autoliteral |
228 | 228 | */ |
229 | - public function isAutoLiteral() |
|
230 | - { |
|
231 | - return $this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
232 | - strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false; |
|
233 | - } |
|
234 | - |
|
235 | - private $_yy_state = 1; |
|
236 | - |
|
237 | - private $_yy_stack = array(); |
|
238 | - |
|
239 | - public function yylex() |
|
240 | - { |
|
241 | - return $this->{'yylex' . $this->_yy_state}(); |
|
242 | - } |
|
243 | - |
|
244 | - public function yypushstate($state) |
|
245 | - { |
|
246 | - if ($this->yyTraceFILE) { |
|
247 | - fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt, |
|
248 | - isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : |
|
249 | - $this->_yy_state); |
|
250 | - } |
|
251 | - array_push($this->_yy_stack, $this->_yy_state); |
|
252 | - $this->_yy_state = $state; |
|
253 | - if ($this->yyTraceFILE) { |
|
254 | - fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, |
|
255 | - isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : |
|
256 | - $this->_yy_state); |
|
257 | - } |
|
258 | - } |
|
259 | - |
|
260 | - public function yypopstate() |
|
261 | - { |
|
262 | - if ($this->yyTraceFILE) { |
|
263 | - fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt, |
|
264 | - isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : |
|
265 | - $this->_yy_state); |
|
266 | - } |
|
267 | - $this->_yy_state = array_pop($this->_yy_stack); |
|
268 | - if ($this->yyTraceFILE) { |
|
269 | - fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, |
|
270 | - isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : |
|
271 | - $this->_yy_state); |
|
272 | - } |
|
273 | - } |
|
274 | - |
|
275 | - public function yybegin($state) |
|
276 | - { |
|
277 | - $this->_yy_state = $state; |
|
278 | - if ($this->yyTraceFILE) { |
|
279 | - fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt, |
|
280 | - isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : |
|
281 | - $this->_yy_state); |
|
282 | - } |
|
283 | - } |
|
284 | - |
|
285 | - public function yylex1() |
|
286 | - { |
|
287 | - if (!isset($this->yy_global_pattern1)) { |
|
288 | - $this->yy_global_pattern1 = |
|
289 | - "/\G([{][}])|\G(" . $this->ldel . "[*])|\G((" . $this->ldel . "\\s*php([ ].*?)?" . $this->rdel . ")|(" . |
|
290 | - $this->ldel . "\\s*[\/]php" . $this->rdel . "))|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . |
|
291 | - ")|\G(" . $this->ldel . "\\s*)|\G(\\s*" . $this->rdel . |
|
292 | - ")|\G((<[?]((php\\s+|=)|\\s+))|(<[%])|(<[?]xml\\s+)|(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|([?][>])|([%][>]))|\G([\S\s])/isS"; |
|
293 | - } |
|
294 | - if ($this->counter >= strlen($this->data)) { |
|
295 | - return false; // end of input |
|
296 | - } |
|
297 | - |
|
298 | - do { |
|
299 | - if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, null, $this->counter)) { |
|
300 | - $yysubmatches = $yymatches; |
|
301 | - if (strlen($yysubmatches[ 0 ]) < 200) { |
|
302 | - $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
|
303 | - } else { |
|
304 | - $yymatches = array_filter($yymatches, 'strlen'); |
|
305 | - } |
|
306 | - if (empty($yymatches)) { |
|
307 | - throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . |
|
308 | - substr($this->data, $this->counter, 5) . '... state TEXT'); |
|
309 | - } |
|
310 | - next($yymatches); // skip global match |
|
311 | - $this->token = key($yymatches); // token number |
|
312 | - $this->value = current($yymatches); // token value |
|
313 | - $r = $this->{'yy_r1_' . $this->token}(); |
|
314 | - if ($r === null) { |
|
315 | - $this->counter += strlen($this->value); |
|
316 | - $this->line += substr_count($this->value, "\n"); |
|
317 | - // accept this token |
|
318 | - return true; |
|
319 | - } elseif ($r === true) { |
|
320 | - // we have changed state |
|
321 | - // process this token in the new state |
|
322 | - return $this->yylex(); |
|
323 | - } elseif ($r === false) { |
|
324 | - $this->counter += strlen($this->value); |
|
325 | - $this->line += substr_count($this->value, "\n"); |
|
326 | - if ($this->counter >= strlen($this->data)) { |
|
327 | - return false; // end of input |
|
328 | - } |
|
329 | - // skip this token |
|
330 | - continue; |
|
331 | - } |
|
332 | - } else { |
|
333 | - throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]); |
|
334 | - } |
|
335 | - break; |
|
336 | - } |
|
337 | - while (true); |
|
338 | - } // end function |
|
339 | - |
|
340 | - const TEXT = 1; |
|
341 | - |
|
342 | - public function yy_r1_1() |
|
343 | - { |
|
344 | - |
|
345 | - $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
346 | - } |
|
347 | - |
|
348 | - public function yy_r1_2() |
|
349 | - { |
|
350 | - |
|
351 | - preg_match("/[*]{$this->rdel}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); |
|
352 | - if (isset($match[ 0 ][ 1 ])) { |
|
353 | - $to = $match[ 0 ][ 1 ] + strlen($match[ 0 ][ 0 ]); |
|
354 | - } else { |
|
355 | - $this->compiler->trigger_template_error("missing or misspelled comment closing tag '*{$this->smarty->right_delimiter}'"); |
|
356 | - } |
|
357 | - $this->value = substr($this->data, $this->counter, $to - $this->counter); |
|
358 | - return false; |
|
359 | - } |
|
360 | - |
|
361 | - public function yy_r1_3() |
|
362 | - { |
|
363 | - |
|
364 | - $obj = new Smarty_Internal_Compile_Private_Php(); |
|
365 | - $obj->parsePhp($this); |
|
366 | - } |
|
367 | - |
|
368 | - public function yy_r1_7() |
|
369 | - { |
|
370 | - |
|
371 | - if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
372 | - strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false |
|
373 | - ) { |
|
374 | - $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
375 | - } else { |
|
376 | - $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART; |
|
377 | - $this->yypushstate(self::LITERAL); |
|
378 | - } |
|
379 | - } |
|
380 | - |
|
381 | - public function yy_r1_8() |
|
382 | - { |
|
383 | - |
|
384 | - if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
385 | - strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false |
|
386 | - ) { |
|
387 | - $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
388 | - } else { |
|
389 | - $this->yypushstate(self::TAG); |
|
390 | - return true; |
|
391 | - } |
|
392 | - } |
|
393 | - |
|
394 | - public function yy_r1_9() |
|
395 | - { |
|
396 | - |
|
397 | - $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
398 | - } |
|
399 | - |
|
400 | - public function yy_r1_10() |
|
401 | - { |
|
402 | - |
|
403 | - $obj = new Smarty_Internal_Compile_Private_Php(); |
|
404 | - $obj->parsePhp($this); |
|
405 | - } |
|
406 | - |
|
407 | - public function yy_r1_19() |
|
408 | - { |
|
409 | - |
|
410 | - $to = strlen($this->data); |
|
411 | - preg_match("/($this->ldel)|(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*[\"']?\s*php\s*[\"']?\s*>)|([?][>])|([%][>])/i", |
|
412 | - $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); |
|
413 | - if (isset($match[ 0 ][ 1 ])) { |
|
414 | - $to = $match[ 0 ][ 1 ]; |
|
415 | - } |
|
416 | - $this->value = substr($this->data, $this->counter, $to - $this->counter); |
|
417 | - $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
418 | - } |
|
419 | - |
|
420 | - public function yylex2() |
|
421 | - { |
|
422 | - if (!isset($this->yy_global_pattern2)) { |
|
423 | - $this->yy_global_pattern2 = |
|
424 | - "/\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" . |
|
425 | - $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*setfilter\\s+)|\G(" . $this->ldel . |
|
426 | - "\\s*make_nocache\\s+)|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . |
|
427 | - ")|\G(" . $this->ldel . "\\s*[\/](?:(?!block)[0-9]*[a-zA-Z_]\\w*)\\s*" . $this->rdel . ")|\G(" . |
|
428 | - $this->ldel . "\\s*[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel . |
|
429 | - "\\s*[\/])|\G(" . $this->ldel . "\\s*)/isS"; |
|
430 | - } |
|
431 | - if ($this->counter >= strlen($this->data)) { |
|
432 | - return false; // end of input |
|
433 | - } |
|
434 | - |
|
435 | - do { |
|
436 | - if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, null, $this->counter)) { |
|
437 | - $yysubmatches = $yymatches; |
|
438 | - if (strlen($yysubmatches[ 0 ]) < 200) { |
|
439 | - $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
|
440 | - } else { |
|
441 | - $yymatches = array_filter($yymatches, 'strlen'); |
|
442 | - } |
|
443 | - if (empty($yymatches)) { |
|
444 | - throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . |
|
445 | - substr($this->data, $this->counter, 5) . '... state TAG'); |
|
446 | - } |
|
447 | - next($yymatches); // skip global match |
|
448 | - $this->token = key($yymatches); // token number |
|
449 | - $this->value = current($yymatches); // token value |
|
450 | - $r = $this->{'yy_r2_' . $this->token}(); |
|
451 | - if ($r === null) { |
|
452 | - $this->counter += strlen($this->value); |
|
453 | - $this->line += substr_count($this->value, "\n"); |
|
454 | - // accept this token |
|
455 | - return true; |
|
456 | - } elseif ($r === true) { |
|
457 | - // we have changed state |
|
458 | - // process this token in the new state |
|
459 | - return $this->yylex(); |
|
460 | - } elseif ($r === false) { |
|
461 | - $this->counter += strlen($this->value); |
|
462 | - $this->line += substr_count($this->value, "\n"); |
|
463 | - if ($this->counter >= strlen($this->data)) { |
|
464 | - return false; // end of input |
|
465 | - } |
|
466 | - // skip this token |
|
467 | - continue; |
|
468 | - } |
|
469 | - } else { |
|
470 | - throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]); |
|
471 | - } |
|
472 | - break; |
|
473 | - } |
|
474 | - while (true); |
|
475 | - } // end function |
|
476 | - |
|
477 | - const TAG = 2; |
|
478 | - |
|
479 | - public function yy_r2_1() |
|
480 | - { |
|
481 | - |
|
482 | - $this->token = Smarty_Internal_Templateparser::TP_LDELIF; |
|
483 | - $this->yybegin(self::TAGBODY); |
|
484 | - $this->taglineno = $this->line; |
|
485 | - } |
|
486 | - |
|
487 | - public function yy_r2_3() |
|
488 | - { |
|
489 | - |
|
490 | - $this->token = Smarty_Internal_Templateparser::TP_LDELFOR; |
|
491 | - $this->yybegin(self::TAGBODY); |
|
492 | - $this->taglineno = $this->line; |
|
493 | - } |
|
494 | - |
|
495 | - public function yy_r2_4() |
|
496 | - { |
|
497 | - |
|
498 | - $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH; |
|
499 | - $this->yybegin(self::TAGBODY); |
|
500 | - $this->taglineno = $this->line; |
|
501 | - } |
|
502 | - |
|
503 | - public function yy_r2_5() |
|
504 | - { |
|
505 | - |
|
506 | - $this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER; |
|
507 | - $this->yybegin(self::TAGBODY); |
|
508 | - $this->taglineno = $this->line; |
|
509 | - } |
|
510 | - |
|
511 | - public function yy_r2_6() |
|
512 | - { |
|
513 | - |
|
514 | - $this->token = Smarty_Internal_Templateparser::TP_LDELMAKENOCACHE; |
|
515 | - $this->yybegin(self::TAGBODY); |
|
516 | - $this->taglineno = $this->line; |
|
517 | - } |
|
518 | - |
|
519 | - public function yy_r2_7() |
|
520 | - { |
|
521 | - |
|
522 | - $this->yypopstate(); |
|
523 | - $this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG; |
|
524 | - $this->taglineno = $this->line; |
|
525 | - } |
|
526 | - |
|
527 | - public function yy_r2_9() |
|
528 | - { |
|
529 | - |
|
530 | - $this->yypopstate(); |
|
531 | - $this->token = Smarty_Internal_Templateparser::TP_CLOSETAG; |
|
532 | - $this->taglineno = $this->line; |
|
533 | - } |
|
534 | - |
|
535 | - public function yy_r2_10() |
|
536 | - { |
|
537 | - |
|
538 | - if ($this->_yy_stack[ count($this->_yy_stack) - 1 ] == self::TEXT) { |
|
539 | - $this->yypopstate(); |
|
540 | - $this->token = Smarty_Internal_Templateparser::TP_SIMPELOUTPUT; |
|
541 | - $this->taglineno = $this->line; |
|
542 | - } else { |
|
543 | - $this->value = $this->smarty->left_delimiter; |
|
544 | - $this->token = Smarty_Internal_Templateparser::TP_LDEL; |
|
545 | - $this->yybegin(self::TAGBODY); |
|
546 | - $this->taglineno = $this->line; |
|
547 | - } |
|
548 | - } |
|
549 | - |
|
550 | - public function yy_r2_12() |
|
551 | - { |
|
552 | - |
|
553 | - $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; |
|
554 | - $this->yybegin(self::TAGBODY); |
|
555 | - $this->taglineno = $this->line; |
|
556 | - } |
|
557 | - |
|
558 | - public function yy_r2_13() |
|
559 | - { |
|
560 | - |
|
561 | - $this->token = Smarty_Internal_Templateparser::TP_LDEL; |
|
562 | - $this->yybegin(self::TAGBODY); |
|
563 | - $this->taglineno = $this->line; |
|
564 | - } |
|
565 | - |
|
566 | - public function yylex3() |
|
567 | - { |
|
568 | - if (!isset($this->yy_global_pattern3)) { |
|
569 | - $this->yy_global_pattern3 = "/\G(\\s*" . $this->rdel . ")|\G(" . $this->ldel . |
|
570 | - "\\s*)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$]smarty\\.block\\.(child|parent))|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*(([!=][=]{1,2})|([<][=>]?)|([>][=]?)|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\\s+)|\G(\\s+(is\\s+(not\\s+)?(odd|even|div)\\s+by)\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G(([!]\\s*)|(not\\s+))|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|])|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS"; |
|
571 | - } |
|
572 | - if ($this->counter >= strlen($this->data)) { |
|
573 | - return false; // end of input |
|
574 | - } |
|
575 | - |
|
576 | - do { |
|
577 | - if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, null, $this->counter)) { |
|
578 | - $yysubmatches = $yymatches; |
|
579 | - if (strlen($yysubmatches[ 0 ]) < 200) { |
|
580 | - $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
|
581 | - } else { |
|
582 | - $yymatches = array_filter($yymatches, 'strlen'); |
|
583 | - } |
|
584 | - if (empty($yymatches)) { |
|
585 | - throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . |
|
586 | - substr($this->data, $this->counter, 5) . '... state TAGBODY'); |
|
587 | - } |
|
588 | - next($yymatches); // skip global match |
|
589 | - $this->token = key($yymatches); // token number |
|
590 | - $this->value = current($yymatches); // token value |
|
591 | - $r = $this->{'yy_r3_' . $this->token}(); |
|
592 | - if ($r === null) { |
|
593 | - $this->counter += strlen($this->value); |
|
594 | - $this->line += substr_count($this->value, "\n"); |
|
595 | - // accept this token |
|
596 | - return true; |
|
597 | - } elseif ($r === true) { |
|
598 | - // we have changed state |
|
599 | - // process this token in the new state |
|
600 | - return $this->yylex(); |
|
601 | - } elseif ($r === false) { |
|
602 | - $this->counter += strlen($this->value); |
|
603 | - $this->line += substr_count($this->value, "\n"); |
|
604 | - if ($this->counter >= strlen($this->data)) { |
|
605 | - return false; // end of input |
|
606 | - } |
|
607 | - // skip this token |
|
608 | - continue; |
|
609 | - } |
|
610 | - } else { |
|
611 | - throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]); |
|
612 | - } |
|
613 | - break; |
|
614 | - } |
|
615 | - while (true); |
|
616 | - } // end function |
|
617 | - |
|
618 | - const TAGBODY = 3; |
|
619 | - |
|
620 | - public function yy_r3_1() |
|
621 | - { |
|
622 | - |
|
623 | - $this->token = Smarty_Internal_Templateparser::TP_RDEL; |
|
624 | - $this->yypopstate(); |
|
625 | - } |
|
626 | - |
|
627 | - public function yy_r3_2() |
|
628 | - { |
|
629 | - |
|
630 | - if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
631 | - strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false |
|
632 | - ) { |
|
633 | - $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
634 | - } else { |
|
635 | - $this->yypushstate(self::TAG); |
|
636 | - return true; |
|
637 | - } |
|
638 | - } |
|
639 | - |
|
640 | - public function yy_r3_3() |
|
641 | - { |
|
642 | - |
|
643 | - $this->token = Smarty_Internal_Templateparser::TP_QUOTE; |
|
644 | - $this->yypushstate(self::DOUBLEQUOTEDSTRING); |
|
645 | - } |
|
646 | - |
|
647 | - public function yy_r3_4() |
|
648 | - { |
|
649 | - |
|
650 | - $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING; |
|
651 | - } |
|
652 | - |
|
653 | - public function yy_r3_5() |
|
654 | - { |
|
655 | - |
|
656 | - $this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT; |
|
657 | - $this->taglineno = $this->line; |
|
658 | - } |
|
659 | - |
|
660 | - public function yy_r3_7() |
|
661 | - { |
|
662 | - |
|
663 | - $this->token = Smarty_Internal_Templateparser::TP_DOLLARID; |
|
664 | - } |
|
665 | - |
|
666 | - public function yy_r3_8() |
|
667 | - { |
|
668 | - |
|
669 | - $this->token = Smarty_Internal_Templateparser::TP_DOLLAR; |
|
670 | - } |
|
229 | + public function isAutoLiteral() |
|
230 | + { |
|
231 | + return $this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
232 | + strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false; |
|
233 | + } |
|
234 | + |
|
235 | + private $_yy_state = 1; |
|
236 | + |
|
237 | + private $_yy_stack = array(); |
|
238 | + |
|
239 | + public function yylex() |
|
240 | + { |
|
241 | + return $this->{'yylex' . $this->_yy_state}(); |
|
242 | + } |
|
243 | + |
|
244 | + public function yypushstate($state) |
|
245 | + { |
|
246 | + if ($this->yyTraceFILE) { |
|
247 | + fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt, |
|
248 | + isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : |
|
249 | + $this->_yy_state); |
|
250 | + } |
|
251 | + array_push($this->_yy_stack, $this->_yy_state); |
|
252 | + $this->_yy_state = $state; |
|
253 | + if ($this->yyTraceFILE) { |
|
254 | + fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, |
|
255 | + isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : |
|
256 | + $this->_yy_state); |
|
257 | + } |
|
258 | + } |
|
259 | + |
|
260 | + public function yypopstate() |
|
261 | + { |
|
262 | + if ($this->yyTraceFILE) { |
|
263 | + fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt, |
|
264 | + isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : |
|
265 | + $this->_yy_state); |
|
266 | + } |
|
267 | + $this->_yy_state = array_pop($this->_yy_stack); |
|
268 | + if ($this->yyTraceFILE) { |
|
269 | + fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, |
|
270 | + isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : |
|
271 | + $this->_yy_state); |
|
272 | + } |
|
273 | + } |
|
274 | + |
|
275 | + public function yybegin($state) |
|
276 | + { |
|
277 | + $this->_yy_state = $state; |
|
278 | + if ($this->yyTraceFILE) { |
|
279 | + fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt, |
|
280 | + isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : |
|
281 | + $this->_yy_state); |
|
282 | + } |
|
283 | + } |
|
284 | + |
|
285 | + public function yylex1() |
|
286 | + { |
|
287 | + if (!isset($this->yy_global_pattern1)) { |
|
288 | + $this->yy_global_pattern1 = |
|
289 | + "/\G([{][}])|\G(" . $this->ldel . "[*])|\G((" . $this->ldel . "\\s*php([ ].*?)?" . $this->rdel . ")|(" . |
|
290 | + $this->ldel . "\\s*[\/]php" . $this->rdel . "))|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . |
|
291 | + ")|\G(" . $this->ldel . "\\s*)|\G(\\s*" . $this->rdel . |
|
292 | + ")|\G((<[?]((php\\s+|=)|\\s+))|(<[%])|(<[?]xml\\s+)|(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|([?][>])|([%][>]))|\G([\S\s])/isS"; |
|
293 | + } |
|
294 | + if ($this->counter >= strlen($this->data)) { |
|
295 | + return false; // end of input |
|
296 | + } |
|
297 | + |
|
298 | + do { |
|
299 | + if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, null, $this->counter)) { |
|
300 | + $yysubmatches = $yymatches; |
|
301 | + if (strlen($yysubmatches[ 0 ]) < 200) { |
|
302 | + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
|
303 | + } else { |
|
304 | + $yymatches = array_filter($yymatches, 'strlen'); |
|
305 | + } |
|
306 | + if (empty($yymatches)) { |
|
307 | + throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . |
|
308 | + substr($this->data, $this->counter, 5) . '... state TEXT'); |
|
309 | + } |
|
310 | + next($yymatches); // skip global match |
|
311 | + $this->token = key($yymatches); // token number |
|
312 | + $this->value = current($yymatches); // token value |
|
313 | + $r = $this->{'yy_r1_' . $this->token}(); |
|
314 | + if ($r === null) { |
|
315 | + $this->counter += strlen($this->value); |
|
316 | + $this->line += substr_count($this->value, "\n"); |
|
317 | + // accept this token |
|
318 | + return true; |
|
319 | + } elseif ($r === true) { |
|
320 | + // we have changed state |
|
321 | + // process this token in the new state |
|
322 | + return $this->yylex(); |
|
323 | + } elseif ($r === false) { |
|
324 | + $this->counter += strlen($this->value); |
|
325 | + $this->line += substr_count($this->value, "\n"); |
|
326 | + if ($this->counter >= strlen($this->data)) { |
|
327 | + return false; // end of input |
|
328 | + } |
|
329 | + // skip this token |
|
330 | + continue; |
|
331 | + } |
|
332 | + } else { |
|
333 | + throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]); |
|
334 | + } |
|
335 | + break; |
|
336 | + } |
|
337 | + while (true); |
|
338 | + } // end function |
|
339 | + |
|
340 | + const TEXT = 1; |
|
341 | + |
|
342 | + public function yy_r1_1() |
|
343 | + { |
|
344 | + |
|
345 | + $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
346 | + } |
|
347 | + |
|
348 | + public function yy_r1_2() |
|
349 | + { |
|
350 | + |
|
351 | + preg_match("/[*]{$this->rdel}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); |
|
352 | + if (isset($match[ 0 ][ 1 ])) { |
|
353 | + $to = $match[ 0 ][ 1 ] + strlen($match[ 0 ][ 0 ]); |
|
354 | + } else { |
|
355 | + $this->compiler->trigger_template_error("missing or misspelled comment closing tag '*{$this->smarty->right_delimiter}'"); |
|
356 | + } |
|
357 | + $this->value = substr($this->data, $this->counter, $to - $this->counter); |
|
358 | + return false; |
|
359 | + } |
|
360 | + |
|
361 | + public function yy_r1_3() |
|
362 | + { |
|
363 | + |
|
364 | + $obj = new Smarty_Internal_Compile_Private_Php(); |
|
365 | + $obj->parsePhp($this); |
|
366 | + } |
|
367 | + |
|
368 | + public function yy_r1_7() |
|
369 | + { |
|
370 | + |
|
371 | + if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
372 | + strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false |
|
373 | + ) { |
|
374 | + $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
375 | + } else { |
|
376 | + $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART; |
|
377 | + $this->yypushstate(self::LITERAL); |
|
378 | + } |
|
379 | + } |
|
380 | + |
|
381 | + public function yy_r1_8() |
|
382 | + { |
|
383 | + |
|
384 | + if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
385 | + strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false |
|
386 | + ) { |
|
387 | + $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
388 | + } else { |
|
389 | + $this->yypushstate(self::TAG); |
|
390 | + return true; |
|
391 | + } |
|
392 | + } |
|
393 | + |
|
394 | + public function yy_r1_9() |
|
395 | + { |
|
396 | + |
|
397 | + $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
398 | + } |
|
399 | + |
|
400 | + public function yy_r1_10() |
|
401 | + { |
|
402 | + |
|
403 | + $obj = new Smarty_Internal_Compile_Private_Php(); |
|
404 | + $obj->parsePhp($this); |
|
405 | + } |
|
406 | + |
|
407 | + public function yy_r1_19() |
|
408 | + { |
|
409 | + |
|
410 | + $to = strlen($this->data); |
|
411 | + preg_match("/($this->ldel)|(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*[\"']?\s*php\s*[\"']?\s*>)|([?][>])|([%][>])/i", |
|
412 | + $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); |
|
413 | + if (isset($match[ 0 ][ 1 ])) { |
|
414 | + $to = $match[ 0 ][ 1 ]; |
|
415 | + } |
|
416 | + $this->value = substr($this->data, $this->counter, $to - $this->counter); |
|
417 | + $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
418 | + } |
|
419 | + |
|
420 | + public function yylex2() |
|
421 | + { |
|
422 | + if (!isset($this->yy_global_pattern2)) { |
|
423 | + $this->yy_global_pattern2 = |
|
424 | + "/\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" . |
|
425 | + $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*setfilter\\s+)|\G(" . $this->ldel . |
|
426 | + "\\s*make_nocache\\s+)|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . |
|
427 | + ")|\G(" . $this->ldel . "\\s*[\/](?:(?!block)[0-9]*[a-zA-Z_]\\w*)\\s*" . $this->rdel . ")|\G(" . |
|
428 | + $this->ldel . "\\s*[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel . |
|
429 | + "\\s*[\/])|\G(" . $this->ldel . "\\s*)/isS"; |
|
430 | + } |
|
431 | + if ($this->counter >= strlen($this->data)) { |
|
432 | + return false; // end of input |
|
433 | + } |
|
434 | + |
|
435 | + do { |
|
436 | + if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, null, $this->counter)) { |
|
437 | + $yysubmatches = $yymatches; |
|
438 | + if (strlen($yysubmatches[ 0 ]) < 200) { |
|
439 | + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
|
440 | + } else { |
|
441 | + $yymatches = array_filter($yymatches, 'strlen'); |
|
442 | + } |
|
443 | + if (empty($yymatches)) { |
|
444 | + throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . |
|
445 | + substr($this->data, $this->counter, 5) . '... state TAG'); |
|
446 | + } |
|
447 | + next($yymatches); // skip global match |
|
448 | + $this->token = key($yymatches); // token number |
|
449 | + $this->value = current($yymatches); // token value |
|
450 | + $r = $this->{'yy_r2_' . $this->token}(); |
|
451 | + if ($r === null) { |
|
452 | + $this->counter += strlen($this->value); |
|
453 | + $this->line += substr_count($this->value, "\n"); |
|
454 | + // accept this token |
|
455 | + return true; |
|
456 | + } elseif ($r === true) { |
|
457 | + // we have changed state |
|
458 | + // process this token in the new state |
|
459 | + return $this->yylex(); |
|
460 | + } elseif ($r === false) { |
|
461 | + $this->counter += strlen($this->value); |
|
462 | + $this->line += substr_count($this->value, "\n"); |
|
463 | + if ($this->counter >= strlen($this->data)) { |
|
464 | + return false; // end of input |
|
465 | + } |
|
466 | + // skip this token |
|
467 | + continue; |
|
468 | + } |
|
469 | + } else { |
|
470 | + throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]); |
|
471 | + } |
|
472 | + break; |
|
473 | + } |
|
474 | + while (true); |
|
475 | + } // end function |
|
476 | + |
|
477 | + const TAG = 2; |
|
478 | + |
|
479 | + public function yy_r2_1() |
|
480 | + { |
|
481 | + |
|
482 | + $this->token = Smarty_Internal_Templateparser::TP_LDELIF; |
|
483 | + $this->yybegin(self::TAGBODY); |
|
484 | + $this->taglineno = $this->line; |
|
485 | + } |
|
486 | + |
|
487 | + public function yy_r2_3() |
|
488 | + { |
|
489 | + |
|
490 | + $this->token = Smarty_Internal_Templateparser::TP_LDELFOR; |
|
491 | + $this->yybegin(self::TAGBODY); |
|
492 | + $this->taglineno = $this->line; |
|
493 | + } |
|
494 | + |
|
495 | + public function yy_r2_4() |
|
496 | + { |
|
497 | + |
|
498 | + $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH; |
|
499 | + $this->yybegin(self::TAGBODY); |
|
500 | + $this->taglineno = $this->line; |
|
501 | + } |
|
502 | + |
|
503 | + public function yy_r2_5() |
|
504 | + { |
|
505 | + |
|
506 | + $this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER; |
|
507 | + $this->yybegin(self::TAGBODY); |
|
508 | + $this->taglineno = $this->line; |
|
509 | + } |
|
510 | + |
|
511 | + public function yy_r2_6() |
|
512 | + { |
|
513 | + |
|
514 | + $this->token = Smarty_Internal_Templateparser::TP_LDELMAKENOCACHE; |
|
515 | + $this->yybegin(self::TAGBODY); |
|
516 | + $this->taglineno = $this->line; |
|
517 | + } |
|
518 | + |
|
519 | + public function yy_r2_7() |
|
520 | + { |
|
521 | + |
|
522 | + $this->yypopstate(); |
|
523 | + $this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG; |
|
524 | + $this->taglineno = $this->line; |
|
525 | + } |
|
526 | + |
|
527 | + public function yy_r2_9() |
|
528 | + { |
|
529 | + |
|
530 | + $this->yypopstate(); |
|
531 | + $this->token = Smarty_Internal_Templateparser::TP_CLOSETAG; |
|
532 | + $this->taglineno = $this->line; |
|
533 | + } |
|
534 | + |
|
535 | + public function yy_r2_10() |
|
536 | + { |
|
537 | + |
|
538 | + if ($this->_yy_stack[ count($this->_yy_stack) - 1 ] == self::TEXT) { |
|
539 | + $this->yypopstate(); |
|
540 | + $this->token = Smarty_Internal_Templateparser::TP_SIMPELOUTPUT; |
|
541 | + $this->taglineno = $this->line; |
|
542 | + } else { |
|
543 | + $this->value = $this->smarty->left_delimiter; |
|
544 | + $this->token = Smarty_Internal_Templateparser::TP_LDEL; |
|
545 | + $this->yybegin(self::TAGBODY); |
|
546 | + $this->taglineno = $this->line; |
|
547 | + } |
|
548 | + } |
|
549 | + |
|
550 | + public function yy_r2_12() |
|
551 | + { |
|
552 | + |
|
553 | + $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; |
|
554 | + $this->yybegin(self::TAGBODY); |
|
555 | + $this->taglineno = $this->line; |
|
556 | + } |
|
557 | + |
|
558 | + public function yy_r2_13() |
|
559 | + { |
|
560 | + |
|
561 | + $this->token = Smarty_Internal_Templateparser::TP_LDEL; |
|
562 | + $this->yybegin(self::TAGBODY); |
|
563 | + $this->taglineno = $this->line; |
|
564 | + } |
|
565 | + |
|
566 | + public function yylex3() |
|
567 | + { |
|
568 | + if (!isset($this->yy_global_pattern3)) { |
|
569 | + $this->yy_global_pattern3 = "/\G(\\s*" . $this->rdel . ")|\G(" . $this->ldel . |
|
570 | + "\\s*)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$]smarty\\.block\\.(child|parent))|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*(([!=][=]{1,2})|([<][=>]?)|([>][=]?)|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\\s+)|\G(\\s+(is\\s+(not\\s+)?(odd|even|div)\\s+by)\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G(([!]\\s*)|(not\\s+))|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|])|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS"; |
|
571 | + } |
|
572 | + if ($this->counter >= strlen($this->data)) { |
|
573 | + return false; // end of input |
|
574 | + } |
|
575 | + |
|
576 | + do { |
|
577 | + if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, null, $this->counter)) { |
|
578 | + $yysubmatches = $yymatches; |
|
579 | + if (strlen($yysubmatches[ 0 ]) < 200) { |
|
580 | + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
|
581 | + } else { |
|
582 | + $yymatches = array_filter($yymatches, 'strlen'); |
|
583 | + } |
|
584 | + if (empty($yymatches)) { |
|
585 | + throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . |
|
586 | + substr($this->data, $this->counter, 5) . '... state TAGBODY'); |
|
587 | + } |
|
588 | + next($yymatches); // skip global match |
|
589 | + $this->token = key($yymatches); // token number |
|
590 | + $this->value = current($yymatches); // token value |
|
591 | + $r = $this->{'yy_r3_' . $this->token}(); |
|
592 | + if ($r === null) { |
|
593 | + $this->counter += strlen($this->value); |
|
594 | + $this->line += substr_count($this->value, "\n"); |
|
595 | + // accept this token |
|
596 | + return true; |
|
597 | + } elseif ($r === true) { |
|
598 | + // we have changed state |
|
599 | + // process this token in the new state |
|
600 | + return $this->yylex(); |
|
601 | + } elseif ($r === false) { |
|
602 | + $this->counter += strlen($this->value); |
|
603 | + $this->line += substr_count($this->value, "\n"); |
|
604 | + if ($this->counter >= strlen($this->data)) { |
|
605 | + return false; // end of input |
|
606 | + } |
|
607 | + // skip this token |
|
608 | + continue; |
|
609 | + } |
|
610 | + } else { |
|
611 | + throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]); |
|
612 | + } |
|
613 | + break; |
|
614 | + } |
|
615 | + while (true); |
|
616 | + } // end function |
|
617 | + |
|
618 | + const TAGBODY = 3; |
|
619 | + |
|
620 | + public function yy_r3_1() |
|
621 | + { |
|
622 | + |
|
623 | + $this->token = Smarty_Internal_Templateparser::TP_RDEL; |
|
624 | + $this->yypopstate(); |
|
625 | + } |
|
626 | + |
|
627 | + public function yy_r3_2() |
|
628 | + { |
|
629 | + |
|
630 | + if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
631 | + strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false |
|
632 | + ) { |
|
633 | + $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
634 | + } else { |
|
635 | + $this->yypushstate(self::TAG); |
|
636 | + return true; |
|
637 | + } |
|
638 | + } |
|
639 | + |
|
640 | + public function yy_r3_3() |
|
641 | + { |
|
642 | + |
|
643 | + $this->token = Smarty_Internal_Templateparser::TP_QUOTE; |
|
644 | + $this->yypushstate(self::DOUBLEQUOTEDSTRING); |
|
645 | + } |
|
646 | + |
|
647 | + public function yy_r3_4() |
|
648 | + { |
|
649 | + |
|
650 | + $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING; |
|
651 | + } |
|
652 | + |
|
653 | + public function yy_r3_5() |
|
654 | + { |
|
655 | + |
|
656 | + $this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT; |
|
657 | + $this->taglineno = $this->line; |
|
658 | + } |
|
659 | + |
|
660 | + public function yy_r3_7() |
|
661 | + { |
|
662 | + |
|
663 | + $this->token = Smarty_Internal_Templateparser::TP_DOLLARID; |
|
664 | + } |
|
665 | + |
|
666 | + public function yy_r3_8() |
|
667 | + { |
|
668 | + |
|
669 | + $this->token = Smarty_Internal_Templateparser::TP_DOLLAR; |
|
670 | + } |
|
671 | 671 | |
672 | - public function yy_r3_9() |
|
673 | - { |
|
672 | + public function yy_r3_9() |
|
673 | + { |
|
674 | 674 | |
675 | - $this->token = Smarty_Internal_Templateparser::TP_ISIN; |
|
676 | - } |
|
675 | + $this->token = Smarty_Internal_Templateparser::TP_ISIN; |
|
676 | + } |
|
677 | 677 | |
678 | - public function yy_r3_10() |
|
679 | - { |
|
678 | + public function yy_r3_10() |
|
679 | + { |
|
680 | 680 | |
681 | - $this->token = Smarty_Internal_Templateparser::TP_AS; |
|
682 | - } |
|
681 | + $this->token = Smarty_Internal_Templateparser::TP_AS; |
|
682 | + } |
|
683 | 683 | |
684 | - public function yy_r3_11() |
|
685 | - { |
|
684 | + public function yy_r3_11() |
|
685 | + { |
|
686 | 686 | |
687 | - $this->token = Smarty_Internal_Templateparser::TP_TO; |
|
688 | - } |
|
687 | + $this->token = Smarty_Internal_Templateparser::TP_TO; |
|
688 | + } |
|
689 | 689 | |
690 | - public function yy_r3_12() |
|
691 | - { |
|
690 | + public function yy_r3_12() |
|
691 | + { |
|
692 | 692 | |
693 | - $this->token = Smarty_Internal_Templateparser::TP_STEP; |
|
694 | - } |
|
693 | + $this->token = Smarty_Internal_Templateparser::TP_STEP; |
|
694 | + } |
|
695 | 695 | |
696 | - public function yy_r3_13() |
|
697 | - { |
|
696 | + public function yy_r3_13() |
|
697 | + { |
|
698 | 698 | |
699 | - $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF; |
|
700 | - } |
|
699 | + $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF; |
|
700 | + } |
|
701 | 701 | |
702 | - public function yy_r3_14() |
|
703 | - { |
|
702 | + public function yy_r3_14() |
|
703 | + { |
|
704 | 704 | |
705 | - $this->token = Smarty_Internal_Templateparser::TP_LOGOP; |
|
706 | - } |
|
705 | + $this->token = Smarty_Internal_Templateparser::TP_LOGOP; |
|
706 | + } |
|
707 | 707 | |
708 | - public function yy_r3_19() |
|
709 | - { |
|
708 | + public function yy_r3_19() |
|
709 | + { |
|
710 | 710 | |
711 | - $this->token = Smarty_Internal_Templateparser::TP_SLOGOP; |
|
712 | - } |
|
711 | + $this->token = Smarty_Internal_Templateparser::TP_SLOGOP; |
|
712 | + } |
|
713 | 713 | |
714 | - public function yy_r3_21() |
|
715 | - { |
|
714 | + public function yy_r3_21() |
|
715 | + { |
|
716 | 716 | |
717 | - $this->token = Smarty_Internal_Templateparser::TP_TLOGOP; |
|
718 | - } |
|
717 | + $this->token = Smarty_Internal_Templateparser::TP_TLOGOP; |
|
718 | + } |
|
719 | 719 | |
720 | - public function yy_r3_25() |
|
721 | - { |
|
720 | + public function yy_r3_25() |
|
721 | + { |
|
722 | 722 | |
723 | - $this->token = Smarty_Internal_Templateparser::TP_SINGLECOND; |
|
724 | - } |
|
723 | + $this->token = Smarty_Internal_Templateparser::TP_SINGLECOND; |
|
724 | + } |
|
725 | 725 | |
726 | - public function yy_r3_28() |
|
727 | - { |
|
726 | + public function yy_r3_28() |
|
727 | + { |
|
728 | 728 | |
729 | - $this->token = Smarty_Internal_Templateparser::TP_NOT; |
|
730 | - } |
|
729 | + $this->token = Smarty_Internal_Templateparser::TP_NOT; |
|
730 | + } |
|
731 | 731 | |
732 | - public function yy_r3_31() |
|
733 | - { |
|
732 | + public function yy_r3_31() |
|
733 | + { |
|
734 | 734 | |
735 | - $this->token = Smarty_Internal_Templateparser::TP_TYPECAST; |
|
736 | - } |
|
735 | + $this->token = Smarty_Internal_Templateparser::TP_TYPECAST; |
|
736 | + } |
|
737 | 737 | |
738 | - public function yy_r3_35() |
|
739 | - { |
|
738 | + public function yy_r3_35() |
|
739 | + { |
|
740 | 740 | |
741 | - $this->token = Smarty_Internal_Templateparser::TP_OPENP; |
|
742 | - } |
|
741 | + $this->token = Smarty_Internal_Templateparser::TP_OPENP; |
|
742 | + } |
|
743 | 743 | |
744 | - public function yy_r3_36() |
|
745 | - { |
|
744 | + public function yy_r3_36() |
|
745 | + { |
|
746 | 746 | |
747 | - $this->token = Smarty_Internal_Templateparser::TP_CLOSEP; |
|
748 | - } |
|
747 | + $this->token = Smarty_Internal_Templateparser::TP_CLOSEP; |
|
748 | + } |
|
749 | 749 | |
750 | - public function yy_r3_37() |
|
751 | - { |
|
750 | + public function yy_r3_37() |
|
751 | + { |
|
752 | 752 | |
753 | - $this->token = Smarty_Internal_Templateparser::TP_OPENB; |
|
754 | - } |
|
753 | + $this->token = Smarty_Internal_Templateparser::TP_OPENB; |
|
754 | + } |
|
755 | 755 | |
756 | - public function yy_r3_38() |
|
757 | - { |
|
756 | + public function yy_r3_38() |
|
757 | + { |
|
758 | 758 | |
759 | - $this->token = Smarty_Internal_Templateparser::TP_CLOSEB; |
|
760 | - } |
|
759 | + $this->token = Smarty_Internal_Templateparser::TP_CLOSEB; |
|
760 | + } |
|
761 | 761 | |
762 | - public function yy_r3_39() |
|
763 | - { |
|
762 | + public function yy_r3_39() |
|
763 | + { |
|
764 | 764 | |
765 | - $this->token = Smarty_Internal_Templateparser::TP_PTR; |
|
766 | - } |
|
765 | + $this->token = Smarty_Internal_Templateparser::TP_PTR; |
|
766 | + } |
|
767 | 767 | |
768 | - public function yy_r3_40() |
|
769 | - { |
|
768 | + public function yy_r3_40() |
|
769 | + { |
|
770 | 770 | |
771 | - $this->token = Smarty_Internal_Templateparser::TP_APTR; |
|
772 | - } |
|
771 | + $this->token = Smarty_Internal_Templateparser::TP_APTR; |
|
772 | + } |
|
773 | 773 | |
774 | - public function yy_r3_41() |
|
775 | - { |
|
774 | + public function yy_r3_41() |
|
775 | + { |
|
776 | 776 | |
777 | - $this->token = Smarty_Internal_Templateparser::TP_EQUAL; |
|
778 | - } |
|
777 | + $this->token = Smarty_Internal_Templateparser::TP_EQUAL; |
|
778 | + } |
|
779 | 779 | |
780 | - public function yy_r3_42() |
|
781 | - { |
|
780 | + public function yy_r3_42() |
|
781 | + { |
|
782 | 782 | |
783 | - $this->token = Smarty_Internal_Templateparser::TP_INCDEC; |
|
784 | - } |
|
783 | + $this->token = Smarty_Internal_Templateparser::TP_INCDEC; |
|
784 | + } |
|
785 | 785 | |
786 | - public function yy_r3_44() |
|
787 | - { |
|
786 | + public function yy_r3_44() |
|
787 | + { |
|
788 | 788 | |
789 | - $this->token = Smarty_Internal_Templateparser::TP_UNIMATH; |
|
790 | - } |
|
789 | + $this->token = Smarty_Internal_Templateparser::TP_UNIMATH; |
|
790 | + } |
|
791 | 791 | |
792 | - public function yy_r3_46() |
|
793 | - { |
|
792 | + public function yy_r3_46() |
|
793 | + { |
|
794 | 794 | |
795 | - $this->token = Smarty_Internal_Templateparser::TP_MATH; |
|
796 | - } |
|
795 | + $this->token = Smarty_Internal_Templateparser::TP_MATH; |
|
796 | + } |
|
797 | 797 | |
798 | - public function yy_r3_48() |
|
799 | - { |
|
798 | + public function yy_r3_48() |
|
799 | + { |
|
800 | 800 | |
801 | - $this->token = Smarty_Internal_Templateparser::TP_AT; |
|
802 | - } |
|
801 | + $this->token = Smarty_Internal_Templateparser::TP_AT; |
|
802 | + } |
|
803 | 803 | |
804 | - public function yy_r3_49() |
|
805 | - { |
|
804 | + public function yy_r3_49() |
|
805 | + { |
|
806 | 806 | |
807 | - $this->token = Smarty_Internal_Templateparser::TP_HATCH; |
|
808 | - } |
|
807 | + $this->token = Smarty_Internal_Templateparser::TP_HATCH; |
|
808 | + } |
|
809 | 809 | |
810 | - public function yy_r3_50() |
|
811 | - { |
|
810 | + public function yy_r3_50() |
|
811 | + { |
|
812 | 812 | |
813 | - // resolve conflicts with shorttag and right_delimiter starting with '=' |
|
814 | - if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) == |
|
815 | - $this->smarty->right_delimiter |
|
816 | - ) { |
|
817 | - preg_match("/\s+/", $this->value, $match); |
|
818 | - $this->value = $match[ 0 ]; |
|
819 | - $this->token = Smarty_Internal_Templateparser::TP_SPACE; |
|
820 | - } else { |
|
821 | - $this->token = Smarty_Internal_Templateparser::TP_ATTR; |
|
822 | - } |
|
823 | - } |
|
813 | + // resolve conflicts with shorttag and right_delimiter starting with '=' |
|
814 | + if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) == |
|
815 | + $this->smarty->right_delimiter |
|
816 | + ) { |
|
817 | + preg_match("/\s+/", $this->value, $match); |
|
818 | + $this->value = $match[ 0 ]; |
|
819 | + $this->token = Smarty_Internal_Templateparser::TP_SPACE; |
|
820 | + } else { |
|
821 | + $this->token = Smarty_Internal_Templateparser::TP_ATTR; |
|
822 | + } |
|
823 | + } |
|
824 | 824 | |
825 | - public function yy_r3_51() |
|
826 | - { |
|
825 | + public function yy_r3_51() |
|
826 | + { |
|
827 | 827 | |
828 | - $this->token = Smarty_Internal_Templateparser::TP_NAMESPACE; |
|
829 | - } |
|
828 | + $this->token = Smarty_Internal_Templateparser::TP_NAMESPACE; |
|
829 | + } |
|
830 | 830 | |
831 | - public function yy_r3_54() |
|
832 | - { |
|
831 | + public function yy_r3_54() |
|
832 | + { |
|
833 | 833 | |
834 | - $this->token = Smarty_Internal_Templateparser::TP_ID; |
|
835 | - } |
|
834 | + $this->token = Smarty_Internal_Templateparser::TP_ID; |
|
835 | + } |
|
836 | 836 | |
837 | - public function yy_r3_55() |
|
838 | - { |
|
837 | + public function yy_r3_55() |
|
838 | + { |
|
839 | 839 | |
840 | - $this->token = Smarty_Internal_Templateparser::TP_INTEGER; |
|
841 | - } |
|
840 | + $this->token = Smarty_Internal_Templateparser::TP_INTEGER; |
|
841 | + } |
|
842 | 842 | |
843 | - public function yy_r3_56() |
|
844 | - { |
|
843 | + public function yy_r3_56() |
|
844 | + { |
|
845 | 845 | |
846 | - $this->token = Smarty_Internal_Templateparser::TP_BACKTICK; |
|
847 | - $this->yypopstate(); |
|
848 | - } |
|
846 | + $this->token = Smarty_Internal_Templateparser::TP_BACKTICK; |
|
847 | + $this->yypopstate(); |
|
848 | + } |
|
849 | 849 | |
850 | - public function yy_r3_57() |
|
851 | - { |
|
850 | + public function yy_r3_57() |
|
851 | + { |
|
852 | 852 | |
853 | - $this->token = Smarty_Internal_Templateparser::TP_VERT; |
|
854 | - } |
|
853 | + $this->token = Smarty_Internal_Templateparser::TP_VERT; |
|
854 | + } |
|
855 | 855 | |
856 | - public function yy_r3_58() |
|
857 | - { |
|
858 | - |
|
859 | - $this->token = Smarty_Internal_Templateparser::TP_DOT; |
|
860 | - } |
|
861 | - |
|
862 | - public function yy_r3_59() |
|
863 | - { |
|
864 | - |
|
865 | - $this->token = Smarty_Internal_Templateparser::TP_COMMA; |
|
866 | - } |
|
867 | - |
|
868 | - public function yy_r3_60() |
|
869 | - { |
|
870 | - |
|
871 | - $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON; |
|
872 | - } |
|
873 | - |
|
874 | - public function yy_r3_61() |
|
875 | - { |
|
876 | - |
|
877 | - $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON; |
|
878 | - } |
|
879 | - |
|
880 | - public function yy_r3_62() |
|
881 | - { |
|
882 | - |
|
883 | - $this->token = Smarty_Internal_Templateparser::TP_COLON; |
|
884 | - } |
|
885 | - |
|
886 | - public function yy_r3_63() |
|
887 | - { |
|
888 | - |
|
889 | - $this->token = Smarty_Internal_Templateparser::TP_QMARK; |
|
890 | - } |
|
891 | - |
|
892 | - public function yy_r3_64() |
|
893 | - { |
|
894 | - |
|
895 | - $this->token = Smarty_Internal_Templateparser::TP_HEX; |
|
896 | - } |
|
897 | - |
|
898 | - public function yy_r3_65() |
|
899 | - { |
|
900 | - |
|
901 | - $this->token = Smarty_Internal_Templateparser::TP_SPACE; |
|
902 | - } |
|
903 | - |
|
904 | - public function yy_r3_66() |
|
905 | - { |
|
906 | - |
|
907 | - $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
908 | - } |
|
909 | - |
|
910 | - public function yylex4() |
|
911 | - { |
|
912 | - if (!isset($this->yy_global_pattern4)) { |
|
913 | - $this->yy_global_pattern4 = |
|
914 | - "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" . |
|
915 | - $this->rdel . ")|\G([\S\s])/isS"; |
|
916 | - } |
|
917 | - if ($this->counter >= strlen($this->data)) { |
|
918 | - return false; // end of input |
|
919 | - } |
|
920 | - |
|
921 | - do { |
|
922 | - if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, null, $this->counter)) { |
|
923 | - $yysubmatches = $yymatches; |
|
924 | - if (strlen($yysubmatches[ 0 ]) < 200) { |
|
925 | - $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
|
926 | - } else { |
|
927 | - $yymatches = array_filter($yymatches, 'strlen'); |
|
928 | - } |
|
929 | - if (empty($yymatches)) { |
|
930 | - throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . |
|
931 | - substr($this->data, $this->counter, 5) . '... state LITERAL'); |
|
932 | - } |
|
933 | - next($yymatches); // skip global match |
|
934 | - $this->token = key($yymatches); // token number |
|
935 | - $this->value = current($yymatches); // token value |
|
936 | - $r = $this->{'yy_r4_' . $this->token}(); |
|
937 | - if ($r === null) { |
|
938 | - $this->counter += strlen($this->value); |
|
939 | - $this->line += substr_count($this->value, "\n"); |
|
940 | - // accept this token |
|
941 | - return true; |
|
942 | - } elseif ($r === true) { |
|
943 | - // we have changed state |
|
944 | - // process this token in the new state |
|
945 | - return $this->yylex(); |
|
946 | - } elseif ($r === false) { |
|
947 | - $this->counter += strlen($this->value); |
|
948 | - $this->line += substr_count($this->value, "\n"); |
|
949 | - if ($this->counter >= strlen($this->data)) { |
|
950 | - return false; // end of input |
|
951 | - } |
|
952 | - // skip this token |
|
953 | - continue; |
|
954 | - } |
|
955 | - } else { |
|
956 | - throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]); |
|
957 | - } |
|
958 | - break; |
|
959 | - } |
|
960 | - while (true); |
|
961 | - } // end function |
|
962 | - |
|
963 | - const LITERAL = 4; |
|
964 | - |
|
965 | - public function yy_r4_1() |
|
966 | - { |
|
967 | - |
|
968 | - $this->literal_cnt ++; |
|
969 | - $this->token = Smarty_Internal_Templateparser::TP_LITERAL; |
|
970 | - } |
|
971 | - |
|
972 | - public function yy_r4_2() |
|
973 | - { |
|
974 | - |
|
975 | - if ($this->literal_cnt) { |
|
976 | - $this->literal_cnt --; |
|
977 | - $this->token = Smarty_Internal_Templateparser::TP_LITERAL; |
|
978 | - } else { |
|
979 | - $this->token = Smarty_Internal_Templateparser::TP_LITERALEND; |
|
980 | - $this->yypopstate(); |
|
981 | - } |
|
982 | - } |
|
983 | - |
|
984 | - public function yy_r4_3() |
|
985 | - { |
|
986 | - |
|
987 | - $to = strlen($this->data); |
|
988 | - preg_match("/{$this->ldel}[\/]?literal{$this->rdel}/i", $this->data, $match, PREG_OFFSET_CAPTURE, |
|
989 | - $this->counter); |
|
990 | - if (isset($match[ 0 ][ 1 ])) { |
|
991 | - $to = $match[ 0 ][ 1 ]; |
|
992 | - } else { |
|
993 | - $this->compiler->trigger_template_error("missing or misspelled literal closing tag"); |
|
994 | - } |
|
995 | - $this->value = substr($this->data, $this->counter, $to - $this->counter); |
|
996 | - $this->token = Smarty_Internal_Templateparser::TP_LITERAL; |
|
997 | - } |
|
998 | - |
|
999 | - public function yylex5() |
|
1000 | - { |
|
1001 | - if (!isset($this->yy_global_pattern5)) { |
|
1002 | - $this->yy_global_pattern5 = |
|
1003 | - "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" . |
|
1004 | - $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*)|\G(" . |
|
1005 | - $this->ldel . |
|
1006 | - "\\s*)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(" . |
|
1007 | - $this->ldel . "|\\$|`\\$|\")))|\G([\S\s])/isS"; |
|
1008 | - } |
|
1009 | - if ($this->counter >= strlen($this->data)) { |
|
1010 | - return false; // end of input |
|
1011 | - } |
|
1012 | - |
|
1013 | - do { |
|
1014 | - if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, null, $this->counter)) { |
|
1015 | - $yysubmatches = $yymatches; |
|
1016 | - if (strlen($yysubmatches[ 0 ]) < 200) { |
|
1017 | - $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
|
1018 | - } else { |
|
1019 | - $yymatches = array_filter($yymatches, 'strlen'); |
|
1020 | - } |
|
1021 | - if (empty($yymatches)) { |
|
1022 | - throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . |
|
1023 | - substr($this->data, $this->counter, 5) . '... state DOUBLEQUOTEDSTRING'); |
|
1024 | - } |
|
1025 | - next($yymatches); // skip global match |
|
1026 | - $this->token = key($yymatches); // token number |
|
1027 | - $this->value = current($yymatches); // token value |
|
1028 | - $r = $this->{'yy_r5_' . $this->token}(); |
|
1029 | - if ($r === null) { |
|
1030 | - $this->counter += strlen($this->value); |
|
1031 | - $this->line += substr_count($this->value, "\n"); |
|
1032 | - // accept this token |
|
1033 | - return true; |
|
1034 | - } elseif ($r === true) { |
|
1035 | - // we have changed state |
|
1036 | - // process this token in the new state |
|
1037 | - return $this->yylex(); |
|
1038 | - } elseif ($r === false) { |
|
1039 | - $this->counter += strlen($this->value); |
|
1040 | - $this->line += substr_count($this->value, "\n"); |
|
1041 | - if ($this->counter >= strlen($this->data)) { |
|
1042 | - return false; // end of input |
|
1043 | - } |
|
1044 | - // skip this token |
|
1045 | - continue; |
|
1046 | - } |
|
1047 | - } else { |
|
1048 | - throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]); |
|
1049 | - } |
|
1050 | - break; |
|
1051 | - } |
|
1052 | - while (true); |
|
1053 | - } // end function |
|
1054 | - |
|
1055 | - const DOUBLEQUOTEDSTRING = 5; |
|
1056 | - |
|
1057 | - public function yy_r5_1() |
|
1058 | - { |
|
1059 | - |
|
1060 | - $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
1061 | - } |
|
1062 | - |
|
1063 | - public function yy_r5_2() |
|
1064 | - { |
|
1065 | - |
|
1066 | - $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
1067 | - } |
|
1068 | - |
|
1069 | - public function yy_r5_3() |
|
1070 | - { |
|
1071 | - |
|
1072 | - if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
1073 | - strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false |
|
1074 | - ) { |
|
1075 | - $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
1076 | - } else { |
|
1077 | - $this->yypushstate(self::TAG); |
|
1078 | - return true; |
|
1079 | - } |
|
1080 | - } |
|
1081 | - |
|
1082 | - public function yy_r5_4() |
|
1083 | - { |
|
1084 | - |
|
1085 | - if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
1086 | - strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false |
|
1087 | - ) { |
|
1088 | - $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
1089 | - } else { |
|
1090 | - $this->yypushstate(self::TAG); |
|
1091 | - return true; |
|
1092 | - } |
|
1093 | - } |
|
1094 | - |
|
1095 | - public function yy_r5_5() |
|
1096 | - { |
|
1097 | - |
|
1098 | - if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
1099 | - strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false |
|
1100 | - ) { |
|
1101 | - $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
1102 | - } else { |
|
1103 | - $this->token = Smarty_Internal_Templateparser::TP_LDEL; |
|
1104 | - $this->taglineno = $this->line; |
|
1105 | - $this->yypushstate(self::TAGBODY); |
|
1106 | - } |
|
1107 | - } |
|
1108 | - |
|
1109 | - public function yy_r5_6() |
|
1110 | - { |
|
1111 | - |
|
1112 | - $this->token = Smarty_Internal_Templateparser::TP_QUOTE; |
|
1113 | - $this->yypopstate(); |
|
1114 | - } |
|
1115 | - |
|
1116 | - public function yy_r5_7() |
|
1117 | - { |
|
1118 | - |
|
1119 | - $this->token = Smarty_Internal_Templateparser::TP_BACKTICK; |
|
1120 | - $this->value = substr($this->value, 0, - 1); |
|
1121 | - $this->yypushstate(self::TAGBODY); |
|
1122 | - $this->taglineno = $this->line; |
|
1123 | - } |
|
1124 | - |
|
1125 | - public function yy_r5_8() |
|
1126 | - { |
|
1127 | - |
|
1128 | - $this->token = Smarty_Internal_Templateparser::TP_DOLLARID; |
|
1129 | - } |
|
1130 | - |
|
1131 | - public function yy_r5_9() |
|
1132 | - { |
|
1133 | - |
|
1134 | - $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
1135 | - } |
|
1136 | - |
|
1137 | - public function yy_r5_10() |
|
1138 | - { |
|
1139 | - |
|
1140 | - $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
1141 | - } |
|
1142 | - |
|
1143 | - public function yy_r5_14() |
|
1144 | - { |
|
1145 | - |
|
1146 | - $to = strlen($this->data); |
|
1147 | - $this->value = substr($this->data, $this->counter, $to - $this->counter); |
|
1148 | - $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
1149 | - } |
|
856 | + public function yy_r3_58() |
|
857 | + { |
|
858 | + |
|
859 | + $this->token = Smarty_Internal_Templateparser::TP_DOT; |
|
860 | + } |
|
861 | + |
|
862 | + public function yy_r3_59() |
|
863 | + { |
|
864 | + |
|
865 | + $this->token = Smarty_Internal_Templateparser::TP_COMMA; |
|
866 | + } |
|
867 | + |
|
868 | + public function yy_r3_60() |
|
869 | + { |
|
870 | + |
|
871 | + $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON; |
|
872 | + } |
|
873 | + |
|
874 | + public function yy_r3_61() |
|
875 | + { |
|
876 | + |
|
877 | + $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON; |
|
878 | + } |
|
879 | + |
|
880 | + public function yy_r3_62() |
|
881 | + { |
|
882 | + |
|
883 | + $this->token = Smarty_Internal_Templateparser::TP_COLON; |
|
884 | + } |
|
885 | + |
|
886 | + public function yy_r3_63() |
|
887 | + { |
|
888 | + |
|
889 | + $this->token = Smarty_Internal_Templateparser::TP_QMARK; |
|
890 | + } |
|
891 | + |
|
892 | + public function yy_r3_64() |
|
893 | + { |
|
894 | + |
|
895 | + $this->token = Smarty_Internal_Templateparser::TP_HEX; |
|
896 | + } |
|
897 | + |
|
898 | + public function yy_r3_65() |
|
899 | + { |
|
900 | + |
|
901 | + $this->token = Smarty_Internal_Templateparser::TP_SPACE; |
|
902 | + } |
|
903 | + |
|
904 | + public function yy_r3_66() |
|
905 | + { |
|
906 | + |
|
907 | + $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
908 | + } |
|
909 | + |
|
910 | + public function yylex4() |
|
911 | + { |
|
912 | + if (!isset($this->yy_global_pattern4)) { |
|
913 | + $this->yy_global_pattern4 = |
|
914 | + "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" . |
|
915 | + $this->rdel . ")|\G([\S\s])/isS"; |
|
916 | + } |
|
917 | + if ($this->counter >= strlen($this->data)) { |
|
918 | + return false; // end of input |
|
919 | + } |
|
920 | + |
|
921 | + do { |
|
922 | + if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, null, $this->counter)) { |
|
923 | + $yysubmatches = $yymatches; |
|
924 | + if (strlen($yysubmatches[ 0 ]) < 200) { |
|
925 | + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
|
926 | + } else { |
|
927 | + $yymatches = array_filter($yymatches, 'strlen'); |
|
928 | + } |
|
929 | + if (empty($yymatches)) { |
|
930 | + throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . |
|
931 | + substr($this->data, $this->counter, 5) . '... state LITERAL'); |
|
932 | + } |
|
933 | + next($yymatches); // skip global match |
|
934 | + $this->token = key($yymatches); // token number |
|
935 | + $this->value = current($yymatches); // token value |
|
936 | + $r = $this->{'yy_r4_' . $this->token}(); |
|
937 | + if ($r === null) { |
|
938 | + $this->counter += strlen($this->value); |
|
939 | + $this->line += substr_count($this->value, "\n"); |
|
940 | + // accept this token |
|
941 | + return true; |
|
942 | + } elseif ($r === true) { |
|
943 | + // we have changed state |
|
944 | + // process this token in the new state |
|
945 | + return $this->yylex(); |
|
946 | + } elseif ($r === false) { |
|
947 | + $this->counter += strlen($this->value); |
|
948 | + $this->line += substr_count($this->value, "\n"); |
|
949 | + if ($this->counter >= strlen($this->data)) { |
|
950 | + return false; // end of input |
|
951 | + } |
|
952 | + // skip this token |
|
953 | + continue; |
|
954 | + } |
|
955 | + } else { |
|
956 | + throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]); |
|
957 | + } |
|
958 | + break; |
|
959 | + } |
|
960 | + while (true); |
|
961 | + } // end function |
|
962 | + |
|
963 | + const LITERAL = 4; |
|
964 | + |
|
965 | + public function yy_r4_1() |
|
966 | + { |
|
967 | + |
|
968 | + $this->literal_cnt ++; |
|
969 | + $this->token = Smarty_Internal_Templateparser::TP_LITERAL; |
|
970 | + } |
|
971 | + |
|
972 | + public function yy_r4_2() |
|
973 | + { |
|
974 | + |
|
975 | + if ($this->literal_cnt) { |
|
976 | + $this->literal_cnt --; |
|
977 | + $this->token = Smarty_Internal_Templateparser::TP_LITERAL; |
|
978 | + } else { |
|
979 | + $this->token = Smarty_Internal_Templateparser::TP_LITERALEND; |
|
980 | + $this->yypopstate(); |
|
981 | + } |
|
982 | + } |
|
983 | + |
|
984 | + public function yy_r4_3() |
|
985 | + { |
|
986 | + |
|
987 | + $to = strlen($this->data); |
|
988 | + preg_match("/{$this->ldel}[\/]?literal{$this->rdel}/i", $this->data, $match, PREG_OFFSET_CAPTURE, |
|
989 | + $this->counter); |
|
990 | + if (isset($match[ 0 ][ 1 ])) { |
|
991 | + $to = $match[ 0 ][ 1 ]; |
|
992 | + } else { |
|
993 | + $this->compiler->trigger_template_error("missing or misspelled literal closing tag"); |
|
994 | + } |
|
995 | + $this->value = substr($this->data, $this->counter, $to - $this->counter); |
|
996 | + $this->token = Smarty_Internal_Templateparser::TP_LITERAL; |
|
997 | + } |
|
998 | + |
|
999 | + public function yylex5() |
|
1000 | + { |
|
1001 | + if (!isset($this->yy_global_pattern5)) { |
|
1002 | + $this->yy_global_pattern5 = |
|
1003 | + "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" . |
|
1004 | + $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*)|\G(" . |
|
1005 | + $this->ldel . |
|
1006 | + "\\s*)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(" . |
|
1007 | + $this->ldel . "|\\$|`\\$|\")))|\G([\S\s])/isS"; |
|
1008 | + } |
|
1009 | + if ($this->counter >= strlen($this->data)) { |
|
1010 | + return false; // end of input |
|
1011 | + } |
|
1012 | + |
|
1013 | + do { |
|
1014 | + if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, null, $this->counter)) { |
|
1015 | + $yysubmatches = $yymatches; |
|
1016 | + if (strlen($yysubmatches[ 0 ]) < 200) { |
|
1017 | + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); |
|
1018 | + } else { |
|
1019 | + $yymatches = array_filter($yymatches, 'strlen'); |
|
1020 | + } |
|
1021 | + if (empty($yymatches)) { |
|
1022 | + throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . |
|
1023 | + substr($this->data, $this->counter, 5) . '... state DOUBLEQUOTEDSTRING'); |
|
1024 | + } |
|
1025 | + next($yymatches); // skip global match |
|
1026 | + $this->token = key($yymatches); // token number |
|
1027 | + $this->value = current($yymatches); // token value |
|
1028 | + $r = $this->{'yy_r5_' . $this->token}(); |
|
1029 | + if ($r === null) { |
|
1030 | + $this->counter += strlen($this->value); |
|
1031 | + $this->line += substr_count($this->value, "\n"); |
|
1032 | + // accept this token |
|
1033 | + return true; |
|
1034 | + } elseif ($r === true) { |
|
1035 | + // we have changed state |
|
1036 | + // process this token in the new state |
|
1037 | + return $this->yylex(); |
|
1038 | + } elseif ($r === false) { |
|
1039 | + $this->counter += strlen($this->value); |
|
1040 | + $this->line += substr_count($this->value, "\n"); |
|
1041 | + if ($this->counter >= strlen($this->data)) { |
|
1042 | + return false; // end of input |
|
1043 | + } |
|
1044 | + // skip this token |
|
1045 | + continue; |
|
1046 | + } |
|
1047 | + } else { |
|
1048 | + throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]); |
|
1049 | + } |
|
1050 | + break; |
|
1051 | + } |
|
1052 | + while (true); |
|
1053 | + } // end function |
|
1054 | + |
|
1055 | + const DOUBLEQUOTEDSTRING = 5; |
|
1056 | + |
|
1057 | + public function yy_r5_1() |
|
1058 | + { |
|
1059 | + |
|
1060 | + $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
1061 | + } |
|
1062 | + |
|
1063 | + public function yy_r5_2() |
|
1064 | + { |
|
1065 | + |
|
1066 | + $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
1067 | + } |
|
1068 | + |
|
1069 | + public function yy_r5_3() |
|
1070 | + { |
|
1071 | + |
|
1072 | + if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
1073 | + strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false |
|
1074 | + ) { |
|
1075 | + $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
1076 | + } else { |
|
1077 | + $this->yypushstate(self::TAG); |
|
1078 | + return true; |
|
1079 | + } |
|
1080 | + } |
|
1081 | + |
|
1082 | + public function yy_r5_4() |
|
1083 | + { |
|
1084 | + |
|
1085 | + if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
1086 | + strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false |
|
1087 | + ) { |
|
1088 | + $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
1089 | + } else { |
|
1090 | + $this->yypushstate(self::TAG); |
|
1091 | + return true; |
|
1092 | + } |
|
1093 | + } |
|
1094 | + |
|
1095 | + public function yy_r5_5() |
|
1096 | + { |
|
1097 | + |
|
1098 | + if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? |
|
1099 | + strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false |
|
1100 | + ) { |
|
1101 | + $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
1102 | + } else { |
|
1103 | + $this->token = Smarty_Internal_Templateparser::TP_LDEL; |
|
1104 | + $this->taglineno = $this->line; |
|
1105 | + $this->yypushstate(self::TAGBODY); |
|
1106 | + } |
|
1107 | + } |
|
1108 | + |
|
1109 | + public function yy_r5_6() |
|
1110 | + { |
|
1111 | + |
|
1112 | + $this->token = Smarty_Internal_Templateparser::TP_QUOTE; |
|
1113 | + $this->yypopstate(); |
|
1114 | + } |
|
1115 | + |
|
1116 | + public function yy_r5_7() |
|
1117 | + { |
|
1118 | + |
|
1119 | + $this->token = Smarty_Internal_Templateparser::TP_BACKTICK; |
|
1120 | + $this->value = substr($this->value, 0, - 1); |
|
1121 | + $this->yypushstate(self::TAGBODY); |
|
1122 | + $this->taglineno = $this->line; |
|
1123 | + } |
|
1124 | + |
|
1125 | + public function yy_r5_8() |
|
1126 | + { |
|
1127 | + |
|
1128 | + $this->token = Smarty_Internal_Templateparser::TP_DOLLARID; |
|
1129 | + } |
|
1130 | + |
|
1131 | + public function yy_r5_9() |
|
1132 | + { |
|
1133 | + |
|
1134 | + $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
1135 | + } |
|
1136 | + |
|
1137 | + public function yy_r5_10() |
|
1138 | + { |
|
1139 | + |
|
1140 | + $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
1141 | + } |
|
1142 | + |
|
1143 | + public function yy_r5_14() |
|
1144 | + { |
|
1145 | + |
|
1146 | + $to = strlen($this->data); |
|
1147 | + $this->value = substr($this->data, $this->counter, $to - $this->counter); |
|
1148 | + $this->token = Smarty_Internal_Templateparser::TP_TEXT; |
|
1149 | + } |
|
1150 | 1150 | |
1151 | 1151 | } |
1152 | 1152 | |
1153 | - |
|
1154 | 1153 | \ No newline at end of file |
1154 | + |
|
1155 | 1155 | \ No newline at end of file |
@@ -183,7 +183,7 @@ |
||
183 | 183 | * @param string $resource_name template_resource or config_resource to parse |
184 | 184 | * @param string $default_resource the default resource_type defined in $smarty |
185 | 185 | * |
186 | - * @return array with parsed resource name and type |
|
186 | + * @return string[] with parsed resource name and type |
|
187 | 187 | */ |
188 | 188 | public static function parseResourceName($resource_name, $default_resource) |
189 | 189 | { |
@@ -129,28 +129,28 @@ discard block |
||
129 | 129 | public static function load(Smarty $smarty, $type) |
130 | 130 | { |
131 | 131 | // try smarty's cache |
132 | - if (isset($smarty->_cache[ 'resource_handlers' ][ $type ])) { |
|
133 | - return $smarty->_cache[ 'resource_handlers' ][ $type ]; |
|
132 | + if (isset($smarty->_cache['resource_handlers'][$type])) { |
|
133 | + return $smarty->_cache['resource_handlers'][$type]; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | // try registered resource |
137 | - if (isset($smarty->registered_resources[ $type ])) { |
|
138 | - return $smarty->_cache[ 'resource_handlers' ][ $type ] = |
|
139 | - $smarty->registered_resources[ $type ] instanceof Smarty_Resource ? |
|
140 | - $smarty->registered_resources[ $type ] : new Smarty_Internal_Resource_Registered(); |
|
137 | + if (isset($smarty->registered_resources[$type])) { |
|
138 | + return $smarty->_cache['resource_handlers'][$type] = |
|
139 | + $smarty->registered_resources[$type] instanceof Smarty_Resource ? |
|
140 | + $smarty->registered_resources[$type] : new Smarty_Internal_Resource_Registered(); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | // try sysplugins dir |
144 | - if (isset(self::$sysplugins[ $type ])) { |
|
144 | + if (isset(self::$sysplugins[$type])) { |
|
145 | 145 | $_resource_class = 'Smarty_Internal_Resource_' . ucfirst($type); |
146 | - return $smarty->_cache[ 'resource_handlers' ][ $type ] = new $_resource_class(); |
|
146 | + return $smarty->_cache['resource_handlers'][$type] = new $_resource_class(); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | // try plugins dir |
150 | 150 | $_resource_class = 'Smarty_Resource_' . ucfirst($type); |
151 | 151 | if ($smarty->loadPlugin($_resource_class)) { |
152 | 152 | if (class_exists($_resource_class, false)) { |
153 | - return $smarty->_cache[ 'resource_handlers' ][ $type ] = new $_resource_class(); |
|
153 | + return $smarty->_cache['resource_handlers'][$type] = new $_resource_class(); |
|
154 | 154 | } else { |
155 | 155 | $smarty->registerResource($type, |
156 | 156 | array("smarty_resource_{$type}_source", "smarty_resource_{$type}_timestamp", |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | if (is_object($smarty->security_policy)) { |
168 | 168 | $smarty->security_policy->isTrustedStream($type); |
169 | 169 | } |
170 | - return $smarty->_cache[ 'resource_handlers' ][ $type ] = new Smarty_Internal_Resource_Stream(); |
|
170 | + return $smarty->_cache['resource_handlers'][$type] = new Smarty_Internal_Resource_Stream(); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // TODO: try default_(template|config)_handler |
@@ -188,8 +188,8 @@ discard block |
||
188 | 188 | public static function parseResourceName($resource_name, $default_resource) |
189 | 189 | { |
190 | 190 | if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]/', $resource_name, $match)) { |
191 | - $type = $match[ 1 ]; |
|
192 | - $name = substr($resource_name, strlen($match[ 0 ])); |
|
191 | + $type = $match[1]; |
|
192 | + $name = substr($resource_name, strlen($match[0])); |
|
193 | 193 | } else { |
194 | 194 | // no resource given, use default |
195 | 195 | // or single character before the colon is not a resource type, but part of the filepath |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | // TODO: optimize for Smarty's internal resource types |
215 | 215 | $resource = Smarty_Resource::load($smarty, $type); |
216 | 216 | // go relative to a given template? |
217 | - $_file_is_dotted = $name[ 0 ] == '.' && ($name[ 1 ] == '.' || $name[ 1 ] == '/'); |
|
217 | + $_file_is_dotted = $name[0] == '.' && ($name[1] == '.' || $name[1] == '/'); |
|
218 | 218 | if ($obj->_objType == 2 && $_file_is_dotted && |
219 | 219 | ($obj->source->type == 'file' || $obj->parent->source->type == 'extends') |
220 | 220 | ) { |
@@ -20,231 +20,231 @@ |
||
20 | 20 | */ |
21 | 21 | abstract class Smarty_Resource |
22 | 22 | { |
23 | - /** |
|
24 | - * Source is bypassing compiler |
|
25 | - * |
|
26 | - * @var boolean |
|
27 | - */ |
|
28 | - public $uncompiled = false; |
|
29 | - |
|
30 | - /** |
|
31 | - * Source must be recompiled on every occasion |
|
32 | - * |
|
33 | - * @var boolean |
|
34 | - */ |
|
35 | - public $recompiled = false; |
|
36 | - |
|
37 | - /** |
|
38 | - * resource types provided by the core |
|
39 | - * |
|
40 | - * @var array |
|
41 | - */ |
|
42 | - public static $sysplugins = array('file' => 'smarty_internal_resource_file.php', |
|
43 | - 'string' => 'smarty_internal_resource_string.php', |
|
44 | - 'extends' => 'smarty_internal_resource_extends.php', |
|
45 | - 'stream' => 'smarty_internal_resource_stream.php', |
|
46 | - 'eval' => 'smarty_internal_resource_eval.php', |
|
47 | - 'php' => 'smarty_internal_resource_php.php'); |
|
48 | - |
|
49 | - /** |
|
50 | - * Flag if resource does implement populateCompiledFilepath() method |
|
51 | - * |
|
52 | - * @var bool |
|
53 | - */ |
|
54 | - public $hasCompiledHandler = false; |
|
55 | - |
|
56 | - /** |
|
57 | - * Load template's source into current template object |
|
58 | - * |
|
59 | - * @param Smarty_Template_Source $source source object |
|
60 | - * |
|
61 | - * @return string template source |
|
62 | - * @throws SmartyException if source cannot be loaded |
|
63 | - */ |
|
64 | - abstract public function getContent(Smarty_Template_Source $source); |
|
65 | - |
|
66 | - /** |
|
67 | - * populate Source Object with meta data from Resource |
|
68 | - * |
|
69 | - * @param Smarty_Template_Source $source source object |
|
70 | - * @param Smarty_Internal_Template $_template template object |
|
71 | - */ |
|
72 | - abstract public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null); |
|
73 | - |
|
74 | - /** |
|
75 | - * populate Source Object with timestamp and exists from Resource |
|
76 | - * |
|
77 | - * @param Smarty_Template_Source $source source object |
|
78 | - */ |
|
79 | - public function populateTimestamp(Smarty_Template_Source $source) |
|
80 | - { |
|
81 | - // intentionally left blank |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * modify resource_name according to resource handlers specifications |
|
86 | - * |
|
87 | - * @param Smarty $smarty Smarty instance |
|
88 | - * @param string $resource_name resource_name to make unique |
|
89 | - * @param boolean $isConfig flag for config resource |
|
90 | - * |
|
91 | - * @return string unique resource name |
|
92 | - */ |
|
93 | - public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false) |
|
94 | - { |
|
95 | - if ($isConfig) { |
|
96 | - if (!isset($smarty->_joined_config_dir)) { |
|
97 | - $smarty->getTemplateDir(null, true); |
|
98 | - } |
|
99 | - return get_class($this) . '#' . $smarty->_joined_config_dir . '#' . $resource_name; |
|
100 | - } else { |
|
101 | - if (!isset($smarty->_joined_template_dir)) { |
|
102 | - $smarty->getTemplateDir(); |
|
103 | - } |
|
104 | - return get_class($this) . '#' . $smarty->_joined_template_dir . '#' . $resource_name; |
|
105 | - } |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Determine basename for compiled filename |
|
110 | - * |
|
111 | - * @param Smarty_Template_Source $source source object |
|
112 | - * |
|
113 | - * @return string resource's basename |
|
114 | - */ |
|
115 | - public function getBasename(Smarty_Template_Source $source) |
|
116 | - { |
|
117 | - return basename(preg_replace('![^\w]+!', '_', $source->name)); |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Load Resource Handler |
|
122 | - * |
|
123 | - * @param Smarty $smarty smarty object |
|
124 | - * @param string $type name of the resource |
|
125 | - * |
|
126 | - * @throws SmartyException |
|
127 | - * @return Smarty_Resource Resource Handler |
|
128 | - */ |
|
129 | - public static function load(Smarty $smarty, $type) |
|
130 | - { |
|
131 | - // try smarty's cache |
|
132 | - if (isset($smarty->_cache[ 'resource_handlers' ][ $type ])) { |
|
133 | - return $smarty->_cache[ 'resource_handlers' ][ $type ]; |
|
134 | - } |
|
135 | - |
|
136 | - // try registered resource |
|
137 | - if (isset($smarty->registered_resources[ $type ])) { |
|
138 | - return $smarty->_cache[ 'resource_handlers' ][ $type ] = |
|
139 | - $smarty->registered_resources[ $type ] instanceof Smarty_Resource ? |
|
140 | - $smarty->registered_resources[ $type ] : new Smarty_Internal_Resource_Registered(); |
|
141 | - } |
|
142 | - |
|
143 | - // try sysplugins dir |
|
144 | - if (isset(self::$sysplugins[ $type ])) { |
|
145 | - $_resource_class = 'Smarty_Internal_Resource_' . ucfirst($type); |
|
146 | - return $smarty->_cache[ 'resource_handlers' ][ $type ] = new $_resource_class(); |
|
147 | - } |
|
148 | - |
|
149 | - // try plugins dir |
|
150 | - $_resource_class = 'Smarty_Resource_' . ucfirst($type); |
|
151 | - if ($smarty->loadPlugin($_resource_class)) { |
|
152 | - if (class_exists($_resource_class, false)) { |
|
153 | - return $smarty->_cache[ 'resource_handlers' ][ $type ] = new $_resource_class(); |
|
154 | - } else { |
|
155 | - $smarty->registerResource($type, |
|
156 | - array("smarty_resource_{$type}_source", "smarty_resource_{$type}_timestamp", |
|
157 | - "smarty_resource_{$type}_secure", "smarty_resource_{$type}_trusted")); |
|
158 | - // give it another try, now that the resource is registered properly |
|
159 | - return self::load($smarty, $type); |
|
160 | - } |
|
161 | - } |
|
162 | - |
|
163 | - // try streams |
|
164 | - $_known_stream = stream_get_wrappers(); |
|
165 | - if (in_array($type, $_known_stream)) { |
|
166 | - // is known stream |
|
167 | - if (is_object($smarty->security_policy)) { |
|
168 | - $smarty->security_policy->isTrustedStream($type); |
|
169 | - } |
|
170 | - return $smarty->_cache[ 'resource_handlers' ][ $type ] = new Smarty_Internal_Resource_Stream(); |
|
171 | - } |
|
172 | - |
|
173 | - throw new SmartyException("Unknown resource type '{$type}'"); |
|
174 | - } |
|
175 | - |
|
176 | - /** |
|
177 | - * extract resource_type and resource_name from template_resource and config_resource |
|
178 | - * @note "C:/foo.tpl" was forced to file resource up till Smarty 3.1.3 (including). |
|
179 | - * |
|
180 | - * @param string $resource_name template_resource or config_resource to parse |
|
181 | - * @param string $default_resource the default resource_type defined in $smarty |
|
182 | - * |
|
183 | - * @return array with parsed resource name and type |
|
184 | - */ |
|
185 | - public static function parseResourceName($resource_name, $default_resource) |
|
186 | - { |
|
187 | - if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]/', $resource_name, $match)) { |
|
188 | - $type = $match[ 1 ]; |
|
189 | - $name = substr($resource_name, strlen($match[ 0 ])); |
|
190 | - } else { |
|
191 | - // no resource given, use default |
|
192 | - // or single character before the colon is not a resource type, but part of the filepath |
|
193 | - $type = $default_resource; |
|
194 | - $name = $resource_name; |
|
195 | - } |
|
196 | - return array($name, $type); |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * modify template_resource according to resource handlers specifications |
|
201 | - * |
|
202 | - * @param \Smarty_Internal_Template|\Smarty $obj Smarty instance |
|
203 | - * @param string $template_resource template_resource to extract resource handler and name of |
|
204 | - * |
|
205 | - * @return string unique resource name |
|
206 | - */ |
|
207 | - public static function getUniqueTemplateName($obj, $template_resource) |
|
208 | - { |
|
209 | - $smarty = $obj->_objType == 2 ? $obj->smarty : $obj; |
|
210 | - list($name, $type) = self::parseResourceName($template_resource, $smarty->default_resource_type); |
|
211 | - $resource = Smarty_Resource::load($smarty, $type); |
|
212 | - // go relative to a given template? |
|
213 | - $_file_is_dotted = $name[ 0 ] == '.' && ($name[ 1 ] == '.' || $name[ 1 ] == '/'); |
|
214 | - if ($obj->_objType == 2 && $_file_is_dotted && |
|
215 | - ($obj->source->type == 'file' || $obj->parent->source->type == 'extends') |
|
216 | - ) { |
|
217 | - $name = $smarty->_realpath(dirname($obj->parent->source->filepath) . DS . $name); |
|
218 | - } |
|
219 | - return $resource->buildUniqueResourceName($smarty, $name); |
|
220 | - } |
|
221 | - |
|
222 | - /* |
|
23 | + /** |
|
24 | + * Source is bypassing compiler |
|
25 | + * |
|
26 | + * @var boolean |
|
27 | + */ |
|
28 | + public $uncompiled = false; |
|
29 | + |
|
30 | + /** |
|
31 | + * Source must be recompiled on every occasion |
|
32 | + * |
|
33 | + * @var boolean |
|
34 | + */ |
|
35 | + public $recompiled = false; |
|
36 | + |
|
37 | + /** |
|
38 | + * resource types provided by the core |
|
39 | + * |
|
40 | + * @var array |
|
41 | + */ |
|
42 | + public static $sysplugins = array('file' => 'smarty_internal_resource_file.php', |
|
43 | + 'string' => 'smarty_internal_resource_string.php', |
|
44 | + 'extends' => 'smarty_internal_resource_extends.php', |
|
45 | + 'stream' => 'smarty_internal_resource_stream.php', |
|
46 | + 'eval' => 'smarty_internal_resource_eval.php', |
|
47 | + 'php' => 'smarty_internal_resource_php.php'); |
|
48 | + |
|
49 | + /** |
|
50 | + * Flag if resource does implement populateCompiledFilepath() method |
|
51 | + * |
|
52 | + * @var bool |
|
53 | + */ |
|
54 | + public $hasCompiledHandler = false; |
|
55 | + |
|
56 | + /** |
|
57 | + * Load template's source into current template object |
|
58 | + * |
|
59 | + * @param Smarty_Template_Source $source source object |
|
60 | + * |
|
61 | + * @return string template source |
|
62 | + * @throws SmartyException if source cannot be loaded |
|
63 | + */ |
|
64 | + abstract public function getContent(Smarty_Template_Source $source); |
|
65 | + |
|
66 | + /** |
|
67 | + * populate Source Object with meta data from Resource |
|
68 | + * |
|
69 | + * @param Smarty_Template_Source $source source object |
|
70 | + * @param Smarty_Internal_Template $_template template object |
|
71 | + */ |
|
72 | + abstract public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null); |
|
73 | + |
|
74 | + /** |
|
75 | + * populate Source Object with timestamp and exists from Resource |
|
76 | + * |
|
77 | + * @param Smarty_Template_Source $source source object |
|
78 | + */ |
|
79 | + public function populateTimestamp(Smarty_Template_Source $source) |
|
80 | + { |
|
81 | + // intentionally left blank |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * modify resource_name according to resource handlers specifications |
|
86 | + * |
|
87 | + * @param Smarty $smarty Smarty instance |
|
88 | + * @param string $resource_name resource_name to make unique |
|
89 | + * @param boolean $isConfig flag for config resource |
|
90 | + * |
|
91 | + * @return string unique resource name |
|
92 | + */ |
|
93 | + public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false) |
|
94 | + { |
|
95 | + if ($isConfig) { |
|
96 | + if (!isset($smarty->_joined_config_dir)) { |
|
97 | + $smarty->getTemplateDir(null, true); |
|
98 | + } |
|
99 | + return get_class($this) . '#' . $smarty->_joined_config_dir . '#' . $resource_name; |
|
100 | + } else { |
|
101 | + if (!isset($smarty->_joined_template_dir)) { |
|
102 | + $smarty->getTemplateDir(); |
|
103 | + } |
|
104 | + return get_class($this) . '#' . $smarty->_joined_template_dir . '#' . $resource_name; |
|
105 | + } |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Determine basename for compiled filename |
|
110 | + * |
|
111 | + * @param Smarty_Template_Source $source source object |
|
112 | + * |
|
113 | + * @return string resource's basename |
|
114 | + */ |
|
115 | + public function getBasename(Smarty_Template_Source $source) |
|
116 | + { |
|
117 | + return basename(preg_replace('![^\w]+!', '_', $source->name)); |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Load Resource Handler |
|
122 | + * |
|
123 | + * @param Smarty $smarty smarty object |
|
124 | + * @param string $type name of the resource |
|
125 | + * |
|
126 | + * @throws SmartyException |
|
127 | + * @return Smarty_Resource Resource Handler |
|
128 | + */ |
|
129 | + public static function load(Smarty $smarty, $type) |
|
130 | + { |
|
131 | + // try smarty's cache |
|
132 | + if (isset($smarty->_cache[ 'resource_handlers' ][ $type ])) { |
|
133 | + return $smarty->_cache[ 'resource_handlers' ][ $type ]; |
|
134 | + } |
|
135 | + |
|
136 | + // try registered resource |
|
137 | + if (isset($smarty->registered_resources[ $type ])) { |
|
138 | + return $smarty->_cache[ 'resource_handlers' ][ $type ] = |
|
139 | + $smarty->registered_resources[ $type ] instanceof Smarty_Resource ? |
|
140 | + $smarty->registered_resources[ $type ] : new Smarty_Internal_Resource_Registered(); |
|
141 | + } |
|
142 | + |
|
143 | + // try sysplugins dir |
|
144 | + if (isset(self::$sysplugins[ $type ])) { |
|
145 | + $_resource_class = 'Smarty_Internal_Resource_' . ucfirst($type); |
|
146 | + return $smarty->_cache[ 'resource_handlers' ][ $type ] = new $_resource_class(); |
|
147 | + } |
|
148 | + |
|
149 | + // try plugins dir |
|
150 | + $_resource_class = 'Smarty_Resource_' . ucfirst($type); |
|
151 | + if ($smarty->loadPlugin($_resource_class)) { |
|
152 | + if (class_exists($_resource_class, false)) { |
|
153 | + return $smarty->_cache[ 'resource_handlers' ][ $type ] = new $_resource_class(); |
|
154 | + } else { |
|
155 | + $smarty->registerResource($type, |
|
156 | + array("smarty_resource_{$type}_source", "smarty_resource_{$type}_timestamp", |
|
157 | + "smarty_resource_{$type}_secure", "smarty_resource_{$type}_trusted")); |
|
158 | + // give it another try, now that the resource is registered properly |
|
159 | + return self::load($smarty, $type); |
|
160 | + } |
|
161 | + } |
|
162 | + |
|
163 | + // try streams |
|
164 | + $_known_stream = stream_get_wrappers(); |
|
165 | + if (in_array($type, $_known_stream)) { |
|
166 | + // is known stream |
|
167 | + if (is_object($smarty->security_policy)) { |
|
168 | + $smarty->security_policy->isTrustedStream($type); |
|
169 | + } |
|
170 | + return $smarty->_cache[ 'resource_handlers' ][ $type ] = new Smarty_Internal_Resource_Stream(); |
|
171 | + } |
|
172 | + |
|
173 | + throw new SmartyException("Unknown resource type '{$type}'"); |
|
174 | + } |
|
175 | + |
|
176 | + /** |
|
177 | + * extract resource_type and resource_name from template_resource and config_resource |
|
178 | + * @note "C:/foo.tpl" was forced to file resource up till Smarty 3.1.3 (including). |
|
179 | + * |
|
180 | + * @param string $resource_name template_resource or config_resource to parse |
|
181 | + * @param string $default_resource the default resource_type defined in $smarty |
|
182 | + * |
|
183 | + * @return array with parsed resource name and type |
|
184 | + */ |
|
185 | + public static function parseResourceName($resource_name, $default_resource) |
|
186 | + { |
|
187 | + if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]/', $resource_name, $match)) { |
|
188 | + $type = $match[ 1 ]; |
|
189 | + $name = substr($resource_name, strlen($match[ 0 ])); |
|
190 | + } else { |
|
191 | + // no resource given, use default |
|
192 | + // or single character before the colon is not a resource type, but part of the filepath |
|
193 | + $type = $default_resource; |
|
194 | + $name = $resource_name; |
|
195 | + } |
|
196 | + return array($name, $type); |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * modify template_resource according to resource handlers specifications |
|
201 | + * |
|
202 | + * @param \Smarty_Internal_Template|\Smarty $obj Smarty instance |
|
203 | + * @param string $template_resource template_resource to extract resource handler and name of |
|
204 | + * |
|
205 | + * @return string unique resource name |
|
206 | + */ |
|
207 | + public static function getUniqueTemplateName($obj, $template_resource) |
|
208 | + { |
|
209 | + $smarty = $obj->_objType == 2 ? $obj->smarty : $obj; |
|
210 | + list($name, $type) = self::parseResourceName($template_resource, $smarty->default_resource_type); |
|
211 | + $resource = Smarty_Resource::load($smarty, $type); |
|
212 | + // go relative to a given template? |
|
213 | + $_file_is_dotted = $name[ 0 ] == '.' && ($name[ 1 ] == '.' || $name[ 1 ] == '/'); |
|
214 | + if ($obj->_objType == 2 && $_file_is_dotted && |
|
215 | + ($obj->source->type == 'file' || $obj->parent->source->type == 'extends') |
|
216 | + ) { |
|
217 | + $name = $smarty->_realpath(dirname($obj->parent->source->filepath) . DS . $name); |
|
218 | + } |
|
219 | + return $resource->buildUniqueResourceName($smarty, $name); |
|
220 | + } |
|
221 | + |
|
222 | + /* |
|
223 | 223 | * Check if resource must check time stamps when when loading complied or cached templates. |
224 | 224 | * Resources like 'extends' which use source components my disable timestamp checks on own resource. |
225 | 225 | * |
226 | 226 | * @return bool |
227 | 227 | */ |
228 | - public function checkTimestamps() |
|
229 | - { |
|
230 | - return true; |
|
231 | - } |
|
232 | - |
|
233 | - /** |
|
234 | - * initialize Source Object for given resource |
|
235 | - * wrapper for backward compatibility to versions < 3.1.22 |
|
236 | - * Either [$_template] or [$smarty, $template_resource] must be specified |
|
237 | - * |
|
238 | - * @param Smarty_Internal_Template $_template template object |
|
239 | - * @param Smarty $smarty smarty object |
|
240 | - * @param string $template_resource resource identifier |
|
241 | - * |
|
242 | - * @return Smarty_Template_Source Source Object |
|
243 | - */ |
|
244 | - public static function source(Smarty_Internal_Template $_template = null, Smarty $smarty = null, |
|
245 | - $template_resource = null) |
|
246 | - { |
|
247 | - return Smarty_Template_Source::load($_template, $smarty, $template_resource); |
|
248 | - } |
|
228 | + public function checkTimestamps() |
|
229 | + { |
|
230 | + return true; |
|
231 | + } |
|
232 | + |
|
233 | + /** |
|
234 | + * initialize Source Object for given resource |
|
235 | + * wrapper for backward compatibility to versions < 3.1.22 |
|
236 | + * Either [$_template] or [$smarty, $template_resource] must be specified |
|
237 | + * |
|
238 | + * @param Smarty_Internal_Template $_template template object |
|
239 | + * @param Smarty $smarty smarty object |
|
240 | + * @param string $template_resource resource identifier |
|
241 | + * |
|
242 | + * @return Smarty_Template_Source Source Object |
|
243 | + */ |
|
244 | + public static function source(Smarty_Internal_Template $_template = null, Smarty $smarty = null, |
|
245 | + $template_resource = null) |
|
246 | + { |
|
247 | + return Smarty_Template_Source::load($_template, $smarty, $template_resource); |
|
248 | + } |
|
249 | 249 | } |
250 | 250 |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * Check if PHP function is trusted. |
259 | 259 | * |
260 | 260 | * @param string $function_name |
261 | - * @param object $compiler compiler object |
|
261 | + * @param Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
262 | 262 | * |
263 | 263 | * @return boolean true if function is trusted |
264 | 264 | * @throws SmartyCompilerException if php function is not trusted |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @param string $class_name |
305 | 305 | * @param string $params |
306 | - * @param object $compiler compiler object |
|
306 | + * @param Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
307 | 307 | * |
308 | 308 | * @return boolean true if class method is trusted |
309 | 309 | * @throws SmartyCompilerException if static class method is not trusted |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | * Check if PHP modifier is trusted. |
342 | 342 | * |
343 | 343 | * @param string $modifier_name |
344 | - * @param object $compiler compiler object |
|
344 | + * @param Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
345 | 345 | * |
346 | 346 | * @return boolean true if modifier is trusted |
347 | 347 | * @throws SmartyCompilerException if modifier is not trusted |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * Check if tag is trusted. |
364 | 364 | * |
365 | 365 | * @param string $tag_name |
366 | - * @param object $compiler compiler object |
|
366 | + * @param Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
367 | 367 | * |
368 | 368 | * @return boolean true if tag is trusted |
369 | 369 | * @throws SmartyCompilerException if modifier is not trusted |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | * Check if special $smarty variable is trusted. |
399 | 399 | * |
400 | 400 | * @param string $var_name |
401 | - * @param object $compiler compiler object |
|
401 | + * @param Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
402 | 402 | * |
403 | 403 | * @return boolean true if tag is trusted |
404 | 404 | * @throws SmartyCompilerException if modifier is not trusted |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | * Check if modifier plugin is trusted. |
420 | 420 | * |
421 | 421 | * @param string $modifier_name |
422 | - * @param object $compiler compiler object |
|
422 | + * @param Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
423 | 423 | * |
424 | 424 | * @return boolean true if tag is trusted |
425 | 425 | * @throws SmartyCompilerException if modifier is not trusted |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * Check if constants are enabled or trusted |
455 | 455 | * |
456 | 456 | * @param string $const constant name |
457 | - * @param object $compiler compiler object |
|
457 | + * @param Smarty_Internal_TemplateCompilerBase $compiler compiler object |
|
458 | 458 | * |
459 | 459 | * @return bool |
460 | 460 | */ |
@@ -250,8 +250,8 @@ discard block |
||
250 | 250 | public function __construct($smarty) |
251 | 251 | { |
252 | 252 | $this->smarty = $smarty; |
253 | - $this->smarty->_cache[ 'template_dir_new' ] = true; |
|
254 | - $this->smarty->_cache[ 'config_dir_new' ] = true; |
|
253 | + $this->smarty->_cache['template_dir_new'] = true; |
|
254 | + $this->smarty->_cache['config_dir_new'] = true; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -310,25 +310,25 @@ discard block |
||
310 | 310 | */ |
311 | 311 | public function isTrustedStaticClassAccess($class_name, $params, $compiler) |
312 | 312 | { |
313 | - if (!isset($params[ 2 ])) { |
|
313 | + if (!isset($params[2])) { |
|
314 | 314 | // fall back |
315 | 315 | return $this->isTrustedStaticClass($class_name, $compiler); |
316 | 316 | } |
317 | - if ($params[ 2 ] == 'method') { |
|
317 | + if ($params[2] == 'method') { |
|
318 | 318 | $allowed = $this->trusted_static_methods; |
319 | - $name = substr($params[ 0 ], 0, strpos($params[ 0 ], '(')); |
|
319 | + $name = substr($params[0], 0, strpos($params[0], '(')); |
|
320 | 320 | } else { |
321 | 321 | $allowed = $this->trusted_static_properties; |
322 | 322 | // strip '$' |
323 | - $name = substr($params[ 0 ], 1); |
|
323 | + $name = substr($params[0], 1); |
|
324 | 324 | } |
325 | 325 | if (isset($allowed)) { |
326 | 326 | if (empty($allowed)) { |
327 | 327 | // fall back |
328 | 328 | return $this->isTrustedStaticClass($class_name, $compiler); |
329 | 329 | } |
330 | - if (isset($allowed[ $class_name ]) && |
|
331 | - (empty($allowed[ $class_name ]) || in_array($name, $allowed[ $class_name ])) |
|
330 | + if (isset($allowed[$class_name]) && |
|
331 | + (empty($allowed[$class_name]) || in_array($name, $allowed[$class_name])) |
|
332 | 332 | ) { |
333 | 333 | return true; |
334 | 334 | } |
@@ -507,55 +507,55 @@ discard block |
||
507 | 507 | { |
508 | 508 | if ($this->_include_path_status !== $this->smarty->use_include_path) { |
509 | 509 | foreach ($this->_include_dir as $directory) { |
510 | - unset($this->_resource_dir[ $directory ]); |
|
510 | + unset($this->_resource_dir[$directory]); |
|
511 | 511 | } |
512 | 512 | if ($this->smarty->use_include_path) { |
513 | 513 | $this->_include_dir = array(); |
514 | 514 | $_dirs = $this->smarty->ext->_getIncludePath->getIncludePathDirs($this->smarty); |
515 | 515 | foreach ($_dirs as $directory) { |
516 | 516 | $this->_include_dir[] = $directory; |
517 | - $this->_resource_dir[ $directory ] = true; |
|
517 | + $this->_resource_dir[$directory] = true; |
|
518 | 518 | } |
519 | 519 | } |
520 | 520 | $this->_include_path_status = $this->smarty->use_include_path; |
521 | 521 | } |
522 | 522 | if ($isConfig !== true && |
523 | - (!isset($this->smarty->_cache[ 'template_dir_new' ]) || $this->smarty->_cache[ 'template_dir_new' ]) |
|
523 | + (!isset($this->smarty->_cache['template_dir_new']) || $this->smarty->_cache['template_dir_new']) |
|
524 | 524 | ) { |
525 | 525 | $_dir = $this->smarty->getTemplateDir(); |
526 | 526 | if ($this->_template_dir !== $_dir) { |
527 | 527 | foreach ($this->_template_dir as $directory) { |
528 | - unset($this->_resource_dir[ $directory ]); |
|
528 | + unset($this->_resource_dir[$directory]); |
|
529 | 529 | } |
530 | 530 | foreach ($_dir as $directory) { |
531 | - $this->_resource_dir[ $directory ] = true; |
|
531 | + $this->_resource_dir[$directory] = true; |
|
532 | 532 | } |
533 | 533 | $this->_template_dir = $_dir; |
534 | 534 | } |
535 | - $this->smarty->_cache[ 'template_dir_new' ] = false; |
|
535 | + $this->smarty->_cache['template_dir_new'] = false; |
|
536 | 536 | } |
537 | 537 | if ($isConfig !== false && |
538 | - (!isset($this->smarty->_cache[ 'config_dir_new' ]) || $this->smarty->_cache[ 'config_dir_new' ]) |
|
538 | + (!isset($this->smarty->_cache['config_dir_new']) || $this->smarty->_cache['config_dir_new']) |
|
539 | 539 | ) { |
540 | 540 | $_dir = $this->smarty->getConfigDir(); |
541 | 541 | if ($this->_config_dir !== $_dir) { |
542 | 542 | foreach ($this->_config_dir as $directory) { |
543 | - unset($this->_resource_dir[ $directory ]); |
|
543 | + unset($this->_resource_dir[$directory]); |
|
544 | 544 | } |
545 | 545 | foreach ($_dir as $directory) { |
546 | - $this->_resource_dir[ $directory ] = true; |
|
546 | + $this->_resource_dir[$directory] = true; |
|
547 | 547 | } |
548 | 548 | $this->_config_dir = $_dir; |
549 | 549 | } |
550 | - $this->smarty->_cache[ 'config_dir_new' ] = false; |
|
550 | + $this->smarty->_cache['config_dir_new'] = false; |
|
551 | 551 | } |
552 | 552 | if ($this->_secure_dir !== (array) $this->secure_dir) { |
553 | 553 | foreach ($this->_secure_dir as $directory) { |
554 | - unset($this->_resource_dir[ $directory ]); |
|
554 | + unset($this->_resource_dir[$directory]); |
|
555 | 555 | } |
556 | 556 | foreach ((array) $this->secure_dir as $directory) { |
557 | 557 | $directory = $this->smarty->_realpath($directory . DS, true); |
558 | - $this->_resource_dir[ $directory ] = true; |
|
558 | + $this->_resource_dir[$directory] = true; |
|
559 | 559 | } |
560 | 560 | $this->_secure_dir = (array) $this->secure_dir; |
561 | 561 | } |
@@ -578,8 +578,8 @@ discard block |
||
578 | 578 | public function isTrustedUri($uri) |
579 | 579 | { |
580 | 580 | $_uri = parse_url($uri); |
581 | - if (!empty($_uri[ 'scheme' ]) && !empty($_uri[ 'host' ])) { |
|
582 | - $_uri = $_uri[ 'scheme' ] . '://' . $_uri[ 'host' ]; |
|
581 | + if (!empty($_uri['scheme']) && !empty($_uri['host'])) { |
|
582 | + $_uri = $_uri['scheme'] . '://' . $_uri['host']; |
|
583 | 583 | foreach ($this->trusted_uri as $pattern) { |
584 | 584 | if (preg_match($pattern, $_uri)) { |
585 | 585 | return true; |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | $this->_trusted_dir = $this->trusted_dir; |
612 | 612 | foreach ((array) $this->trusted_dir as $directory) { |
613 | 613 | $directory = $this->smarty->_realpath($directory . DS, true); |
614 | - $this->_php_resource_dir[ $directory ] = true; |
|
614 | + $this->_php_resource_dir[$directory] = true; |
|
615 | 615 | } |
616 | 616 | } |
617 | 617 | |
@@ -635,9 +635,9 @@ discard block |
||
635 | 635 | $_directory = array(); |
636 | 636 | while (true) { |
637 | 637 | // remember the directory to add it to _resource_dir in case we're successful |
638 | - $_directory[ $directory ] = true; |
|
638 | + $_directory[$directory] = true; |
|
639 | 639 | // test if the directory is trusted |
640 | - if (isset($dirs[ $directory ])) { |
|
640 | + if (isset($dirs[$directory])) { |
|
641 | 641 | // merge sub directories of current $directory into _resource_dir to speed up subsequent lookup |
642 | 642 | $dirs = array_merge($dirs, $_directory); |
643 | 643 | |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | */ |
694 | 694 | public function startTemplate($template) |
695 | 695 | { |
696 | - if ($this->max_template_nesting > 0 && $this->_current_template_nesting ++ >= $this->max_template_nesting) { |
|
696 | + if ($this->max_template_nesting > 0 && $this->_current_template_nesting++ >= $this->max_template_nesting) { |
|
697 | 697 | throw new SmartyException("maximum template nesting level of '{$this->max_template_nesting}' exceeded when calling '{$template->template_resource}'"); |
698 | 698 | } |
699 | 699 | } |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | public function endTemplate() |
706 | 706 | { |
707 | 707 | if ($this->max_template_nesting > 0) { |
708 | - $this->_current_template_nesting --; |
|
708 | + $this->_current_template_nesting--; |
|
709 | 709 | } |
710 | 710 | } |
711 | 711 |
@@ -13,710 +13,710 @@ |
||
13 | 13 | */ |
14 | 14 | class Smarty_Security |
15 | 15 | { |
16 | - /** |
|
17 | - * This determines how Smarty handles "<?php ... ?>" tags in templates. |
|
18 | - * possible values: |
|
19 | - * <ul> |
|
20 | - * <li>Smarty::PHP_PASSTHRU -> echo PHP tags as they are</li> |
|
21 | - * <li>Smarty::PHP_QUOTE -> escape tags as entities</li> |
|
22 | - * <li>Smarty::PHP_REMOVE -> remove php tags</li> |
|
23 | - * <li>Smarty::PHP_ALLOW -> execute php tags</li> |
|
24 | - * </ul> |
|
25 | - * |
|
26 | - * @var integer |
|
27 | - */ |
|
28 | - public $php_handling = Smarty::PHP_PASSTHRU; |
|
29 | - |
|
30 | - /** |
|
31 | - * This is the list of template directories that are considered secure. |
|
32 | - * $template_dir is in this list implicitly. |
|
33 | - * |
|
34 | - * @var array |
|
35 | - */ |
|
36 | - public $secure_dir = array(); |
|
37 | - |
|
38 | - /** |
|
39 | - * This is an array of directories where trusted php scripts reside. |
|
40 | - * {@link $security} is disabled during their inclusion/execution. |
|
41 | - * |
|
42 | - * @var array |
|
43 | - */ |
|
44 | - public $trusted_dir = array(); |
|
45 | - |
|
46 | - /** |
|
47 | - * List of regular expressions (PCRE) that include trusted URIs |
|
48 | - * |
|
49 | - * @var array |
|
50 | - */ |
|
51 | - public $trusted_uri = array(); |
|
52 | - |
|
53 | - /** |
|
54 | - * List of trusted constants names |
|
55 | - * |
|
56 | - * @var array |
|
57 | - */ |
|
58 | - public $trusted_constants = array(); |
|
59 | - |
|
60 | - /** |
|
61 | - * This is an array of trusted static classes. |
|
62 | - * If empty access to all static classes is allowed. |
|
63 | - * If set to 'none' none is allowed. |
|
64 | - * |
|
65 | - * @var array |
|
66 | - */ |
|
67 | - public $static_classes = array(); |
|
68 | - |
|
69 | - /** |
|
70 | - * This is an nested array of trusted classes and static methods. |
|
71 | - * If empty access to all static classes and methods is allowed. |
|
72 | - * Format: |
|
73 | - * array ( |
|
74 | - * 'class_1' => array('method_1', 'method_2'), // allowed methods listed |
|
75 | - * 'class_2' => array(), // all methods of class allowed |
|
76 | - * ) |
|
77 | - * If set to null none is allowed. |
|
78 | - * |
|
79 | - * @var array |
|
80 | - */ |
|
81 | - public $trusted_static_methods = array(); |
|
82 | - |
|
83 | - /** |
|
84 | - * This is an array of trusted static properties. |
|
85 | - * If empty access to all static classes and properties is allowed. |
|
86 | - * Format: |
|
87 | - * array ( |
|
88 | - * 'class_1' => array('prop_1', 'prop_2'), // allowed properties listed |
|
89 | - * 'class_2' => array(), // all properties of class allowed |
|
90 | - * ) |
|
91 | - * If set to null none is allowed. |
|
92 | - * |
|
93 | - * @var array |
|
94 | - */ |
|
95 | - public $trusted_static_properties = array(); |
|
96 | - |
|
97 | - /** |
|
98 | - * This is an array of trusted PHP functions. |
|
99 | - * If empty all functions are allowed. |
|
100 | - * To disable all PHP functions set $php_functions = null. |
|
101 | - * |
|
102 | - * @var array |
|
103 | - */ |
|
104 | - public $php_functions = array('isset', 'empty', 'count', 'sizeof', 'in_array', 'is_array', 'time',); |
|
105 | - |
|
106 | - /** |
|
107 | - * This is an array of trusted PHP modifiers. |
|
108 | - * If empty all modifiers are allowed. |
|
109 | - * To disable all modifier set $php_modifiers = null. |
|
110 | - * |
|
111 | - * @var array |
|
112 | - */ |
|
113 | - public $php_modifiers = array('escape', 'count', 'nl2br',); |
|
114 | - |
|
115 | - /** |
|
116 | - * This is an array of allowed tags. |
|
117 | - * If empty no restriction by allowed_tags. |
|
118 | - * |
|
119 | - * @var array |
|
120 | - */ |
|
121 | - public $allowed_tags = array(); |
|
122 | - |
|
123 | - /** |
|
124 | - * This is an array of disabled tags. |
|
125 | - * If empty no restriction by disabled_tags. |
|
126 | - * |
|
127 | - * @var array |
|
128 | - */ |
|
129 | - public $disabled_tags = array(); |
|
130 | - |
|
131 | - /** |
|
132 | - * This is an array of allowed modifier plugins. |
|
133 | - * If empty no restriction by allowed_modifiers. |
|
134 | - * |
|
135 | - * @var array |
|
136 | - */ |
|
137 | - public $allowed_modifiers = array(); |
|
138 | - |
|
139 | - /** |
|
140 | - * This is an array of disabled modifier plugins. |
|
141 | - * If empty no restriction by disabled_modifiers. |
|
142 | - * |
|
143 | - * @var array |
|
144 | - */ |
|
145 | - public $disabled_modifiers = array(); |
|
146 | - |
|
147 | - /** |
|
148 | - * This is an array of disabled special $smarty variables. |
|
149 | - * |
|
150 | - * @var array |
|
151 | - */ |
|
152 | - public $disabled_special_smarty_vars = array(); |
|
153 | - |
|
154 | - /** |
|
155 | - * This is an array of trusted streams. |
|
156 | - * If empty all streams are allowed. |
|
157 | - * To disable all streams set $streams = null. |
|
158 | - * |
|
159 | - * @var array |
|
160 | - */ |
|
161 | - public $streams = array('file'); |
|
162 | - |
|
163 | - /** |
|
164 | - * + flag if constants can be accessed from template |
|
165 | - * |
|
166 | - * @var boolean |
|
167 | - */ |
|
168 | - public $allow_constants = true; |
|
169 | - |
|
170 | - /** |
|
171 | - * + flag if super globals can be accessed from template |
|
172 | - * |
|
173 | - * @var boolean |
|
174 | - */ |
|
175 | - public $allow_super_globals = true; |
|
176 | - |
|
177 | - /** |
|
178 | - * max template nesting level |
|
179 | - * |
|
180 | - * @var int |
|
181 | - */ |
|
182 | - public $max_template_nesting = 0; |
|
183 | - |
|
184 | - /** |
|
185 | - * current template nesting level |
|
186 | - * |
|
187 | - * @var int |
|
188 | - */ |
|
189 | - private $_current_template_nesting = 0; |
|
190 | - |
|
191 | - /** |
|
192 | - * Cache for $resource_dir lookup |
|
193 | - * |
|
194 | - * @var array |
|
195 | - */ |
|
196 | - protected $_resource_dir = array(); |
|
197 | - |
|
198 | - /** |
|
199 | - * Cache for $template_dir lookup |
|
200 | - * |
|
201 | - * @var array |
|
202 | - */ |
|
203 | - protected $_template_dir = array(); |
|
204 | - |
|
205 | - /** |
|
206 | - * Cache for $config_dir lookup |
|
207 | - * |
|
208 | - * @var array |
|
209 | - */ |
|
210 | - protected $_config_dir = array(); |
|
211 | - |
|
212 | - /** |
|
213 | - * Cache for $secure_dir lookup |
|
214 | - * |
|
215 | - * @var array |
|
216 | - */ |
|
217 | - protected $_secure_dir = array(); |
|
218 | - |
|
219 | - /** |
|
220 | - * Cache for $php_resource_dir lookup |
|
221 | - * |
|
222 | - * @var array |
|
223 | - */ |
|
224 | - protected $_php_resource_dir = null; |
|
225 | - |
|
226 | - /** |
|
227 | - * Cache for $trusted_dir lookup |
|
228 | - * |
|
229 | - * @var array |
|
230 | - */ |
|
231 | - protected $_trusted_dir = null; |
|
232 | - |
|
233 | - /** |
|
234 | - * Cache for include path status |
|
235 | - * |
|
236 | - * @var bool |
|
237 | - */ |
|
238 | - protected $_include_path_status = false; |
|
239 | - |
|
240 | - /** |
|
241 | - * Cache for $_include_array lookup |
|
242 | - * |
|
243 | - * @var array |
|
244 | - */ |
|
245 | - protected $_include_dir = array(); |
|
246 | - |
|
247 | - /** |
|
248 | - * @param Smarty $smarty |
|
249 | - */ |
|
250 | - public function __construct($smarty) |
|
251 | - { |
|
252 | - $this->smarty = $smarty; |
|
253 | - $this->smarty->_cache[ 'template_dir_new' ] = true; |
|
254 | - $this->smarty->_cache[ 'config_dir_new' ] = true; |
|
255 | - } |
|
256 | - |
|
257 | - /** |
|
258 | - * Check if PHP function is trusted. |
|
259 | - * |
|
260 | - * @param string $function_name |
|
261 | - * @param object $compiler compiler object |
|
262 | - * |
|
263 | - * @return boolean true if function is trusted |
|
264 | - * @throws SmartyCompilerException if php function is not trusted |
|
265 | - */ |
|
266 | - public function isTrustedPhpFunction($function_name, $compiler) |
|
267 | - { |
|
268 | - if (isset($this->php_functions) && |
|
269 | - (empty($this->php_functions) || in_array($function_name, $this->php_functions)) |
|
270 | - ) { |
|
271 | - return true; |
|
272 | - } |
|
273 | - |
|
274 | - $compiler->trigger_template_error("PHP function '{$function_name}' not allowed by security setting"); |
|
275 | - |
|
276 | - return false; // should not, but who knows what happens to the compiler in the future? |
|
277 | - } |
|
278 | - |
|
279 | - /** |
|
280 | - * Check if static class is trusted. |
|
281 | - * |
|
282 | - * @param string $class_name |
|
283 | - * @param object $compiler compiler object |
|
284 | - * |
|
285 | - * @return boolean true if class is trusted |
|
286 | - * @throws SmartyCompilerException if static class is not trusted |
|
287 | - */ |
|
288 | - public function isTrustedStaticClass($class_name, $compiler) |
|
289 | - { |
|
290 | - if (isset($this->static_classes) && |
|
291 | - (empty($this->static_classes) || in_array($class_name, $this->static_classes)) |
|
292 | - ) { |
|
293 | - return true; |
|
294 | - } |
|
295 | - |
|
296 | - $compiler->trigger_template_error("access to static class '{$class_name}' not allowed by security setting"); |
|
297 | - |
|
298 | - return false; // should not, but who knows what happens to the compiler in the future? |
|
299 | - } |
|
300 | - |
|
301 | - /** |
|
302 | - * Check if static class method/property is trusted. |
|
303 | - * |
|
304 | - * @param string $class_name |
|
305 | - * @param string $params |
|
306 | - * @param object $compiler compiler object |
|
307 | - * |
|
308 | - * @return boolean true if class method is trusted |
|
309 | - * @throws SmartyCompilerException if static class method is not trusted |
|
310 | - */ |
|
311 | - public function isTrustedStaticClassAccess($class_name, $params, $compiler) |
|
312 | - { |
|
313 | - if (!isset($params[ 2 ])) { |
|
314 | - // fall back |
|
315 | - return $this->isTrustedStaticClass($class_name, $compiler); |
|
316 | - } |
|
317 | - if ($params[ 2 ] == 'method') { |
|
318 | - $allowed = $this->trusted_static_methods; |
|
319 | - $name = substr($params[ 0 ], 0, strpos($params[ 0 ], '(')); |
|
320 | - } else { |
|
321 | - $allowed = $this->trusted_static_properties; |
|
322 | - // strip '$' |
|
323 | - $name = substr($params[ 0 ], 1); |
|
324 | - } |
|
325 | - if (isset($allowed)) { |
|
326 | - if (empty($allowed)) { |
|
327 | - // fall back |
|
328 | - return $this->isTrustedStaticClass($class_name, $compiler); |
|
329 | - } |
|
330 | - if (isset($allowed[ $class_name ]) && |
|
331 | - (empty($allowed[ $class_name ]) || in_array($name, $allowed[ $class_name ])) |
|
332 | - ) { |
|
333 | - return true; |
|
334 | - } |
|
335 | - } |
|
336 | - $compiler->trigger_template_error("access to static class '{$class_name}' {$params[2]} '{$name}' not allowed by security setting"); |
|
337 | - return false; // should not, but who knows what happens to the compiler in the future? |
|
338 | - } |
|
339 | - |
|
340 | - /** |
|
341 | - * Check if PHP modifier is trusted. |
|
342 | - * |
|
343 | - * @param string $modifier_name |
|
344 | - * @param object $compiler compiler object |
|
345 | - * |
|
346 | - * @return boolean true if modifier is trusted |
|
347 | - * @throws SmartyCompilerException if modifier is not trusted |
|
348 | - */ |
|
349 | - public function isTrustedPhpModifier($modifier_name, $compiler) |
|
350 | - { |
|
351 | - if (isset($this->php_modifiers) && |
|
352 | - (empty($this->php_modifiers) || in_array($modifier_name, $this->php_modifiers)) |
|
353 | - ) { |
|
354 | - return true; |
|
355 | - } |
|
356 | - |
|
357 | - $compiler->trigger_template_error("modifier '{$modifier_name}' not allowed by security setting"); |
|
358 | - |
|
359 | - return false; // should not, but who knows what happens to the compiler in the future? |
|
360 | - } |
|
361 | - |
|
362 | - /** |
|
363 | - * Check if tag is trusted. |
|
364 | - * |
|
365 | - * @param string $tag_name |
|
366 | - * @param object $compiler compiler object |
|
367 | - * |
|
368 | - * @return boolean true if tag is trusted |
|
369 | - * @throws SmartyCompilerException if modifier is not trusted |
|
370 | - */ |
|
371 | - public function isTrustedTag($tag_name, $compiler) |
|
372 | - { |
|
373 | - // check for internal always required tags |
|
374 | - if (in_array($tag_name, |
|
375 | - array('assign', 'call', 'private_filter', 'private_block_plugin', 'private_function_plugin', |
|
376 | - 'private_object_block_function', 'private_object_function', 'private_registered_function', |
|
377 | - 'private_registered_block', 'private_special_variable', 'private_print_expression', |
|
378 | - 'private_modifier'))) { |
|
379 | - return true; |
|
380 | - } |
|
381 | - // check security settings |
|
382 | - if (empty($this->allowed_tags)) { |
|
383 | - if (empty($this->disabled_tags) || !in_array($tag_name, $this->disabled_tags)) { |
|
384 | - return true; |
|
385 | - } else { |
|
386 | - $compiler->trigger_template_error("tag '{$tag_name}' disabled by security setting", null, true); |
|
387 | - } |
|
388 | - } elseif (in_array($tag_name, $this->allowed_tags) && !in_array($tag_name, $this->disabled_tags)) { |
|
389 | - return true; |
|
390 | - } else { |
|
391 | - $compiler->trigger_template_error("tag '{$tag_name}' not allowed by security setting", null, true); |
|
392 | - } |
|
393 | - |
|
394 | - return false; // should not, but who knows what happens to the compiler in the future? |
|
395 | - } |
|
396 | - |
|
397 | - /** |
|
398 | - * Check if special $smarty variable is trusted. |
|
399 | - * |
|
400 | - * @param string $var_name |
|
401 | - * @param object $compiler compiler object |
|
402 | - * |
|
403 | - * @return boolean true if tag is trusted |
|
404 | - * @throws SmartyCompilerException if modifier is not trusted |
|
405 | - */ |
|
406 | - public function isTrustedSpecialSmartyVar($var_name, $compiler) |
|
407 | - { |
|
408 | - if (!in_array($var_name, $this->disabled_special_smarty_vars)) { |
|
409 | - return true; |
|
410 | - } else { |
|
411 | - $compiler->trigger_template_error("special variable '\$smarty.{$var_name}' not allowed by security setting", |
|
412 | - null, true); |
|
413 | - } |
|
414 | - |
|
415 | - return false; // should not, but who knows what happens to the compiler in the future? |
|
416 | - } |
|
417 | - |
|
418 | - /** |
|
419 | - * Check if modifier plugin is trusted. |
|
420 | - * |
|
421 | - * @param string $modifier_name |
|
422 | - * @param object $compiler compiler object |
|
423 | - * |
|
424 | - * @return boolean true if tag is trusted |
|
425 | - * @throws SmartyCompilerException if modifier is not trusted |
|
426 | - */ |
|
427 | - public function isTrustedModifier($modifier_name, $compiler) |
|
428 | - { |
|
429 | - // check for internal always allowed modifier |
|
430 | - if (in_array($modifier_name, array('default'))) { |
|
431 | - return true; |
|
432 | - } |
|
433 | - // check security settings |
|
434 | - if (empty($this->allowed_modifiers)) { |
|
435 | - if (empty($this->disabled_modifiers) || !in_array($modifier_name, $this->disabled_modifiers)) { |
|
436 | - return true; |
|
437 | - } else { |
|
438 | - $compiler->trigger_template_error("modifier '{$modifier_name}' disabled by security setting", null, |
|
439 | - true); |
|
440 | - } |
|
441 | - } elseif (in_array($modifier_name, $this->allowed_modifiers) && |
|
442 | - !in_array($modifier_name, $this->disabled_modifiers) |
|
443 | - ) { |
|
444 | - return true; |
|
445 | - } else { |
|
446 | - $compiler->trigger_template_error("modifier '{$modifier_name}' not allowed by security setting", null, |
|
447 | - true); |
|
448 | - } |
|
449 | - |
|
450 | - return false; // should not, but who knows what happens to the compiler in the future? |
|
451 | - } |
|
452 | - |
|
453 | - /** |
|
454 | - * Check if constants are enabled or trusted |
|
455 | - * |
|
456 | - * @param string $const constant name |
|
457 | - * @param object $compiler compiler object |
|
458 | - * |
|
459 | - * @return bool |
|
460 | - */ |
|
461 | - public function isTrustedConstant($const, $compiler) |
|
462 | - { |
|
463 | - if (in_array($const, array('true', 'false', 'null'))) { |
|
464 | - return true; |
|
465 | - } |
|
466 | - if (!empty($this->trusted_constants)) { |
|
467 | - if (!in_array($const, $this->trusted_constants)) { |
|
468 | - $compiler->trigger_template_error("Security: access to constant '{$const}' not permitted"); |
|
469 | - return false; |
|
470 | - } |
|
471 | - return true; |
|
472 | - } |
|
473 | - if ($this->allow_constants) { |
|
474 | - return true; |
|
475 | - } |
|
476 | - $compiler->trigger_template_error("Security: access to constants not permitted"); |
|
477 | - return false; |
|
478 | - } |
|
479 | - |
|
480 | - /** |
|
481 | - * Check if stream is trusted. |
|
482 | - * |
|
483 | - * @param string $stream_name |
|
484 | - * |
|
485 | - * @return boolean true if stream is trusted |
|
486 | - * @throws SmartyException if stream is not trusted |
|
487 | - */ |
|
488 | - public function isTrustedStream($stream_name) |
|
489 | - { |
|
490 | - if (isset($this->streams) && (empty($this->streams) || in_array($stream_name, $this->streams))) { |
|
491 | - return true; |
|
492 | - } |
|
493 | - |
|
494 | - throw new SmartyException("stream '{$stream_name}' not allowed by security setting"); |
|
495 | - } |
|
496 | - |
|
497 | - /** |
|
498 | - * Check if directory of file resource is trusted. |
|
499 | - * |
|
500 | - * @param string $filepath |
|
501 | - * @param null|bool $isConfig |
|
502 | - * |
|
503 | - * @return bool true if directory is trusted |
|
504 | - * @throws \SmartyException if directory is not trusted |
|
505 | - */ |
|
506 | - public function isTrustedResourceDir($filepath, $isConfig = null) |
|
507 | - { |
|
508 | - if ($this->_include_path_status !== $this->smarty->use_include_path) { |
|
509 | - foreach ($this->_include_dir as $directory) { |
|
510 | - unset($this->_resource_dir[ $directory ]); |
|
511 | - } |
|
512 | - if ($this->smarty->use_include_path) { |
|
513 | - $this->_include_dir = array(); |
|
514 | - $_dirs = $this->smarty->ext->_getIncludePath->getIncludePathDirs($this->smarty); |
|
515 | - foreach ($_dirs as $directory) { |
|
516 | - $this->_include_dir[] = $directory; |
|
517 | - $this->_resource_dir[ $directory ] = true; |
|
518 | - } |
|
519 | - } |
|
520 | - $this->_include_path_status = $this->smarty->use_include_path; |
|
521 | - } |
|
522 | - if ($isConfig !== true && |
|
523 | - (!isset($this->smarty->_cache[ 'template_dir_new' ]) || $this->smarty->_cache[ 'template_dir_new' ]) |
|
524 | - ) { |
|
525 | - $_dir = $this->smarty->getTemplateDir(); |
|
526 | - if ($this->_template_dir !== $_dir) { |
|
527 | - foreach ($this->_template_dir as $directory) { |
|
528 | - unset($this->_resource_dir[ $directory ]); |
|
529 | - } |
|
530 | - foreach ($_dir as $directory) { |
|
531 | - $this->_resource_dir[ $directory ] = true; |
|
532 | - } |
|
533 | - $this->_template_dir = $_dir; |
|
534 | - } |
|
535 | - $this->smarty->_cache[ 'template_dir_new' ] = false; |
|
536 | - } |
|
537 | - if ($isConfig !== false && |
|
538 | - (!isset($this->smarty->_cache[ 'config_dir_new' ]) || $this->smarty->_cache[ 'config_dir_new' ]) |
|
539 | - ) { |
|
540 | - $_dir = $this->smarty->getConfigDir(); |
|
541 | - if ($this->_config_dir !== $_dir) { |
|
542 | - foreach ($this->_config_dir as $directory) { |
|
543 | - unset($this->_resource_dir[ $directory ]); |
|
544 | - } |
|
545 | - foreach ($_dir as $directory) { |
|
546 | - $this->_resource_dir[ $directory ] = true; |
|
547 | - } |
|
548 | - $this->_config_dir = $_dir; |
|
549 | - } |
|
550 | - $this->smarty->_cache[ 'config_dir_new' ] = false; |
|
551 | - } |
|
552 | - if ($this->_secure_dir !== (array) $this->secure_dir) { |
|
553 | - foreach ($this->_secure_dir as $directory) { |
|
554 | - unset($this->_resource_dir[ $directory ]); |
|
555 | - } |
|
556 | - foreach ((array) $this->secure_dir as $directory) { |
|
557 | - $directory = $this->smarty->_realpath($directory . DS, true); |
|
558 | - $this->_resource_dir[ $directory ] = true; |
|
559 | - } |
|
560 | - $this->_secure_dir = (array) $this->secure_dir; |
|
561 | - } |
|
562 | - $this->_resource_dir = $this->_checkDir($filepath, $this->_resource_dir); |
|
563 | - return true; |
|
564 | - } |
|
565 | - |
|
566 | - /** |
|
567 | - * Check if URI (e.g. {fetch} or {html_image}) is trusted |
|
568 | - * To simplify things, isTrustedUri() resolves all input to "{$PROTOCOL}://{$HOSTNAME}". |
|
569 | - * So "http://username:[email protected]:8080/some-path?some=query-string" |
|
570 | - * is reduced to "http://hello.world.example.org" prior to applying the patters from {@link $trusted_uri}. |
|
571 | - * |
|
572 | - * @param string $uri |
|
573 | - * |
|
574 | - * @return boolean true if URI is trusted |
|
575 | - * @throws SmartyException if URI is not trusted |
|
576 | - * @uses $trusted_uri for list of patterns to match against $uri |
|
577 | - */ |
|
578 | - public function isTrustedUri($uri) |
|
579 | - { |
|
580 | - $_uri = parse_url($uri); |
|
581 | - if (!empty($_uri[ 'scheme' ]) && !empty($_uri[ 'host' ])) { |
|
582 | - $_uri = $_uri[ 'scheme' ] . '://' . $_uri[ 'host' ]; |
|
583 | - foreach ($this->trusted_uri as $pattern) { |
|
584 | - if (preg_match($pattern, $_uri)) { |
|
585 | - return true; |
|
586 | - } |
|
587 | - } |
|
588 | - } |
|
589 | - |
|
590 | - throw new SmartyException("URI '{$uri}' not allowed by security setting"); |
|
591 | - } |
|
592 | - |
|
593 | - /** |
|
594 | - * Check if directory of file resource is trusted. |
|
595 | - * |
|
596 | - * @param string $filepath |
|
597 | - * |
|
598 | - * @return boolean true if directory is trusted |
|
599 | - * @throws SmartyException if PHP directory is not trusted |
|
600 | - */ |
|
601 | - public function isTrustedPHPDir($filepath) |
|
602 | - { |
|
603 | - if (empty($this->trusted_dir)) { |
|
604 | - throw new SmartyException("directory '{$filepath}' not allowed by security setting (no trusted_dir specified)"); |
|
605 | - } |
|
606 | - |
|
607 | - // check if index is outdated |
|
608 | - if (!$this->_trusted_dir || $this->_trusted_dir !== $this->trusted_dir) { |
|
609 | - $this->_php_resource_dir = array(); |
|
610 | - |
|
611 | - $this->_trusted_dir = $this->trusted_dir; |
|
612 | - foreach ((array) $this->trusted_dir as $directory) { |
|
613 | - $directory = $this->smarty->_realpath($directory . DS, true); |
|
614 | - $this->_php_resource_dir[ $directory ] = true; |
|
615 | - } |
|
616 | - } |
|
617 | - |
|
618 | - $this->_php_resource_dir = |
|
619 | - $this->_checkDir($this->smarty->_realpath($filepath, true), $this->_php_resource_dir); |
|
620 | - return true; |
|
621 | - } |
|
16 | + /** |
|
17 | + * This determines how Smarty handles "<?php ... ?>" tags in templates. |
|
18 | + * possible values: |
|
19 | + * <ul> |
|
20 | + * <li>Smarty::PHP_PASSTHRU -> echo PHP tags as they are</li> |
|
21 | + * <li>Smarty::PHP_QUOTE -> escape tags as entities</li> |
|
22 | + * <li>Smarty::PHP_REMOVE -> remove php tags</li> |
|
23 | + * <li>Smarty::PHP_ALLOW -> execute php tags</li> |
|
24 | + * </ul> |
|
25 | + * |
|
26 | + * @var integer |
|
27 | + */ |
|
28 | + public $php_handling = Smarty::PHP_PASSTHRU; |
|
29 | + |
|
30 | + /** |
|
31 | + * This is the list of template directories that are considered secure. |
|
32 | + * $template_dir is in this list implicitly. |
|
33 | + * |
|
34 | + * @var array |
|
35 | + */ |
|
36 | + public $secure_dir = array(); |
|
37 | + |
|
38 | + /** |
|
39 | + * This is an array of directories where trusted php scripts reside. |
|
40 | + * {@link $security} is disabled during their inclusion/execution. |
|
41 | + * |
|
42 | + * @var array |
|
43 | + */ |
|
44 | + public $trusted_dir = array(); |
|
45 | + |
|
46 | + /** |
|
47 | + * List of regular expressions (PCRE) that include trusted URIs |
|
48 | + * |
|
49 | + * @var array |
|
50 | + */ |
|
51 | + public $trusted_uri = array(); |
|
52 | + |
|
53 | + /** |
|
54 | + * List of trusted constants names |
|
55 | + * |
|
56 | + * @var array |
|
57 | + */ |
|
58 | + public $trusted_constants = array(); |
|
59 | + |
|
60 | + /** |
|
61 | + * This is an array of trusted static classes. |
|
62 | + * If empty access to all static classes is allowed. |
|
63 | + * If set to 'none' none is allowed. |
|
64 | + * |
|
65 | + * @var array |
|
66 | + */ |
|
67 | + public $static_classes = array(); |
|
68 | + |
|
69 | + /** |
|
70 | + * This is an nested array of trusted classes and static methods. |
|
71 | + * If empty access to all static classes and methods is allowed. |
|
72 | + * Format: |
|
73 | + * array ( |
|
74 | + * 'class_1' => array('method_1', 'method_2'), // allowed methods listed |
|
75 | + * 'class_2' => array(), // all methods of class allowed |
|
76 | + * ) |
|
77 | + * If set to null none is allowed. |
|
78 | + * |
|
79 | + * @var array |
|
80 | + */ |
|
81 | + public $trusted_static_methods = array(); |
|
82 | + |
|
83 | + /** |
|
84 | + * This is an array of trusted static properties. |
|
85 | + * If empty access to all static classes and properties is allowed. |
|
86 | + * Format: |
|
87 | + * array ( |
|
88 | + * 'class_1' => array('prop_1', 'prop_2'), // allowed properties listed |
|
89 | + * 'class_2' => array(), // all properties of class allowed |
|
90 | + * ) |
|
91 | + * If set to null none is allowed. |
|
92 | + * |
|
93 | + * @var array |
|
94 | + */ |
|
95 | + public $trusted_static_properties = array(); |
|
96 | + |
|
97 | + /** |
|
98 | + * This is an array of trusted PHP functions. |
|
99 | + * If empty all functions are allowed. |
|
100 | + * To disable all PHP functions set $php_functions = null. |
|
101 | + * |
|
102 | + * @var array |
|
103 | + */ |
|
104 | + public $php_functions = array('isset', 'empty', 'count', 'sizeof', 'in_array', 'is_array', 'time',); |
|
105 | + |
|
106 | + /** |
|
107 | + * This is an array of trusted PHP modifiers. |
|
108 | + * If empty all modifiers are allowed. |
|
109 | + * To disable all modifier set $php_modifiers = null. |
|
110 | + * |
|
111 | + * @var array |
|
112 | + */ |
|
113 | + public $php_modifiers = array('escape', 'count', 'nl2br',); |
|
114 | + |
|
115 | + /** |
|
116 | + * This is an array of allowed tags. |
|
117 | + * If empty no restriction by allowed_tags. |
|
118 | + * |
|
119 | + * @var array |
|
120 | + */ |
|
121 | + public $allowed_tags = array(); |
|
122 | + |
|
123 | + /** |
|
124 | + * This is an array of disabled tags. |
|
125 | + * If empty no restriction by disabled_tags. |
|
126 | + * |
|
127 | + * @var array |
|
128 | + */ |
|
129 | + public $disabled_tags = array(); |
|
130 | + |
|
131 | + /** |
|
132 | + * This is an array of allowed modifier plugins. |
|
133 | + * If empty no restriction by allowed_modifiers. |
|
134 | + * |
|
135 | + * @var array |
|
136 | + */ |
|
137 | + public $allowed_modifiers = array(); |
|
138 | + |
|
139 | + /** |
|
140 | + * This is an array of disabled modifier plugins. |
|
141 | + * If empty no restriction by disabled_modifiers. |
|
142 | + * |
|
143 | + * @var array |
|
144 | + */ |
|
145 | + public $disabled_modifiers = array(); |
|
146 | + |
|
147 | + /** |
|
148 | + * This is an array of disabled special $smarty variables. |
|
149 | + * |
|
150 | + * @var array |
|
151 | + */ |
|
152 | + public $disabled_special_smarty_vars = array(); |
|
153 | + |
|
154 | + /** |
|
155 | + * This is an array of trusted streams. |
|
156 | + * If empty all streams are allowed. |
|
157 | + * To disable all streams set $streams = null. |
|
158 | + * |
|
159 | + * @var array |
|
160 | + */ |
|
161 | + public $streams = array('file'); |
|
162 | + |
|
163 | + /** |
|
164 | + * + flag if constants can be accessed from template |
|
165 | + * |
|
166 | + * @var boolean |
|
167 | + */ |
|
168 | + public $allow_constants = true; |
|
169 | + |
|
170 | + /** |
|
171 | + * + flag if super globals can be accessed from template |
|
172 | + * |
|
173 | + * @var boolean |
|
174 | + */ |
|
175 | + public $allow_super_globals = true; |
|
176 | + |
|
177 | + /** |
|
178 | + * max template nesting level |
|
179 | + * |
|
180 | + * @var int |
|
181 | + */ |
|
182 | + public $max_template_nesting = 0; |
|
183 | + |
|
184 | + /** |
|
185 | + * current template nesting level |
|
186 | + * |
|
187 | + * @var int |
|
188 | + */ |
|
189 | + private $_current_template_nesting = 0; |
|
190 | + |
|
191 | + /** |
|
192 | + * Cache for $resource_dir lookup |
|
193 | + * |
|
194 | + * @var array |
|
195 | + */ |
|
196 | + protected $_resource_dir = array(); |
|
197 | + |
|
198 | + /** |
|
199 | + * Cache for $template_dir lookup |
|
200 | + * |
|
201 | + * @var array |
|
202 | + */ |
|
203 | + protected $_template_dir = array(); |
|
204 | + |
|
205 | + /** |
|
206 | + * Cache for $config_dir lookup |
|
207 | + * |
|
208 | + * @var array |
|
209 | + */ |
|
210 | + protected $_config_dir = array(); |
|
211 | + |
|
212 | + /** |
|
213 | + * Cache for $secure_dir lookup |
|
214 | + * |
|
215 | + * @var array |
|
216 | + */ |
|
217 | + protected $_secure_dir = array(); |
|
218 | + |
|
219 | + /** |
|
220 | + * Cache for $php_resource_dir lookup |
|
221 | + * |
|
222 | + * @var array |
|
223 | + */ |
|
224 | + protected $_php_resource_dir = null; |
|
225 | + |
|
226 | + /** |
|
227 | + * Cache for $trusted_dir lookup |
|
228 | + * |
|
229 | + * @var array |
|
230 | + */ |
|
231 | + protected $_trusted_dir = null; |
|
232 | + |
|
233 | + /** |
|
234 | + * Cache for include path status |
|
235 | + * |
|
236 | + * @var bool |
|
237 | + */ |
|
238 | + protected $_include_path_status = false; |
|
239 | + |
|
240 | + /** |
|
241 | + * Cache for $_include_array lookup |
|
242 | + * |
|
243 | + * @var array |
|
244 | + */ |
|
245 | + protected $_include_dir = array(); |
|
246 | + |
|
247 | + /** |
|
248 | + * @param Smarty $smarty |
|
249 | + */ |
|
250 | + public function __construct($smarty) |
|
251 | + { |
|
252 | + $this->smarty = $smarty; |
|
253 | + $this->smarty->_cache[ 'template_dir_new' ] = true; |
|
254 | + $this->smarty->_cache[ 'config_dir_new' ] = true; |
|
255 | + } |
|
256 | + |
|
257 | + /** |
|
258 | + * Check if PHP function is trusted. |
|
259 | + * |
|
260 | + * @param string $function_name |
|
261 | + * @param object $compiler compiler object |
|
262 | + * |
|
263 | + * @return boolean true if function is trusted |
|
264 | + * @throws SmartyCompilerException if php function is not trusted |
|
265 | + */ |
|
266 | + public function isTrustedPhpFunction($function_name, $compiler) |
|
267 | + { |
|
268 | + if (isset($this->php_functions) && |
|
269 | + (empty($this->php_functions) || in_array($function_name, $this->php_functions)) |
|
270 | + ) { |
|
271 | + return true; |
|
272 | + } |
|
273 | + |
|
274 | + $compiler->trigger_template_error("PHP function '{$function_name}' not allowed by security setting"); |
|
275 | + |
|
276 | + return false; // should not, but who knows what happens to the compiler in the future? |
|
277 | + } |
|
278 | + |
|
279 | + /** |
|
280 | + * Check if static class is trusted. |
|
281 | + * |
|
282 | + * @param string $class_name |
|
283 | + * @param object $compiler compiler object |
|
284 | + * |
|
285 | + * @return boolean true if class is trusted |
|
286 | + * @throws SmartyCompilerException if static class is not trusted |
|
287 | + */ |
|
288 | + public function isTrustedStaticClass($class_name, $compiler) |
|
289 | + { |
|
290 | + if (isset($this->static_classes) && |
|
291 | + (empty($this->static_classes) || in_array($class_name, $this->static_classes)) |
|
292 | + ) { |
|
293 | + return true; |
|
294 | + } |
|
295 | + |
|
296 | + $compiler->trigger_template_error("access to static class '{$class_name}' not allowed by security setting"); |
|
297 | + |
|
298 | + return false; // should not, but who knows what happens to the compiler in the future? |
|
299 | + } |
|
300 | + |
|
301 | + /** |
|
302 | + * Check if static class method/property is trusted. |
|
303 | + * |
|
304 | + * @param string $class_name |
|
305 | + * @param string $params |
|
306 | + * @param object $compiler compiler object |
|
307 | + * |
|
308 | + * @return boolean true if class method is trusted |
|
309 | + * @throws SmartyCompilerException if static class method is not trusted |
|
310 | + */ |
|
311 | + public function isTrustedStaticClassAccess($class_name, $params, $compiler) |
|
312 | + { |
|
313 | + if (!isset($params[ 2 ])) { |
|
314 | + // fall back |
|
315 | + return $this->isTrustedStaticClass($class_name, $compiler); |
|
316 | + } |
|
317 | + if ($params[ 2 ] == 'method') { |
|
318 | + $allowed = $this->trusted_static_methods; |
|
319 | + $name = substr($params[ 0 ], 0, strpos($params[ 0 ], '(')); |
|
320 | + } else { |
|
321 | + $allowed = $this->trusted_static_properties; |
|
322 | + // strip '$' |
|
323 | + $name = substr($params[ 0 ], 1); |
|
324 | + } |
|
325 | + if (isset($allowed)) { |
|
326 | + if (empty($allowed)) { |
|
327 | + // fall back |
|
328 | + return $this->isTrustedStaticClass($class_name, $compiler); |
|
329 | + } |
|
330 | + if (isset($allowed[ $class_name ]) && |
|
331 | + (empty($allowed[ $class_name ]) || in_array($name, $allowed[ $class_name ])) |
|
332 | + ) { |
|
333 | + return true; |
|
334 | + } |
|
335 | + } |
|
336 | + $compiler->trigger_template_error("access to static class '{$class_name}' {$params[2]} '{$name}' not allowed by security setting"); |
|
337 | + return false; // should not, but who knows what happens to the compiler in the future? |
|
338 | + } |
|
339 | + |
|
340 | + /** |
|
341 | + * Check if PHP modifier is trusted. |
|
342 | + * |
|
343 | + * @param string $modifier_name |
|
344 | + * @param object $compiler compiler object |
|
345 | + * |
|
346 | + * @return boolean true if modifier is trusted |
|
347 | + * @throws SmartyCompilerException if modifier is not trusted |
|
348 | + */ |
|
349 | + public function isTrustedPhpModifier($modifier_name, $compiler) |
|
350 | + { |
|
351 | + if (isset($this->php_modifiers) && |
|
352 | + (empty($this->php_modifiers) || in_array($modifier_name, $this->php_modifiers)) |
|
353 | + ) { |
|
354 | + return true; |
|
355 | + } |
|
356 | + |
|
357 | + $compiler->trigger_template_error("modifier '{$modifier_name}' not allowed by security setting"); |
|
358 | + |
|
359 | + return false; // should not, but who knows what happens to the compiler in the future? |
|
360 | + } |
|
361 | + |
|
362 | + /** |
|
363 | + * Check if tag is trusted. |
|
364 | + * |
|
365 | + * @param string $tag_name |
|
366 | + * @param object $compiler compiler object |
|
367 | + * |
|
368 | + * @return boolean true if tag is trusted |
|
369 | + * @throws SmartyCompilerException if modifier is not trusted |
|
370 | + */ |
|
371 | + public function isTrustedTag($tag_name, $compiler) |
|
372 | + { |
|
373 | + // check for internal always required tags |
|
374 | + if (in_array($tag_name, |
|
375 | + array('assign', 'call', 'private_filter', 'private_block_plugin', 'private_function_plugin', |
|
376 | + 'private_object_block_function', 'private_object_function', 'private_registered_function', |
|
377 | + 'private_registered_block', 'private_special_variable', 'private_print_expression', |
|
378 | + 'private_modifier'))) { |
|
379 | + return true; |
|
380 | + } |
|
381 | + // check security settings |
|
382 | + if (empty($this->allowed_tags)) { |
|
383 | + if (empty($this->disabled_tags) || !in_array($tag_name, $this->disabled_tags)) { |
|
384 | + return true; |
|
385 | + } else { |
|
386 | + $compiler->trigger_template_error("tag '{$tag_name}' disabled by security setting", null, true); |
|
387 | + } |
|
388 | + } elseif (in_array($tag_name, $this->allowed_tags) && !in_array($tag_name, $this->disabled_tags)) { |
|
389 | + return true; |
|
390 | + } else { |
|
391 | + $compiler->trigger_template_error("tag '{$tag_name}' not allowed by security setting", null, true); |
|
392 | + } |
|
393 | + |
|
394 | + return false; // should not, but who knows what happens to the compiler in the future? |
|
395 | + } |
|
396 | + |
|
397 | + /** |
|
398 | + * Check if special $smarty variable is trusted. |
|
399 | + * |
|
400 | + * @param string $var_name |
|
401 | + * @param object $compiler compiler object |
|
402 | + * |
|
403 | + * @return boolean true if tag is trusted |
|
404 | + * @throws SmartyCompilerException if modifier is not trusted |
|
405 | + */ |
|
406 | + public function isTrustedSpecialSmartyVar($var_name, $compiler) |
|
407 | + { |
|
408 | + if (!in_array($var_name, $this->disabled_special_smarty_vars)) { |
|
409 | + return true; |
|
410 | + } else { |
|
411 | + $compiler->trigger_template_error("special variable '\$smarty.{$var_name}' not allowed by security setting", |
|
412 | + null, true); |
|
413 | + } |
|
414 | + |
|
415 | + return false; // should not, but who knows what happens to the compiler in the future? |
|
416 | + } |
|
417 | + |
|
418 | + /** |
|
419 | + * Check if modifier plugin is trusted. |
|
420 | + * |
|
421 | + * @param string $modifier_name |
|
422 | + * @param object $compiler compiler object |
|
423 | + * |
|
424 | + * @return boolean true if tag is trusted |
|
425 | + * @throws SmartyCompilerException if modifier is not trusted |
|
426 | + */ |
|
427 | + public function isTrustedModifier($modifier_name, $compiler) |
|
428 | + { |
|
429 | + // check for internal always allowed modifier |
|
430 | + if (in_array($modifier_name, array('default'))) { |
|
431 | + return true; |
|
432 | + } |
|
433 | + // check security settings |
|
434 | + if (empty($this->allowed_modifiers)) { |
|
435 | + if (empty($this->disabled_modifiers) || !in_array($modifier_name, $this->disabled_modifiers)) { |
|
436 | + return true; |
|
437 | + } else { |
|
438 | + $compiler->trigger_template_error("modifier '{$modifier_name}' disabled by security setting", null, |
|
439 | + true); |
|
440 | + } |
|
441 | + } elseif (in_array($modifier_name, $this->allowed_modifiers) && |
|
442 | + !in_array($modifier_name, $this->disabled_modifiers) |
|
443 | + ) { |
|
444 | + return true; |
|
445 | + } else { |
|
446 | + $compiler->trigger_template_error("modifier '{$modifier_name}' not allowed by security setting", null, |
|
447 | + true); |
|
448 | + } |
|
449 | + |
|
450 | + return false; // should not, but who knows what happens to the compiler in the future? |
|
451 | + } |
|
452 | + |
|
453 | + /** |
|
454 | + * Check if constants are enabled or trusted |
|
455 | + * |
|
456 | + * @param string $const constant name |
|
457 | + * @param object $compiler compiler object |
|
458 | + * |
|
459 | + * @return bool |
|
460 | + */ |
|
461 | + public function isTrustedConstant($const, $compiler) |
|
462 | + { |
|
463 | + if (in_array($const, array('true', 'false', 'null'))) { |
|
464 | + return true; |
|
465 | + } |
|
466 | + if (!empty($this->trusted_constants)) { |
|
467 | + if (!in_array($const, $this->trusted_constants)) { |
|
468 | + $compiler->trigger_template_error("Security: access to constant '{$const}' not permitted"); |
|
469 | + return false; |
|
470 | + } |
|
471 | + return true; |
|
472 | + } |
|
473 | + if ($this->allow_constants) { |
|
474 | + return true; |
|
475 | + } |
|
476 | + $compiler->trigger_template_error("Security: access to constants not permitted"); |
|
477 | + return false; |
|
478 | + } |
|
479 | + |
|
480 | + /** |
|
481 | + * Check if stream is trusted. |
|
482 | + * |
|
483 | + * @param string $stream_name |
|
484 | + * |
|
485 | + * @return boolean true if stream is trusted |
|
486 | + * @throws SmartyException if stream is not trusted |
|
487 | + */ |
|
488 | + public function isTrustedStream($stream_name) |
|
489 | + { |
|
490 | + if (isset($this->streams) && (empty($this->streams) || in_array($stream_name, $this->streams))) { |
|
491 | + return true; |
|
492 | + } |
|
493 | + |
|
494 | + throw new SmartyException("stream '{$stream_name}' not allowed by security setting"); |
|
495 | + } |
|
496 | + |
|
497 | + /** |
|
498 | + * Check if directory of file resource is trusted. |
|
499 | + * |
|
500 | + * @param string $filepath |
|
501 | + * @param null|bool $isConfig |
|
502 | + * |
|
503 | + * @return bool true if directory is trusted |
|
504 | + * @throws \SmartyException if directory is not trusted |
|
505 | + */ |
|
506 | + public function isTrustedResourceDir($filepath, $isConfig = null) |
|
507 | + { |
|
508 | + if ($this->_include_path_status !== $this->smarty->use_include_path) { |
|
509 | + foreach ($this->_include_dir as $directory) { |
|
510 | + unset($this->_resource_dir[ $directory ]); |
|
511 | + } |
|
512 | + if ($this->smarty->use_include_path) { |
|
513 | + $this->_include_dir = array(); |
|
514 | + $_dirs = $this->smarty->ext->_getIncludePath->getIncludePathDirs($this->smarty); |
|
515 | + foreach ($_dirs as $directory) { |
|
516 | + $this->_include_dir[] = $directory; |
|
517 | + $this->_resource_dir[ $directory ] = true; |
|
518 | + } |
|
519 | + } |
|
520 | + $this->_include_path_status = $this->smarty->use_include_path; |
|
521 | + } |
|
522 | + if ($isConfig !== true && |
|
523 | + (!isset($this->smarty->_cache[ 'template_dir_new' ]) || $this->smarty->_cache[ 'template_dir_new' ]) |
|
524 | + ) { |
|
525 | + $_dir = $this->smarty->getTemplateDir(); |
|
526 | + if ($this->_template_dir !== $_dir) { |
|
527 | + foreach ($this->_template_dir as $directory) { |
|
528 | + unset($this->_resource_dir[ $directory ]); |
|
529 | + } |
|
530 | + foreach ($_dir as $directory) { |
|
531 | + $this->_resource_dir[ $directory ] = true; |
|
532 | + } |
|
533 | + $this->_template_dir = $_dir; |
|
534 | + } |
|
535 | + $this->smarty->_cache[ 'template_dir_new' ] = false; |
|
536 | + } |
|
537 | + if ($isConfig !== false && |
|
538 | + (!isset($this->smarty->_cache[ 'config_dir_new' ]) || $this->smarty->_cache[ 'config_dir_new' ]) |
|
539 | + ) { |
|
540 | + $_dir = $this->smarty->getConfigDir(); |
|
541 | + if ($this->_config_dir !== $_dir) { |
|
542 | + foreach ($this->_config_dir as $directory) { |
|
543 | + unset($this->_resource_dir[ $directory ]); |
|
544 | + } |
|
545 | + foreach ($_dir as $directory) { |
|
546 | + $this->_resource_dir[ $directory ] = true; |
|
547 | + } |
|
548 | + $this->_config_dir = $_dir; |
|
549 | + } |
|
550 | + $this->smarty->_cache[ 'config_dir_new' ] = false; |
|
551 | + } |
|
552 | + if ($this->_secure_dir !== (array) $this->secure_dir) { |
|
553 | + foreach ($this->_secure_dir as $directory) { |
|
554 | + unset($this->_resource_dir[ $directory ]); |
|
555 | + } |
|
556 | + foreach ((array) $this->secure_dir as $directory) { |
|
557 | + $directory = $this->smarty->_realpath($directory . DS, true); |
|
558 | + $this->_resource_dir[ $directory ] = true; |
|
559 | + } |
|
560 | + $this->_secure_dir = (array) $this->secure_dir; |
|
561 | + } |
|
562 | + $this->_resource_dir = $this->_checkDir($filepath, $this->_resource_dir); |
|
563 | + return true; |
|
564 | + } |
|
565 | + |
|
566 | + /** |
|
567 | + * Check if URI (e.g. {fetch} or {html_image}) is trusted |
|
568 | + * To simplify things, isTrustedUri() resolves all input to "{$PROTOCOL}://{$HOSTNAME}". |
|
569 | + * So "http://username:[email protected]:8080/some-path?some=query-string" |
|
570 | + * is reduced to "http://hello.world.example.org" prior to applying the patters from {@link $trusted_uri}. |
|
571 | + * |
|
572 | + * @param string $uri |
|
573 | + * |
|
574 | + * @return boolean true if URI is trusted |
|
575 | + * @throws SmartyException if URI is not trusted |
|
576 | + * @uses $trusted_uri for list of patterns to match against $uri |
|
577 | + */ |
|
578 | + public function isTrustedUri($uri) |
|
579 | + { |
|
580 | + $_uri = parse_url($uri); |
|
581 | + if (!empty($_uri[ 'scheme' ]) && !empty($_uri[ 'host' ])) { |
|
582 | + $_uri = $_uri[ 'scheme' ] . '://' . $_uri[ 'host' ]; |
|
583 | + foreach ($this->trusted_uri as $pattern) { |
|
584 | + if (preg_match($pattern, $_uri)) { |
|
585 | + return true; |
|
586 | + } |
|
587 | + } |
|
588 | + } |
|
589 | + |
|
590 | + throw new SmartyException("URI '{$uri}' not allowed by security setting"); |
|
591 | + } |
|
592 | + |
|
593 | + /** |
|
594 | + * Check if directory of file resource is trusted. |
|
595 | + * |
|
596 | + * @param string $filepath |
|
597 | + * |
|
598 | + * @return boolean true if directory is trusted |
|
599 | + * @throws SmartyException if PHP directory is not trusted |
|
600 | + */ |
|
601 | + public function isTrustedPHPDir($filepath) |
|
602 | + { |
|
603 | + if (empty($this->trusted_dir)) { |
|
604 | + throw new SmartyException("directory '{$filepath}' not allowed by security setting (no trusted_dir specified)"); |
|
605 | + } |
|
606 | + |
|
607 | + // check if index is outdated |
|
608 | + if (!$this->_trusted_dir || $this->_trusted_dir !== $this->trusted_dir) { |
|
609 | + $this->_php_resource_dir = array(); |
|
610 | + |
|
611 | + $this->_trusted_dir = $this->trusted_dir; |
|
612 | + foreach ((array) $this->trusted_dir as $directory) { |
|
613 | + $directory = $this->smarty->_realpath($directory . DS, true); |
|
614 | + $this->_php_resource_dir[ $directory ] = true; |
|
615 | + } |
|
616 | + } |
|
617 | + |
|
618 | + $this->_php_resource_dir = |
|
619 | + $this->_checkDir($this->smarty->_realpath($filepath, true), $this->_php_resource_dir); |
|
620 | + return true; |
|
621 | + } |
|
622 | 622 | |
623 | - /** |
|
624 | - * Check if file is inside a valid directory |
|
625 | - * |
|
626 | - * @param string $filepath |
|
627 | - * @param array $dirs valid directories |
|
628 | - * |
|
629 | - * @return array |
|
630 | - * @throws \SmartyException |
|
631 | - */ |
|
632 | - private function _checkDir($filepath, $dirs) |
|
633 | - { |
|
634 | - $directory = dirname($filepath) . DS; |
|
635 | - $_directory = array(); |
|
636 | - while (true) { |
|
637 | - // remember the directory to add it to _resource_dir in case we're successful |
|
638 | - $_directory[ $directory ] = true; |
|
639 | - // test if the directory is trusted |
|
640 | - if (isset($dirs[ $directory ])) { |
|
641 | - // merge sub directories of current $directory into _resource_dir to speed up subsequent lookup |
|
642 | - $dirs = array_merge($dirs, $_directory); |
|
643 | - |
|
644 | - return $dirs; |
|
645 | - } |
|
646 | - // abort if we've reached root |
|
647 | - if (!preg_match('#[\\\/][^\\\/]+[\\\/]$#', $directory)) { |
|
648 | - break; |
|
649 | - } |
|
650 | - // bubble up one level |
|
651 | - $directory = preg_replace('#[\\\/][^\\\/]+[\\\/]$#', DS, $directory); |
|
652 | - } |
|
653 | - |
|
654 | - // give up |
|
655 | - throw new SmartyException("directory '{$filepath}' not allowed by security setting"); |
|
656 | - } |
|
657 | - |
|
658 | - /** |
|
659 | - * Loads security class and enables security |
|
660 | - * |
|
661 | - * @param \Smarty $smarty |
|
662 | - * @param string|Smarty_Security $security_class if a string is used, it must be class-name |
|
663 | - * |
|
664 | - * @return \Smarty current Smarty instance for chaining |
|
665 | - * @throws \SmartyException when an invalid class name is provided |
|
666 | - */ |
|
667 | - public static function enableSecurity(Smarty $smarty, $security_class) |
|
668 | - { |
|
669 | - if ($security_class instanceof Smarty_Security) { |
|
670 | - $smarty->security_policy = $security_class; |
|
671 | - return; |
|
672 | - } elseif (is_object($security_class)) { |
|
673 | - throw new SmartyException("Class '" . get_class($security_class) . "' must extend Smarty_Security."); |
|
674 | - } |
|
675 | - if ($security_class === null) { |
|
676 | - $security_class = $smarty->security_class; |
|
677 | - } |
|
678 | - if (!class_exists($security_class)) { |
|
679 | - throw new SmartyException("Security class '$security_class' is not defined"); |
|
680 | - } elseif ($security_class !== 'Smarty_Security' && !is_subclass_of($security_class, 'Smarty_Security')) { |
|
681 | - throw new SmartyException("Class '$security_class' must extend Smarty_Security."); |
|
682 | - } else { |
|
683 | - $smarty->security_policy = new $security_class($smarty); |
|
684 | - } |
|
685 | - return; |
|
686 | - } |
|
687 | - /** |
|
688 | - * Start template processing |
|
689 | - * |
|
690 | - * @param $template |
|
691 | - * |
|
692 | - * @throws SmartyException |
|
693 | - */ |
|
694 | - public function startTemplate($template) |
|
695 | - { |
|
696 | - if ($this->max_template_nesting > 0 && $this->_current_template_nesting ++ >= $this->max_template_nesting) { |
|
697 | - throw new SmartyException("maximum template nesting level of '{$this->max_template_nesting}' exceeded when calling '{$template->template_resource}'"); |
|
698 | - } |
|
699 | - } |
|
700 | - |
|
701 | - /** |
|
702 | - * Exit template processing |
|
703 | - * |
|
704 | - */ |
|
705 | - public function endTemplate() |
|
706 | - { |
|
707 | - if ($this->max_template_nesting > 0) { |
|
708 | - $this->_current_template_nesting --; |
|
709 | - } |
|
710 | - } |
|
711 | - |
|
712 | - /** |
|
713 | - * Register callback functions call at start/end of template rendering |
|
714 | - * |
|
715 | - * @param \Smarty_Internal_Template $template |
|
716 | - */ |
|
717 | - public function registerCallBacks(Smarty_Internal_Template $template) |
|
718 | - { |
|
719 | - $template->startRenderCallbacks[] = array($this, 'startTemplate'); |
|
720 | - $template->endRenderCallbacks[] = array($this, 'endTemplate'); |
|
721 | - } |
|
623 | + /** |
|
624 | + * Check if file is inside a valid directory |
|
625 | + * |
|
626 | + * @param string $filepath |
|
627 | + * @param array $dirs valid directories |
|
628 | + * |
|
629 | + * @return array |
|
630 | + * @throws \SmartyException |
|
631 | + */ |
|
632 | + private function _checkDir($filepath, $dirs) |
|
633 | + { |
|
634 | + $directory = dirname($filepath) . DS; |
|
635 | + $_directory = array(); |
|
636 | + while (true) { |
|
637 | + // remember the directory to add it to _resource_dir in case we're successful |
|
638 | + $_directory[ $directory ] = true; |
|
639 | + // test if the directory is trusted |
|
640 | + if (isset($dirs[ $directory ])) { |
|
641 | + // merge sub directories of current $directory into _resource_dir to speed up subsequent lookup |
|
642 | + $dirs = array_merge($dirs, $_directory); |
|
643 | + |
|
644 | + return $dirs; |
|
645 | + } |
|
646 | + // abort if we've reached root |
|
647 | + if (!preg_match('#[\\\/][^\\\/]+[\\\/]$#', $directory)) { |
|
648 | + break; |
|
649 | + } |
|
650 | + // bubble up one level |
|
651 | + $directory = preg_replace('#[\\\/][^\\\/]+[\\\/]$#', DS, $directory); |
|
652 | + } |
|
653 | + |
|
654 | + // give up |
|
655 | + throw new SmartyException("directory '{$filepath}' not allowed by security setting"); |
|
656 | + } |
|
657 | + |
|
658 | + /** |
|
659 | + * Loads security class and enables security |
|
660 | + * |
|
661 | + * @param \Smarty $smarty |
|
662 | + * @param string|Smarty_Security $security_class if a string is used, it must be class-name |
|
663 | + * |
|
664 | + * @return \Smarty current Smarty instance for chaining |
|
665 | + * @throws \SmartyException when an invalid class name is provided |
|
666 | + */ |
|
667 | + public static function enableSecurity(Smarty $smarty, $security_class) |
|
668 | + { |
|
669 | + if ($security_class instanceof Smarty_Security) { |
|
670 | + $smarty->security_policy = $security_class; |
|
671 | + return; |
|
672 | + } elseif (is_object($security_class)) { |
|
673 | + throw new SmartyException("Class '" . get_class($security_class) . "' must extend Smarty_Security."); |
|
674 | + } |
|
675 | + if ($security_class === null) { |
|
676 | + $security_class = $smarty->security_class; |
|
677 | + } |
|
678 | + if (!class_exists($security_class)) { |
|
679 | + throw new SmartyException("Security class '$security_class' is not defined"); |
|
680 | + } elseif ($security_class !== 'Smarty_Security' && !is_subclass_of($security_class, 'Smarty_Security')) { |
|
681 | + throw new SmartyException("Class '$security_class' must extend Smarty_Security."); |
|
682 | + } else { |
|
683 | + $smarty->security_policy = new $security_class($smarty); |
|
684 | + } |
|
685 | + return; |
|
686 | + } |
|
687 | + /** |
|
688 | + * Start template processing |
|
689 | + * |
|
690 | + * @param $template |
|
691 | + * |
|
692 | + * @throws SmartyException |
|
693 | + */ |
|
694 | + public function startTemplate($template) |
|
695 | + { |
|
696 | + if ($this->max_template_nesting > 0 && $this->_current_template_nesting ++ >= $this->max_template_nesting) { |
|
697 | + throw new SmartyException("maximum template nesting level of '{$this->max_template_nesting}' exceeded when calling '{$template->template_resource}'"); |
|
698 | + } |
|
699 | + } |
|
700 | + |
|
701 | + /** |
|
702 | + * Exit template processing |
|
703 | + * |
|
704 | + */ |
|
705 | + public function endTemplate() |
|
706 | + { |
|
707 | + if ($this->max_template_nesting > 0) { |
|
708 | + $this->_current_template_nesting --; |
|
709 | + } |
|
710 | + } |
|
711 | + |
|
712 | + /** |
|
713 | + * Register callback functions call at start/end of template rendering |
|
714 | + * |
|
715 | + * @param \Smarty_Internal_Template $template |
|
716 | + */ |
|
717 | + public function registerCallBacks(Smarty_Internal_Template $template) |
|
718 | + { |
|
719 | + $template->startRenderCallbacks[] = array($this, 'startTemplate'); |
|
720 | + $template->endRenderCallbacks[] = array($this, 'endTemplate'); |
|
721 | + } |
|
722 | 722 | } |
@@ -126,7 +126,6 @@ |
||
126 | 126 | /** |
127 | 127 | * create Source Object container |
128 | 128 | * |
129 | - * @param Smarty_Resource $handler Resource Handler this source object communicates with |
|
130 | 129 | * @param Smarty $smarty Smarty instance this source object belongs to |
131 | 130 | * @param string $resource full template_resource |
132 | 131 | * @param string $type type of resource |
@@ -11,200 +11,200 @@ |
||
11 | 11 | */ |
12 | 12 | class Smarty_Template_Source |
13 | 13 | { |
14 | - /** |
|
15 | - * Unique Template ID |
|
16 | - * |
|
17 | - * @var string |
|
18 | - */ |
|
19 | - public $uid = null; |
|
20 | - |
|
21 | - /** |
|
22 | - * Template Resource (Smarty_Internal_Template::$template_resource) |
|
23 | - * |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - public $resource = null; |
|
27 | - |
|
28 | - /** |
|
29 | - * Resource Type |
|
30 | - * |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - public $type = null; |
|
34 | - |
|
35 | - /** |
|
36 | - * Resource Name |
|
37 | - * |
|
38 | - * @var string |
|
39 | - */ |
|
40 | - public $name = null; |
|
41 | - |
|
42 | - /** |
|
43 | - * Source Filepath |
|
44 | - * |
|
45 | - * @var string |
|
46 | - */ |
|
47 | - public $filepath = null; |
|
48 | - |
|
49 | - /** |
|
50 | - * Source Timestamp |
|
51 | - * |
|
52 | - * @var integer |
|
53 | - */ |
|
54 | - public $timestamp = null; |
|
55 | - |
|
56 | - /** |
|
57 | - * Source Existence |
|
58 | - * |
|
59 | - * @var boolean |
|
60 | - */ |
|
61 | - public $exists = false; |
|
62 | - |
|
63 | - /** |
|
64 | - * Source File Base name |
|
65 | - * |
|
66 | - * @var string |
|
67 | - */ |
|
68 | - public $basename = null; |
|
69 | - |
|
70 | - /** |
|
71 | - * The Components an extended template is made of |
|
72 | - * |
|
73 | - * @var \Smarty_Template_Source[] |
|
74 | - */ |
|
75 | - public $components = null; |
|
76 | - |
|
77 | - /** |
|
78 | - * Resource Handler |
|
79 | - * |
|
80 | - * @var \Smarty_Resource |
|
81 | - */ |
|
82 | - public $handler = null; |
|
83 | - |
|
84 | - /** |
|
85 | - * Smarty instance |
|
86 | - * |
|
87 | - * @var Smarty |
|
88 | - */ |
|
89 | - public $smarty = null; |
|
90 | - |
|
91 | - /** |
|
92 | - * Resource is source |
|
93 | - * |
|
94 | - * @var bool |
|
95 | - */ |
|
96 | - public $isConfig = false; |
|
97 | - |
|
98 | - /** |
|
99 | - * Template source content eventually set by default handler |
|
100 | - * |
|
101 | - * @var string |
|
102 | - */ |
|
103 | - public $content = null; |
|
104 | - |
|
105 | - /** |
|
106 | - * Name of the Class to compile this resource's contents with |
|
107 | - * |
|
108 | - * @var string |
|
109 | - */ |
|
110 | - public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler'; |
|
111 | - |
|
112 | - /** |
|
113 | - * Name of the Class to tokenize this resource's contents with |
|
114 | - * |
|
115 | - * @var string |
|
116 | - */ |
|
117 | - public $template_lexer_class = 'Smarty_Internal_Templatelexer'; |
|
118 | - |
|
119 | - /** |
|
120 | - * Name of the Class to parse this resource's contents with |
|
121 | - * |
|
122 | - * @var string |
|
123 | - */ |
|
124 | - public $template_parser_class = 'Smarty_Internal_Templateparser'; |
|
125 | - |
|
126 | - /** |
|
127 | - * create Source Object container |
|
128 | - * |
|
129 | - * @param Smarty_Resource $handler Resource Handler this source object communicates with |
|
130 | - * @param Smarty $smarty Smarty instance this source object belongs to |
|
131 | - * @param string $resource full template_resource |
|
132 | - * @param string $type type of resource |
|
133 | - * @param string $name resource name |
|
134 | - * |
|
135 | - */ |
|
136 | - public function __construct(Smarty $smarty, $resource, $type, $name) |
|
137 | - { |
|
138 | - $this->handler = |
|
139 | - isset($smarty->_cache[ 'resource_handlers' ][ $type ]) ? $smarty->_cache[ 'resource_handlers' ][ $type ] : |
|
140 | - Smarty_Resource::load($smarty, $type); |
|
141 | - $this->smarty = $smarty; |
|
142 | - $this->resource = $resource; |
|
143 | - $this->type = $type; |
|
144 | - $this->name = $name; |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * initialize Source Object for given resource |
|
149 | - * Either [$_template] or [$smarty, $template_resource] must be specified |
|
150 | - * |
|
151 | - * @param Smarty_Internal_Template $_template template object |
|
152 | - * @param Smarty $smarty smarty object |
|
153 | - * @param string $template_resource resource identifier |
|
154 | - * |
|
155 | - * @return Smarty_Template_Source Source Object |
|
156 | - * @throws SmartyException |
|
157 | - */ |
|
158 | - public static function load(Smarty_Internal_Template $_template = null, Smarty $smarty = null, |
|
159 | - $template_resource = null) |
|
160 | - { |
|
161 | - if ($_template) { |
|
162 | - $smarty = $_template->smarty; |
|
163 | - $template_resource = $_template->template_resource; |
|
164 | - } |
|
165 | - if (empty($template_resource)) { |
|
166 | - throw new SmartyException('Source: Missing name'); |
|
167 | - } |
|
168 | - // parse resource_name, load resource handler, identify unique resource name |
|
169 | - if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]([\s\S]*)$/', $template_resource, $match)) { |
|
170 | - $type = $match[ 1 ]; |
|
171 | - $name = $match[ 2 ]; |
|
172 | - } else { |
|
173 | - // no resource given, use default |
|
174 | - // or single character before the colon is not a resource type, but part of the filepath |
|
175 | - $type = $smarty->default_resource_type; |
|
176 | - $name = $template_resource; |
|
177 | - } |
|
178 | - // create new source object |
|
179 | - $source = new Smarty_Template_Source($smarty, $template_resource, $type, $name); |
|
180 | - $source->handler->populate($source, $_template); |
|
181 | - if (!$source->exists && isset($_template->smarty->default_template_handler_func)) { |
|
182 | - Smarty_Internal_Method_RegisterDefaultTemplateHandler::_getDefaultTemplate($source); |
|
183 | - $source->handler->populate($source, $_template); |
|
184 | - } |
|
185 | - return $source; |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Get source time stamp |
|
190 | - * |
|
191 | - * @return int |
|
192 | - */ |
|
193 | - public function getTimeStamp() |
|
194 | - { |
|
195 | - if (!isset($this->timestamp)) { |
|
196 | - $this->handler->populateTimestamp($this); |
|
197 | - } |
|
198 | - return $this->timestamp; |
|
199 | - } |
|
200 | - |
|
201 | - /** |
|
202 | - * Get source content |
|
203 | - * |
|
204 | - * @return string |
|
205 | - */ |
|
206 | - public function getContent() |
|
207 | - { |
|
208 | - return isset($this->content) ? $this->content : $this->handler->getContent($this); |
|
209 | - } |
|
14 | + /** |
|
15 | + * Unique Template ID |
|
16 | + * |
|
17 | + * @var string |
|
18 | + */ |
|
19 | + public $uid = null; |
|
20 | + |
|
21 | + /** |
|
22 | + * Template Resource (Smarty_Internal_Template::$template_resource) |
|
23 | + * |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + public $resource = null; |
|
27 | + |
|
28 | + /** |
|
29 | + * Resource Type |
|
30 | + * |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + public $type = null; |
|
34 | + |
|
35 | + /** |
|
36 | + * Resource Name |
|
37 | + * |
|
38 | + * @var string |
|
39 | + */ |
|
40 | + public $name = null; |
|
41 | + |
|
42 | + /** |
|
43 | + * Source Filepath |
|
44 | + * |
|
45 | + * @var string |
|
46 | + */ |
|
47 | + public $filepath = null; |
|
48 | + |
|
49 | + /** |
|
50 | + * Source Timestamp |
|
51 | + * |
|
52 | + * @var integer |
|
53 | + */ |
|
54 | + public $timestamp = null; |
|
55 | + |
|
56 | + /** |
|
57 | + * Source Existence |
|
58 | + * |
|
59 | + * @var boolean |
|
60 | + */ |
|
61 | + public $exists = false; |
|
62 | + |
|
63 | + /** |
|
64 | + * Source File Base name |
|
65 | + * |
|
66 | + * @var string |
|
67 | + */ |
|
68 | + public $basename = null; |
|
69 | + |
|
70 | + /** |
|
71 | + * The Components an extended template is made of |
|
72 | + * |
|
73 | + * @var \Smarty_Template_Source[] |
|
74 | + */ |
|
75 | + public $components = null; |
|
76 | + |
|
77 | + /** |
|
78 | + * Resource Handler |
|
79 | + * |
|
80 | + * @var \Smarty_Resource |
|
81 | + */ |
|
82 | + public $handler = null; |
|
83 | + |
|
84 | + /** |
|
85 | + * Smarty instance |
|
86 | + * |
|
87 | + * @var Smarty |
|
88 | + */ |
|
89 | + public $smarty = null; |
|
90 | + |
|
91 | + /** |
|
92 | + * Resource is source |
|
93 | + * |
|
94 | + * @var bool |
|
95 | + */ |
|
96 | + public $isConfig = false; |
|
97 | + |
|
98 | + /** |
|
99 | + * Template source content eventually set by default handler |
|
100 | + * |
|
101 | + * @var string |
|
102 | + */ |
|
103 | + public $content = null; |
|
104 | + |
|
105 | + /** |
|
106 | + * Name of the Class to compile this resource's contents with |
|
107 | + * |
|
108 | + * @var string |
|
109 | + */ |
|
110 | + public $compiler_class = 'Smarty_Internal_SmartyTemplateCompiler'; |
|
111 | + |
|
112 | + /** |
|
113 | + * Name of the Class to tokenize this resource's contents with |
|
114 | + * |
|
115 | + * @var string |
|
116 | + */ |
|
117 | + public $template_lexer_class = 'Smarty_Internal_Templatelexer'; |
|
118 | + |
|
119 | + /** |
|
120 | + * Name of the Class to parse this resource's contents with |
|
121 | + * |
|
122 | + * @var string |
|
123 | + */ |
|
124 | + public $template_parser_class = 'Smarty_Internal_Templateparser'; |
|
125 | + |
|
126 | + /** |
|
127 | + * create Source Object container |
|
128 | + * |
|
129 | + * @param Smarty_Resource $handler Resource Handler this source object communicates with |
|
130 | + * @param Smarty $smarty Smarty instance this source object belongs to |
|
131 | + * @param string $resource full template_resource |
|
132 | + * @param string $type type of resource |
|
133 | + * @param string $name resource name |
|
134 | + * |
|
135 | + */ |
|
136 | + public function __construct(Smarty $smarty, $resource, $type, $name) |
|
137 | + { |
|
138 | + $this->handler = |
|
139 | + isset($smarty->_cache[ 'resource_handlers' ][ $type ]) ? $smarty->_cache[ 'resource_handlers' ][ $type ] : |
|
140 | + Smarty_Resource::load($smarty, $type); |
|
141 | + $this->smarty = $smarty; |
|
142 | + $this->resource = $resource; |
|
143 | + $this->type = $type; |
|
144 | + $this->name = $name; |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * initialize Source Object for given resource |
|
149 | + * Either [$_template] or [$smarty, $template_resource] must be specified |
|
150 | + * |
|
151 | + * @param Smarty_Internal_Template $_template template object |
|
152 | + * @param Smarty $smarty smarty object |
|
153 | + * @param string $template_resource resource identifier |
|
154 | + * |
|
155 | + * @return Smarty_Template_Source Source Object |
|
156 | + * @throws SmartyException |
|
157 | + */ |
|
158 | + public static function load(Smarty_Internal_Template $_template = null, Smarty $smarty = null, |
|
159 | + $template_resource = null) |
|
160 | + { |
|
161 | + if ($_template) { |
|
162 | + $smarty = $_template->smarty; |
|
163 | + $template_resource = $_template->template_resource; |
|
164 | + } |
|
165 | + if (empty($template_resource)) { |
|
166 | + throw new SmartyException('Source: Missing name'); |
|
167 | + } |
|
168 | + // parse resource_name, load resource handler, identify unique resource name |
|
169 | + if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]([\s\S]*)$/', $template_resource, $match)) { |
|
170 | + $type = $match[ 1 ]; |
|
171 | + $name = $match[ 2 ]; |
|
172 | + } else { |
|
173 | + // no resource given, use default |
|
174 | + // or single character before the colon is not a resource type, but part of the filepath |
|
175 | + $type = $smarty->default_resource_type; |
|
176 | + $name = $template_resource; |
|
177 | + } |
|
178 | + // create new source object |
|
179 | + $source = new Smarty_Template_Source($smarty, $template_resource, $type, $name); |
|
180 | + $source->handler->populate($source, $_template); |
|
181 | + if (!$source->exists && isset($_template->smarty->default_template_handler_func)) { |
|
182 | + Smarty_Internal_Method_RegisterDefaultTemplateHandler::_getDefaultTemplate($source); |
|
183 | + $source->handler->populate($source, $_template); |
|
184 | + } |
|
185 | + return $source; |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Get source time stamp |
|
190 | + * |
|
191 | + * @return int |
|
192 | + */ |
|
193 | + public function getTimeStamp() |
|
194 | + { |
|
195 | + if (!isset($this->timestamp)) { |
|
196 | + $this->handler->populateTimestamp($this); |
|
197 | + } |
|
198 | + return $this->timestamp; |
|
199 | + } |
|
200 | + |
|
201 | + /** |
|
202 | + * Get source content |
|
203 | + * |
|
204 | + * @return string |
|
205 | + */ |
|
206 | + public function getContent() |
|
207 | + { |
|
208 | + return isset($this->content) ? $this->content : $this->handler->getContent($this); |
|
209 | + } |
|
210 | 210 | } |
@@ -136,8 +136,7 @@ discard block |
||
136 | 136 | public function __construct(Smarty $smarty, $resource, $type, $name) |
137 | 137 | { |
138 | 138 | $this->handler = |
139 | - isset($smarty->_cache[ 'resource_handlers' ][ $type ]) ? $smarty->_cache[ 'resource_handlers' ][ $type ] : |
|
140 | - Smarty_Resource::load($smarty, $type); |
|
139 | + isset($smarty->_cache['resource_handlers'][$type]) ? $smarty->_cache['resource_handlers'][$type] : Smarty_Resource::load($smarty, $type); |
|
141 | 140 | $this->smarty = $smarty; |
142 | 141 | $this->resource = $resource; |
143 | 142 | $this->type = $type; |
@@ -167,8 +166,8 @@ discard block |
||
167 | 166 | } |
168 | 167 | // parse resource_name, load resource handler, identify unique resource name |
169 | 168 | if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]([\s\S]*)$/', $template_resource, $match)) { |
170 | - $type = $match[ 1 ]; |
|
171 | - $name = $match[ 2 ]; |
|
169 | + $type = $match[1]; |
|
170 | + $name = $match[2]; |
|
172 | 171 | } else { |
173 | 172 | // no resource given, use default |
174 | 173 | // or single character before the colon is not a resource type, but part of the filepath |
@@ -611,6 +611,7 @@ discard block |
||
611 | 611 | * @param integer $id - accountid |
612 | 612 | * @param array $parent_accounts - Array of all the parent accounts |
613 | 613 | * returns All the parent accounts of the given accountid in array format |
614 | + * @param integer[] $encountered_accounts |
|
614 | 615 | */ |
615 | 616 | public function __getParentAccounts($id, &$parent_accounts, &$encountered_accounts, $depthBase = 0) |
616 | 617 | { |
@@ -673,7 +674,7 @@ discard block |
||
673 | 674 | * Function to Recursively get all the child accounts of a given Account |
674 | 675 | * @param integer $id - accountid |
675 | 676 | * @param array $child_accounts - Array of all the child accounts |
676 | - * @param integer $depth - Depth at which the particular account has to be placed in the hierarchy |
|
677 | + * @param integer $depthBase - Depth at which the particular account has to be placed in the hierarchy |
|
677 | 678 | * returns All the child accounts of the given accountid in array format |
678 | 679 | */ |
679 | 680 | public function __getChildAccounts($id, &$child_accounts, $depthBase) |
@@ -113,10 +113,11 @@ discard block |
||
113 | 113 | $query .= $this->getNonAdminAccessControlQuery('Accounts', $current_user); |
114 | 114 | $where_auto = " vtiger_crmentity.deleted = 0 "; |
115 | 115 | |
116 | - if ($where != '') |
|
117 | - $query .= sprintf(' where (%s) && %s', $where, $where_auto); |
|
118 | - else |
|
119 | - $query .= sprintf(' where %s', $where_auto); |
|
116 | + if ($where != '') { |
|
117 | + $query .= sprintf(' where (%s) && %s', $where, $where_auto); |
|
118 | + } else { |
|
119 | + $query .= sprintf(' where %s', $where_auto); |
|
120 | + } |
|
120 | 121 | |
121 | 122 | \App\Log::trace("Exiting create_export_query method ..."); |
122 | 123 | return $query; |
@@ -435,8 +436,9 @@ discard block |
||
435 | 436 | public function unlinkRelationship($id, $return_module, $return_id, $relatedName = false) |
436 | 437 | { |
437 | 438 | |
438 | - if (empty($return_module) || empty($return_id)) |
|
439 | - return; |
|
439 | + if (empty($return_module) || empty($return_id)) { |
|
440 | + return; |
|
441 | + } |
|
440 | 442 | |
441 | 443 | if ($return_module == 'Campaigns') { |
442 | 444 | $this->db->delete('vtiger_campaign_records', 'crmid=? && campaignid=?', [$id, $return_id]); |
@@ -451,8 +453,9 @@ discard block |
||
451 | 453 | public function save_related_module($module, $crmid, $with_module, $with_crmids, $relatedName = false) |
452 | 454 | { |
453 | 455 | $db = PearDatabase::getInstance(); |
454 | - if (!is_array($with_crmids)) |
|
455 | - $with_crmids = [$with_crmids]; |
|
456 | + if (!is_array($with_crmids)) { |
|
457 | + $with_crmids = [$with_crmids]; |
|
458 | + } |
|
456 | 459 | if (!in_array($with_module, ['Products', 'Campaigns'])) { |
457 | 460 | parent::save_related_module($module, $crmid, $with_module, $with_crmids, $relatedName); |
458 | 461 | } else { |
@@ -502,10 +505,12 @@ discard block |
||
502 | 505 | continue; |
503 | 506 | } |
504 | 507 | // Setup the default JOIN conditions if not specified |
505 | - if (empty($relmap[1])) |
|
506 | - $relmap[1] = $other->table_name; |
|
507 | - if (empty($relmap[2])) |
|
508 | - $relmap[2] = $relmap[0]; |
|
508 | + if (empty($relmap[1])) { |
|
509 | + $relmap[1] = $other->table_name; |
|
510 | + } |
|
511 | + if (empty($relmap[2])) { |
|
512 | + $relmap[2] = $relmap[0]; |
|
513 | + } |
|
509 | 514 | $join .= " LEFT JOIN $tname ON $tname.$relmap[0] = $relmap[1].$relmap[2]"; |
510 | 515 | } |
511 | 516 | } |
@@ -530,14 +535,16 @@ discard block |
||
530 | 535 | public function getRelatedContactsIds($id = null) |
531 | 536 | { |
532 | 537 | |
533 | - if ($id === null) |
|
534 | - $id = $this->id; |
|
538 | + if ($id === null) { |
|
539 | + $id = $this->id; |
|
540 | + } |
|
535 | 541 | $query = (new \App\Db\Query())->select('contactid')->from('vtiger_contactdetails') |
536 | 542 | ->innerJoin('vtiger_crmentity', 'vtiger_contactdetails.contactid = vtiger_crmentity.crmid') |
537 | 543 | ->where(['vtiger_contactdetails.parentid' => $id, 'vtiger_crmentity.deleted' => 0]); |
538 | 544 | $entityIds = $query->column(); |
539 | - if (empty($entityIds)) |
|
540 | - $entityIds = []; |
|
545 | + if (empty($entityIds)) { |
|
546 | + $entityIds = []; |
|
547 | + } |
|
541 | 548 | |
542 | 549 | return $entityIds; |
543 | 550 | } |
@@ -36,6 +36,9 @@ |
||
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | + /** |
|
40 | + * @param Vtiger_Widget_Model $widget |
|
41 | + */ |
|
39 | 42 | public function getData(Vtiger_Request $request, $widget) |
40 | 43 | { |
41 | 44 | $db = PearDatabase::getInstance(); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @param $userid -- The user Id:: Type integer |
57 | 57 | * @param $from_datetime -- The start date Obj :: Type Array |
58 | 58 | * @param $to_datetime -- The end date Obj :: Type Array |
59 | - * @param $view -- The calendar view :: Type String |
|
59 | + * @param string $view -- The calendar view :: Type String |
|
60 | 60 | * @returns $list :: Type Array |
61 | 61 | */ |
62 | 62 | public function readAppointment($userid, &$from_datetime, &$to_datetime, $view) |
@@ -286,6 +286,9 @@ discard block |
||
286 | 286 | return ($a->start_time->ts < $b->start_time->ts) ? -1 : 1; |
287 | 287 | } |
288 | 288 | |
289 | +/** |
|
290 | + * @param string $fldname |
|
291 | + */ |
|
289 | 292 | function getRoleBasesdPickList($fldname, $exist_val) |
290 | 293 | { |
291 | 294 | $adb = PearDatabase::getInstance(); |
@@ -222,13 +222,15 @@ discard block |
||
222 | 222 | $que = "select * from vtiger_sharedcalendar where sharedid=? and userid=?"; |
223 | 223 | $row = $adb->pquery($que, array($currentUser->id, $act_array["smownerid"])); |
224 | 224 | $no = $adb->getRowCount($row); |
225 | - if ($no > 0) |
|
226 | - $this->shared = true; |
|
225 | + if ($no > 0) { |
|
226 | + $this->shared = true; |
|
227 | + } |
|
227 | 228 | } |
228 | 229 | } |
229 | 230 | $this->image_name = $act_array["activitytype"] . ".gif"; |
230 | - if (!empty($act_array["recurringid"]) && !empty($act_array["recurringtype"])) |
|
231 | - $this->recurring = "Recurring.gif"; |
|
231 | + if (!empty($act_array["recurringid"]) && !empty($act_array["recurringtype"])) { |
|
232 | + $this->recurring = "Recurring.gif"; |
|
233 | + } |
|
232 | 234 | |
233 | 235 | $this->record = $act_array["activityid"]; |
234 | 236 | $date = new DateTimeField($act_array["date_start"] . ' ' . $act_array['time_start']); |
@@ -296,8 +298,9 @@ discard block |
||
296 | 298 | $roleid = $currentUser->roleid; |
297 | 299 | $roleids = Array(); |
298 | 300 | $subrole = getRoleSubordinates($roleid); |
299 | - if (count($subrole) > 0) |
|
300 | - $roleids = $subrole; |
|
301 | + if (count($subrole) > 0) { |
|
302 | + $roleids = $subrole; |
|
303 | + } |
|
301 | 304 | array_push($roleids, $roleid); |
302 | 305 | |
303 | 306 | //here we are checking wheather the table contains the sortorder column .If sortorder is present in the main picklist table, then the role2picklist will be applicable for this table... |
@@ -311,12 +314,14 @@ discard block |
||
311 | 314 | $res_val = $adb->pquery($pick_query, array($roleids)); |
312 | 315 | $num_val = $adb->num_rows($res_val); |
313 | 316 | } |
314 | - if ($num_val > 0) |
|
317 | + if ($num_val > 0) { |
|
318 | + $pick_val = $exist_val; |
|
319 | + } else { |
|
320 | + $pick_val = \App\Language::translate('LBL_NOT_ACCESSIBLE'); |
|
321 | + } |
|
322 | + } else { |
|
315 | 323 | $pick_val = $exist_val; |
316 | - else |
|
317 | - $pick_val = \App\Language::translate('LBL_NOT_ACCESSIBLE'); |
|
318 | - } else |
|
319 | - $pick_val = $exist_val; |
|
324 | + } |
|
320 | 325 | |
321 | 326 | return $pick_val; |
322 | 327 | } |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | |
385 | 385 | /** |
386 | 386 | * |
387 | - * @return Date |
|
387 | + * @return string |
|
388 | 388 | */ |
389 | 389 | public function get_DB_formatted_date() |
390 | 390 | { |
@@ -529,10 +529,6 @@ discard block |
||
529 | 529 | * This should be used whereever possible |
530 | 530 | * |
531 | 531 | * @param integer $index - number between 0 to 42 |
532 | - * @param string $day - date |
|
533 | - * @param string $month - month |
|
534 | - * @param string $year - year |
|
535 | - * return vt_DateTime obj $datetimevalue |
|
536 | 532 | */ |
537 | 533 | public function getThisMonthsDayByIndex($index) |
538 | 534 | { |
@@ -87,12 +87,15 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function getTodayDatetimebyIndex($index, $day = '', $month = '', $year = '') |
89 | 89 | { |
90 | - if ($day === '') |
|
91 | - $day = $this->day; |
|
92 | - if ($month === '') |
|
93 | - $month = $this->month; |
|
94 | - if ($year === '') |
|
95 | - $year = $this->year; |
|
90 | + if ($day === '') { |
|
91 | + $day = $this->day; |
|
92 | + } |
|
93 | + if ($month === '') { |
|
94 | + $month = $this->month; |
|
95 | + } |
|
96 | + if ($year === '') { |
|
97 | + $year = $this->year; |
|
98 | + } |
|
96 | 99 | $day_array = array(); |
97 | 100 | |
98 | 101 | if ($index < 0 || $index > 23) { |
@@ -140,12 +143,15 @@ discard block |
||
140 | 143 | */ |
141 | 144 | public function getThismonthDaysbyIndex($index, $day = '', $month = '', $year = '') |
142 | 145 | { |
143 | - if ($day == '') |
|
144 | - $day = $index + 1; |
|
145 | - if ($month == '') |
|
146 | - $month = $this->month; |
|
147 | - if ($year == '') |
|
148 | - $year = $this->year; |
|
146 | + if ($day == '') { |
|
147 | + $day = $index + 1; |
|
148 | + } |
|
149 | + if ($month == '') { |
|
150 | + $month = $this->month; |
|
151 | + } |
|
152 | + if ($year == '') { |
|
153 | + $year = $this->year; |
|
154 | + } |
|
149 | 155 | $month_array = array(); |
150 | 156 | $month_array['day'] = $day; |
151 | 157 | $month_array['month'] = $month; |
@@ -356,8 +362,9 @@ discard block |
||
356 | 362 | } else { |
357 | 363 | die("year was not set"); |
358 | 364 | } |
359 | - if (empty($hour) && $hour !== 0) |
|
360 | - $hour = 0; |
|
365 | + if (empty($hour) && $hour !== 0) { |
|
366 | + $hour = 0; |
|
367 | + } |
|
361 | 368 | $this->ts = mktime($hour, $minute, $second, $month, $day, $year); |
362 | 369 | $this->setDateTime($this->ts); |
363 | 370 | } |
@@ -399,10 +406,12 @@ discard block |
||
399 | 406 | { |
400 | 407 | $hour = $this->z_hour; |
401 | 408 | $min = $this->minute; |
402 | - if (empty($hour)) |
|
403 | - $hour = '00'; |
|
404 | - if (empty($min)) |
|
405 | - $min = '00'; |
|
409 | + if (empty($hour)) { |
|
410 | + $hour = '00'; |
|
411 | + } |
|
412 | + if (empty($min)) { |
|
413 | + $min = '00'; |
|
414 | + } |
|
406 | 415 | return $hour . ':' . $min; |
407 | 416 | } |
408 | 417 | |
@@ -413,10 +422,11 @@ discard block |
||
413 | 422 | */ |
414 | 423 | public function get_changed_day($mode) |
415 | 424 | { |
416 | - if ($mode == 'increment') |
|
417 | - $day = $this->day + 1; |
|
418 | - else |
|
419 | - $day = $this->day - 1; |
|
425 | + if ($mode == 'increment') { |
|
426 | + $day = $this->day + 1; |
|
427 | + } else { |
|
428 | + $day = $this->day - 1; |
|
429 | + } |
|
420 | 430 | $date_data = array('day' => $day, |
421 | 431 | 'month' => $this->month, |
422 | 432 | 'year' => $this->year |
@@ -432,10 +442,11 @@ discard block |
||
432 | 442 | public function get_first_day_of_changed_week($mode) |
433 | 443 | { |
434 | 444 | $first_day = $this->getThisweekDaysbyIndex(1); |
435 | - if ($mode == 'increment') |
|
436 | - $day = $first_day->day + 7; |
|
437 | - else |
|
438 | - $day = $first_day->day - 7; |
|
445 | + if ($mode == 'increment') { |
|
446 | + $day = $first_day->day + 7; |
|
447 | + } else { |
|
448 | + $day = $first_day->day - 7; |
|
449 | + } |
|
439 | 450 | $date_data = array('day' => $day, |
440 | 451 | 'month' => $first_day->month, |
441 | 452 | 'year' => $first_day->year |