Take two:
[www-register-wizard.git] / helpers / xml_helper.php
1 <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');\r
2 /**\r
3  * CodeIgniter\r
4  *\r
5  * An open source application development framework for PHP 4.3.2 or newer\r
6  *\r
7  * @package             CodeIgniter\r
8  * @author              ExpressionEngine Dev Team\r
9  * @copyright   Copyright (c) 2008, EllisLab, Inc.\r
10  * @license             http://codeigniter.com/user_guide/license.html\r
11  * @link                http://codeigniter.com\r
12  * @since               Version 1.0\r
13  * @filesource\r
14  */\r
15 \r
16 // ------------------------------------------------------------------------\r
17 \r
18 /**\r
19  * CodeIgniter XML Helpers\r
20  *\r
21  * @package             CodeIgniter\r
22  * @subpackage  Helpers\r
23  * @category    Helpers\r
24  * @author              ExpressionEngine Dev Team\r
25  * @link                http://codeigniter.com/user_guide/helpers/xml_helper.html\r
26  */\r
27 \r
28 // ------------------------------------------------------------------------\r
29 \r
30 /**\r
31  * Convert Reserved XML characters to Entities\r
32  *\r
33  * @access      public\r
34  * @param       string\r
35  * @return      string\r
36  */     \r
37 if ( ! function_exists('xml_convert'))\r
38 {\r
39         function xml_convert($str)\r
40         {\r
41                 $temp = '__TEMP_AMPERSANDS__';\r
42 \r
43                 // Replace entities to temporary markers so that \r
44                 // ampersands won't get messed up\r
45                 $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);\r
46                 $str = preg_replace("/&(\w+);/",  "$temp\\1;", $str);\r
47         \r
48                 $str = str_replace(array("&","<",">","\"", "'", "-"),\r
49                                                    array("&amp;", "&lt;", "&gt;", "&quot;", "&#39;", "&#45;"),\r
50                                                    $str);\r
51 \r
52                 // Decode the temp markers back to entities             \r
53                 $str = preg_replace("/$temp(\d+);/","&#\\1;",$str);\r
54                 $str = preg_replace("/$temp(\w+);/","&\\1;", $str);\r
55                 \r
56                 return $str;\r
57         }\r
58 }\r
59 \r
60 \r
61 /* End of file xml_helper.php */\r
62 /* Location: ./system/helpers/xml_helper.php */