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.  * @author     Jordi Boggiano <j.boggiano@seld.be>
  23.  * @copyright  Copyright (c) 2008, Jordi Boggiano
  24.  * @license    http://dwoo.org/LICENSE   Modified BSD License
  25.  * @link       http://dwoo.org/
  26.  * @version    1.0.0
  27.  * @date       2008-10-23
  28.  * @package    Dwoo
  29.  */
  30. {
  31.     public function init()
  32.     {
  33.     }
  34.  
  35.     public static function preProcessing(Dwoo_Compiler $compilerarray $params$prepend$append$type)
  36.     {
  37.         $preContent '';
  38.         while (true{
  39.             $preContent .= $compiler->removeTopBlock();
  40.             $block =$compiler->getCurrentBlock();
  41.             $interfaces class_implements($block['class']false);
  42.             if (in_array('Dwoo_IElseable'$interfaces!== false{
  43.                 break;
  44.             }
  45.         }
  46.  
  47.         $params['initialized'true;
  48.         $compiler->injectBlock($type$params);
  49.         return $preContent;
  50.     }
  51.  
  52.     public static function postProcessing(Dwoo_Compiler $compilerarray $params$prepend$append$content)
  53.     {
  54.         if (!isset($params['initialized'])) {
  55.             return '';
  56.         }
  57.  
  58.         $block =$compiler->getCurrentBlock();
  59.         $block['params']['hasElse'Dwoo_Compiler::PHP_OPEN."else {\n".Dwoo_Compiler::PHP_CLOSE $content Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE;
  60.         return '';
  61.     }
  62. }

Documentation generated on Sat, 18 Jul 2009 21:04:56 +0200 by phpDocumentor 1.4.0