[gosa.git] / gosa-core / include / smarty / sysplugins / smarty_internal_compile_private_function_plugin.php
1 <?php
2 /**
3 * Smarty Internal Plugin Compile Function Plugin
4 *
5 * Compiles code for the execution of function plugin
6 *
7 * @package Smarty
8 * @subpackage Compiler
9 * @author Uwe Tews
10 */
12 /**
13 * Smarty Internal Plugin Compile Function Plugin Class
14 */
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');
20 /**
21 * Compiles code for the execution of function plugin
22 *
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
29 */
30 public function compile($args, $compiler, $parameter, $tag, $function)
31 {
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;
40 }
41 unset($_attr['nocache']);
42 // convert attributes into parameter array string
43 $_paramsArray = array();
44 foreach ($_attr as $_key => $_value) {
45 if (is_int($_key)) {
46 $_paramsArray[] = "$_key=>$_value";
47 } else {
48 $_paramsArray[] = "'$_key'=>$_value";
49 }
50 }
51 $_params = 'array(' . implode(",", $_paramsArray) . ')';
52 // compile code
53 $output = "<?php echo {$function}({$_params},\$_smarty_tpl);?>\n";
54 return $output;
55 }
56 }
58 ?>