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.  * @author     Jordi Boggiano <j.boggiano@seld.be>
  27.  * @copyright  Copyright (c) 2008, Jordi Boggiano
  28.  * @license    http://dwoo.org/LICENSE   Modified BSD License
  29.  * @link       http://dwoo.org/
  30.  * @version    1.0.0
  31.  * @date       2008-10-23
  32.  * @package    Dwoo
  33.  */
  34. {
  35.     public function init($name 'default'$assign null$cat false$trim false)
  36.     {
  37.     }
  38.  
  39.     public static function preProcessing(Dwoo_Compiler $compilerarray $params$prepend$append$type)
  40.     {
  41.         return Dwoo_Compiler::PHP_OPEN.$prepend.'ob_start();'.$append.Dwoo_Compiler::PHP_CLOSE;
  42.     }
  43.  
  44.     public static function postProcessing(Dwoo_Compiler $compilerarray $params$prepend$append$content)
  45.     {
  46.         $params $compiler->getCompiledParams($params);
  47.  
  48.         $out $content Dwoo_Compiler::PHP_OPEN.$prepend."\n".'$tmp = ob_get_clean();';
  49.         if ($params['trim'!== 'false' && $params['trim'!== 0{
  50.             $out .= "\n".'$tmp = trim($tmp);';
  51.         }
  52.         if ($params['cat'=== 'true' || $params['cat'=== 1{
  53.             $out .= "\n".'$tmp = $this->readVar(\'dwoo.capture.\'.'.$params['name'].') . $tmp;';
  54.         }
  55.         if ($params['assign'!== 'null'{
  56.             $out .= "\n".'$this->scope['.$params['assign'].'] = $tmp;';
  57.         }
  58.         return $out "\n".'$this->globals[\'capture\']['.$params['name'].'] = $tmp;'.$append.Dwoo_Compiler::PHP_CLOSE;
  59.     }
  60. }

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