/**
  * Compiles code for the {while} tag
  *
  * @param  array                                $args      array with attributes from parser
  * @param \Smarty_Internal_TemplateCompilerBase $compiler  compiler object
  * @param  array                                $parameter array with compilation parameter
  *
  * @return string compiled code
  * @throws \SmartyCompilerException
  */
 public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
 {
     $compiler->loopNesting++;
     // check and get attributes
     $_attr = $this->getAttributes($compiler, $args);
     $this->openTag($compiler, 'while', $compiler->nocache);
     if (!array_key_exists("if condition", $parameter)) {
         $compiler->trigger_template_error("missing while condition", null, true);
     }
     // maybe nocache because of nocache variables
     $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
     if (is_array($parameter['if condition'])) {
         if ($compiler->nocache) {
             $_nocache = ',true';
             // create nocache var to make it know for further compiling
             if (is_array($parameter['if condition']['var'])) {
                 $var = $parameter['if condition']['var']['var'];
             } else {
                 $var = $parameter['if condition']['var'];
             }
             $compiler->setNocacheInVariable($var);
         } else {
             $_nocache = '';
         }
         $assignCompiler = new Smarty_Internal_Compile_Assign();
         $assignAttr = array();
         $assignAttr[]['value'] = $parameter['if condition']['value'];
         if (is_array($parameter['if condition']['var'])) {
             $assignAttr[]['var'] = $parameter['if condition']['var']['var'];
             $_output = "<?php while (" . $parameter['if condition']['value'] . ") {?>";
             $_output .= $assignCompiler->compile($assignAttr, $compiler, array('smarty_internal_index' => $parameter['if condition']['var']['smarty_internal_index']));
         } else {
             $assignAttr[]['var'] = $parameter['if condition']['var'];
             $_output = "<?php while (" . $parameter['if condition']['value'] . ") {?>";
             $_output .= $assignCompiler->compile($assignAttr, $compiler, array());
         }
         return $_output;
     } else {
         return "<?php\n while ({$parameter['if condition']}) {?>";
     }
 }
 public function compile($args, $compiler, $parameter)
 {
     $this->required_attributes = array('var', 'value');
     $this->shorttag_order = array('var', 'value');
     $this->optional_attributes = array('scope', 'index');
     $_attr = $this->getAttributes($compiler, $args);
     if (isset($_attr['index'])) {
         $_params['smarty_internal_index'] = '[' . $_attr['index'] . ']';
         unset($_attr['index']);
     } else {
         $_params['smarty_internal_index'] = '[]';
     }
     $_new_attr = array();
     foreach ($_attr as $key => $value) {
         $_new_attr[] = array($key => $value);
     }
     return parent::compile($_new_attr, $compiler, $_params);
 }
 /**
  * Compiles code for the {append} tag
  * 
  * @param array $args array with attributes from parser
  * @param object $compiler compiler object
  * @param array $parameter array with compilation parameter
  * @return string compiled code
  */
 public function compile($args, $compiler, $parameter)
 {
     $this->compiler = $compiler;
     // check and get attributes
     $_attr = $this->_get_attributes($args);
     // map to compile assign attributes
     if (isset($_attr['index'])) {
         $_params['smarty_internal_index'] = '[' . $_attr['index'] . ']';
         unset($_attr['index']);
     } else {
         $_params['smarty_internal_index'] = '[]';
     }
     $_new_attr = array();
     foreach ($_attr as $key => $value) {
         $_new_attr[] = array($key => $value);
     }
     // call compile assign
     return parent::compile($_new_attr, $compiler, $_params);
 }
 /**
  * Compiles code for the {append} tag
  *
  * @param  array  $args      array with attributes from parser
  * @param  object $compiler  compiler object
  * @param  array  $parameter array with compilation parameter
  *
  * @return string compiled code
  */
 public function compile($args, $compiler, $parameter)
 {
     // the following must be assigned at runtime because it will be overwritten in parent class
     $this->required_attributes = array('var', 'value');
     $this->shorttag_order = array('var', 'value');
     $this->optional_attributes = array('scope', 'index');
     // check and get attributes
     $_attr = $this->getAttributes($compiler, $args);
     // map to compile assign attributes
     if (isset($_attr['index'])) {
         $_params['smarty_internal_index'] = '[' . $_attr['index'] . ']';
         unset($_attr['index']);
     } else {
         $_params['smarty_internal_index'] = '[]';
     }
     $_new_attr = array();
     foreach ($_attr as $key => $value) {
         $_new_attr[] = array($key => $value);
     }
     // call compile assign
     return parent::compile($_new_attr, $compiler, $_params);
 }
 /**
  * Compiles code for the {elseif} tag
  *
  * @param array                                 $args      array with attributes from parser
  * @param \Smarty_Internal_TemplateCompilerBase $compiler  compiler object
  * @param array                                 $parameter array with compilation parameter
  *
  * @return string compiled code
  * @throws \SmartyCompilerException
  */
 public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
 {
     // check and get attributes
     $_attr = $this->getAttributes($compiler, $args);
     list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif'));
     if (!array_key_exists("if condition", $parameter)) {
         $compiler->trigger_template_error("missing elseif condition", null, true);
     }
     $assignCode = '';
     $var = '';
     if (is_array($parameter['if condition'])) {
         $condition_by_assign = true;
         if (is_array($parameter['if condition']['var'])) {
             $var = $parameter['if condition']['var']['var'];
         } else {
             $var = $parameter['if condition']['var'];
         }
         if ($compiler->nocache) {
             // create nocache var to make it know for further compiling
             $compiler->setNocacheInVariable($var);
         }
         $prefixVar = $compiler->getNewPrefixVariable();
         $assignCode = "<?php {$prefixVar} = " . $parameter['if condition']['value'] . ";?>\n";
         $assignCompiler = new Smarty_Internal_Compile_Assign();
         $assignAttr = array();
         $assignAttr[]['value'] = "{$prefixVar}";
         if (is_array($parameter['if condition']['var'])) {
             $assignAttr[]['var'] = $parameter['if condition']['var']['var'];
             $assignCode .= $assignCompiler->compile($assignAttr, $compiler, array('smarty_internal_index' => $parameter['if condition']['var']['smarty_internal_index']));
         } else {
             $assignAttr[]['var'] = $parameter['if condition']['var'];
             $assignCode .= $assignCompiler->compile($assignAttr, $compiler, array());
         }
     } else {
         $condition_by_assign = false;
     }
     $prefixCode = $compiler->getPrefixCode();
     if (empty($prefixCode)) {
         if ($condition_by_assign) {
             $this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));
             $_output = $compiler->appendCode("<?php } else {\n?>", $assignCode);
             return $compiler->appendCode($_output, "<?php if ({$prefixVar}) {?>");
         } else {
             $this->openTag($compiler, 'elseif', array($nesting, $compiler->tag_nocache));
             return "<?php } elseif ({$parameter['if condition']}) {?>";
         }
     } else {
         $_output = $compiler->appendCode("<?php } else {\n?>", $prefixCode);
         $this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));
         if ($condition_by_assign) {
             $_output = $compiler->appendCode($_output, $assignCode);
             return $compiler->appendCode($_output, "<?php if ({$prefixVar}) {?>");
         } else {
             return $compiler->appendCode($_output, "<?php if ({$parameter['if condition']}) {?>");
         }
     }
 }