Source for file capture.php

Documentation is available at capture.php

  1. <?php
  2.  
  3. /**
  4.  * Captures all the output within this block and saves it into {$.capture.default} by default,
  5.  * or {$.capture.name} if you provide another name.
  6.  * <pre>
  7.  *  * name : capture name, used to read the value afterwards
  8.  *  * assign : if set, the value is also saved in the given variable
  9.  *  * cat : if true, the value is appended to the previous one (if any) instead of overwriting it
  10.  * </pre>
  11.  * If the cat parameter is true, the content
  12.  * will be appended to the existing content
  13.  *
  14.  * Example :
  15.  *
  16.  * <code>
  17.  * {capture "foo"}
  18.  *   Anything in here won't show, it will be saved for later use..
  19.  * {/capture}
  20.  * Output was : {$.capture.foo}
  21.  * </code>
  22.  *
  23.  * This software is provided 'as-is', without any express or implied warranty.
  24.  * In no event will the authors be held liable for any damages arising from the use of this software.
  25.  *
  26.  * This file is released under the LGPL
  27.  * "GNU Lesser General Public License"
  28.  * More information can be found here:
  29.  * {@link http://www.gnu.org/copyleft/lesser.html}
  30.  *
  31.  * @author     Jordi Boggiano <[email protected]>
  32.  * @copyright  Copyright (c) 2008, Jordi Boggiano
  33.  * @license    http://www.gnu.org/copyleft/lesser.html  GNU Lesser General Public License
  34.  * @link       http://dwoo.org/
  35.  * @version    0.9.1
  36.  * @date       2008-05-30
  37.  * @package    Dwoo
  38.  */
  39. {
  40.     public function init($name 'default'$assign null$cat false$trim false)
  41.     {
  42.     }
  43.  
  44.     public static function preProcessing(Dwoo_Compiler $compilerarray $params$prepend$append$type)
  45.     {
  46.         return Dwoo_Compiler::PHP_OPEN.$prepend.'ob_start();'.$append.Dwoo_Compiler::PHP_CLOSE;
  47.     }
  48.  
  49.     public static function postProcessing(Dwoo_Compiler $compilerarray $params$prepend$append$content)
  50.     {
  51.         $params $compiler->getCompiledParams($params);
  52.  
  53.         $out $content Dwoo_Compiler::PHP_OPEN.$prepend."\n".'$tmp = ob_get_clean();';
  54.         if ($params['trim'!== 'false' && $params['trim'!== 0{
  55.             $out .= "\n".'$tmp = trim($tmp);';
  56.         }
  57.         if ($params['cat'=== 'true' || $params['cat'=== 1{
  58.             $out .= "\n".'$tmp = $this->readVar(\'dwoo.capture.\'.'.$params['name'].') . $tmp;';
  59.         }
  60.         if ($params['assign'!== 'null'{
  61.             $out .= "\n".'$this->scope['.$params['assign'].'] = $tmp;';
  62.         }
  63.         return $out "\n".'$this->globals[\'capture\']['.$params['name'].'] = $tmp;'.$append.Dwoo_Compiler::PHP_CLOSE;
  64.     }
  65. }

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