您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

modifiercompiler.unescape.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Smarty plugin
  4. *
  5. * @package Smarty
  6. * @subpackage PluginsModifierCompiler
  7. */
  8. /**
  9. * Smarty unescape modifier plugin
  10. * Type: modifier<br>
  11. * Name: unescape<br>
  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. }