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();
28 * Attribute definition: Overwrites base class.
31 * @see Smarty_Internal_CompileBase
33 public $optional_attributes = array('_any');
36 * Compiles code for the execution of function plugin
38 * @param array $args array with attributes from parser
39 * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
40 * @param array $parameter array with compilation parameter
41 * @param string $tag name of function plugin
42 * @param string $function PHP function name
44 * @return string compiled code
46 public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter, $tag, $function)
48 // check and get attributes
49 $_attr = $this->getAttributes($compiler, $args);
51 unset($_attr[ 'nocache' ]);
52 // convert attributes into parameter array string
53 $_paramsArray = array();
54 foreach ($_attr as $_key => $_value) {
56 $_paramsArray[] = "$_key=>$_value";
58 $_paramsArray[] = "'$_key'=>$_value";
61 $_params = 'array(' . implode(",", $_paramsArray) . ')';
63 $output = "{$function}({$_params},\$_smarty_tpl)";
64 if (!empty($parameter[ 'modifierlist' ])) {
65 $output = $compiler->compileTag('private_modifier', array(),
66 array('modifierlist' => $parameter[ 'modifierlist' ],
69 //Does tag create output
70 $compiler->has_output = true;
71 $output = "<?php echo {$output};?>\n";