You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 line
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