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