72b8a48c207547bf5be6bd8d579c39f3cd732c79
[atutor.git] / mods / phpdoc2 / PhpDocumentor / phpDocumentor / Smarty-2.6.0 / libs / plugins / shared.escape_special_chars.php
1 <?php\r
2 /**\r
3  * Smarty shared plugin\r
4  * @package Smarty\r
5  * @subpackage plugins\r
6  */\r
7 \r
8 \r
9 /**\r
10  * escape_special_chars common function\r
11  *\r
12  * Function: smarty_function_escape_special_chars<br>\r
13  * Purpose:  used by other smarty functions to escape\r
14  *           special chars except for already escaped ones\r
15  * @param string\r
16  * @return string\r
17  */\r
18 function smarty_function_escape_special_chars($string)\r
19 {\r
20         if(!is_array($string))  {\r
21                 $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);\r
22                 $string = htmlspecialchars($string);\r
23                 $string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string);\r
24         }\r
25         return $string; \r
26 }\r
27 \r
28 /* vim: set expandtab: */\r
29 \r
30 ?>\r