3 * Smarty Internal Plugin Compile Function Plugin
5 * Compiles code for the execution of function plugin
13 * Smarty Internal Plugin Compile Function Plugin Class
15 class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_CompileBase {
16 // attribute definitions
17 public $required_attributes = array();
18 public $optional_attributes = array('_any');
21 * Compiles code for the execution of function plugin
23 * @param array $args array with attributes from parser
24 * @param object $compiler compiler object
25 * @param array $parameter array with compilation parameter
26 * @param string $tag name of function plugin
27 * @param string $function PHP function name
28 * @return string compiled code
30 public function compile($args, $compiler, $parameter, $tag, $function)
32 $this->compiler = $compiler;
33 // This tag does create output
34 $this->compiler->has_output = true;
36 // check and get attributes
37 $_attr = $this->_get_attributes($args);
38 if ($_attr['nocache'] === true) {
39 $this->compiler->tag_nocache = true;
41 unset($_attr['nocache']);
42 // convert attributes into parameter array string
43 $_paramsArray = array();
44 foreach ($_attr as $_key => $_value) {
46 $_paramsArray[] = "$_key=>$_value";
48 $_paramsArray[] = "'$_key'=>$_value";
51 $_params = 'array(' . implode(",", $_paramsArray) . ')';
53 $output = "<?php echo {$function}({$_params},\$_smarty_tpl);?>\n";