Code

Readded smarty
[gosa.git] / gosa-core / include / smarty / sysplugins / smarty_internal_compile_continue.php
1 <?php\r
2 /**\r
3  * Smarty Internal Plugin Compile Continue\r
4  *\r
5  * Compiles the {continue} tag\r
6  *\r
7  * @package Smarty\r
8  * @subpackage Compiler\r
9  * @author Uwe Tews\r
10  */\r
11 \r
12 /**\r
13  * Smarty Internal Plugin Compile Continue Class\r
14  *\r
15  * @package Smarty\r
16  * @subpackage Compiler\r
17  */\r
18 class Smarty_Internal_Compile_Continue extends Smarty_Internal_CompileBase {\r
19 \r
20     /**\r
21      * Attribute definition: Overwrites base class.\r
22      *\r
23      * @var array\r
24      * @see Smarty_Internal_CompileBase\r
25      */\r
26     public $optional_attributes = array('levels');\r
27     /**\r
28      * Attribute definition: Overwrites base class.\r
29      *\r
30      * @var array\r
31      * @see Smarty_Internal_CompileBase\r
32      */\r
33     public $shorttag_order = array('levels');\r
34 \r
35     /**\r
36      * Compiles code for the {continue} tag\r
37      *\r
38      * @param array  $args      array with attributes from parser\r
39      * @param object $compiler  compiler object\r
40      * @param array  $parameter array with compilation parameter\r
41      * @return string compiled code\r
42      */\r
43     public function compile($args, $compiler, $parameter)\r
44     {\r
45         static $_is_loopy = array('for' => true, 'foreach' => true, 'while' => true, 'section' => true);\r
46         // check and get attributes\r
47         $_attr = $this->getAttributes($compiler, $args);\r
48 \r
49         if ($_attr['nocache'] === true) {\r
50             $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);\r
51         }\r
52 \r
53         if (isset($_attr['levels'])) {\r
54             if (!is_numeric($_attr['levels'])) {\r
55                 $compiler->trigger_template_error('level attribute must be a numeric constant', $compiler->lex->taglineno);\r
56             }\r
57             $_levels = $_attr['levels'];\r
58         } else {\r
59             $_levels = 1;\r
60         }\r
61         $level_count = $_levels;\r
62         $stack_count = count($compiler->_tag_stack) - 1;\r
63         while ($level_count > 0 && $stack_count >= 0) {\r
64             if (isset($_is_loopy[$compiler->_tag_stack[$stack_count][0]])) {\r
65                 $level_count--;\r
66             }\r
67             $stack_count--;\r
68         }\r
69         if ($level_count != 0) {\r
70             $compiler->trigger_template_error("cannot continue {$_levels} level(s)", $compiler->lex->taglineno);\r
71         }\r
72         $compiler->has_code = true;\r
73         return "<?php continue {$_levels}?>";\r
74     }\r
75 \r
76 }\r
77 \r
78 ?>