home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / Text / Highlighter / Renderer / XML.php < prev   
Encoding:
PHP Script  |  2008-07-02  |  2.7 KB  |  104 lines

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3. /**
  4.  * XML renderer.
  5.  *
  6.  * Based on the HTML renderer by Andrey Demenev.
  7.  *
  8.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  9.  * that is available through the world-wide-web at the following URI:
  10.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  11.  * the PHP License and are unable to obtain it through the web, please
  12.  * send a note to license@php.net so we can mail you a copy immediately.
  13.  *
  14.  * @category   Text
  15.  * @package    Text_Highlighter
  16.  * @author     Stoyan Stefanov <ssttoo@gmail.com>
  17.  * @copyright  2006 Stoyan Stefanov
  18.  * @license    http://www.php.net/license/3_0.txt  PHP License
  19.  * @version    CVS: $Id: XML.php,v 1.1 2007/06/03 02:37:09 ssttoo Exp $
  20.  * @link       http://pear.php.net/package/Text_Highlighter
  21.  */
  22.  
  23. /**
  24.  * @ignore
  25.  */
  26.  
  27. require_once 'Text/Highlighter/Renderer.php';
  28. require_once 'Text/Highlighter/Renderer/Array.php';
  29. require_once 'XML/Serializer.php';
  30.  
  31. /**
  32.  * XML renderer, based on Andrey Demenev's HTML renderer.
  33.  *
  34.  * @author     Stoyan Stefanov <ssttoo@gmail.com>
  35.  * @category   Text
  36.  * @package    Text_Highlighter
  37.  * @copyright  2006 Stoyan Stefanov
  38.  * @license    http://www.php.net/license/3_0.txt  PHP License
  39.  * @version    Release: 0.5.0
  40.  * @link       http://pear.php.net/package/Text_Highlighter
  41.  */
  42.  
  43. class Text_Highlighter_Renderer_XML extends Text_Highlighter_Renderer_Array
  44. {
  45.  
  46.  
  47.     /**
  48.      * Options for XML_Serializer
  49.      *
  50.      * @access private
  51.      * @var array
  52.      */
  53.     var $_serializer_options = array();
  54.  
  55.  
  56.     /**
  57.      * Resets renderer state
  58.      *
  59.      * Descendents of Text_Highlighter call this method from the constructor,
  60.      * passing $options they get as parameter.
  61.      *
  62.      * @access protected
  63.      */
  64.     function reset()
  65.     {
  66.         parent::reset();
  67.         if (isset($this->_options['xml_serializer'])) {
  68.             $this->_serializer_options = $this->_options['xml_serializer'];
  69.         }
  70.     }
  71.  
  72.  
  73.     /**
  74.      * Signals that no more tokens are available
  75.      *
  76.      * @abstract
  77.      * @access public
  78.      */
  79.     function finalize()
  80.     {
  81.  
  82.         // call parent's finalize(), then serialize array into XML
  83.         parent::finalize();
  84.         $output = parent::getOutput();
  85.  
  86.         $serializer =& new XML_Serializer($this->_serializer_options);
  87.         $result = $serializer->serialize($output);
  88.         if ($result === true) {
  89.             $this->_output = $serializer->getSerializedData();
  90.         }
  91.     }
  92.  
  93.  
  94. }
  95.  
  96. /*
  97.  * Local variables:
  98.  * tab-width: 4
  99.  * c-basic-offset: 4
  100.  * c-hanging-comment-ender-p: nil
  101.  * End:
  102.  */
  103.  
  104. ?>