Rev 130 Rev 139
Line 1... Line 1...
1 <?php 1 <?php
2 // +----------------------------------------------------------------------+ 2 // +----------------------------------------------------------------------+
3 // | PHP Version 4 | 3 // | PHP Version 4 |
4 // +----------------------------------------------------------------------+ 4 // +----------------------------------------------------------------------+
5 // | Copyright (c) 1997-2004 The PHP Group | 5 // | Copyright (c) 1997-2004 The PHP Group |
6 // +----------------------------------------------------------------------+ 6 // +----------------------------------------------------------------------+
7 // | This source file is subject to version 3.0 of the PHP license, | 7 // | This source file is subject to version 3.0 of the PHP license, |
8 // | that is bundled with this package in the file LICENSE, and is | 8 // | that is bundled with this package in the file LICENSE, and is |
9 // | available at through the world-wide-web at | 9 // | available at through the world-wide-web at |
10 // | http://www.php.net/license/3_0.txt. | 10 // | http://www.php.net/license/3_0.txt. |
11 // | If you did not receive a copy of the PHP license and are unable to | 11 // | If you did not receive a copy of the PHP license and are unable to |
12 // | obtain it through the world-wide-web, please send a note to | 12 // | obtain it through the world-wide-web, please send a note to |
13 // | license@php.net so we can mail you a copy immediately. | 13 // | license@php.net so we can mail you a copy immediately. |
14 // +----------------------------------------------------------------------+ 14 // +----------------------------------------------------------------------+
15 // | Authors: David Irvine <dave@codexweb.co.za> | 15 // | Authors: David Irvine <dave@codexweb.co.za> |
16 // | Aidan Lister <aidan@php.net> | 16 // | Aidan Lister <aidan@php.net> |
17 // +----------------------------------------------------------------------+ 17 // +----------------------------------------------------------------------+
18 // 18 //
19 // $Id: html_entity_decode.php,v 1.8 2005/12/07 21:08:57 aidan Exp $ 19 // $Id: html_entity_decode.php,v 1.8 2005/12/07 21:08:57 aidan Exp $
20   20  
21   21  
22 if (!defined('ENT_NOQUOTES')) { 22 if (!defined('ENT_NOQUOTES')) {
23 define('ENT_NOQUOTES', 0); 23 define('ENT_NOQUOTES', 0);
24 } 24 }
25   25  
26 if (!defined('ENT_COMPAT')) { 26 if (!defined('ENT_COMPAT')) {
27 define('ENT_COMPAT', 2); 27 define('ENT_COMPAT', 2);
28 } 28 }
29   29  
30 if (!defined('ENT_QUOTES')) { 30 if (!defined('ENT_QUOTES')) {
31 define('ENT_QUOTES', 3); 31 define('ENT_QUOTES', 3);
32 } 32 }
33   33  
34   34  
35 /** 35 /**
36 * Replace html_entity_decode() 36 * Replace html_entity_decode()
37 * 37 *
38 * @category PHP 38 * @category PHP
39 * @package PHP_Compat 39 * @package PHP_Compat
40 * @link http://php.net/function.html_entity_decode 40 * @link http://php.net/function.html_entity_decode
41 * @author David Irvine <dave@codexweb.co.za> 41 * @author David Irvine <dave@codexweb.co.za>
42 * @author Aidan Lister <aidan@php.net> 42 * @author Aidan Lister <aidan@php.net>
43 * @version $Revision: 1.8 $ 43 * @version $Revision: 1.8 $
44 * @since PHP 4.3.0 44 * @since PHP 4.3.0
45 * @internal Setting the charset will not do anything 45 * @internal Setting the charset will not do anything
46 * @require PHP 4.0.0 (user_error) 46 * @require PHP 4.0.0 (user_error)
47 */ 47 */
48 if (!function_exists('html_entity_decode')) { 48 if (!function_exists('html_entity_decode')) {
49 function html_entity_decode($string, $quote_style = ENT_COMPAT, $charset = null) 49 function html_entity_decode($string, $quote_style = ENT_COMPAT, $charset = null)
50 { 50 {
51 if (!is_int($quote_style)) { 51 if (!is_int($quote_style)) {
52 user_error('html_entity_decode() expects parameter 2 to be long, ' . 52 user_error('html_entity_decode() expects parameter 2 to be long, ' .
53 gettype($quote_style) . ' given', E_USER_WARNING); 53 gettype($quote_style) . ' given', E_USER_WARNING);
54 return; 54 return;
55 } 55 }
56   56  
57 $trans_tbl = get_html_translation_table(HTML_ENTITIES); 57 $trans_tbl = get_html_translation_table(HTML_ENTITIES);
58 $trans_tbl = array_flip($trans_tbl); 58 $trans_tbl = array_flip($trans_tbl);
59   59  
60 // Add single quote to translation table; 60 // Add single quote to translation table;
61 $trans_tbl['&#039;'] = '\''; 61 $trans_tbl['&#039;'] = '\'';
62   62  
63 // Not translating double quotes 63 // Not translating double quotes
64 if ($quote_style & ENT_NOQUOTES) { 64 if ($quote_style & ENT_NOQUOTES) {
65 // Remove double quote from translation table 65 // Remove double quote from translation table
66 unset($trans_tbl['&quot;']); 66 unset($trans_tbl['&quot;']);
67 } 67 }
68   68  
69 return strtr($string, $trans_tbl); 69 return strtr($string, $trans_tbl);
70 } 70 }
71 } 71 }
72   72  
73 ?> 73 ?>
74 74