[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/libraries/Smarty/libs/sysplugins/ -> smarty_internal_compile_continue.php (source)

   1  <?php
   2  /**

   3   * Smarty Internal Plugin Compile Continue

   4   *

   5   * Compiles the {continue} tag

   6   *

   7   * @package Smarty

   8   * @subpackage Compiler

   9   * @author Uwe Tews

  10   */
  11  
  12  /**

  13   * Smarty Internal Plugin Compile Continue Class

  14   *

  15   * @package Smarty

  16   * @subpackage Compiler

  17   */
  18  class Smarty_Internal_Compile_Continue extends Smarty_Internal_CompileBase {
  19  
  20      /**

  21       * Attribute definition: Overwrites base class.

  22       *

  23       * @var array

  24       * @see Smarty_Internal_CompileBase

  25       */
  26      public $optional_attributes = array('levels');
  27      /**

  28       * Attribute definition: Overwrites base class.

  29       *

  30       * @var array

  31       * @see Smarty_Internal_CompileBase

  32       */
  33      public $shorttag_order = array('levels');
  34  
  35      /**

  36       * Compiles code for the {continue} tag

  37       *

  38       * @param array  $args      array with attributes from parser

  39       * @param object $compiler  compiler object

  40       * @param array  $parameter array with compilation parameter

  41       * @return string compiled code

  42       */
  43      public function compile($args, $compiler, $parameter)
  44      {
  45          static $_is_loopy = array('for' => true, 'foreach' => true, 'while' => true, 'section' => true);
  46          // check and get attributes

  47          $_attr = $this->getAttributes($compiler, $args);
  48  
  49          if ($_attr['nocache'] === true) {
  50              $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
  51          }
  52  
  53          if (isset($_attr['levels'])) {
  54              if (!is_numeric($_attr['levels'])) {
  55                  $compiler->trigger_template_error('level attribute must be a numeric constant', $compiler->lex->taglineno);
  56              }
  57              $_levels = $_attr['levels'];
  58          } else {
  59              $_levels = 1;
  60          }
  61          $level_count = $_levels;
  62          $stack_count = count($compiler->_tag_stack) - 1;
  63          while ($level_count > 0 && $stack_count >= 0) {
  64              if (isset($_is_loopy[$compiler->_tag_stack[$stack_count][0]])) {
  65                  $level_count--;
  66              }
  67              $stack_count--;
  68          }
  69          if ($level_count != 0) {
  70              $compiler->trigger_template_error("cannot continue {$_levels} level(s)", $compiler->lex->taglineno);
  71          }
  72          $compiler->has_code = true;
  73          return "<?php continue {$_levels}?>";
  74      }
  75  
  76  }
  77  
  78  ?>


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1