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