Adjusted time.php to honor note on separate row option.
[timetracker.git] / WEB-INF / lib / smarty / sysplugins / smarty_internal_compile_break.php
1 <?php
2
3 /**
4  * Smarty Internal Plugin Compile Break
5  * 
6  * Compiles the {break} tag
7  * 
8  * @package Smarty
9  * @subpackage Compiler
10  * @author Uwe Tews 
11  */
12 /**
13  * Smarty Internal Plugin Compile Break Class
14  */
15 class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase {
16         // attribute definitions
17     public $optional_attributes = array('levels'); 
18     public $shorttag_order = array('levels');
19
20
21     /**
22      * Compiles code for the {break} tag
23      * 
24      * @param array $args array with attributes from parser
25      * @param object $compiler compiler object
26      * @param array $parameter array with compilation parameter
27      * @return string compiled code
28      */
29     public function compile($args, $compiler, $parameter)
30     {    
31         $this->compiler = $compiler;
32         $this->smarty = $compiler->smarty;
33         // check and get attributes
34         $_attr = $this->_get_attributes($args);
35
36         if ($_attr['nocache'] === true) {
37                 $this->compiler->trigger_template_error('nocache option not allowed', $this->compiler->lex->taglineno);
38         }
39
40         if (isset($_attr['levels'])) {
41             if (!is_numeric($_attr['levels'])) {
42                 $this->compiler->trigger_template_error('level attribute must be a numeric constant', $this->compiler->lex->taglineno);
43             } 
44             $_levels = $_attr['levels'];
45         } else {
46             $_levels = 1;
47         } 
48         $level_count = $_levels;
49         $stack_count = count($compiler->_tag_stack) - 1;
50         while ($level_count > 0 && $stack_count >= 0) {
51             if (in_array($compiler->_tag_stack[$stack_count][0], array('for', 'foreach', 'while', 'section'))) {
52                 $level_count--;
53             } 
54             $stack_count--;
55         } 
56         if ($level_count != 0) {
57             $this->compiler->trigger_template_error("cannot break {$_levels} level(s)", $this->compiler->lex->taglineno);
58         } 
59         // this tag does not return compiled code
60         $this->compiler->has_code = true;
61         return "<?php break {$_levels}?>";
62     } 
63
64
65 ?>