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-12-20 23:47:18 +01:00
|
|
|
* @param \Smarty\Compiler\Template $compiler
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2013-07-14 22:15:45 +00:00
|
|
|
* @return string with compiled code
|
|
|
|
|
*/
|
2022-12-20 23:47:18 +01:00
|
|
|
function smarty_modifiercompiler_unescape($params, \Smarty\Compiler\Template $compiler)
|
2013-07-14 22:15:45 +00:00
|
|
|
{
|
2022-08-01 23:49:19 +02:00
|
|
|
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
|
|
|
|
|
2016-02-09 01:27:15 +01:00
|
|
|
if (!isset($params[ 2 ])) {
|
2022-11-30 00:25:27 +01:00
|
|
|
$params[ 2 ] = '\'' . addslashes(\Smarty\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':
|
2022-12-01 21:56:12 +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
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|