1: <?php
2: /**
3: *
4: * @package Legacy
5: * @version $Id: modifier.xoops_escape.php,v 1.3 2008/09/25 15:12:37 kilica Exp $
6: * @copyright Copyright 2005-2007 XOOPS Cube Project <https://github.com/xoopscube/legacy>
7: * @license https://github.com/xoopscube/legacy/blob/master/docs/GPL_V2.txt GNU GENERAL PUBLIC LICENSE Version 2
8: *
9: */
10:
11: /*
12: * Smarty plugin
13: * -------------------------------------------------------------
14: * Type: modifier
15: * Name: xoops_escape
16: * Author: nobunobu
17: * Purpose: Escape the string according to escapement type(XOOPS custom version)
18: * @param string
19: * @param show|edit|plain|link
20: * @return string
21: *
22: * Examples: {$msg|xoops_excape}
23: * -------------------------------------------------------------
24: */
25:
26: function smarty_modifier_xoops_escape($string, $esc_type = 'show')
27: {
28: static $textFilter;
29: if (!isset($textFilter)) {
30: $root =& XCube_Root::getSingleton();
31: $textFilter = $root->getTextFilter();
32: }
33: switch ($esc_type) {
34: case 'show':
35: return $textFilter->toShow($string);
36:
37: case 'edit':
38: return $textFilter->toEdit($string);
39:
40: case 'plain':
41: case 'link':
42: return htmlspecialchars($string, ENT_QUOTES);
43:
44: default:
45: return $string;
46: }
47: }
48: ?>
49: