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

41 行
859B

  1. <?php
  2. /**
  3. * Injector that displays the URL of an anchor instead of linking to it, in addition to showing the text of the link.
  4. */
  5. class HTMLPurifier_Injector_DisplayLinkURI extends HTMLPurifier_Injector
  6. {
  7. /**
  8. * @type string
  9. */
  10. public $name = 'DisplayLinkURI';
  11. /**
  12. * @type array
  13. */
  14. public $needed = array('a');
  15. /**
  16. * @param $token
  17. */
  18. public function handleElement(&$token)
  19. {
  20. }
  21. /**
  22. * @param HTMLPurifier_Token $token
  23. */
  24. public function handleEnd(&$token)
  25. {
  26. if (isset($token->start->attr['href'])) {
  27. $url = $token->start->attr['href'];
  28. unset($token->start->attr['href']);
  29. $token = array($token, new HTMLPurifier_Token_Text(" ($url)"));
  30. } else {
  31. // nothing to display
  32. }
  33. }
  34. }
  35. // vim: et sw=4 sts=4