Source for file with.php

Documentation is available at with.php

  1. <?php
  2.  
  3. /**
  4.  * Moves the scope down into the provided variable, allowing you to use shorter
  5.  * variable names if you repeatedly access values into a single array
  6.  *
  7.  * The with block won't display anything at all if the provided scope is empty,
  8.  * so in effect it acts as {if $var}*content*{/if}
  9.  * <pre>
  10.  *  * var : the variable name to move into
  11.  * </pre>
  12.  * Example :
  13.  *
  14.  * instead of the following :
  15.  *
  16.  * <code>
  17.  * {if $long.boring.prefix}
  18.  *   {$long.boring.prefix.val} - {$long.boring.prefix.secondVal} - {$long.boring.prefix.thirdVal}
  19.  * {/if}
  20.  * </code>
  21.  *
  22.  * you can use :
  23.  *
  24.  * <code>
  25.  * {with $long.boring.prefix}
  26.  *   {$val} - {$secondVal} - {$thirdVal}
  27.  * {/with}
  28.  * </code>
  29.  *
  30.  * This software is provided 'as-is', without any express or implied warranty.
  31.  * In no event will the authors be held liable for any damages arising from the use of this software.
  32.  *
  33.  * This file is released under the LGPL
  34.  * "GNU Lesser General Public License"
  35.  * More information can be found here:
  36.  * {@link http://www.gnu.org/copyleft/lesser.html}
  37.  *
  38.  * @author     Jordi Boggiano <[email protected]>
  39.  * @copyright  Copyright (c) 2008, Jordi Boggiano
  40.  * @license    http://www.gnu.org/copyleft/lesser.html  GNU Lesser General Public License
  41.  * @link       http://dwoo.org/
  42.  * @version    0.9.1
  43.  * @date       2008-05-30
  44.  * @package    Dwoo
  45.  */
  46. {
  47.     protected static $cnt=0;
  48.  
  49.     public function init($var)
  50.     {
  51.     }
  52.  
  53.     public static function preProcessing(Dwoo_Compiler $compilerarray $params$prepend$append$type)
  54.     {
  55.         $rparams $compiler->getRealParams($params);
  56.         $cparams $compiler->getCompiledParams($params);
  57.  
  58.         $compiler->setScope($rparams['var']);
  59.  
  60.         $params =$compiler->getCurrentBlock();
  61.         $params['params']['postOutput'Dwoo_Compiler::PHP_OPEN."\n/* -- end with output */\n".'$this->setScope($_with'.(self::$cnt).', true);'."\n}\n".Dwoo_Compiler::PHP_CLOSE;
  62.  
  63.         return Dwoo_Compiler::PHP_OPEN.'if ('.$cparams['var'].')'."\n{\n".'$_with'.(self::$cnt++).' = $this->setScope("'.$rparams['var'].'");'."\n/* -- start with output */\n".Dwoo_Compiler::PHP_CLOSE;
  64.     }
  65.  
  66.     public static function postProcessing(Dwoo_Compiler $compilerarray $params$prepend$append$content)
  67.     {
  68.         return $content $params['postOutput'];
  69.     }
  70. }

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