source: branches/version-2_5-dev/data/module/Smarty/libs/plugins/shared.escape_special_chars.php @ 20119

Revision 20119, 774 bytes checked in by nanasess, 13 years ago (diff)

module 以下は svn:keywords を除外

  • Property svn:eol-style set to LF
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/**
3 * Smarty shared plugin
4 * @package Smarty
5 * @subpackage plugins
6 */
7
8
9/**
10 * escape_special_chars common function
11 *
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 * @author   Monte Ohrt <monte at ohrt dot com>
16 * @param string
17 * @return string
18 */
19function smarty_function_escape_special_chars($string)
20{
21    if(!is_array($string)) {
22        $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
23        $string = htmlspecialchars($string);
24        $string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string);
25    }
26    return $string;
27}
28
29/* vim: set expandtab: */
30
31?>
Note: See TracBrowser for help on using the repository browser.