PageRenderTime 39ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/web/lib/smarty/plugins/modifiercompiler.strip_tags.php

https://code.google.com/p/gctour/
PHP | 33 lines | 13 code | 2 blank | 18 comment | 3 complexity | bdf3af4b31f661477f7f168bcf16bc45 MD5 | raw file
  1. <?php
  2. /**
  3. * Smarty plugin
  4. *
  5. * @package Smarty
  6. * @subpackage PluginsModifierCompiler
  7. */
  8. /**
  9. * Smarty strip_tags modifier plugin
  10. *
  11. * Type: modifier<br>
  12. * Name: strip_tags<br>
  13. * Purpose: strip html tags from text
  14. *
  15. * @link http://www.smarty.net/manual/en/language.modifier.strip.tags.php strip_tags (Smarty online manual)
  16. * @author Uwe Tews
  17. * @param array $params parameters
  18. * @return string with compiled code
  19. */
  20. function smarty_modifiercompiler_strip_tags($params, $compiler)
  21. {
  22. if (!isset($params[1])) {
  23. $params[1] = true;
  24. }
  25. if ($params[1] === true) {
  26. return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})";
  27. } else {
  28. return 'strip_tags(' . $params[0] . ')';
  29. }
  30. }
  31. ?>