3 * Smarty Internal Plugin Compile Continue
\r
5 * Compiles the {continue} tag
\r
8 * @subpackage Compiler
\r
13 * Smarty Internal Plugin Compile Continue Class
\r
16 * @subpackage Compiler
\r
18 class Smarty_Internal_Compile_Continue extends Smarty_Internal_CompileBase {
\r
21 * Attribute definition: Overwrites base class.
\r
24 * @see Smarty_Internal_CompileBase
\r
26 public $optional_attributes = array('levels');
\r
28 * Attribute definition: Overwrites base class.
\r
31 * @see Smarty_Internal_CompileBase
\r
33 public $shorttag_order = array('levels');
\r
36 * Compiles code for the {continue} tag
\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
43 public function compile($args, $compiler, $parameter)
\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
49 if ($_attr['nocache'] === true) {
\r
50 $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
\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
57 $_levels = $_attr['levels'];
\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
69 if ($level_count != 0) {
\r
70 $compiler->trigger_template_error("cannot continue {$_levels} level(s)", $compiler->lex->taglineno);
\r
72 $compiler->has_code = true;
\r
73 return "<?php continue {$_levels}?>";
\r