Source for file elseif.php

Documentation is available at elseif.php

  1. <?php
  2.  
  3. /**
  4.  * Acts as a php elseif block, allowing you to add one more condition
  5.  * if the previous one(s) didn't match. See the {if} plugin for syntax details
  6.  *
  7.  * This software is provided 'as-is', without any express or implied warranty.
  8.  * In no event will the authors be held liable for any damages arising from the use of this software.
  9.  *
  10.  * This file is released under the LGPL
  11.  * "GNU Lesser General Public License"
  12.  * More information can be found here:
  13.  * {@link http://www.gnu.org/copyleft/lesser.html}
  14.  *
  15.  * @author     Jordi Boggiano <[email protected]>
  16.  * @copyright  Copyright (c) 2008, Jordi Boggiano
  17.  * @license    http://www.gnu.org/copyleft/lesser.html  GNU Lesser General Public License
  18.  * @link       http://dwoo.org/
  19.  * @version    0.9.1
  20.  * @date       2008-05-30
  21.  * @package    Dwoo
  22.  */
  23. {
  24.     public static $types array
  25.     (
  26.         'if' => true'elseif' => true
  27.     );
  28.  
  29.     public function init(array $rest)
  30.     {
  31.     }
  32.  
  33.     public static function preProcessing(Dwoo_Compiler $compilerarray $params$prepend$append$type)
  34.     {
  35.         // delete this block
  36.         $compiler->removeTopBlock();
  37.         // fetch the top of the stack
  38.         $parent =$compiler->getCurrentBlock();
  39.         // loop until we get an elseif or if block
  40.         $out '';
  41.         while (!isset(self::$types[$parent['type']])) {
  42.             $out .= $compiler->removeTopBlock();
  43.             $parent =$compiler->getCurrentBlock();
  44.         }
  45.         //
  46.         $out .= $parent['params']['postOutput'];
  47.         $parent['params']['postOutput''';
  48.  
  49.         // reinsert this block
  50.         $compiler->injectBlock($type$params1);
  51.  
  52.         // generate post-output
  53.         $currentBlock =$compiler->getCurrentBlock();
  54.         $currentBlock['params']['postOutput'Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE;
  55.  
  56.         if ($out === ''{
  57.             $out Dwoo_Compiler::PHP_OPEN."\n}";
  58.         else {
  59.             $out substr($out0-strlen(Dwoo_Compiler::PHP_CLOSE));
  60.         }
  61.  
  62.         $params $compiler->getCompiledParams($params);
  63.  
  64.         return $out " elseif (".implode(' 'self::replaceKeywords($params['*']$compiler)).") {\n" Dwoo_Compiler::PHP_CLOSE;
  65.     }
  66.  
  67.     public static function postProcessing(Dwoo_Compiler $compilerarray $params$prepend$append$content)
  68.     {
  69.         if (isset($params['postOutput'])) {
  70.             return $content $params['postOutput'];
  71.         else {
  72.             return $content;
  73.         }
  74.     }
  75. }

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