Code

Updated smarty
[gosa.git] / gosa-core / include / smarty / sysplugins / smarty_internal_compile_private_object_block_function.php
1 <?php
2 /**
3 * Smarty Internal Plugin Compile Object Block Function
4
5 * Compiles code for registered objects as block function
6
7 * @package Smarty
8 * @subpackage Compiler
9 * @author Uwe Tews 
10 */
11 /**
12 * Smarty Internal Plugin Compile Object Block Function Class
13 */
14 class Smarty_Internal_Compile_Private_Object_Block_Function extends Smarty_Internal_CompileBase {
15     /**
16     * Compiles code for the execution of block plugin
17     * 
18     * @param array $args array with attributes from parser
19     * @param string $tag name of block 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         if (strlen($tag) < 5 || substr_compare($tag, 'close', -5, 5) != 0) {
28             // opening tag of block plugin
29             $this->required_attributes = array();
30             $this->optional_attributes = array('_any'); 
31             // check and get attributes
32             $_attr = $this->_get_attributes($args); 
33             // convert attributes into parameter array string
34             $_paramsArray = array();
35             foreach ($_attr as $_key => $_value) {
36                 if (is_int($_key)) {
37                     $_paramsArray[] = "$_key=>$_value";
38                 } else {
39                     $_paramsArray[] = "'$_key'=>$_value";
40                 } 
41             } 
42             $_params = 'array(' . implode(",", $_paramsArray) . ')';
44             $this->_open_tag($tag . '->' . $methode, $_params); 
45             // compile code
46             $output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}->{$methode}', {$_params}); \$_block_repeat=true; \$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$methode}({$_params}, null, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl);while (\$_block_repeat) { ob_start();?>";
47         } else {
48             $base_tag = substr($tag, 0, -5); 
49             // closing tag of block plugin
50             $_params = $this->_close_tag($base_tag . '->' . $methode); 
51             // This tag does create output
52             $this->compiler->has_output = true; 
53             // compile code
54             $output = "<?php \$_block_content = ob_get_contents(); ob_end_clean(); \$_block_repeat=false; echo \$_smarty_tpl->smarty->registered_objects['{$base_tag}'][0]->{$methode}({$_params}, \$_block_content, \$_smarty_tpl->smarty, \$_block_repeat, \$_smarty_tpl); } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
55         } 
56         return $output."\n";
57     } 
58
60 ?>