2013-07-14 22:15:45 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Smarty plugin
|
|
|
|
*
|
2014-06-06 02:40:04 +00:00
|
|
|
* @package Smarty
|
2013-07-14 22:15:45 +00:00
|
|
|
* @subpackage PluginsModifierCompiler
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* Smarty unescape modifier plugin
|
2017-11-11 07:11:33 +01:00
|
|
|
* Type: modifier
|
|
|
|
* Name: unescape
|
2013-07-14 22:15:45 +00:00
|
|
|
* Purpose: unescape html entities
|
|
|
|
*
|
|
|
|
* @author Rodney Rehm
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2013-07-14 22:15:45 +00:00
|
|
|
* @param array $params parameters
|
2022-08-01 23:49:19 +02:00
|
|
|
* @param Smarty_Internal_TemplateCompilerBase $compiler
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2013-07-14 22:15:45 +00:00
|
|
|
* @return string with compiled code
|
|
|
|
*/
|
2022-08-01 23:49:19 +02:00
|
|
|
function smarty_modifiercompiler_unescape($params, Smarty_Internal_TemplateCompilerBase $compiler)
|
2013-07-14 22:15:45 +00:00
|
|
|
{
|
2022-08-01 23:49:19 +02:00
|
|
|
$compiler->template->_checkPlugins(
|
|
|
|
array(
|
|
|
|
array(
|
|
|
|
'function' => 'smarty_literal_compiler_param',
|
|
|
|
'file' => SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
|
|
|
|
2016-02-09 01:27:15 +01:00
|
|
|
if (!isset($params[ 2 ])) {
|
|
|
|
$params[ 2 ] = '\'' . addslashes(Smarty::$_CHARSET) . '\'';
|
2013-07-14 22:15:45 +00:00
|
|
|
}
|
2022-08-01 23:49:19 +02:00
|
|
|
|
|
|
|
switch ($esc_type) {
|
2018-08-19 02:35:46 +02:00
|
|
|
case 'entity':
|
|
|
|
case 'htmlall':
|
|
|
|
if (Smarty::$_MBSTRING) {
|
2022-11-22 21:22:57 +01:00
|
|
|
return 'html_entity_decode(mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'UTF-8\'), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ' . $params[ 2 ] . ')';
|
2018-08-19 02:35:46 +02:00
|
|
|
}
|
2022-11-22 21:22:57 +01:00
|
|
|
return 'html_entity_decode(' . $params[ 0 ] . ', ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ' . $params[ 2 ] . ')';
|
2018-08-19 02:35:46 +02:00
|
|
|
case 'html':
|
|
|
|
return 'htmlspecialchars_decode(' . $params[ 0 ] . ', ENT_QUOTES)';
|
|
|
|
case 'url':
|
|
|
|
return 'rawurldecode(' . $params[ 0 ] . ')';
|
|
|
|
default:
|
|
|
|
return $params[ 0 ];
|
2013-07-14 22:15:45 +00:00
|
|
|
}
|
|
|
|
}
|