ILIAS
release_5-3 Revision v5.3.23-19-g915713cf615
◀ ilDoc Overview
PurifierLinkify.php
Go to the documentation of this file.
1
<?php
2
7
class
HTMLPurifier_Injector_PurifierLinkify
extends
HTMLPurifier_Injector
8
{
12
public
$name
=
'PurifierLinkify'
;
13
17
public
$docURL
;
18
22
public
$needed
=
array
(
'a'
=>
array
(
'href'
));
23
29
public
function
prepare
(
$config
, $context)
30
{
31
$this->docURL =
$config
->get(
'AutoFormat.PurifierLinkify.DocURL'
);
32
return
parent::prepare(
$config
, $context);
33
}
34
38
public
function
handleText
(&$token)
39
{
40
if
(!$this->
allowsElement
(
'a'
)) {
41
return
;
42
}
43
if
(strpos($token->data,
'%'
) ===
false
) {
44
return
;
45
}
46
47
$bits = preg_split(
'#%([a-z0-9]+\.[a-z0-9]+)#Si'
, $token->data, -1, PREG_SPLIT_DELIM_CAPTURE);
48
$token =
array
();
49
50
// $i = index
51
// $c = count
52
// $l = is link
53
for
(
$i
= 0, $c = count($bits),
$l
=
false
;
$i
< $c;
$i
++,
$l
= !
$l
) {
54
if
(!$l) {
55
if
($bits[
$i
] ===
''
) {
56
continue
;
57
}
58
$token[] =
new
HTMLPurifier_Token_Text
($bits[
$i
]);
59
}
else
{
60
$token[] =
new
HTMLPurifier_Token_Start
(
61
'a'
,
62
array
(
'href'
=> str_replace(
'%s'
, $bits[
$i
], $this->docURL))
63
);
64
$token[] =
new
HTMLPurifier_Token_Text
(
'%'
. $bits[$i]);
65
$token[] =
new
HTMLPurifier_Token_End
(
'a'
);
66
}
67
}
68
}
69
}
70
71
// vim: et sw=4 sts=4
HTMLPurifier_Injector\allowsElement
allowsElement($name)
Tests if the context node allows a certain element.
Definition:
Injector.php:147
HTMLPurifier_Token_End
Concrete end token class.
Definition:
End.php:10
HTMLPurifier_Injector_PurifierLinkify\$docURL
$docURL
string
Definition:
PurifierLinkify.php:17
$config
$config
Definition:
flush-definition-cache.php:23
HTMLPurifier_Injector_PurifierLinkify\handleText
handleText(&$token)
Definition:
PurifierLinkify.php:38
HTMLPurifier_Injector_PurifierLinkify\prepare
prepare($config, $context)
Definition:
PurifierLinkify.php:29
HTMLPurifier_Token_Start
Concrete start token class.
Definition:
Start.php:6
HTMLPurifier_Injector_PurifierLinkify\$name
$name
string
Definition:
PurifierLinkify.php:12
HTMLPurifier_Injector_PurifierLinkify
Injector that converts configuration directive syntax Namespace.Directive to links.
Definition:
PurifierLinkify.php:7
array
Create styles array
The data for the language used.
Definition:
40duplicateStyle.php:19
HTMLPurifier_Injector
Injects tokens into the document while parsing for well-formedness.
Definition:
Injector.php:16
$l
global $l
Definition:
afr.php:30
$i
$i
Definition:
disco.tpl.php:19
HTMLPurifier_Injector_PurifierLinkify\$needed
$needed
array
Definition:
PurifierLinkify.php:22
HTMLPurifier_Token_Text
Concrete text token class.
Definition:
Text.php:12
libs
composer
vendor
ezyang
htmlpurifier
library
HTMLPurifier
Injector
PurifierLinkify.php
Generated on Sat Jan 18 2025 19:01:02 for ILIAS by
1.8.13 (using
Doxyfile
)