Code

Updated smarty
[gosa.git] / gosa-core / include / 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 * Smarty Internal Plugin Compile While Class
13 */
14 class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase {
15     /**
16     * Compiles code for the {while} tag
17     * 
18     * @param array $args array with attributes from parser
19     * @param object $compiler compiler object
20     * @return string compiled code
21     */
22     public function compile($args, $compiler)
23     {
24         $this->compiler = $compiler;
25         $this->required_attributes = array('if condition'); 
26         // check and get attributes
27         $_attr = $this->_get_attributes($args);
28         $this->_open_tag('while', $this->compiler->nocache);
30         // maybe nocache because of nocache variables
31                 $this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache;
33                 
34         if (is_array($args['if condition'])) {
35             $_output = " <?php if (!isset(\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."])) \$_smarty_tpl->tpl_vars[".$args['if condition']['var']."] = new Smarty_Variable;\n";
36             $_output .= " while (\$_smarty_tpl->tpl_vars[".$args['if condition']['var']."]->value = ".$args['if condition']['value'].") {\n ?>";
37             return $_output;
38         } else {
39             return '<?php while (' . $args['if condition'] . ') { ?>';
40         } 
41     } 
42
44 /**
45 * Smarty Internal Plugin Compile Whileclose Class
46 */
47 class Smarty_Internal_Compile_Whileclose extends Smarty_Internal_CompileBase {
48     /**
49     * Compiles code for the {/while} tag
50     * 
51     * @param array $args array with attributes from parser
52     * @param object $compiler compiler object
53     * @return string compiled code
54     */
55     public function compile($args, $compiler)
56     {
57         $this->compiler = $compiler; 
58                 // must endblock be nocache?
59                 if ($this->compiler->nocache) {
60                  $this->compiler->tag_nocache = true;
61         }
62         $this->compiler->nocache = $this->_close_tag(array('while'));
63         return "<?php }?>";
64     } 
65
66 ?>