86 $this->_db_qstr_regexp =
'"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"';
91 $this->_si_qstr_regexp =
'\'[^\
'\\\\]*(?:\\\\.[^\'\\\\]*)*\'';
94 $this->_qstr_regexp =
'(?:' . $this->_db_qstr_regexp .
'|' . $this->_si_qstr_regexp .
')';
100 $this->_var_bracket_regexp =
'\[\$?[\w\.]+\]';
106 $this->_num_const_regexp =
'(?:\-?\d+(?:\.\d+)?)';
116 $this->_dvar_math_regexp =
'(?:[\+\*\/\%]|(?:-(?!>)))';
117 $this->_dvar_math_var_regexp =
'[\$\w\.\+\-\*\/\%\d>\[\]]';
118 $this->_dvar_guts_regexp =
'\w+(?:' . $this->_var_bracket_regexp
119 .
')*(?:\.\$?\w+(?:' . $this->_var_bracket_regexp .
')*)*(?:' . $this->_dvar_math_regexp .
'(?:' . $this->_num_const_regexp .
'|' . $this->_dvar_math_var_regexp .
')*)?';
125 $this->_cvar_regexp =
'\#\w+\#';
129 $this->_svar_regexp =
'\%\w+\.\w+\%';
132 $this->_avar_regexp =
'(?:' . $this->_dvar_regexp .
'|'
133 . $this->_cvar_regexp .
'|' . $this->_svar_regexp .
')';
142 $this->_var_regexp =
'(?:' . $this->_avar_regexp .
'|' . $this->_qstr_regexp .
')';
155 $this->_obj_ext_regexp =
'\->(?:\$?' . $this->_dvar_guts_regexp .
')';
156 $this->_obj_restricted_param_regexp =
'(?:'
157 .
'(?:' . $this->_var_regexp .
'|' . $this->_num_const_regexp .
')(?:' . $this->_obj_ext_regexp .
'(?:\((?:(?:' . $this->_var_regexp .
'|' . $this->_num_const_regexp .
')'
158 .
'(?:\s*,\s*(?:' . $this->_var_regexp .
'|' . $this->_num_const_regexp .
'))*)?\))?)*)';
159 $this->_obj_single_param_regexp =
'(?:\w+|' . $this->_obj_restricted_param_regexp .
'(?:\s*,\s*(?:(?:\w+|'
160 . $this->_var_regexp . $this->_obj_restricted_param_regexp .
')))*)';
161 $this->_obj_params_regexp =
'\((?:' . $this->_obj_single_param_regexp
162 .
'(?:\s*,\s*' . $this->_obj_single_param_regexp .
')*)?\)';
163 $this->_obj_start_regexp =
'(?:' . $this->_dvar_regexp .
'(?:' . $this->_obj_ext_regexp .
')+)';
164 $this->_obj_call_regexp =
'(?:' . $this->_obj_start_regexp .
'(?:' . $this->_obj_params_regexp .
')?(?:' . $this->_dvar_math_regexp .
'(?:' . $this->_num_const_regexp .
'|' . $this->_dvar_math_var_regexp .
')*)?)';
174 $this->_mod_regexp =
'(?:\|@?\w+(?::(?:\w+|' . $this->_num_const_regexp .
'|'
175 . $this->_obj_call_regexp .
'|' . $this->_avar_regexp .
'|' . $this->_qstr_regexp .
'))*)';
180 $this->_func_regexp =
'[a-zA-Z_]\w*';
184 $this->_reg_obj_regexp =
'[a-zA-Z_]\w*->[a-zA-Z_]\w*';
195 $this->_param_regexp =
'(?:\s*(?:' . $this->_obj_call_regexp .
'|'
196 . $this->_var_regexp .
'|' . $this->_num_const_regexp .
'|\w+)(?>' . $this->_mod_regexp .
'*)\s*)';
203 $this->_parenth_param_regexp =
'(?:\((?:\w+|'
204 . $this->_param_regexp .
'(?:\s*,\s*(?:(?:\w+|'
205 . $this->_param_regexp .
')))*)?\))';
212 $this->_func_call_regexp =
'(?:' . $this->_func_regexp .
'\s*(?:'
213 . $this->_parenth_param_regexp .
'))';
228 if ($this->security) {
231 !$this->security_settings[
'PHP_HANDLING']) {
238 $this->_current_file = $resource_name;
239 $this->_current_line_no = 1;
240 $ldq = preg_quote($this->left_delimiter,
'~');
241 $rdq = preg_quote($this->right_delimiter,
'~');
244 if (count($this->_plugins[
'prefilter']) > 0) {
245 foreach ($this->_plugins[
'prefilter'] as $filter_name => $prefilter) {
246 if ($prefilter ===
false)
continue;
247 if ($prefilter[3] || is_callable($prefilter[0])) {
248 $source_content = call_user_func_array($prefilter[0],
249 array($source_content, &$this));
250 $this->_plugins[
'prefilter'][$filter_name][3] =
true;
258 $search =
"~{$ldq}\*(.*?)\*{$rdq}|{$ldq}\s*literal\s*{$rdq}(.*?){$ldq}\s*/literal\s*{$rdq}|{$ldq}\s*php\s*{$rdq}(.*?){$ldq}\s*/php\s*{$rdq}~s";
260 preg_match_all($search, $source_content, $match, PREG_SET_ORDER);
261 $this->_folded_blocks = $match;
262 reset($this->_folded_blocks);
265 $source_content = preg_replace($search.
'e',
"'"
266 . $this->_quote_replace($this->left_delimiter) .
'php'
267 .
"' . str_repeat(\"\n\", substr_count('\\0', \"\n\")) .'"
273 preg_match_all(
"~{$ldq}\s*(.*?)\s*{$rdq}~s", $source_content, $_match);
274 $template_tags = $_match[1];
276 $text_blocks = preg_split(
"~{$ldq}.*?{$rdq}~s", $source_content);
279 for ($curr_tb = 0, $for_max = count($text_blocks); $curr_tb < $for_max; $curr_tb++) {
281 if (preg_match_all(
'~(<\?(?:\w+|=)?|\?>|language\s*=\s*[\"\']?\s*php\s*[\"\']?)~is', $text_blocks[$curr_tb], $sp_match)) {
283 $sp_match[1] = array_unique($sp_match[1]);
284 usort($sp_match[1],
'_smarty_sort_length');
285 for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) {
286 $text_blocks[$curr_tb] = str_replace($sp_match[1][$curr_sp],
'%%%SMARTYSP'.$curr_sp.
'%%%',$text_blocks[$curr_tb]);
289 for ($curr_sp = 0, $for_max2 = count($sp_match[1]); $curr_sp < $for_max2; $curr_sp++) {
292 $text_blocks[$curr_tb] = str_replace(
'%%%SMARTYSP'.$curr_sp.
'%%%',
'<?php echo \''.str_replace(
"'",
"\'", $sp_match[1][$curr_sp]).
'\'; ?>
'."\n", $text_blocks[$curr_tb]);
293 } else if ($this->php_handling == SMARTY_PHP_QUOTE) {
295 $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP
'.$curr_sp.'%%%
', htmlspecialchars($sp_match[1][$curr_sp]), $text_blocks[$curr_tb]);
296 } else if ($this->php_handling == SMARTY_PHP_REMOVE) {
297 /* remove php tags */
298 $text_blocks[$curr_tb] = str_replace('%%%SMARTYSP
'.$curr_sp.'%%%
', '', $text_blocks[$curr_tb]);
300 /* SMARTY_PHP_ALLOW, but echo non php starting tags */
301 $sp_match[1][$curr_sp] = preg_replace('~(<\?(?!php|=|$))~i
', '<?php echo \
'\\1\'?>'.
"\n", $sp_match[1][$curr_sp]);
302 $text_blocks[$curr_tb] = str_replace(
'%%%SMARTYSP'.$curr_sp.
'%%%', $sp_match[1][$curr_sp], $text_blocks[$curr_tb]);
309 $compiled_tags = array();
310 for (
$i = 0, $for_max = count($template_tags);
$i < $for_max;
$i++) {
311 $this->_current_line_no += substr_count($text_blocks[
$i],
"\n");
312 $compiled_tags[] = $this->
_compile_tag($template_tags[$i]);
313 $this->_current_line_no += substr_count($template_tags[$i],
"\n");
315 if (count($this->_tag_stack)>0) {
316 list($_open_tag, $_line_no) = end($this->_tag_stack);
317 $this->
_syntax_error(
"unclosed tag \{$_open_tag} (opened line $_line_no).", E_USER_ERROR, __FILE__, __LINE__);
324 for (
$i = 0, $for_max = count($compiled_tags);
$i < $for_max;
$i++) {
325 if ($compiled_tags[
$i] ==
'{strip}') {
326 $compiled_tags[
$i] =
'';
329 $text_blocks[
$i + 1] = ltrim($text_blocks[
$i + 1]);
333 for (
$j =
$i + 1;
$j < $for_max;
$j++) {
335 $text_blocks[
$j] = preg_replace(
'![\t ]*[\r\n]+[\t ]*!',
'', $text_blocks[
$j]);
336 if ($compiled_tags[$j] ==
'{/strip}') {
338 $text_blocks[
$j] = rtrim($text_blocks[$j]);
340 $text_blocks[
$j] =
"<?php echo '" . strtr($text_blocks[$j], array(
"'"=>
"\'",
"\\"=>
"\\\\")) .
"'; ?>";
341 if ($compiled_tags[$j] ==
'{/strip}') {
342 $compiled_tags[
$j] =
"\n";
351 $compiled_content =
'';
353 $tag_guard =
'%%%SMARTYOTG' . md5(uniqid(rand(),
true)) .
'%%%';
356 for (
$i = 0, $for_max = count($compiled_tags);
$i < $for_max;
$i++) {
357 if ($compiled_tags[
$i] ==
'') {
359 $text_blocks[
$i+1] = preg_replace(
'~^(\r\n|\r|\n)~',
'', $text_blocks[
$i+1]);
362 $text_blocks[
$i] = str_replace(
'<?', $tag_guard, $text_blocks[
$i]);
363 $compiled_tags[
$i] = str_replace(
'<?', $tag_guard, $compiled_tags[$i]);
365 $compiled_content .= $text_blocks[
$i] . $compiled_tags[
$i];
367 $compiled_content .= str_replace(
'<?', $tag_guard, $text_blocks[
$i]);
370 $compiled_content = str_replace(
'<?',
"<?php echo '<?' ?>\n", $compiled_content);
371 $compiled_content = preg_replace(
"~(?<!')language\s*=\s*[\"\']?\s*php\s*[\"\']?~",
"<?php echo 'language=php' ?>\n", $compiled_content);
374 $compiled_content = str_replace($tag_guard,
'<?', $compiled_content);
377 if (strlen($compiled_content) && (substr($compiled_content, -1) ==
"\n") ) {
378 $compiled_content = substr($compiled_content, 0, -1);
381 if (!empty($this->_cache_serial)) {
382 $compiled_content =
"<?php \$this->_cache_serials['".$this->_cache_include.
"'] = '".$this->_cache_serial.
"'; ?>" . $compiled_content;
386 if (count($this->_plugins[
'postfilter']) > 0) {
387 foreach ($this->_plugins[
'postfilter'] as $filter_name => $postfilter) {
388 if ($postfilter ===
false)
continue;
389 if ($postfilter[3] || is_callable($postfilter[0])) {
390 $compiled_content = call_user_func_array($postfilter[0],
391 array($compiled_content, &$this));
392 $this->_plugins[
'postfilter'][$filter_name][3] =
true;
394 $this->
_trigger_fatal_error(
"Smarty plugin error: postfilter '$filter_name' is not implemented");
400 $template_header =
"<?php /* Smarty version ".$this->_version.
", created on ".strftime(
"%Y-%m-%d %H:%M:%S").
"\n";
401 $template_header .=
" compiled from ".strtr(urlencode($resource_name), array(
'%2F'=>
'/',
'%3A'=>
':')).
" */ ?>\n";
404 $this->_plugins_code =
'';
405 if (count($this->_plugin_info)) {
406 $_plugins_params =
"array('plugins' => array(";
407 foreach ($this->_plugin_info as $plugin_type => $plugins) {
408 foreach ($plugins as $plugin_name => $plugin_info) {
409 $_plugins_params .=
"array('$plugin_type', '$plugin_name', '" . strtr($plugin_info[0], array(
"'" =>
"\\'",
"\\" =>
"\\\\")) .
"', $plugin_info[1], ";
410 $_plugins_params .= $plugin_info[2] ?
'true),' :
'false),';
413 $_plugins_params .=
'))';
414 $plugins_code =
"<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');\nsmarty_core_load_plugins($_plugins_params, \$this); ?>\n";
415 $template_header .= $plugins_code;
416 $this->_plugin_info = array();
417 $this->_plugins_code = $plugins_code;
420 if ($this->_init_smarty_vars) {
421 $template_header .=
"<?php require_once(SMARTY_CORE_DIR . 'core.assign_smarty_interface.php');\nsmarty_core_assign_smarty_interface(null, \$this); ?>\n";
422 $this->_init_smarty_vars =
false;
425 $compiled_content = $template_header . $compiled_content;
438 if (substr($template_tag, 0, 1) ==
'*' && substr($template_tag, -1) ==
'*')
442 if(! preg_match(
'~^(?:(' . $this->_num_const_regexp .
'|' . $this->_obj_call_regexp .
'|' . $this->_var_regexp
443 .
'|\/?' . $this->_reg_obj_regexp .
'|\/?' . $this->_func_regexp .
')(' . $this->_mod_regexp .
'*))
445 ~xs', $template_tag, $match)) {
446 $this->
_syntax_error(
"unrecognized tag: $template_tag", E_USER_ERROR, __FILE__, __LINE__);
449 $tag_command = $match[1];
450 $tag_modifier = isset($match[2]) ? $match[2] : null;
451 $tag_args = isset($match[3]) ? $match[3] : null;
453 if (preg_match(
'~^' . $this->_num_const_regexp .
'|' . $this->_obj_call_regexp .
'|' . $this->_var_regexp .
'$~', $tag_command)) {
460 if (preg_match(
'~^\/?' . $this->_reg_obj_regexp .
'$~', $tag_command)) {
464 switch ($tag_command) {
476 list($_open_tag) = end($this->_tag_stack);
477 if ($_open_tag !=
'if' && $_open_tag !=
'elseif')
478 $this->
_syntax_error(
'unexpected {else}', E_USER_ERROR, __FILE__, __LINE__);
481 return '<?php else: ?>';
484 list($_open_tag) = end($this->_tag_stack);
485 if ($_open_tag !=
'if' && $_open_tag !=
'elseif')
486 $this->
_syntax_error(
'unexpected {elseif}', E_USER_ERROR, __FILE__, __LINE__);
487 if ($_open_tag ==
'if')
493 return '<?php endif; ?>';
513 return "<?php endfor; else: ?>";
517 $_open_tag = $this->
_pop_tag(
'section');
518 if ($_open_tag ==
'sectionelse')
519 return "<?php endif; ?>";
521 return "<?php endfor; endif; ?>";
530 return "<?php endforeach; else: ?>";
533 $_open_tag = $this->
_pop_tag(
'foreach');
534 if ($_open_tag ==
'foreachelse')
535 return "<?php endif; unset(\$_from); ?>";
537 return "<?php endforeach; endif; unset(\$_from); ?>";
542 if (substr($tag_command, 0, 1)==
'/') {
544 if (--$this->_strip_depth==0) {
545 $this->_additional_newline =
"\n";
546 return '{' . $tag_command .
'}';
550 if ($this->_strip_depth++==0) {
551 $this->_additional_newline =
"";
552 return '{' . $tag_command .
'}';
559 list(, $block) = each($this->_folded_blocks);
560 $this->_current_line_no += substr_count($block[0],
"\n");
563 switch (count($block)) {
571 if ($this->security && !$this->security_settings[
'PHP_TAGS']) {
572 $this->
_syntax_error(
"(secure mode) php tags not permitted", E_USER_WARNING, __FILE__, __LINE__);
575 return '<?php ' . $block[3] .
' ?>';
585 }
else if ($this->
_compile_block_tag($tag_command, $tag_args, $tag_modifier, $output)) {
590 $this->
_syntax_error(
"unrecognized tag '$tag_command'", E_USER_ERROR, __FILE__, __LINE__);
609 $have_function =
true;
615 if (isset($this->_plugins[
'compiler'][$tag_command])) {
617 $plugin_func = $this->_plugins[
'compiler'][$tag_command][0];
618 if (!is_callable($plugin_func)) {
619 $message =
"compiler function '$tag_command' is not implemented";
620 $have_function =
false;
630 include_once $plugin_file;
632 $plugin_func =
'smarty_compiler_' . $tag_command;
633 if (!is_callable($plugin_func)) {
634 $message =
"plugin function $plugin_func() not found in $plugin_file\n";
635 $have_function =
false;
637 $this->_plugins[
'compiler'][$tag_command] = array($plugin_func, null, null, null,
true);
648 if ($have_function) {
649 $output = call_user_func_array($plugin_func, array($tag_args, &$this));
656 $this->
_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);
677 if (substr($tag_command, 0, 1) ==
'/') {
679 $tag_command = substr($tag_command, 1);
684 $have_function =
true;
690 if (isset($this->_plugins[
'block'][$tag_command])) {
692 $plugin_func = $this->_plugins[
'block'][$tag_command][0];
693 if (!is_callable($plugin_func)) {
694 $message =
"block function '$tag_command' is not implemented";
695 $have_function =
false;
705 include_once $plugin_file;
707 $plugin_func =
'smarty_block_' . $tag_command;
708 if (!function_exists($plugin_func)) {
709 $message =
"plugin function $plugin_func() not found in $plugin_file\n";
710 $have_function =
false;
712 $this->_plugins[
'block'][$tag_command] = array($plugin_func, null, null, null,
true);
719 }
else if (!$have_function) {
720 $this->
_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);
740 $arg_list = $this->
_compile_arg_list(
'block', $tag_command, $attrs, $_cache_attrs);
741 $output .=
"$_cache_attrs\$this->_tag_stack[] = array('$tag_command', array(".implode(
',', $arg_list).
')); ';
742 $output .=
'$_block_repeat=true;' . $this->
_compile_plugin_call(
'block', $tag_command).
'($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat);';
743 $output .=
'while ($_block_repeat) { ob_start(); ?>';
745 $output =
'<?php $_block_content = ob_get_contents(); ob_end_clean(); ';
746 $_out_tag_text = $this->
_compile_plugin_call(
'block', $tag_command).
'($this->_tag_stack[count($this->_tag_stack)-1][1], $_block_content, $this, $_block_repeat)';
747 if ($tag_modifier !=
'') {
750 $output .=
'$_block_repeat=false;echo ' . $_out_tag_text .
'; } ';
751 $output .=
" array_pop(\$this->_tag_stack); " . $this->
_pop_cacheable_state(
'block', $tag_command) .
'?>';
769 $have_function =
true;
775 if (isset($this->_plugins[
'function'][$tag_command])) {
777 $plugin_func = $this->_plugins[
'function'][$tag_command][0];
778 if (!is_callable($plugin_func)) {
779 $message =
"custom function '$tag_command' is not implemented";
780 $have_function =
false;
790 include_once $plugin_file;
792 $plugin_func =
'smarty_function_' . $tag_command;
793 if (!function_exists($plugin_func)) {
794 $message =
"plugin function $plugin_func() not found in $plugin_file\n";
795 $have_function =
false;
797 $this->_plugins[
'function'][$tag_command] = array($plugin_func, null, null, null,
true);
804 }
else if (!$have_function) {
805 $this->
_syntax_error($message, E_USER_WARNING, __FILE__, __LINE__);
816 $arg_list = $this->
_compile_arg_list(
'function', $tag_command, $attrs, $_cache_attrs);
818 $output = $this->
_compile_plugin_call(
'function', $tag_command).
'(array('.implode(
',', $arg_list).
"), \$this)";
819 if($tag_modifier !=
'') {
841 if (substr($tag_command, 0, 1) ==
'/') {
843 $tag_command = substr($tag_command, 1);
848 list($object, $obj_comp) = explode(
'->', $tag_command);
852 $_assign_var =
false;
853 foreach ($attrs as $arg_name => $arg_value) {
854 if($arg_name ==
'assign') {
855 $_assign_var = $arg_value;
856 unset($attrs[
'assign']);
859 if (is_bool($arg_value))
860 $arg_value = $arg_value ?
'true' :
'false';
861 $arg_list[] =
"'$arg_name' => $arg_value";
865 if($this->_reg_objects[$object][2]) {
867 $args =
"array(".implode(
',', (array)$arg_list).
"), \$this";
870 $args = implode(
',', array_values($attrs));
879 if(!is_object($this->_reg_objects[$object][0])) {
880 $this->
_trigger_fatal_error(
"registered '$object' is not an object" , $this->_current_file, $this->_current_line_no, __FILE__, __LINE__);
881 } elseif(!empty($this->_reg_objects[$object][1]) && !in_array($obj_comp, $this->_reg_objects[$object][1])) {
882 $this->
_trigger_fatal_error(
"'$obj_comp' is not a registered component of object '$object'", $this->_current_file, $this->_current_line_no, __FILE__, __LINE__);
883 } elseif(method_exists($this->_reg_objects[$object][0], $obj_comp)) {
885 if(in_array($obj_comp, $this->_reg_objects[$object][3])) {
888 $prefix =
"\$this->_tag_stack[] = array('$obj_comp', $args); ";
889 $prefix .=
"\$_block_repeat=true; \$this->_reg_objects['$object'][0]->$obj_comp(\$this->_tag_stack[count(\$this->_tag_stack)-1][1], null, \$this, \$_block_repeat); ";
890 $prefix .=
"while (\$_block_repeat) { ob_start();";
894 $prefix =
"\$_obj_block_content = ob_get_contents(); ob_end_clean(); \$_block_repeat=false;";
895 $return =
"\$this->_reg_objects['$object'][0]->$obj_comp(\$this->_tag_stack[count(\$this->_tag_stack)-1][1], \$_obj_block_content, \$this, \$_block_repeat)";
896 $postfix =
"} array_pop(\$this->_tag_stack);";
900 $return =
"\$this->_reg_objects['$object'][0]->$obj_comp($args)";
904 $return =
"\$this->_reg_objects['$object'][0]->$obj_comp";
907 if($return != null) {
908 if($tag_modifier !=
'') {
912 if(!empty($_assign_var)) {
913 $output =
"\$this->assign('" . $this->
_dequote($_assign_var) .
"', $return);";
915 $output =
'echo ' . $return .
';';
922 return '<?php ' . $prefix . $output . $postfix .
"?>" . $newline;
934 $name = $this->
_dequote($attrs[
'name']);
937 return $this->
_syntax_error(
"missing insert name", E_USER_ERROR, __FILE__, __LINE__);
940 if (!preg_match(
'~^\w+$~', $name)) {
941 return $this->
_syntax_error(
"'insert: 'name' must be an insert function name", E_USER_ERROR, __FILE__, __LINE__);
944 if (!empty($attrs[
'script'])) {
945 $delayed_loading =
true;
947 $delayed_loading =
false;
950 foreach ($attrs as $arg_name => $arg_value) {
951 if (is_bool($arg_value))
952 $arg_value = $arg_value ?
'true' :
'false';
953 $arg_list[] =
"'$arg_name' => $arg_value";
956 $this->
_add_plugin(
'insert', $name, $delayed_loading);
958 $_params =
"array('args' => array(".implode(
', ', (array)$arg_list).
"))";
960 return "<?php require_once(SMARTY_CORE_DIR . 'core.run_insert_handler.php');\necho smarty_core_run_insert_handler($_params, \$this); ?>" .
$this->_additional_newline;
974 if (empty($attrs[
'file'])) {
975 $this->
_syntax_error(
"missing 'file' attribute in include tag", E_USER_ERROR, __FILE__, __LINE__);
978 foreach ($attrs as $arg_name => $arg_value) {
979 if ($arg_name ==
'file') {
980 $include_file = $arg_value;
982 }
else if ($arg_name ==
'assign') {
983 $assign_var = $arg_value;
986 if (is_bool($arg_value))
987 $arg_value = $arg_value ?
'true' :
'false';
988 $arg_list[] =
"'$arg_name' => $arg_value";
993 if (isset($assign_var)) {
994 $output .=
"ob_start();\n";
998 "\$_smarty_tpl_vars = \$this->_tpl_vars;\n";
1001 $_params =
"array('smarty_include_tpl_file' => " . $include_file .
", 'smarty_include_vars' => array(".implode(
',', (array)$arg_list).
"))";
1002 $output .=
"\$this->_smarty_include($_params);\n" .
1003 "\$this->_tpl_vars = \$_smarty_tpl_vars;\n" .
1004 "unset(\$_smarty_tpl_vars);\n";
1006 if (isset($assign_var)) {
1007 $output .=
"\$this->assign(" . $assign_var .
", ob_get_contents()); ob_end_clean();\n";
1026 if (empty($attrs[
'file'])) {
1027 $this->
_syntax_error(
"missing 'file' attribute in include_php tag", E_USER_ERROR, __FILE__, __LINE__);
1030 $assign_var = (empty($attrs[
'assign'])) ?
'' : $this->
_dequote($attrs[
'assign']);
1031 $once_var = (empty($attrs[
'once']) || $attrs[
'once']==
'false') ?
'false' :
'true';
1033 $arg_list = array();
1034 foreach($attrs as $arg_name => $arg_value) {
1035 if($arg_name !=
'file' AND $arg_name !=
'once' AND $arg_name !=
'assign') {
1036 if(is_bool($arg_value))
1037 $arg_value = $arg_value ?
'true' :
'false';
1038 $arg_list[] =
"'$arg_name' => $arg_value";
1042 $_params =
"array('smarty_file' => " . $attrs[
'file'] .
", 'smarty_assign' => '$assign_var', 'smarty_once' => $once_var, 'smarty_include_vars' => array(".implode(
',', $arg_list).
"))";
1044 return "<?php require_once(SMARTY_CORE_DIR . 'core.smarty_include_php.php');\nsmarty_core_smarty_include_php($_params, \$this); ?>" .
$this->_additional_newline;
1057 $arg_list = array();
1060 $section_name = $attrs[
'name'];
1061 if (empty($section_name)) {
1062 $this->
_syntax_error(
"missing section name", E_USER_ERROR, __FILE__, __LINE__);
1065 $output .=
"unset(\$this->_sections[$section_name]);\n";
1066 $section_props =
"\$this->_sections[$section_name]";
1068 foreach ($attrs as $attr_name => $attr_value) {
1069 switch ($attr_name) {
1071 $output .=
"{$section_props}['loop'] = is_array(\$_loop=$attr_value) ? count(\$_loop) : max(0, (int)\$_loop); unset(\$_loop);\n";
1075 if (is_bool($attr_value))
1076 $show_attr_value = $attr_value ?
'true' :
'false';
1078 $show_attr_value =
"(bool)$attr_value";
1079 $output .=
"{$section_props}['show'] = $show_attr_value;\n";
1083 $output .=
"{$section_props}['$attr_name'] = $attr_value;\n";
1088 $output .=
"{$section_props}['$attr_name'] = (int)$attr_value;\n";
1092 $output .=
"{$section_props}['$attr_name'] = ((int)$attr_value) == 0 ? 1 : (int)$attr_value;\n";
1096 $this->
_syntax_error(
"unknown section attribute - '$attr_name'", E_USER_ERROR, __FILE__, __LINE__);
1101 if (!isset($attrs[
'show']))
1102 $output .=
"{$section_props}['show'] = true;\n";
1104 if (!isset($attrs[
'loop']))
1105 $output .=
"{$section_props}['loop'] = 1;\n";
1107 if (!isset($attrs[
'max']))
1108 $output .=
"{$section_props}['max'] = {$section_props}['loop'];\n";
1110 $output .=
"if ({$section_props}['max'] < 0)\n" .
1111 " {$section_props}['max'] = {$section_props}['loop'];\n";
1113 if (!isset($attrs[
'step']))
1114 $output .=
"{$section_props}['step'] = 1;\n";
1116 if (!isset($attrs[
'start']))
1117 $output .=
"{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n";
1119 $output .=
"if ({$section_props}['start'] < 0)\n" .
1120 " {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n" .
1122 " {$section_props}['start'] = min({$section_props}['start'], {$section_props}['step'] > 0 ? {$section_props}['loop'] : {$section_props}['loop']-1);\n";
1125 $output .=
"if ({$section_props}['show']) {\n";
1126 if (!isset($attrs[
'start']) && !isset($attrs[
'step']) && !isset($attrs[
'max'])) {
1127 $output .=
" {$section_props}['total'] = {$section_props}['loop'];\n";
1129 $output .=
" {$section_props}['total'] = min(ceil(({$section_props}['step'] > 0 ? {$section_props}['loop'] - {$section_props}['start'] : {$section_props}['start']+1)/abs({$section_props}['step'])), {$section_props}['max']);\n";
1131 $output .=
" if ({$section_props}['total'] == 0)\n" .
1132 " {$section_props}['show'] = false;\n" .
1134 " {$section_props}['total'] = 0;\n";
1136 $output .=
"if ({$section_props}['show']):\n";
1138 for ({$section_props}['index'] = {$section_props}['start'], {$section_props}['iteration'] = 1;
1139 {$section_props}['iteration'] <= {$section_props}['total'];
1140 {$section_props}['index'] += {$section_props}['step'], {$section_props}['iteration']++):\n";
1141 $output .=
"{$section_props}['rownum'] = {$section_props}['iteration'];\n";
1142 $output .=
"{$section_props}['index_prev'] = {$section_props}['index'] - {$section_props}['step'];\n";
1143 $output .=
"{$section_props}['index_next'] = {$section_props}['index'] + {$section_props}['step'];\n";
1144 $output .=
"{$section_props}['first'] = ({$section_props}['iteration'] == 1);\n";
1145 $output .=
"{$section_props}['last'] = ({$section_props}['iteration'] == {$section_props}['total']);\n";
1162 $arg_list = array();
1164 if (empty($attrs[
'from'])) {
1165 return $this->
_syntax_error(
"foreach: missing 'from' attribute", E_USER_ERROR, __FILE__, __LINE__);
1167 $from = $attrs[
'from'];
1169 if (empty($attrs[
'item'])) {
1170 return $this->
_syntax_error(
"foreach: missing 'item' attribute", E_USER_ERROR, __FILE__, __LINE__);
1172 $item = $this->
_dequote($attrs[
'item']);
1173 if (!preg_match(
'~^\w+$~', $item)) {
1174 return $this->
_syntax_error(
"foreach: 'item' must be a variable name (literal string)", E_USER_ERROR, __FILE__, __LINE__);
1177 if (isset($attrs[
'key'])) {
1178 $key = $this->
_dequote($attrs[
'key']);
1179 if (!preg_match(
'~^\w+$~', $key)) {
1180 return $this->
_syntax_error(
"foreach: 'key' must to be a variable name (literal string)", E_USER_ERROR, __FILE__, __LINE__);
1182 $key_part =
"\$this->_tpl_vars['$key'] => ";
1188 if (isset($attrs[
'name'])) {
1189 $name = $attrs[
'name'];
1195 $output .=
"\$_from = $from; if (!is_array(\$_from) && !is_object(\$_from)) { settype(\$_from, 'array'); }";
1197 $foreach_props =
"\$this->_foreach[$name]";
1198 $output .=
"{$foreach_props} = array('total' => count(\$_from), 'iteration' => 0);\n";
1199 $output .=
"if ({$foreach_props}['total'] > 0):\n";
1200 $output .=
" foreach (\$_from as $key_part\$this->_tpl_vars['$item']):\n";
1201 $output .=
" {$foreach_props}['iteration']++;\n";
1203 $output .=
"if (count(\$_from)):\n";
1204 $output .=
" foreach (\$_from as $key_part\$this->_tpl_vars['$item']):\n";
1225 $buffer = isset($attrs[
'name']) ? $attrs[
'name'] :
"'default'";
1226 $assign = isset($attrs[
'assign']) ? $attrs[
'assign'] : null;
1227 $append = isset($attrs[
'append']) ? $attrs[
'append'] : null;
1229 $output =
"<?php ob_start(); ?>";
1230 $this->_capture_stack[] = array($buffer, $assign, $append);
1232 list($buffer, $assign, $append) = array_pop($this->_capture_stack);
1233 $output =
"<?php \$this->_smarty_vars['capture'][$buffer] = ob_get_contents(); ";
1234 if (isset($assign)) {
1235 $output .=
" \$this->assign($assign, ob_get_contents());";
1237 if (isset($append)) {
1238 $output .=
" \$this->append($append, ob_get_contents());";
1240 $output .=
"ob_end_clean(); ?>";
1257 preg_match_all(
'~(?>
1258 ' . $this->_obj_call_regexp .
'(?:' . $this->_mod_regexp .
'*)? | # valid object call
1259 ' . $this->_var_regexp .
'(?:' . $this->_mod_regexp .
'*)? | # var or quoted string
1260 \-?0[xX][0-9a-fA-F]+|\-?\d+(?:\.\d+)?|\.\d+|!==|===|==|!=|<>|<<|>>|<=|>=|\&\&|\|\||\(|\)|,|\!|\^|=|\&|\~|<|>|\||\%|\+|\-|\/|\*|\@ | # valid non-word token
1261 \b\w+\b | # valid word token
1263 )~x', $tag_args, $match);
1265 $tokens = $match[0];
1267 if(empty($tokens)) {
1268 $_error_msg = $elseif ?
"'elseif'" :
"'if'";
1269 $_error_msg .=
' statement requires arguments';
1270 $this->
_syntax_error($_error_msg, E_USER_ERROR, __FILE__, __LINE__);
1275 $token_count = array_count_values($tokens);
1276 if(isset($token_count[
'(']) && $token_count[
'('] != $token_count[
')']) {
1277 $this->
_syntax_error(
"unbalanced parenthesis in if statement", E_USER_ERROR, __FILE__, __LINE__);
1280 $is_arg_stack = array();
1282 for (
$i = 0;
$i < count($tokens);
$i++) {
1286 switch (strtolower(
$token)) {
1359 array_push($is_arg_stack,
$i);
1366 if ($tokens[
$i-1] ==
')') {
1367 $is_arg_start = array_pop($is_arg_stack);
1368 if ($is_arg_start != 0) {
1369 if (preg_match(
'~^' . $this->_func_regexp .
'$~', $tokens[$is_arg_start-1])) {
1374 $is_arg_start =
$i-1;
1377 $is_arg = implode(
' ', array_slice($tokens, $is_arg_start,
$i - $is_arg_start));
1387 array_splice($tokens, $is_arg_start, count($tokens), $new_tokens);
1395 if(preg_match(
'~^' . $this->_func_regexp .
'$~',
$token) ) {
1397 if($this->security &&
1398 !in_array(
$token, $this->security_settings[
'IF_FUNCS'])) {
1399 $this->
_syntax_error(
"(secure mode) '$token' not allowed in if statement", E_USER_ERROR, __FILE__, __LINE__);
1401 } elseif(preg_match(
'~^' . $this->_var_regexp .
'$~',
$token) && (strpos(
'+-*/^%&|', substr(
$token, -1)) ===
false) && isset($tokens[
$i+1]) && $tokens[
$i+1] ==
'(') {
1403 $this->
_syntax_error(
"variable function call '$token' not allowed in if statement", E_USER_ERROR, __FILE__, __LINE__);
1404 } elseif(preg_match(
'~^' . $this->_obj_call_regexp .
'|' . $this->_var_regexp .
'(?:' . $this->_mod_regexp .
'*)$~',
$token)) {
1407 } elseif(is_numeric(
$token)) {
1410 $this->
_syntax_error(
"unidentified token '$token'", E_USER_ERROR, __FILE__, __LINE__);
1417 return '<?php elseif ('.implode(
' ', $tokens).
'): ?>';
1419 return '<?php if ('.implode(
' ', $tokens).
'): ?>';
1424 $arg_list = array();
1426 if (isset(
$type) && isset($name)
1427 && isset($this->_plugins[
$type])
1428 && isset($this->_plugins[$type][$name])
1429 && empty($this->_plugins[$type][$name][4])
1430 && is_array($this->_plugins[$type][$name][5])
1433 $_cache_attrs = $this->_plugins[
$type][$name][5];
1434 $_count = $this->_cache_attrs_count++;
1435 $cache_code =
"\$_cache_attrs =& \$this->_smarty_cache_attrs('$this->_cache_serial','$_count');";
1439 $_cache_attrs = null;
1442 foreach ($attrs as $arg_name => $arg_value) {
1443 if (is_bool($arg_value))
1444 $arg_value = $arg_value ?
'true' :
'false';
1445 if (is_null($arg_value))
1446 $arg_value =
'null';
1447 if ($_cache_attrs && in_array($arg_name, $_cache_attrs)) {
1448 $arg_list[] =
"'$arg_name' => (\$this->_cache_including) ? \$_cache_attrs['$arg_name'] : (\$_cache_attrs['$arg_name']=$arg_value)";
1450 $arg_list[] =
"'$arg_name' => $arg_value";
1466 $negate_expr =
false;
1468 if (($first_token = array_shift($tokens)) ==
'not') {
1469 $negate_expr =
true;
1470 $expr_type = array_shift($tokens);
1472 $expr_type = $first_token;
1474 switch ($expr_type) {
1476 if (isset($tokens[$expr_end]) && $tokens[$expr_end] ==
'by') {
1478 $expr_arg = $tokens[$expr_end++];
1481 $expr =
"!(1 & $is_arg)";
1485 if (isset($tokens[$expr_end]) && $tokens[$expr_end] ==
'by') {
1487 $expr_arg = $tokens[$expr_end++];
1490 $expr =
"(1 & $is_arg)";
1494 if (@$tokens[$expr_end] ==
'by') {
1496 $expr_arg = $tokens[$expr_end++];
1499 $this->
_syntax_error(
"expecting 'by' after 'div'", E_USER_ERROR, __FILE__, __LINE__);
1504 $this->
_syntax_error(
"unknown 'is' expression - '$expr_type'", E_USER_ERROR, __FILE__, __LINE__);
1512 array_splice($tokens, 0, $expr_end, $expr);
1528 preg_match_all(
'~(?:' . $this->_obj_call_regexp .
'|' . $this->_qstr_regexp .
' | (?>[^"\'=\s]+)
1531 ~x', $tag_args, $match);
1532 $tokens = $match[0];
1541 foreach ($tokens as
$token) {
1546 if (preg_match(
'~^\w+$~', $token)) {
1550 $this->
_syntax_error(
"invalid attribute name: '$token'", E_USER_ERROR, __FILE__, __LINE__);
1555 if ($token ==
'=') {
1558 $this->
_syntax_error(
"expecting '=' after attribute name '$last_token'", E_USER_ERROR, __FILE__, __LINE__);
1564 if ($token !=
'=') {
1567 if (preg_match(
'~^(on|yes|true)$~', $token)) {
1569 }
else if (preg_match(
'~^(off|no|false)$~', $token)) {
1571 }
else if ($token ==
'null') {
1573 }
else if (preg_match(
'~^' . $this->_num_const_regexp .
'|0[xX][0-9a-fA-F]+$~', $token)) {
1575 }
else if (!preg_match(
'~^' . $this->_obj_call_regexp .
'|' . $this->_var_regexp .
'(?:' . $this->_mod_regexp .
')*$~', $token)) {
1577 $token =
'"'.addslashes($token).
'"';
1580 $attrs[$attr_name] =
$token;
1583 $this->
_syntax_error(
"'=' cannot be an attribute value", E_USER_ERROR, __FILE__, __LINE__);
1591 $this->
_syntax_error(
"expecting '=' after attribute name '$last_token'", E_USER_ERROR, __FILE__, __LINE__);
1593 $this->
_syntax_error(
"missing attribute value", E_USER_ERROR, __FILE__, __LINE__);
1610 foreach($tokens as $key => $val) {
1627 if(preg_match(
'~^(' . $this->_obj_call_regexp .
'|' . $this->_dvar_regexp .
')(' . $this->_mod_regexp .
'*)$~', $val, $match)) {
1630 $modifiers = $match[2];
1631 if (!empty($this->default_modifiers) && !preg_match(
'~(^|\|)smarty:nodefaults($|\|)~',$modifiers)) {
1632 $_default_mod_string = implode(
'|',(array)$this->default_modifiers);
1633 $modifiers = empty($modifiers) ? $_default_mod_string : $_default_mod_string .
'|' . $modifiers;
1637 } elseif (preg_match(
'~^' . $this->_db_qstr_regexp .
'(?:' . $this->_mod_regexp .
'*)$~', $val)) {
1639 preg_match(
'~^(' . $this->_db_qstr_regexp .
')('. $this->_mod_regexp .
'*)$~', $val, $match);
1641 if($match[2] !=
'') {
1646 elseif(preg_match(
'~^' . $this->_num_const_regexp .
'(?:' . $this->_mod_regexp .
'*)$~', $val)) {
1648 preg_match(
'~^(' . $this->_num_const_regexp .
')('. $this->_mod_regexp .
'*)$~', $val, $match);
1649 if($match[2] !=
'') {
1654 elseif(preg_match(
'~^' . $this->_si_qstr_regexp .
'(?:' . $this->_mod_regexp .
'*)$~', $val)) {
1656 preg_match(
'~^(' . $this->_si_qstr_regexp .
')('. $this->_mod_regexp .
'*)$~', $val, $match);
1657 if($match[2] !=
'') {
1662 elseif(preg_match(
'~^' . $this->_cvar_regexp .
'(?:' . $this->_mod_regexp .
'*)$~', $val)) {
1666 elseif(preg_match(
'~^' . $this->_svar_regexp .
'(?:' . $this->_mod_regexp .
'*)$~', $val)) {
1670 elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) {
1672 return $this->
_expand_quoted_text(
'"' . strtr($val, array(
'\\' =>
'\\\\',
'"' =>
'\\"')) .
'"');
1686 if(preg_match_all(
'~(?:\`(?<!\\\\)\$' . $this->_dvar_guts_regexp .
'(?:' . $this->_obj_ext_regexp .
')*\`)|(?:(?<!\\\\)\$\w+(\[[a-zA-Z0-9]+\])*)~', $var_expr, $_match)) {
1687 $_match = $_match[0];
1688 $_replace = array();
1689 foreach($_match as $_var) {
1690 $_replace[$_var] =
'".(' . $this->
_parse_var(str_replace(
'`',
'',$_var)) .
')."';
1692 $var_expr = strtr($var_expr, $_replace);
1693 $_return = preg_replace(
'~\.""|(?<!\\\\)""\.~',
'', $var_expr);
1695 $_return = $var_expr;
1698 $_return = preg_replace(
'~^"([\s\w]+)"$~',
"'\\1'",$_return);
1712 $_math_vars = preg_split(
'~('.$this->_dvar_math_regexp.
'|'.$this->_qstr_regexp.
')~', $var_expr, -1, PREG_SPLIT_DELIM_CAPTURE);
1714 if(count($_math_vars) > 1) {
1716 $_complete_var =
"";
1719 foreach($_math_vars as $_k => $_math_var) {
1720 $_math_var = $_math_vars[$_k];
1722 if(!empty($_math_var) || is_numeric($_math_var)) {
1724 if(preg_match(
'~^' . $this->_dvar_math_regexp .
'$~', $_math_var)) {
1726 if(!empty($_complete_var) || is_numeric($_complete_var)) {
1727 $_output .= $this->
_parse_var($_complete_var);
1731 $_output .= $_math_var;
1733 if(empty($_first_var))
1734 $_first_var = $_complete_var;
1736 $_complete_var =
"";
1738 $_complete_var .= $_math_var;
1743 if(!empty($_complete_var) || is_numeric($_complete_var))
1744 $_output .= $this->
_parse_var($_complete_var);
1747 $var_expr = $_complete_var;
1752 if(is_numeric(substr($var_expr, 0, 1)))
1753 $_var_ref = $var_expr;
1755 $_var_ref = substr($var_expr, 1);
1760 preg_match_all(
'~(?:^\w+)|' . $this->_obj_params_regexp .
'|(?:' . $this->_var_bracket_regexp .
')|->\$?\w+|\.\$?\w+|\S+~', $_var_ref, $match);
1762 $_indexes = $match[0];
1763 $_var_name = array_shift($_indexes);
1766 if ($_var_name ==
'smarty') {
1773 $_output = $smarty_ref;
1775 $_var_name = substr(array_shift($_indexes), 1);
1776 $_output =
"\$this->_smarty_vars['$_var_name']";
1778 } elseif(is_numeric($_var_name) && is_numeric(substr($var_expr, 0, 1))) {
1780 if(count($_indexes) > 0)
1782 $_var_name .= implode(
"", $_indexes);
1783 $_indexes = array();
1785 $_output = $_var_name;
1787 $_output =
"\$this->_tpl_vars['$_var_name']";
1790 foreach ($_indexes as $_index) {
1791 if (substr($_index, 0, 1) ==
'[') {
1792 $_index = substr($_index, 1, -1);
1793 if (is_numeric($_index)) {
1794 $_output .=
"[$_index]";
1795 } elseif (substr($_index, 0, 1) ==
'$') {
1796 if (strpos($_index,
'.') !==
false) {
1797 $_output .=
'[' . $this->
_parse_var($_index) .
']';
1799 $_output .=
"[\$this->_tpl_vars['" . substr($_index, 1) .
"']]";
1802 $_var_parts = explode(
'.', $_index);
1803 $_var_section = $_var_parts[0];
1804 $_var_section_prop = isset($_var_parts[1]) ? $_var_parts[1] :
'index';
1805 $_output .=
"[\$this->_sections['$_var_section']['$_var_section_prop']]";
1807 }
else if (substr($_index, 0, 1) ==
'.') {
1808 if (substr($_index, 1, 1) ==
'$')
1809 $_output .=
"[\$this->_tpl_vars['" . substr($_index, 2) .
"']]";
1811 $_output .=
"['" . substr($_index, 1) .
"']";
1812 }
else if (substr($_index,0,2) ==
'->') {
1813 if(substr($_index,2,2) ==
'__') {
1814 $this->
_syntax_error(
'call to internal object members is not allowed', E_USER_ERROR, __FILE__, __LINE__);
1815 } elseif($this->security && substr($_index, 2, 1) ==
'_') {
1816 $this->
_syntax_error(
'(secure) call to private object member is not allowed', E_USER_ERROR, __FILE__, __LINE__);
1817 } elseif (substr($_index, 2, 1) ==
'$') {
1818 if ($this->security) {
1819 $this->
_syntax_error(
'(secure) call to dynamic object member is not allowed', E_USER_ERROR, __FILE__, __LINE__);
1821 $_output .=
'->{(($_var=$this->_tpl_vars[\''.substr($_index,3).
'\']) && substr($_var,0,2)!=\
'__\') ? $_var : $this->trigger_error("cannot access property \\"$_var\\"")}';
1824 $_output .= $_index;
1826 } elseif (substr($_index, 0, 1) ==
'(') {
1828 $_output .= $_index;
1830 $_output .= $_index;
1846 preg_match_all(
'~' . $this->_param_regexp .
'~',$parenth_args, $match);
1847 $orig_vals = $match = $match[0];
1850 for (
$i = 0, $count = count($match);
$i < $count;
$i++) {
1851 $replace[$orig_vals[
$i]] = $match[
$i];
1853 return strtr($parenth_args, $replace);
1863 $parts = explode(
'|', $conf_var_expr, 2);
1864 $var_ref = $parts[0];
1865 $modifiers = isset($parts[1]) ? $parts[1] :
'';
1867 $var_name = substr($var_ref, 1, -1);
1869 $output =
"\$this->_config[0]['vars']['$var_name']";
1884 $parts = explode(
'|', $section_prop_expr, 2);
1885 $var_ref = $parts[0];
1886 $modifiers = isset($parts[1]) ? $parts[1] :
'';
1888 preg_match(
'!%(\w+)\.(\w+)%!', $var_ref, $match);
1889 $section_name = $match[1];
1890 $prop_name = $match[2];
1892 $output =
"\$this->_sections['$section_name']['$prop_name']";
1909 preg_match_all(
'~\|(@?\w+)((?>:(?:'. $this->_qstr_regexp .
'|[^|]+))*)~',
'|' . $modifier_string, $_match);
1910 list(, $_modifiers, $modifier_arg_strings) = $_match;
1912 for ($_i = 0, $_for_max = count($_modifiers); $_i < $_for_max; $_i++) {
1913 $_modifier_name = $_modifiers[$_i];
1915 if($_modifier_name ==
'smarty') {
1920 preg_match_all(
'~:(' . $this->_qstr_regexp .
'|[^:]+)~', $modifier_arg_strings[$_i], $_match);
1921 $_modifier_args = $_match[1];
1923 if (substr($_modifier_name, 0, 1) ==
'@') {
1924 $_map_array =
false;
1925 $_modifier_name = substr($_modifier_name, 1);
1930 if (empty($this->_plugins[
'modifier'][$_modifier_name])
1932 && function_exists($_modifier_name)) {
1933 if ($this->security && !in_array($_modifier_name, $this->security_settings[
'MODIFIER_FUNCS'])) {
1934 $this->
_trigger_fatal_error(
"[plugin] (secure mode) modifier '$_modifier_name' is not allowed" , $this->_current_file, $this->_current_line_no, __FILE__, __LINE__);
1936 $this->_plugins[
'modifier'][$_modifier_name] = array($_modifier_name, null, null,
false);
1943 if($_modifier_name ==
'default') {
1945 if(substr($output, 0, 1) ==
'$') {
1946 $output =
'@' . $output;
1948 if(isset($_modifier_args[0]) && substr($_modifier_args[0], 0, 1) ==
'$') {
1949 $_modifier_args[0] =
'@' . $_modifier_args[0];
1952 if (count($_modifier_args) > 0)
1953 $_modifier_args =
', '.implode(
', ', $_modifier_args);
1955 $_modifier_args =
'';
1958 $output =
"((is_array(\$_tmp=$output)) ? \$this->_run_mod_handler('$_modifier_name', true, \$_tmp$_modifier_args) : " . $this->
_compile_plugin_call(
'modifier', $_modifier_name) .
"(\$_tmp$_modifier_args))";
1978 if (!isset($this->_plugin_info[
$type])) {
1979 $this->_plugin_info[
$type] = array();
1981 if (!isset($this->_plugin_info[$type][$name])) {
1982 $this->_plugin_info[
$type][$name] = array($this->_current_file,
1983 $this->_current_line_no,
1998 $_ref = substr($indexes[0], 1);
1999 foreach($indexes as $_index_no=>$_index) {
2000 if (substr($_index, 0, 1) !=
'.' && $_index_no<2 || !preg_match(
'~^(\.|\[|->)~', $_index)) {
2001 $this->
_syntax_error(
'$smarty' . implode(
'', array_slice($indexes, 0, 2)) .
' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__);
2007 $compiled_ref =
'time()';
2012 array_shift($indexes);
2014 $_propname = substr($indexes[1], 1);
2016 switch ($_propname) {
2018 array_shift($indexes);
2019 $compiled_ref =
"(\$this->_foreach[$_var]['iteration']-1)";
2023 array_shift($indexes);
2024 $compiled_ref =
"(\$this->_foreach[$_var]['iteration'] <= 1)";
2028 array_shift($indexes);
2029 $compiled_ref =
"(\$this->_foreach[$_var]['iteration'] == \$this->_foreach[$_var]['total'])";
2033 array_shift($indexes);
2034 $compiled_ref =
"(\$this->_foreach[$_var]['total'] > 0)";
2039 $compiled_ref =
"\$this->_foreach[$_var]";
2044 array_shift($indexes);
2046 $compiled_ref =
"\$this->_sections[$_var]";
2050 if ($this->security && !$this->security_settings[
'ALLOW_SUPER_GLOBALS']) {
2051 $this->
_syntax_error(
"(secure mode) super global access not permitted",
2052 E_USER_WARNING, __FILE__, __LINE__);
2055 $compiled_ref =
"\$_GET";
2059 if ($this->security && !$this->security_settings[
'ALLOW_SUPER_GLOBALS']) {
2060 $this->
_syntax_error(
"(secure mode) super global access not permitted",
2061 E_USER_WARNING, __FILE__, __LINE__);
2064 $compiled_ref =
"\$_POST";
2068 if ($this->security && !$this->security_settings[
'ALLOW_SUPER_GLOBALS']) {
2069 $this->
_syntax_error(
"(secure mode) super global access not permitted",
2070 E_USER_WARNING, __FILE__, __LINE__);
2073 $compiled_ref =
"\$_COOKIE";
2077 if ($this->security && !$this->security_settings[
'ALLOW_SUPER_GLOBALS']) {
2078 $this->
_syntax_error(
"(secure mode) super global access not permitted",
2079 E_USER_WARNING, __FILE__, __LINE__);
2082 $compiled_ref =
"\$_ENV";
2086 if ($this->security && !$this->security_settings[
'ALLOW_SUPER_GLOBALS']) {
2087 $this->
_syntax_error(
"(secure mode) super global access not permitted",
2088 E_USER_WARNING, __FILE__, __LINE__);
2091 $compiled_ref =
"\$_SERVER";
2095 if ($this->security && !$this->security_settings[
'ALLOW_SUPER_GLOBALS']) {
2096 $this->
_syntax_error(
"(secure mode) super global access not permitted",
2097 E_USER_WARNING, __FILE__, __LINE__);
2100 $compiled_ref =
"\$_SESSION";
2108 if ($this->security && !$this->security_settings[
'ALLOW_SUPER_GLOBALS']) {
2109 $this->
_syntax_error(
"(secure mode) super global access not permitted",
2110 E_USER_WARNING, __FILE__, __LINE__);
2113 if ($this->request_use_auto_globals) {
2114 $compiled_ref =
"\$_REQUEST";
2117 $this->_init_smarty_vars =
true;
2125 $compiled_ref =
"'$this->_current_file'";
2130 $compiled_ref =
"'$this->_version'";
2135 if ($this->security && !$this->security_settings[
'ALLOW_CONSTANTS']) {
2136 $this->
_syntax_error(
"(secure mode) constants not permitted",
2137 E_USER_WARNING, __FILE__, __LINE__);
2140 array_shift($indexes);
2141 if (preg_match(
'!^\.\w+$!', $indexes[0])) {
2142 $compiled_ref =
'@' . substr($indexes[0], 1);
2145 $compiled_ref =
'@constant(' . $_val .
')';
2151 $compiled_ref =
"\$this->_config[0]['vars']";
2156 $compiled_ref =
"'$this->left_delimiter'";
2160 $compiled_ref =
"'$this->right_delimiter'";
2164 $this->
_syntax_error(
'$smarty.' . $_ref .
' is an unknown reference', E_USER_ERROR, __FILE__, __LINE__);
2168 if (isset($_max_index) && count($indexes) > $_max_index) {
2169 $this->
_syntax_error(
'$smarty' . implode(
'', $indexes) .
' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__);
2172 array_shift($indexes);
2173 return $compiled_ref;
2187 if (isset($this->_plugins[
$type][$name])) {
2189 if (is_array($this->_plugins[
$type][$name][0])) {
2190 return ((is_object($this->_plugins[
$type][$name][0][0])) ?
2191 "\$this->_plugins['$type']['$name'][0][0]->"
2192 : (
string)($this->_plugins[
$type][$name][0][0]).
'::'
2193 ). $this->_plugins[
$type][$name][0][1];
2197 return $this->_plugins[
$type][$name][0];
2202 return 'smarty_'.$type.
'_'.$name;
2212 if (count($this->_plugins[
'prefilter']) > 0) {
2213 foreach ($this->_plugins[
'prefilter'] as $filter_name => $prefilter) {
2214 if ($prefilter ===
false) {
2215 unset($this->_plugins[
'prefilter'][$filter_name]);
2216 $_params = array(
'plugins' => array(array(
'prefilter', $filter_name, null, null,
false)));
2217 require_once(SMARTY_CORE_DIR .
'core.load_plugins.php');
2222 if (count($this->_plugins[
'postfilter']) > 0) {
2223 foreach ($this->_plugins[
'postfilter'] as $filter_name => $postfilter) {
2224 if ($postfilter ===
false) {
2225 unset($this->_plugins[
'postfilter'][$filter_name]);
2226 $_params = array(
'plugins' => array(array(
'postfilter', $filter_name, null, null,
false)));
2227 require_once(SMARTY_CORE_DIR .
'core.load_plugins.php');
2243 return strtr($string, array(
'\\' =>
'\\\\',
'$' =>
'\\$'));
2256 $this->
_trigger_fatal_error(
"syntax error: $error_msg", $this->_current_file, $this->_current_line_no,
$file, $line, $error_type);
2267 $_cacheable = !isset($this->_plugins[
$type][$name]) || $this->_plugins[
$type][$name][4];
2269 || 0<$this->_cacheable_state++)
return '';
2270 if (!isset($this->_cache_serial)) $this->_cache_serial = md5(uniqid(
'Smarty'));
2271 $_ret =
'if ($this->caching && !$this->_cache_including): echo \'{nocache:'
2272 . $this->_cache_serial .
'#' . $this->_nocache_count
2285 $_cacheable = !isset($this->_plugins[
$type][$name]) || $this->_plugins[
$type][$name][4];
2287 || --$this->_cacheable_state>0)
return '';
2288 return 'if ($this->caching && !$this->_cache_including): echo \'{/nocache:'
2289 . $this->_cache_serial .
'#' . ($this->_nocache_count++)
2300 array_push($this->_tag_stack, array($open_tag, $this->_current_line_no));
2312 if (count($this->_tag_stack)>0) {
2313 list($_open_tag, $_line_no) = array_pop($this->_tag_stack);
2314 if ($close_tag == $_open_tag) {
2317 if ($close_tag ==
'if' && ($_open_tag ==
'else' || $_open_tag ==
'elseif' )) {
2318 return $this->
_pop_tag($close_tag);
2320 if ($close_tag ==
'section' && $_open_tag ==
'sectionelse') {
2324 if ($close_tag ==
'foreach' && $_open_tag ==
'foreachelse') {
2328 if ($_open_tag ==
'else' || $_open_tag ==
'elseif') {
2330 } elseif ($_open_tag ==
'sectionelse') {
2331 $_open_tag =
'section';
2332 } elseif ($_open_tag ==
'foreachelse') {
2333 $_open_tag =
'foreach';
2335 $message =
" expected {/$_open_tag} (opened line $_line_no).";
2337 $this->
_syntax_error(
"mismatched tag {/$close_tag}.$message",
2338 E_USER_ERROR, __FILE__, __LINE__);
2356 if(strlen($a) == strlen($b))
2357 return ($a > $b) ? -1 : 1;
2359 return (strlen($a) > strlen($b)) ? -1 : 1;