friendica/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Injector/DisplayLinkURI.php

41 lines
859 B
PHP
Raw Normal View History

2010-09-09 05:14:17 +02: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
{
2016-02-09 11:06:17 +01:00
/**
* @type string
*/
2010-09-09 05:14:17 +02:00
public $name = 'DisplayLinkURI';
2016-02-09 11:06:17 +01:00
/**
* @type array
*/
2010-09-09 05:14:17 +02:00
public $needed = array('a');
2016-02-09 11:06:17 +01:00
/**
* @param $token
*/
public function handleElement(&$token)
{
2010-09-09 05:14:17 +02:00
}
2016-02-09 11:06:17 +01:00
/**
* @param HTMLPurifier_Token $token
*/
public function handleEnd(&$token)
{
if (isset($token->start->attr['href'])) {
2010-09-09 05:14:17 +02:00
$url = $token->start->attr['href'];
unset($token->start->attr['href']);
$token = array($token, new HTMLPurifier_Token_Text(" ($url)"));
} else {
// nothing to display
}
}
}
// vim: et sw=4 sts=4