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.         $preContent '';
  43.         while (true{
  44.             $preContent .= $compiler->removeTopBlock();
  45.             $block =$compiler->getCurrentBlock();
  46.             $interfaces class_implements($block['class']false);
  47.             if (in_array('Dwoo_IElseable'$interfaces!== false{
  48.                 break;
  49.             }
  50.         }
  51.  
  52.         $params['initialized'true;
  53.         $compiler->injectBlock($type$params);
  54.         return $preContent;
  55.     }
  56.  
  57.     public static function postProcessing(Dwoo_Compiler $compilerarray $params$prepend$append$content)
  58.     {
  59.         if (!isset($params['initialized'])) {
  60.             return '';
  61.         }
  62.  
  63.         $block =$compiler->getCurrentBlock();
  64.         $block['params']['hasElse'Dwoo_Compiler::PHP_OPEN."else {\n".Dwoo_Compiler::PHP_CLOSE $content Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE;
  65.         return '';
  66.     }
  67. }

Documentation generated on Sun, 07 Sep 2008 23:57:44 +0200 by phpDocumentor 1.4.0