2008-10-23 21:11:29 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Injector that displays the URL of an anchor instead of linking to it, in addition to showing the text of the link.
|
|
|
|
*/
|
|
|
|
class HTMLPurifier_Injector_DisplayLinkURI extends HTMLPurifier_Injector
|
|
|
|
{
|
2013-07-16 11:56:14 +00:00
|
|
|
/**
|
|
|
|
* @type string
|
|
|
|
*/
|
2008-10-23 21:11:29 +00:00
|
|
|
public $name = 'DisplayLinkURI';
|
2013-07-16 11:56:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @type array
|
|
|
|
*/
|
2008-10-23 21:11:29 +00:00
|
|
|
public $needed = array('a');
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
/**
|
|
|
|
* @param $token
|
|
|
|
*/
|
|
|
|
public function handleElement(&$token)
|
|
|
|
{
|
2008-10-23 21:11:29 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
/**
|
|
|
|
* @param HTMLPurifier_Token $token
|
|
|
|
*/
|
|
|
|
public function handleEnd(&$token)
|
|
|
|
{
|
|
|
|
if (isset($token->start->attr['href'])) {
|
2008-10-23 21:11:29 +00:00
|
|
|
$url = $token->start->attr['href'];
|
|
|
|
unset($token->start->attr['href']);
|
|
|
|
$token = array($token, new HTMLPurifier_Token_Text(" ($url)"));
|
|
|
|
} else {
|
|
|
|
// nothing to display
|
|
|
|
}
|
|
|
|
}
|
2008-12-06 09:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// vim: et sw=4 sts=4
|