Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
2809 rexy 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
 *
18
 * @return string with compiled code
19
 */
20
function smarty_modifiercompiler_unescape($params)
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
    switch (trim($params[ 1 ], '"\'')) {
31
        case 'entity':
32
        case 'htmlall':
33
            if (Smarty::$_MBSTRING) {
34
                return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'HTML-ENTITIES\')';
35
            }
36
            return 'html_entity_decode(' . $params[ 0 ] . ', ENT_NOQUOTES, ' . $params[ 2 ] . ')';
37
        case 'html':
38
            return 'htmlspecialchars_decode(' . $params[ 0 ] . ', ENT_QUOTES)';
39
        case 'url':
40
            return 'rawurldecode(' . $params[ 0 ] . ')';
41
        default:
42
            return $params[ 0 ];
43
    }
44
}