fusionpbx/resources/templates/engine/smarty/plugins/modifiercompiler.unescape.php

53 lines
1.5 KiB
PHP
Raw Normal View History

2013-11-09 21:02:56 +01:00
<?php
/**
* Smarty plugin
*
2018-11-07 08:18:14 +01:00
* @package Smarty
2013-11-09 21:02:56 +01:00
* @subpackage PluginsModifierCompiler
*/
/**
* Smarty unescape modifier plugin
2018-11-07 08:18:14 +01:00
* Type: modifier
* Name: unescape
2013-11-09 21:02:56 +01:00
* Purpose: unescape html entities
*
* @author Rodney Rehm
2018-11-07 08:18:14 +01:00
*
2013-11-09 21:02:56 +01:00
* @param array $params parameters
2023-05-08 17:50:42 +02:00
* @param Smarty_Internal_TemplateCompilerBase $compiler
2018-11-07 08:18:14 +01:00
*
2013-11-09 21:02:56 +01:00
* @return string with compiled code
*/
2023-05-08 17:50:42 +02:00
function smarty_modifiercompiler_unescape($params, Smarty_Internal_TemplateCompilerBase $compiler)
2013-11-09 21:02:56 +01:00
{
2023-05-08 17:50:42 +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');
2018-11-07 08:18:14 +01:00
if (!isset($params[ 2 ])) {
$params[ 2 ] = '\'' . addslashes(Smarty::$_CHARSET) . '\'';
2013-11-09 21:02:56 +01:00
}
2023-05-08 17:50:42 +02:00
switch ($esc_type) {
2013-11-09 21:02:56 +01:00
case 'entity':
case 'htmlall':
if (Smarty::$_MBSTRING) {
2023-05-08 17:50:42 +02:00
return 'html_entity_decode(mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'UTF-8\'), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ' . $params[ 2 ] . ')';
2013-11-09 21:02:56 +01:00
}
2023-05-08 17:50:42 +02:00
return 'html_entity_decode(' . $params[ 0 ] . ', ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ' . $params[ 2 ] . ')';
2013-11-09 21:02:56 +01:00
case 'html':
2018-11-07 08:18:14 +01:00
return 'htmlspecialchars_decode(' . $params[ 0 ] . ', ENT_QUOTES)';
2013-11-09 21:02:56 +01:00
case 'url':
2018-11-07 08:18:14 +01:00
return 'rawurldecode(' . $params[ 0 ] . ')';
2013-11-09 21:02:56 +01:00
default:
2018-11-07 08:18:14 +01:00
return $params[ 0 ];
2013-11-09 21:02:56 +01:00
}
}