smarty_internal_compile_if.php
Current file: C:\DATA\Viktor\Diplomka\XSLT-Benchmarking/Libs/Smarty/sysplugins/smarty_internal_compile_if.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
0.00% 0 / 4
0.00% 0 / 4 CRAP
0.00% 0 / 72
Smarty_Internal_Compile_If
0.00% 0 / 1
0.00% 0 / 1 30
0.00% 0 / 20
 compile($args, $compiler, $parameter)
0.00% 0 / 1 30
0.00% 0 / 20
Smarty_Internal_Compile_Else
0.00% 0 / 1
0.00% 0 / 1 2
0.00% 0 / 3
 compile($args, $compiler, $parameter)
0.00% 0 / 1 2
0.00% 0 / 3
Smarty_Internal_Compile_Elseif
0.00% 0 / 1
0.00% 0 / 1 110
0.00% 0 / 40
 compile($args, $compiler, $parameter)
0.00% 0 / 1 110
0.00% 0 / 40
Smarty_Internal_Compile_Ifclose
0.00% 0 / 1
0.00% 0 / 1 12
0.00% 0 / 9
 compile($args, $compiler, $parameter)
0.00% 0 / 1 12
0.00% 0 / 9



       1                 : <?php                                                                                                                                                                                                                                                                                                                                                   
       2                 : /**                                                                                                                                                                                                                                                                                                                                                     
       3                 :  * Smarty Internal Plugin Compile If                                                                                                                                                                                                                                                                                                                    
       4                 :  *                                                                                                                                                                                                                                                                                                                                                      
       5                 :  * Compiles the {if} {else} {elseif} {/if} tags                                                                                                                                                                                                                                                                                                         
       6                 :  *                                                                                                                                                                                                                                                                                                                                                      
       7                 :  * @package Smarty                                                                                                                                                                                                                                                                                                                                      
       8                 :  * @subpackage Compiler                                                                                                                                                                                                                                                                                                                                 
       9                 :  * @author Uwe Tews                                                                                                                                                                                                                                                                                                                                     
      10                 :  */                                                                                                                                                                                                                                                                                                                                                     
      11                 :                                                                                                                                                                                                                                                                                                                                                         
      12                 : /**                                                                                                                                                                                                                                                                                                                                                     
      13                 :  * Smarty Internal Plugin Compile If Class                                                                                                                                                                                                                                                                                                              
      14                 :  *                                                                                                                                                                                                                                                                                                                                                      
      15                 :  * @package Smarty                                                                                                                                                                                                                                                                                                                                      
      16                 :  * @subpackage Compiler                                                                                                                                                                                                                                                                                                                                 
      17                 :  */                                                                                                                                                                                                                                                                                                                                                     
      18                 : class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase {                                                                                                                                                                                                                                                                                  
      19                 :                                                                                                                                                                                                                                                                                                                                                         
      20                 :     /**                                                                                                                                                                                                                                                                                                                                                 
      21                 :      * Compiles code for the {if} tag                                                                                                                                                                                                                                                                                                                   
      22                 :      *                                                                                                                                                                                                                                                                                                                                                  
      23                 :      * @param array  $args       array with attributes from parser                                                                                                                                                                                                                                                                                      
      24                 :      * @param object $compiler   compiler object                                                                                                                                                                                                                                                                                                        
      25                 :      * @param array  $parameter  array with compilation parameter                                                                                                                                                                                                                                                                                       
      26                 :      * @return string compiled code                                                                                                                                                                                                                                                                                                                     
      27                 :      */                                                                                                                                                                                                                                                                                                                                                 
      28                 :     public function compile($args, $compiler, $parameter)                                                                                                                                                                                                                                                                                               
      29                 :     {                                                                                                                                                                                                                                                                                                                                                   
      30                 :         // check and get attributes                                                                                                                                                                                                                                                                                                                     
      31               0 :         $_attr = $this->getAttributes($compiler, $args);                                                                                                                                                                                                                                                                                                
      32               0 :         $this->openTag($compiler, 'if', array(1, $compiler->nocache));                                                                                                                                                                                                                                                                                  
      33                 :         // must whole block be nocache ?                                                                                                                                                                                                                                                                                                                
      34               0 :         $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;                                                                                                                                                                                                                                                                               
      35               0 :         if (is_array($parameter['if condition'])) {                                                                                                                                                                                                                                                                                                     
      36               0 :             if ($compiler->nocache) {                                                                                                                                                                                                                                                                                                                   
      37               0 :                 $_nocache = ',true';                                                                                                                                                                                                                                                                                                                    
      38                 :                 // create nocache var to make it know for further compiling                                                                                                                                                                                                                                                                             
      39               0 :                 if (is_array($parameter['if condition']['var'])) {                                                                                                                                                                                                                                                                                      
      40               0 :                     $compiler->template->tpl_vars[trim($parameter['if condition']['var']['var'], "'")] = new Smarty_variable(null, true);                                                                                                                                                                                                               
      41               0 :                 } else {                                                                                                                                                                                                                                                                                                                                
      42               0 :                     $compiler->template->tpl_vars[trim($parameter['if condition']['var'], "'")] = new Smarty_variable(null, true);                                                                                                                                                                                                                      
      43                 :                 }                                                                                                                                                                                                                                                                                                                                       
      44               0 :             } else {                                                                                                                                                                                                                                                                                                                                    
      45               0 :                 $_nocache = '';                                                                                                                                                                                                                                                                                                                         
      46                 :             }                                                                                                                                                                                                                                                                                                                                           
      47               0 :             if (is_array($parameter['if condition']['var'])) {                                                                                                                                                                                                                                                                                          
      48               0 :                 $_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";                                     
      49               0 :                 $_output .= "if (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]->value".$parameter['if condition']['var']['smarty_internal_index']." = ".$parameter['if condition']['value']."){?>";                                                                                                                             
      50               0 :             } else {                                                                                                                                                                                                                                                                                                                                    
      51               0 :                 $_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."])) \$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."] = new Smarty_Variable(null{$_nocache});";                                                                                                                                  
      52               0 :                 $_output .= "if (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."]->value = ".$parameter['if condition']['value']."){?>";                                                                                                                                                                                                  
      53                 :             }                                                                                                                                                                                                                                                                                                                                           
      54               0 :             return $_output;                                                                                                                                                                                                                                                                                                                            
      55                 :         } else {                                                                                                                                                                                                                                                                                                                                        
      56               0 :             return "<?php if ({$parameter['if condition']}){?>";                                                                                                                                                                                                                                                                                        
      57                 :         }                                                                                                                                                                                                                                                                                                                                               
      58                 :     }                                                                                                                                                                                                                                                                                                                                                   
      59                 :                                                                                                                                                                                                                                                                                                                                                         
      60                 : }                                                                                                                                                                                                                                                                                                                                                       
      61                 :                                                                                                                                                                                                                                                                                                                                                         
      62                 : /**                                                                                                                                                                                                                                                                                                                                                     
      63                 :  * Smarty Internal Plugin Compile Else Class                                                                                                                                                                                                                                                                                                            
      64                 :  *                                                                                                                                                                                                                                                                                                                                                      
      65                 :  * @package Smarty                                                                                                                                                                                                                                                                                                                                      
      66                 :  * @subpackage Compiler                                                                                                                                                                                                                                                                                                                                 
      67                 :  */                                                                                                                                                                                                                                                                                                                                                     
      68                 : class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase {                                                                                                                                                                                                                                                                                
      69                 :                                                                                                                                                                                                                                                                                                                                                         
      70                 :     /**                                                                                                                                                                                                                                                                                                                                                 
      71                 :      * Compiles code for the {else} tag                                                                                                                                                                                                                                                                                                                 
      72                 :      *                                                                                                                                                                                                                                                                                                                                                  
      73                 :      * @param array  $args       array with attributes from parser                                                                                                                                                                                                                                                                                      
      74                 :      * @param object $compiler   compiler object                                                                                                                                                                                                                                                                                                        
      75                 :      * @param array  $parameter  array with compilation parameter                                                                                                                                                                                                                                                                                       
      76                 :      * @return string compiled code                                                                                                                                                                                                                                                                                                                     
      77                 :      */                                                                                                                                                                                                                                                                                                                                                 
      78                 :     public function compile($args, $compiler, $parameter)                                                                                                                                                                                                                                                                                               
      79                 :     {                                                                                                                                                                                                                                                                                                                                                   
      80               0 :         list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif'));                                                                                                                                                                                                                                                     
      81               0 :         $this->openTag($compiler, 'else', array($nesting, $compiler->tag_nocache));                                                                                                                                                                                                                                                                     
      82                 :                                                                                                                                                                                                                                                                                                                                                         
      83               0 :         return "<?php }else{ ?>";                                                                                                                                                                                                                                                                                                                       
      84                 :     }                                                                                                                                                                                                                                                                                                                                                   
      85                 :                                                                                                                                                                                                                                                                                                                                                         
      86                 : }                                                                                                                                                                                                                                                                                                                                                       
      87                 :                                                                                                                                                                                                                                                                                                                                                         
      88                 : /**                                                                                                                                                                                                                                                                                                                                                     
      89                 :  * Smarty Internal Plugin Compile ElseIf Class                                                                                                                                                                                                                                                                                                          
      90                 :  *                                                                                                                                                                                                                                                                                                                                                      
      91                 :  * @package Smarty                                                                                                                                                                                                                                                                                                                                      
      92                 :  * @subpackage Compiler                                                                                                                                                                                                                                                                                                                                 
      93                 :  */                                                                                                                                                                                                                                                                                                                                                     
      94                 : class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase {                                                                                                                                                                                                                                                                              
      95                 :                                                                                                                                                                                                                                                                                                                                                         
      96                 :     /**                                                                                                                                                                                                                                                                                                                                                 
      97                 :      * Compiles code for the {elseif} tag                                                                                                                                                                                                                                                                                                               
      98                 :      *                                                                                                                                                                                                                                                                                                                                                  
      99                 :      * @param array  $args       array with attributes from parser                                                                                                                                                                                                                                                                                      
     100                 :      * @param object $compiler   compiler object                                                                                                                                                                                                                                                                                                        
     101                 :      * @param array  $parameter  array with compilation parameter                                                                                                                                                                                                                                                                                       
     102                 :      * @return string compiled code                                                                                                                                                                                                                                                                                                                     
     103                 :      */                                                                                                                                                                                                                                                                                                                                                 
     104                 :     public function compile($args, $compiler, $parameter)                                                                                                                                                                                                                                                                                               
     105                 :     {                                                                                                                                                                                                                                                                                                                                                   
     106                 :         // check and get attributes                                                                                                                                                                                                                                                                                                                     
     107               0 :         $_attr = $this->getAttributes($compiler, $args);                                                                                                                                                                                                                                                                                                
     108                 :                                                                                                                                                                                                                                                                                                                                                         
     109               0 :         list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif'));                                                                                                                                                                                                                                                     
     110                 :                                                                                                                                                                                                                                                                                                                                                         
     111               0 :         if (is_array($parameter['if condition'])) {                                                                                                                                                                                                                                                                                                     
     112               0 :             $condition_by_assign = true;                                                                                                                                                                                                                                                                                                                
     113               0 :             if ($compiler->nocache) {                                                                                                                                                                                                                                                                                                                   
     114               0 :                 $_nocache = ',true';                                                                                                                                                                                                                                                                                                                    
     115                 :                 // create nocache var to make it know for further compiling                                                                                                                                                                                                                                                                             
     116               0 :                 if (is_array($parameter['if condition']['var'])) {                                                                                                                                                                                                                                                                                      
     117               0 :                     $compiler->template->tpl_vars[trim($parameter['if condition']['var']['var'], "'")] = new Smarty_variable(null, true);                                                                                                                                                                                                               
     118               0 :                 } else {                                                                                                                                                                                                                                                                                                                                
     119               0 :                     $compiler->template->tpl_vars[trim($parameter['if condition']['var'], "'")] = new Smarty_variable(null, true);                                                                                                                                                                                                                      
     120                 :                 }                                                                                                                                                                                                                                                                                                                                       
     121               0 :             } else {                                                                                                                                                                                                                                                                                                                                    
     122               0 :                 $_nocache = '';                                                                                                                                                                                                                                                                                                                         
     123                 :             }                                                                                                                                                                                                                                                                                                                                           
     124               0 :         } else {                                                                                                                                                                                                                                                                                                                                        
     125               0 :             $condition_by_assign = false;                                                                                                                                                                                                                                                                                                               
     126                 :         }                                                                                                                                                                                                                                                                                                                                               
     127                 :                                                                                                                                                                                                                                                                                                                                                         
     128               0 :         if (empty($compiler->prefix_code)) {                                                                                                                                                                                                                                                                                                            
     129               0 :             if ($condition_by_assign) {                                                                                                                                                                                                                                                                                                                 
     130               0 :                 $this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));                                                                                                                                                                                                                                                       
     131               0 :                 if (is_array($parameter['if condition']['var'])) {                                                                                                                                                                                                                                                                                      
     132               0 :                     $_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";              
     133               0 :                     $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" . $parameter['if condition']['var']['smarty_internal_index'] . " = " . $parameter['if condition']['value'] . "){?>";                                                                                                             
     134               0 :                 } else {                                                                                                                                                                                                                                                                                                                                
     135               0 :                     $_output = "<?php  }else{ if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});";                                                                                                              
     136               0 :                     $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . "){?>";                                                                                                                                                                                      
     137                 :                 }                                                                                                                                                                                                                                                                                                                                       
     138               0 :                 return $_output;                                                                                                                                                                                                                                                                                                                        
     139                 :             } else {                                                                                                                                                                                                                                                                                                                                    
     140               0 :                 $this->openTag($compiler, 'elseif', array($nesting, $compiler->tag_nocache));                                                                                                                                                                                                                                                           
     141               0 :                 return "<?php }elseif({$parameter['if condition']}){?>";                                                                                                                                                                                                                                                                                
     142                 :             }                                                                                                                                                                                                                                                                                                                                           
     143                 :         } else {                                                                                                                                                                                                                                                                                                                                        
     144               0 :             $tmp = '';                                                                                                                                                                                                                                                                                                                                  
     145               0 :             foreach ($compiler->prefix_code as $code)                                                                                                                                                                                                                                                                                                   
     146               0 :                 $tmp .= $code;                                                                                                                                                                                                                                                                                                                          
     147               0 :             $compiler->prefix_code = array();                                                                                                                                                                                                                                                                                                           
     148               0 :             $this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));                                                                                                                                                                                                                                                           
     149               0 :             if ($condition_by_assign) {                                                                                                                                                                                                                                                                                                                 
     150               0 :                 if (is_array($parameter['if condition']['var'])) {                                                                                                                                                                                                                                                                                      
     151               0 :                     $_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";
     152               0 :                     $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" . $parameter['if condition']['var']['smarty_internal_index'] . " = " . $parameter['if condition']['value'] . "){?>";                                                                                                             
     153               0 :                 } else {                                                                                                                                                                                                                                                                                                                                
     154               0 :                     $_output = "<?php }else{?>{$tmp}<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});";                                                                                                  
     155               0 :                     $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . "){?>";                                                                                                                                                                                      
     156                 :                 }                                                                                                                                                                                                                                                                                                                                       
     157               0 :                 return $_output;                                                                                                                                                                                                                                                                                                                        
     158                 :             } else {                                                                                                                                                                                                                                                                                                                                    
     159               0 :                 return "<?php }else{?>{$tmp}<?php if ({$parameter['if condition']}){?>";                                                                                                                                                                                                                                                                
     160                 :             }                                                                                                                                                                                                                                                                                                                                           
     161                 :         }                                                                                                                                                                                                                                                                                                                                               
     162                 :     }                                                                                                                                                                                                                                                                                                                                                   
     163                 :                                                                                                                                                                                                                                                                                                                                                         
     164                 : }                                                                                                                                                                                                                                                                                                                                                       
     165                 :                                                                                                                                                                                                                                                                                                                                                         
     166                 : /**                                                                                                                                                                                                                                                                                                                                                     
     167                 :  * Smarty Internal Plugin Compile Ifclose Class                                                                                                                                                                                                                                                                                                         
     168                 :  *                                                                                                                                                                                                                                                                                                                                                      
     169                 :  * @package Smarty                                                                                                                                                                                                                                                                                                                                      
     170                 :  * @subpackage Compiler                                                                                                                                                                                                                                                                                                                                 
     171                 :  */                                                                                                                                                                                                                                                                                                                                                     
     172                 : class Smarty_Internal_Compile_Ifclose extends Smarty_Internal_CompileBase {                                                                                                                                                                                                                                                                             
     173                 :                                                                                                                                                                                                                                                                                                                                                         
     174                 :     /**                                                                                                                                                                                                                                                                                                                                                 
     175                 :      * Compiles code for the {/if} tag                                                                                                                                                                                                                                                                                                                  
     176                 :      *                                                                                                                                                                                                                                                                                                                                                  
     177                 :      * @param array  $args       array with attributes from parser                                                                                                                                                                                                                                                                                      
     178                 :      * @param object $compiler   compiler object                                                                                                                                                                                                                                                                                                        
     179                 :      * @param array  $parameter  array with compilation parameter                                                                                                                                                                                                                                                                                       
     180                 :      * @return string compiled code                                                                                                                                                                                                                                                                                                                     
     181                 :      */                                                                                                                                                                                                                                                                                                                                                 
     182                 :     public function compile($args, $compiler, $parameter)                                                                                                                                                                                                                                                                                               
     183                 :     {                                                                                                                                                                                                                                                                                                                                                   
     184                 :         // must endblock be nocache?                                                                                                                                                                                                                                                                                                                    
     185               0 :         if ($compiler->nocache) {                                                                                                                                                                                                                                                                                                                       
     186               0 :             $compiler->tag_nocache = true;                                                                                                                                                                                                                                                                                                              
     187               0 :         }                                                                                                                                                                                                                                                                                                                                               
     188               0 :         list($nesting, $compiler->nocache) = $this->closeTag($compiler, array('if', 'else', 'elseif'));                                                                                                                                                                                                                                                 
     189               0 :         $tmp = '';                                                                                                                                                                                                                                                                                                                                      
     190               0 :         for ($i = 0; $i < $nesting; $i++) {                                                                                                                                                                                                                                                                                                             
     191               0 :             $tmp .= '}';                                                                                                                                                                                                                                                                                                                                
     192               0 :         }                                                                                                                                                                                                                                                                                                                                               
     193               0 :         return "<?php {$tmp}?>";                                                                                                                                                                                                                                                                                                                        
     194                 :     }                                                                                                                                                                                                                                                                                                                                                   
     195                 :                                                                                                                                                                                                                                                                                                                                                         
     196                 : }                                                                                                                                                                                                                                                                                                                                                       
     197                 :                                                                                                                                                                                                                                                                                                                                                         


Generated by PHP_CodeCoverage @package_version@ using PHP 5.3.6 and PHPUnit @package_version@ at Tue Jun 26 15:06:55 CEST 2012.