3 * Smarty Internal Plugin Compile While
 
   5 * Compiles the {while} tag
 
  13 * Smarty Internal Plugin Compile While Class
 
  15 class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase {
 
  17     * Compiles code for the {while} tag
 
  19     * @param array $args array with attributes from parser
 
  20     * @param object $compiler compiler object
 
  21     * @param array $parameter array with compilation parameter
 
  22     * @return string compiled code
 
  24     public function compile($args, $compiler, $parameter)
 
  26         $this->compiler = $compiler;
 
  27         // check and get attributes
 
  28         $_attr = $this->_get_attributes($args);
 
  29         $this->_open_tag('while', $this->compiler->nocache);
 
  31         // maybe nocache because of nocache variables
 
  32         $this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache;
 
  33         if (is_array($parameter['if condition'])) {
 
  34                 if ($this->compiler->nocache) {
 
  36                 // create nocache var to make it know for further compiling
 
  37                 if (is_array($parameter['if condition']['var'])) {
 
  38                         $this->compiler->template->tpl_vars[trim($parameter['if condition']['var']['var'], "'")] = new Smarty_variable(null, true);
 
  40                         $this->compiler->template->tpl_vars[trim($parameter['if condition']['var'], "'")] = new Smarty_variable(null, true);
 
  45             if (is_array($parameter['if condition']['var'])) {
 
  46                 $_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]) || !is_array(\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]->value)) \$_smarty_tpl->createLocalArrayVariable(".$parameter['if condition']['var']['var']."$_nocache);\n";
 
  47                     $_output .= "while (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]->value".$parameter['if condition']['var']['smarty_internal_index']." = ".$parameter['if condition']['value']."){?>";
 
  49                     $_output = "<?php \$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."] = new Smarty_Variable(\$_smarty_tpl->getVariable(".$parameter['if condition']['var'].",null,true,false)->value{$_nocache});";            
 
  50                     $_output .= "while (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."]->value = ".$parameter['if condition']['value']."){?>";
 
  54             return "<?php while ({$parameter['if condition']}){?>";
 
  60 * Smarty Internal Plugin Compile Whileclose Class
 
  62 class Smarty_Internal_Compile_Whileclose extends Smarty_Internal_CompileBase {
 
  64     * Compiles code for the {/while} tag
 
  66     * @param array $args array with attributes from parser
 
  67     * @param object $compiler compiler object
 
  68     * @return string compiled code
 
  70     public function compile($args, $compiler)
 
  72         $this->compiler = $compiler; 
 
  73         // must endblock be nocache?
 
  74         if ($this->compiler->nocache) {
 
  75                  $this->compiler->tag_nocache = true;
 
  77         $this->compiler->nocache = $this->_close_tag(array('while'));