Deutschland United States United Kingdom
ContentLion - Open Source CMS

Blame internalcompileelseif.php

Details | Last modification | View Log

Rev Author Line
2 user_6
<?php
user_6
/**
user_6
* Smarty Internal Plugin Compile ElseIf Class
user_6
*
user_6
* @package Smarty
user_6
* @subpackage Compiler
user_6
*/
user_6
class Plugin_Smarty_InternalCompileElseif extends Plugin_Smarty_InternalCompileBase
user_6
{
user_6
    /**
user_6
    * Compiles code for the {elseif} tag
user_6
    *
user_6
    * @param array  $args       array with attributes from parser
user_6
    * @param object $compiler   compiler object
user_6
    * @param array  $parameter  array with compilation parameter
user_6
    * @return string compiled code
user_6
    */
user_6
    public function compile($args, $compiler, $parameter)
user_6
    {
user_6
        // check and get attributes
user_6
        $_attr = $this->getAttributes($compiler, $args);
user_6
 
user_6
        list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif'));
user_6
 
user_6
        if (!array_key_exists("if condition",$parameter)) {
user_6
            $compiler->trigger_template_error("missing elseif condition", $compiler->lex->taglineno);
user_6
        }
user_6
 
user_6
        if (is_array($parameter['if condition'])) {
user_6
            $condition_by_assign = true;
user_6
            if ($compiler->nocache) {
user_6
                $_nocache = ',true';
user_6
                // create nocache var to make it know for further compiling
user_6
                if (is_array($parameter['if condition']['var'])) {
user_6
                    $compiler->template->tpl_vars[trim($parameter['if condition']['var']['var'], "'")] = new Plugin_Smarty_Variable(null, true);
user_6
                } else {
user_6
                    $compiler->template->tpl_vars[trim($parameter['if condition']['var'], "'")] = new Plugin_Smarty_Variable(null, true);
user_6
                }
user_6
            } else {
user_6
                $_nocache = '';
user_6
            }
user_6
        } else {
user_6
            $condition_by_assign = false;
user_6
        }
user_6
 
user_6
        if (empty($compiler->prefix_code)) {
user_6
            if ($condition_by_assign) {
user_6
                $this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));
user_6
                if (is_array($parameter['if condition']['var'])) {
user_6
                    $_output = "<?php } else { 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";
user_6
                    $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" . $parameter['if condition']['var']['smarty_internal_index'] . " = " . $parameter['if condition']['value'] . ") {?>";
user_6
                } else {
user_6
                    $_output = "<?php  } else { if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Plugin_Smarty_Variable(null{$_nocache});";
user_6
                    $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . ") {?>";
user_6
                }
user_6
 
user_6
                return $_output;
user_6
            } else {
user_6
                $this->openTag($compiler, 'elseif', array($nesting, $compiler->tag_nocache));
user_6
 
user_6
                return "<?php } elseif ({$parameter['if condition']}) {?>";
user_6
            }
user_6
        } else {
user_6
            $tmp = '';
user_6
            foreach ($compiler->prefix_code as $code)
user_6
            $tmp .= $code;
user_6
            $compiler->prefix_code = array();
user_6
            $this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));
user_6
            if ($condition_by_assign) {
user_6
                if (is_array($parameter['if condition']['var'])) {
user_6
                    $_output = "<?php } else {?>{$tmp}<?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";
user_6
                    $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" . $parameter['if condition']['var']['smarty_internal_index'] . " = " . $parameter['if condition']['value'] . ") {?>";
user_6
                } else {
user_6
                    $_output = "<?php } else {?>{$tmp}<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Plugin_Smarty_Variable(null{$_nocache});";
user_6
                    $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . ") {?>";
user_6
                }
user_6
 
user_6
                return $_output;
user_6
            } else {
user_6
                return "<?php } else {?>{$tmp}<?php if ({$parameter['if condition']}) {?>";
user_6
            }
user_6
        }
user_6
    }
user_6
 
user_6
}