1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: 12: 13: 14: 15: 16:
17: class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
18: {
19: 20: 21: 22: 23: 24:
25: public $required_attributes = array('name');
26: 27: 28: 29: 30: 31:
32: public $shorttag_order = array('name');
33: 34: 35: 36: 37: 38:
39: public $optional_attributes = array('_any');
40:
41: 42: 43: 44: 45: 46: 47: 48:
49: public function compile($args, $compiler)
50: {
51:
52: $_attr = $this->getAttributes($compiler, $args);
53:
54: if (isset($_attr['assign'])) {
55:
56: $_assign = $_attr['assign'];
57: }
58: $_name = $_attr['name'];
59: if ($compiler->compiles_template_function) {
60: $compiler->called_functions[] = trim($_name, "'\"");
61: }
62: unset($_attr['name'], $_attr['assign'], $_attr['nocache']);
63:
64: if ($compiler->nocache || $compiler->tag_nocache) {
65: $_nocache = 'true';
66: } else {
67: $_nocache = 'false';
68: }
69: $_paramsArray = array();
70: foreach ($_attr as $_key => $_value) {
71: if (is_int($_key)) {
72: $_paramsArray[] = "$_key=>$_value";
73: } else {
74: $_paramsArray[] = "'$_key'=>$_value";
75: }
76: }
77: if (isset($compiler->template->properties['function'][$_name]['parameter'])) {
78: foreach ($compiler->template->properties['function'][$_name]['parameter'] as $_key => $_value) {
79: if (!isset($_attr[$_key])) {
80: if (is_int($_key)) {
81: $_paramsArray[] = "$_key=>$_value";
82: } else {
83: $_paramsArray[] = "'$_key'=>$_value";
84: }
85: }
86: }
87: } elseif (isset($compiler->smarty->template_functions[$_name]['parameter'])) {
88: foreach ($compiler->smarty->template_functions[$_name]['parameter'] as $_key => $_value) {
89: if (!isset($_attr[$_key])) {
90: if (is_int($_key)) {
91: $_paramsArray[] = "$_key=>$_value";
92: } else {
93: $_paramsArray[] = "'$_key'=>$_value";
94: }
95: }
96: }
97: }
98:
99: if (!(strpos($_name, '$') === false)) {
100: $call_cache = $_name;
101: $call_function = '$tmp = "smarty_template_function_".' . $_name . '; $tmp';
102: } else {
103: $_name = trim($_name, "'\"");
104: $call_cache = "'{$_name}'";
105: $call_function = 'smarty_template_function_' . $_name;
106: }
107:
108: $_params = 'array(' . implode(",", $_paramsArray) . ')';
109: $_hash = str_replace('-', '_', $compiler->template->properties['nocache_hash']);
110:
111: if (isset($_assign)) {
112: if ($compiler->template->caching) {
113: $_output = "<?php ob_start(); Smarty_Internal_Function_Call_Handler::call ({$call_cache},\$_smarty_tpl,{$_params},'{$_hash}',{$_nocache}); \$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
114: } else {
115: $_output = "<?php ob_start(); {$call_function}(\$_smarty_tpl,{$_params}); \$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
116: }
117: } else {
118: if ($compiler->template->caching) {
119: $_output = "<?php Smarty_Internal_Function_Call_Handler::call ({$call_cache},\$_smarty_tpl,{$_params},'{$_hash}',{$_nocache});?>\n";
120: } else {
121: $_output = "<?php {$call_function}(\$_smarty_tpl,{$_params});?>\n";
122: }
123: }
124:
125: return $_output;
126: }
127: }
128: