equal
deleted
inserted
replaced
|
1 <?php |
|
2 /** |
|
3 * Smarty plugin |
|
4 * |
|
5 * @package Smarty |
|
6 * @subpackage PluginsModifierCompiler |
|
7 */ |
|
8 |
|
9 /** |
|
10 * Smarty unescape modifier plugin |
|
11 * Type: modifier<br> |
|
12 * Name: unescape<br> |
|
13 * Purpose: unescape html entities |
|
14 * |
|
15 * @author Rodney Rehm |
|
16 * |
|
17 * @param array $params parameters |
|
18 * |
|
19 * @return string with compiled code |
|
20 */ |
|
21 function smarty_modifiercompiler_unescape($params) { |
|
22 if (!isset($params[1])) { |
|
23 $params[1] = 'html'; |
|
24 } |
|
25 if (!isset($params[2])) { |
|
26 $params[2] = '\'' . addslashes(Smarty::$_CHARSET) . '\''; |
|
27 } else { |
|
28 $params[2] = "'" . $params[2] . "'"; |
|
29 } |
|
30 |
|
31 switch (trim($params[1], '"\'')) { |
|
32 case 'entity': |
|
33 case 'htmlall': |
|
34 if (Smarty::$_MBSTRING) { |
|
35 return 'mb_convert_encoding(' . $params[0] . ', ' . $params[2] . ', \'HTML-ENTITIES\')'; |
|
36 } |
|
37 |
|
38 return 'html_entity_decode(' . $params[0] . ', ENT_NOQUOTES, ' . $params[2] . ')'; |
|
39 |
|
40 case 'html': |
|
41 return 'htmlspecialchars_decode(' . $params[0] . ', ENT_QUOTES)'; |
|
42 |
|
43 case 'url': |
|
44 return 'rawurldecode(' . $params[0] . ')'; |
|
45 |
|
46 default: |
|
47 return $params[0]; |
|
48 } |
|
49 } |