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 <[email protected]>
  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 static $types array
  37.     (
  38.         'if' => true'elseif' => true'for' => true,
  39.         'foreach' => true'loop' => true'with' => true
  40.     );
  41.  
  42.     public function init()
  43.     {
  44.     }
  45.  
  46.     public static function preProcessing(Dwoo_Compiler $compilerarray $params$prepend$append$type)
  47.     {
  48.         $block =$compiler->getCurrentBlock();
  49.         $out '';
  50.         while (!isset(self::$types[$block['type']])) {
  51.             $out .= $compiler->removeTopBlock();
  52.             $block =$compiler->getCurrentBlock();
  53.         }
  54.  
  55.         $out .= $block['params']['postOutput'];
  56.         $block['params']['postOutput''';
  57.         $out substr($out0-strlen(Dwoo_Compiler::PHP_CLOSE));
  58.  
  59.         $currentBlock =$compiler->getCurrentBlock();
  60.         $currentBlock['params']['postOutput'Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE;
  61.  
  62.         return $out " else {\n".Dwoo_Compiler::PHP_CLOSE;
  63.     }
  64.  
  65.     public static function postProcessing(Dwoo_Compiler $compilerarray $params$prepend$append$content)
  66.     {
  67.         if (isset($params['postOutput'])) {
  68.             return $content $params['postOutput'];
  69.         else {
  70.             return $content;
  71.         }
  72.     }
  73. }

Documentation generated on Sun, 03 Aug 2008 15:12:31 +0200 by phpDocumentor 1.4.0