DisplayLinkURI.php 686 B

1234567891011121314151617181920212223242526
  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. public $name = 'DisplayLinkURI';
  8. public $needed = array('a');
  9. public function handleElement(&$token) {
  10. }
  11. public function handleEnd(&$token) {
  12. if (isset($token->start->attr['href'])){
  13. $url = $token->start->attr['href'];
  14. unset($token->start->attr['href']);
  15. $token = array($token, new HTMLPurifier_Token_Text(" ($url)"));
  16. } else {
  17. // nothing to display
  18. }
  19. }
  20. }
  21. // vim: et sw=4 sts=4