Code

Updated smarty
[gosa.git] / gosa-core / include / smarty / sysplugins / smarty_internal_compile_private_object_function.php
1 <?php
2 /**
3 * Smarty Internal Plugin Compile Object Funtion
4
5 * Compiles code for registered objects as function
6
7 * @package Smarty
8 * @subpackage Compiler
9 * @author Uwe Tews 
10 */
11 /**
12 * Smarty Internal Plugin Compile Object Function Class
13 */
14 class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_CompileBase {
15     /**
16     * Compiles code for the execution of function plugin
17     * 
18     * @param array $args array with attributes from parser
19     * @param string $tag name of function
20     * @param string $methode name of methode to call
21     * @param object $compiler compiler object
22     * @return string compiled code
23     */
24     public function compile($args, $compiler, $tag, $methode)
25     {
26         $this->compiler = $compiler; 
27         // This tag does create output
28         $this->compiler->has_output = true;
30         $this->required_attributes = array();
31         $this->optional_attributes = array('_any'); 
32         // check and get attributes
33         $_attr = $this->_get_attributes($args); 
34         // convert attributes into parameter array string
35         if ($this->compiler->smarty->registered_objects[$tag][2]) {
36             $_paramsArray = array();
37             foreach ($_attr as $_key => $_value) {
38                 if (is_int($_key)) {
39                     $_paramsArray[] = "$_key=>$_value";
40                 } else {
41                     $_paramsArray[] = "'$_key'=>$_value";
42                 } 
43             } 
44             $_params = 'array(' . implode(",", $_paramsArray) . ')';
45             $output = "<?php echo \$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$methode}({$_params},\$_smarty_tpl->smarty,\$_smarty_tpl);?>\n";
46         } else {
47             $_params = implode(",", $_attr);
48             $output = "<?php echo \$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$methode}({$_params});?>\n";
49         } 
50         return $output;
51     } 
52
54 ?>