Another fix in week view for negative hours.
[timetracker.git] / WEB-INF / lib / smarty / sysplugins / smarty_internal_compile_private_registered_block.php
1 <?php
2 /**
3  * Smarty Internal Plugin Compile Registered Block
4  * 
5  * Compiles code for the execution of a registered block function
6  * 
7  * @package Smarty
8  * @subpackage Compiler
9  * @author Uwe Tews 
10  */
11
12 /**
13  * Smarty Internal Plugin Compile Registered Block Class
14  */
15 class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_CompileBase {
16         // attribute definitions
17     public $optional_attributes = array('_any'); 
18
19     /**
20      * Compiles code for the execution of a block function
21      * 
22      * @param array $args array with attributes from parser
23      * @param object $compiler compiler object
24      * @param array $parameter array with compilation parameter
25      * @param string $tag name of block function
26      * @return string compiled code
27      */
28     public function compile($args, $compiler, $parameter, $tag)
29     {
30         $this->compiler = $compiler;
31         if (strlen($tag) < 6 || substr($tag,-5) != 'close') {
32             // opening tag of block plugin
33                 // check and get attributes
34                 $_attr = $this->_get_attributes($args); 
35                 if ($_attr['nocache']) {
36                 $this->compiler->tag_nocache = true;
37                 }
38                 unset($_attr['nocache']);
39             // convert attributes into parameter array string
40             $_paramsArray = array();
41             foreach ($_attr as $_key => $_value) {
42                 if (is_int($_key)) {
43                     $_paramsArray[] = "$_key=>$_value";
44                 } elseif ($this->compiler->template->caching && in_array($_key,$compiler->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$tag][2])) {
45                                         $_value = str_replace("'","^#^",$_value);
46                         $_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^";
47                 } else {
48                     $_paramsArray[] = "'$_key'=>$_value";
49                 } 
50             } 
51             $_params = 'array(' . implode(",", $_paramsArray) . ')';
52
53             $this->_open_tag($tag, array($_params, $this->compiler->nocache)); 
54             // maybe nocache because of nocache variables or nocache plugin
55             $this->compiler->nocache = !$compiler->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$tag][1] | $this->compiler->nocache | $this->compiler->tag_nocache;
56             $function = $compiler->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$tag][0]; 
57             // compile code
58             if (!is_array($function)) {
59                 $output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; {$function}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
60             } else if (is_object($function[0])) {
61                 $output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; \$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]->{$function[1]}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
62             } else {
63                 $output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; {$function[0]}::{$function[1]}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
64             } 
65         } else {
66             // must endblock be nocache?
67             if ($this->compiler->nocache) {
68                 $this->compiler->tag_nocache = true;
69             } 
70             $base_tag = substr($tag, 0, -5); 
71             // closing tag of block plugin, restore nocache
72             list($_params, $this->compiler->nocache) = $this->_close_tag($base_tag); 
73             // This tag does create output
74             $this->compiler->has_output = true;
75             $function = $compiler->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$base_tag][0]; 
76             // compile code
77             if (!isset($parameter['modifier_list'])) {
78                 $mod_pre = $mod_post ='';
79             } else {
80                 $mod_pre = ' ob_start(); ';
81                 $mod_post = 'echo '.$this->compiler->compileTag('private_modifier',array(),array('modifierlist'=>$parameter['modifier_list'],'value'=>'ob_get_clean()')).';';
82             }
83             if (!is_array($function)) {
84                 $output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;".$mod_pre." echo {$function}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat);".$mod_post." } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
85             } else if (is_object($function[0])) {
86                 $output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;".$mod_pre." echo \$_smarty_tpl->smarty->registered_plugins['block']['{$base_tag}'][0][0]->{$function[1]}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); ".$mod_post."} array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
87             } else {
88                 $output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;".$mod_pre." echo {$function[0]}::{$function[1]}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); ".$mod_post."} array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
89             } 
90         } 
91         return $output."\n";
92     } 
93
94
95 ?>