Adjusted header.tpl for Work plugin.
[timetracker.git] / WEB-INF / lib / smarty / sysplugins / smarty_internal_compile_while.php
1 <?php
2 /**
3 * Smarty Internal Plugin Compile While
4
5 * Compiles the {while} tag
6
7 * @package Smarty
8 * @subpackage Compiler
9 * @author Uwe Tews 
10 */
11
12 /**
13 * Smarty Internal Plugin Compile While Class
14 */
15 class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase {
16     /**
17     * Compiles code for the {while} tag
18     * 
19     * @param array $args array with attributes from parser
20     * @param object $compiler compiler object
21     * @param array $parameter array with compilation parameter
22     * @return string compiled code
23     */
24     public function compile($args, $compiler, $parameter)
25     {
26         $this->compiler = $compiler;
27         // check and get attributes
28         $_attr = $this->_get_attributes($args);
29         $this->_open_tag('while', $this->compiler->nocache);
30
31         // maybe nocache because of nocache variables
32         $this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache;
33         if (is_array($parameter['if condition'])) {
34                 if ($this->compiler->nocache) {
35                         $_nocache = ',true';
36                 // create nocache var to make it know for further compiling
37                 if (is_array($parameter['if condition']['var'])) {
38                         $this->compiler->template->tpl_vars[trim($parameter['if condition']['var']['var'], "'")] = new Smarty_variable(null, true);
39                 } else {
40                         $this->compiler->template->tpl_vars[trim($parameter['if condition']['var'], "'")] = new Smarty_variable(null, true);
41                 }
42                 } else {
43                         $_nocache = '';
44                 }
45             if (is_array($parameter['if condition']['var'])) {
46                 $_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]) || !is_array(\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]->value)) \$_smarty_tpl->createLocalArrayVariable(".$parameter['if condition']['var']['var']."$_nocache);\n";
47                     $_output .= "while (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]->value".$parameter['if condition']['var']['smarty_internal_index']." = ".$parameter['if condition']['value']."){?>";
48             } else {
49                     $_output = "<?php \$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."] = new Smarty_Variable(\$_smarty_tpl->getVariable(".$parameter['if condition']['var'].",null,true,false)->value{$_nocache});";            
50                     $_output .= "while (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."]->value = ".$parameter['if condition']['value']."){?>";
51                 }
52             return $_output;
53         } else {
54             return "<?php while ({$parameter['if condition']}){?>";
55         } 
56     } 
57
58
59 /**
60 * Smarty Internal Plugin Compile Whileclose Class
61 */
62 class Smarty_Internal_Compile_Whileclose extends Smarty_Internal_CompileBase {
63     /**
64     * Compiles code for the {/while} tag
65     * 
66     * @param array $args array with attributes from parser
67     * @param object $compiler compiler object
68     * @return string compiled code
69     */
70     public function compile($args, $compiler)
71     {
72         $this->compiler = $compiler; 
73         // must endblock be nocache?
74         if ($this->compiler->nocache) {
75                  $this->compiler->tag_nocache = true;
76         }
77         $this->compiler->nocache = $this->_close_tag(array('while'));
78         return "<?php }?>";
79     } 
80
81
82 ?>