home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 August / PCWorld_2001-08_cd.bin / Komunikace / phptriad / phptriadsetup2-11.exe / php / pear / HTML / Processor.php < prev   
PHP Script  |  2001-01-17  |  3KB  |  102 lines

  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4.0                                                      |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2001 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Sterling Hughes <sterling@php.net>                          |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Processor.php,v 1.1 2001/01/17 16:34:05 sterling Exp $
  20. //
  21. // HTML processing utility functions.
  22. //
  23.  
  24. /**
  25.  * TODO:
  26.  *   -  Extend the XML_Parser module to provide HTML parsing abilities
  27.  */
  28.  
  29. require_once('PEAR.php');
  30.  
  31. // {{{ HTML_Processor
  32.  
  33. $_HTML_Processor_translation_table = array();
  34.  
  35. /**
  36.  * The HTML_Processor class facilitates the parsing and processing of
  37.  * HTML.  Currently only some basic functionality to process HTML is 
  38.  * provided..
  39.  *
  40.  * @access public
  41.  * @author Sterling Hughes <sterling@php.net>
  42.  * @since  PHP 4.0.5
  43.  */
  44. class HTML_Processor extends XML_Parser
  45. {
  46.     // {{{ HTML_Processor()
  47.  
  48.     function HTML_Processor()
  49.     {
  50.         global $_HTML_Processor_translation_table;
  51.         $_HTML_Processor_translation_table = get_html_translation_table();
  52.     }
  53.  
  54.     // }}}
  55.     // {{{ ConvertSpecial()
  56.  
  57.     /**
  58.      * Convert special HTML characters (like ©) into their ASCII
  59.      * equivalents.
  60.      *
  61.      * @param  string &$text The text to convert
  62.      *
  63.      * @access public
  64.      * @author Sterling Hughes <sterling@php.net>
  65.      * @since  PHP 4.0.5
  66.      */
  67.     function ConvertSpecial(&$text)
  68.     {
  69.         global $_HTML_Processor_translation_table;
  70.  
  71.         $text = strtr($text, 
  72.                       array_keys($_HTML_Processor_translation_table), 
  73.                       array_flip(array_values($_HTML_Processor_translation_table)));
  74.     }
  75.  
  76.     // }}}
  77.     // {{{ ConvertASCII()
  78.  
  79.     /**
  80.      * Convert ASCII characters into their HTML equivalents (ie, ' to 
  81.      * ").
  82.      *
  83.      * @param  string &$text The text to convert
  84.      *
  85.      * @access public
  86.      * @author Sterling Hughes <sterling@php.net>
  87.      * @since  PHP 4.0.5
  88.      */
  89.     function ConvertASCII(&$text)
  90.     {
  91.         global $_HTML_Processor_translation_table;
  92.  
  93.         $text = strtr($text,
  94.                       array_flip(array_values($_HTML_Processor_translation_table)), 
  95.                       array_keys($_HTML_Processor_translation_table));
  96.     }
  97.  
  98.     // }}}
  99. }
  100.  
  101. // }}}
  102. ?>