DisplayLinkURI.php 859 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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