PageRenderTime 24ms CodeModel.GetById 16ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/framework/vendor/smarty3/lib/libs/sysplugins/smarty_internal_compile_while.php

http://zoop.googlecode.com/
PHP | 66 lines | 30 code | 4 blank | 32 comment | 5 complexity | 367e8561d18905ab8839d0dc924efa43 MD5 | raw file
 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*/
14class 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);
29
30        // maybe nocache because of nocache variables
31		$this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache;
32
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} 
43
44/**
45* Smarty Internal Plugin Compile Whileclose Class
46*/
47class 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?>