3 * Smarty Internal Plugin Compile Function Plugin
4 * Compiles code for the execution of function plugin
12 * Smarty Internal Plugin Compile Function Plugin Class
15 * @subpackage Compiler
17 class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_CompileBase
20 * Attribute definition: Overwrites base class.
23 * @see Smarty_Internal_CompileBase
25 public $required_attributes = array();
27 * Attribute definition: Overwrites base class.
30 * @see Smarty_Internal_CompileBase
32 public $optional_attributes = array('_any');
35 * Compiles code for the execution of function plugin
37 * @param array $args array with attributes from parser
38 * @param object $compiler compiler object
39 * @param array $parameter array with compilation parameter
40 * @param string $tag name of function plugin
41 * @param string $function PHP function name
43 * @return string compiled code
45 public function compile($args, $compiler, $parameter, $tag, $function)
47 // This tag does create output
48 $compiler->has_output = true;
50 // check and get attributes
51 $_attr = $this->getAttributes($compiler, $args);
52 if ($_attr['nocache'] === true) {
53 $compiler->tag_nocache = true;
55 unset($_attr['nocache']);
56 // convert attributes into parameter array string
57 $_paramsArray = array();
58 foreach ($_attr as $_key => $_value) {
60 $_paramsArray[] = "$_key=>$_value";
62 $_paramsArray[] = "'$_key'=>$_value";
65 $_params = 'array(' . implode(",", $_paramsArray) . ')';
67 $output = "<?php echo {$function}({$_params},\$_smarty_tpl);?>\n";