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
|
|
|
|
* Type: modifier<br>
|
|
|
|
* Name: unescape<br>
|
|
|
|
* 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
|
2014-06-06 02:40:04 +00:00
|
|
|
*
|
2013-07-14 22:15:45 +00:00
|
|
|
* @return string with compiled code
|
|
|
|
*/
|
2014-06-06 02:40:04 +00:00
|
|
|
function smarty_modifiercompiler_unescape($params)
|
2013-07-14 22:15:45 +00:00
|
|
|
{
|
2016-02-09 01:27:15 +01:00
|
|
|
if (!isset($params[ 1 ])) {
|
|
|
|
$params[ 1 ] = 'html';
|
2013-07-14 22:15:45 +00:00
|
|
|
}
|
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
|
|
|
} else {
|
2017-11-06 01:02:56 +01:00
|
|
|
$params[ 2 ] = "'{$params[ 2 ]}'";
|
2013-07-14 22:15:45 +00:00
|
|
|
}
|
|
|
|
|
2016-02-09 01:27:15 +01:00
|
|
|
switch (trim($params[ 1 ], '"\'')) {
|
2013-07-14 22:15:45 +00:00
|
|
|
case 'entity':
|
|
|
|
case 'htmlall':
|
|
|
|
if (Smarty::$_MBSTRING) {
|
2016-02-09 01:27:15 +01:00
|
|
|
return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'HTML-ENTITIES\')';
|
2013-07-14 22:15:45 +00:00
|
|
|
}
|
|
|
|
|
2016-02-09 01:27:15 +01:00
|
|
|
return 'html_entity_decode(' . $params[ 0 ] . ', ENT_NOQUOTES, ' . $params[ 2 ] . ')';
|
2013-07-14 22:15:45 +00:00
|
|
|
|
|
|
|
case 'html':
|
2016-02-09 01:27:15 +01:00
|
|
|
return 'htmlspecialchars_decode(' . $params[ 0 ] . ', ENT_QUOTES)';
|
2013-07-14 22:15:45 +00:00
|
|
|
|
|
|
|
case 'url':
|
2016-02-09 01:27:15 +01:00
|
|
|
return 'rawurldecode(' . $params[ 0 ] . ')';
|
2013-07-14 22:15:45 +00:00
|
|
|
|
|
|
|
default:
|
2016-02-09 01:27:15 +01:00
|
|
|
return $params[ 0 ];
|
2013-07-14 22:15:45 +00:00
|
|
|
}
|
|
|
|
}
|