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.

DisplayLinkURI.php 859B

12345678910111213141516171819202122232425262728293031323334353637383940
  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