Initial repo created
[timetracker.git] / WEB-INF / lib / 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 /**
13  * Smarty Internal Plugin Compile Object Function Class
14  */
15 class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_CompileBase {
16         // attribute definitions
17     public $required_attributes = array();
18     public $optional_attributes = array('_any'); 
19
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
27      * @param string $methode name of methode to call
28      * @return string compiled code
29      */
30     public function compile($args, $compiler, $parameter, $tag, $methode)
31     {
32         $this->compiler = $compiler;
33         // check and get attributes
34         $_attr = $this->_get_attributes($args); 
35         if ($_attr['nocache'] === true) {
36             $this->compiler->tag_nocache = true;
37         }
38         unset($_attr['nocache']);
39         $_assign = null;
40         if (isset($_attr['assign'])) {
41             $_assign = $_attr['assign'];
42             unset($_attr['assign']);
43         } 
44         // convert attributes into parameter array string
45         if ($this->compiler->smarty->registered_objects[$tag][2]) {
46             $_paramsArray = array();
47             foreach ($_attr as $_key => $_value) {
48                 if (is_int($_key)) {
49                     $_paramsArray[] = "$_key=>$_value";
50                 } else {
51                     $_paramsArray[] = "'$_key'=>$_value";
52                 } 
53             } 
54             $_params = 'array(' . implode(",", $_paramsArray) . ')';
55             $return = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$methode}({$_params},\$_smarty_tpl)";
56         } else {
57             $_params = implode(",", $_attr);
58             $return = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$methode}({$_params})";
59         } 
60         if (empty($_assign)) {
61             // This tag does create output
62             $this->compiler->has_output = true;
63             $output = "<?php echo {$return};?>\n";
64         } else {
65             $output = "<?php \$_smarty_tpl->assign({$_assign},{$return});?>\n";
66     }
67         return $output;
68     } 
69 }
70
71 ?>