MDL-9123:
[moodle-linuxchix.git] / lib / smarty / plugins / shared.escape_special_chars.php
blob515763abedc096e496cfbf3dd8424c197d0e387c
1 <?php
2 /**
3 * Smarty shared plugin
4 * @package Smarty
5 * @subpackage plugins
6 */
9 /**
10 * escape_special_chars common function
12 * Function: smarty_function_escape_special_chars<br>
13 * Purpose: used by other smarty functions to escape
14 * special chars except for already escaped ones
15 * @param string
16 * @return string
18 function smarty_function_escape_special_chars($string)
20 if(!is_array($string)) {
21 $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
22 $string = htmlspecialchars($string);
23 $string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string);
25 return $string;
28 /* vim: set expandtab: */