Source for file else.php

Documentation is available at else.php

  1. <?php
  2.  
  3. /**
  4.  * Generic else block, it supports all builtin optional-display blocks which are if/for/foreach/loop/with
  5.  * 
  6.  * If any of those block contains an else statement, the content between {else} and {/block} (you do not
  7.  * need to close the else block) will be shown if the block's condition has no been met
  8.  * 
  9.  * Example :
  10.  * 
  11.  * <code>
  12.  * {foreach $array val}
  13.  *   $array is not empty so we display it's values : {$val}
  14.  * {else}
  15.  *   if this shows, it means that $array is empty or doesn't exist.
  16.  * {/foreach}
  17.  * </code>
  18.  *
  19.  * This software is provided 'as-is', without any express or implied warranty.
  20.  * In no event will the authors be held liable for any damages arising from the use of this software.
  21.  *
  22.  * This file is released under the LGPL
  23.  * "GNU Lesser General Public License"
  24.  * More information can be found here:
  25.  * {@link http://www.gnu.org/copyleft/lesser.html}
  26.  *
  27.  * @author     Jordi Boggiano <j.boggiano@seld.be>
  28.  * @copyright  Copyright (c) 2008, Jordi Boggiano
  29.  * @license    http://www.gnu.org/copyleft/lesser.html  GNU Lesser General Public License
  30.  * @link       http://dwoo.org/
  31.  * @version    0.9.1
  32.  * @date       2008-05-30
  33.  * @package    Dwoo
  34.  */
  35. {
  36.     public function init()
  37.     {
  38.     }
  39.  
  40.     public static function preProcessing(Dwoo_Compiler $compilerarray $params$prepend$append$type)
  41.     {
  42.         $block =$compiler->getCurrentBlock();
  43.         $out '';
  44.         while ($block['type'!== 'if' && $block['type'!== 'foreach' && $block['type'!== 'for' && $block['type'!== 'with' && $block['type'!== 'loop'{
  45.             $out .= $compiler->removeTopBlock();
  46.             $block =$compiler->getCurrentBlock();
  47.         }
  48.  
  49.         $out .= $block['params']['postOutput'];
  50.         $block['params']['postOutput''';
  51.         $out substr($out0-strlen(Dwoo_Compiler::PHP_CLOSE));
  52.  
  53.         $currentBlock =$compiler->getCurrentBlock();
  54.         $currentBlock['params']['postOutput'Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE;
  55.  
  56.         return $out "else {\n".Dwoo_Compiler::PHP_CLOSE;
  57.     }
  58.  
  59.     public static function postProcessing(Dwoo_Compiler $compilerarray $params$prepend$append$content)
  60.     {
  61.         if (isset($params['postOutput'])) {
  62.             return $content $params['postOutput'];
  63.         else {
  64.             return $content;
  65.         }
  66.     }
  67. }

Documentation generated on Sat, 28 Jun 2008 01:38:20 +0200 by phpDocumentor 1.4.0