XML_Transformer
[ class tree: XML_Transformer ] [ index: XML_Transformer ] [ all elements ]

Source for file OutputBuffer.php

Documentation is available at OutputBuffer.php

  1. <?php
  2. //
  3. // +---------------------------------------------------------------------------+
  4. // | PEAR :: XML :: Transformer :: Driver :: OutputBuffer                      |
  5. // +---------------------------------------------------------------------------+
  6. // | Copyright (c) 2002-2005 Sebastian Bergmann <sb@sebastian-bergmann.de> and |
  7. // +---------------------------------------------------------------------------+
  8. // | This source file is subject to version 3.00 of the PHP License,           |
  9. // | that is available at http://www.php.net/license/3_0.txt.                  |
  10. // | If you did not receive a copy of the PHP license and are unable to        |
  11. // | obtain it through the world-wide-web, please send a note to               |
  12. // | license@php.net so we can mail you a copy immediately.                    |
  13. // +---------------------------------------------------------------------------+
  14. //
  15. // $Id$
  16. //
  17.  
  18. require_once 'XML/Transformer.php';
  19.  
  20.  /**
  21.  * Uses PHP's Output Buffering mechanism to catch the
  22.  * output of a script, transforms it, and outputs the
  23.  * result.
  24.  *
  25.  * Example
  26.  *
  27.  * <code>
  28.  * <?php
  29.  * require_once 'XML/Transformer/Driver/OutputBuffer.php';
  30.  * require_once 'XML/Transformer/Namespace.php';
  31.  *
  32.  * class Main extends XML_Transformer_Namespace {
  33.  *     function start_bold($attributes) {
  34.  *         return '<b>';
  35.  *     }
  36.  *
  37.  *     function end_bold($cdata) {
  38.  *         return $cdata . '</b>';
  39.  *     }
  40.  * }
  41.  *
  42.  * $t = new XML_Transformer_Driver_OutputBuffer(
  43.  *   array(
  44.  *     'overloadedNamespaces' => array(
  45.  *       '&MAIN' => new Main
  46.  *     )
  47.  *   )
  48.  * );
  49.  * ?>
  50.  * <bold>text</bold>
  51.  * </code>
  52.  *
  53.  * Output
  54.  *
  55.  * <code>
  56.  * <b>text</b>
  57.  * </code>
  58.  *
  59.  * @author      Sebastian Bergmann <sb@sebastian-bergmann.de>
  60.  * @author
  61.  * @copyright
  62.  * @license     http://www.php.net/license/3_0.txt The PHP License, Version 3.0
  63.  * @category    XML
  64.  * @package     XML_Transformer
  65.  */
  66.     // {{{ Members
  67.  
  68.     /**
  69.     * @var    boolean 
  70.     * @access private
  71.     */
  72.     var $_started = FALSE;
  73.  
  74.     // }}}
  75.     // {{{ function XML_Transformer_Driver_OutputBuffer($parameters = array())
  76.  
  77.     /**
  78.     * Constructor.
  79.     *
  80.     * @param  array 
  81.     * @access public
  82.     */
  83.     function XML_Transformer_Driver_OutputBuffer($parameters = array()) {
  84.         $this->XML_Transformer($parameters);
  85.  
  86.         if (!empty($this->_callbackRegistry->overloadedNamespaces)) {
  87.             $this->start();
  88.         }
  89.     }
  90.  
  91.     // }}}
  92.     // {{{ function start()
  93.  
  94.     /**
  95.     * Starts the output-buffering,
  96.     * and thus the transformation.
  97.     *
  98.     * @access public
  99.     */
  100.     function start({
  101.         if (!$this->_started{
  102.             ob_start(
  103.               array(
  104.                 $this'transform'
  105.               )
  106.             );
  107.  
  108.             $this->_started = TRUE;
  109.  
  110.             if ($this->_checkDebug()) {
  111.                 $this->sendMessage(
  112.                   'start: ' serialize($this)
  113.                 );
  114.             }
  115.         }
  116.     }
  117.  
  118.     // }}}
  119. }
  120.  
  121. /*
  122.  * vim600:  et sw=2 ts=2 fdm=marker
  123.  * vim<600: et sw=2 ts=2
  124.  */
  125. ?>

Documentation generated on Mon, 11 Mar 2019 15:48:10 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.