1: | <?php
|
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | |
9: |
|
10: |
|
11: | |
12: | |
13: | |
14: | |
15: | |
16: |
|
17: | class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Internal_CompileBase
|
18: | {
|
19: | |
20: | |
21: | |
22: | |
23: | |
24: |
|
25: | public $optional_attributes = array('_any');
|
26: |
|
27: | |
28: | |
29: | |
30: | |
31: | |
32: | |
33: | |
34: | |
35: | |
36: | |
37: | |
38: |
|
39: | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter, $tag)
|
40: | {
|
41: |
|
42: | $_attr = $this->getAttributes($compiler, $args);
|
43: | unset($_attr[ 'nocache' ]);
|
44: | if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ])) {
|
45: | $tag_info = $compiler->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ];
|
46: | $is_registered = true;
|
47: | } else {
|
48: | $tag_info = $compiler->default_handler_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ];
|
49: | $is_registered = false;
|
50: | }
|
51: |
|
52: | $compiler->tag_nocache = $compiler->tag_nocache || !$tag_info[ 1 ];
|
53: |
|
54: | $_paramsArray = array();
|
55: | foreach ($_attr as $_key => $_value) {
|
56: | if (is_int($_key)) {
|
57: | $_paramsArray[] = "$_key=>$_value";
|
58: | } elseif ($compiler->template->caching && in_array($_key, $tag_info[ 2 ])) {
|
59: | $_value = str_replace('\'', "^#^", $_value);
|
60: | $_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^";
|
61: | } else {
|
62: | $_paramsArray[] = "'$_key'=>$_value";
|
63: | }
|
64: | }
|
65: | $_params = 'array(' . implode(',', $_paramsArray) . ')';
|
66: |
|
67: | if ($is_registered) {
|
68: | $output =
|
69: | "call_user_func_array( \$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['{$tag}'][0], array( {$_params},\$_smarty_tpl ) )";
|
70: | } else {
|
71: | $function = $tag_info[ 0 ];
|
72: | if (!is_array($function)) {
|
73: | $output = "{$function}({$_params},\$_smarty_tpl)";
|
74: | } else {
|
75: | $output = "{$function[0]}::{$function[1]}({$_params},\$_smarty_tpl)";
|
76: | }
|
77: | }
|
78: | if (!empty($parameter[ 'modifierlist' ])) {
|
79: | $output = $compiler->compileTag(
|
80: | 'private_modifier',
|
81: | array(),
|
82: | array(
|
83: | 'modifierlist' => $parameter[ 'modifierlist' ],
|
84: | 'value' => $output
|
85: | )
|
86: | );
|
87: | }
|
88: | $output = "<?php echo {$output};?>\n";
|
89: | return $output;
|
90: | }
|
91: | }
|
92: | |