Custom Injector to display URL address along with link text.
[htmlpurifier.git] / library / HTMLPurifier / Injector / DisplayLinkURI.php
blob6fc566d70c3a6a34ee4aff51f82cc81dc9db79f9
1 <?php
3 /**
4 * Injector that displays the URL of an anchor instead of linking to it, in addition to showing the text of the link.
5 */
6 class HTMLPurifier_Injector_DisplayLinkURI extends HTMLPurifier_Injector
9 public $name = 'DisplayLinkURI';
10 public $needed = array('a');
12 public function handleElement(&$token) {
15 public function handleEnd(&$token) {
16 if (isset($token->start->attr['href'])){
17 $url = $token->start->attr['href'];
18 unset($token->start->attr['href']);
19 $token = array($token, new HTMLPurifier_Token_Text(" ($url)"));
20 } else {
21 // nothing to display