source: pro-violet-viettel/www/deploy/20150304/application/third_party/Smarty/plugins/modifiercompiler.unescape.php @ 780

Last change on this file since 780 was 780, checked in by dungnv, 10 years ago
File size: 1.2 KB
Line 
1<?php
2/**
3 * Smarty plugin
4 *
5 * @package Smarty
6 * @subpackage PluginsModifierCompiler
7 */
8
9/**
10 * Smarty unescape modifier plugin
11 *
12 * Type:     modifier<br>
13 * Name:     unescape<br>
14 * Purpose:  unescape html entities
15 *
16 * @author Rodney Rehm
17 * @param array $params parameters
18 * @return string with compiled code
19 */
20function smarty_modifiercompiler_unescape($params, $compiler)
21{
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            return 'mb_convert_encoding(' . $params[0] . ', ' . $params[2] . ', \'HTML-ENTITIES\')';
34        case 'htmlall':
35            if (Smarty::$_MBSTRING) {
36                return 'mb_convert_encoding(' . $params[0] . ', ' . $params[2] . ', \'HTML-ENTITIES\')';
37            }
38            return 'html_entity_decode(' . $params[0] . ', ENT_QUOTES, ' . $params[2] . ')';
39
40        case 'html':
41            return 'htmlspecialchars_decode(' . $params[0] . ', ENT_QUOTES)';
42
43        default:
44            return $params[0];
45    }
46}
47
48?>
Note: See TracBrowser for help on using the repository browser.