ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ ilDoc Overview
Required.php
Go to the documentation of this file.
1
<?
php
2
6
class
HTMLPurifier_ChildDef_Required
extends
HTMLPurifier_ChildDef
7
{
12
public
$elements
= array();
13
18
protected
$whitespace
=
false
;
19
23
public
function
__construct
(
$elements
)
24
{
25
if
(is_string(
$elements
)) {
26
$elements
= str_replace(
' '
,
''
,
$elements
);
27
$elements
= explode(
'|'
,
$elements
);
28
}
29
$keys
= array_keys(
$elements
);
30
if
(
$keys
== array_keys(
$keys
)) {
31
$elements
= array_flip(
$elements
);
32
foreach
(
$elements
as
$i
=>
$x
) {
33
$elements
[
$i
] =
true
;
34
if
(empty(
$i
)) {
35
unset(
$elements
[
$i
]);
36
}
// remove blank
37
}
38
}
39
$this->elements =
$elements
;
40
}
41
45
public
$allow_empty
=
false
;
46
50
public
$type
=
'required'
;
51
58
public
function
validateChildren
($children,
$config
,
$context
)
59
{
60
// Flag for subclasses
61
$this->whitespace =
false
;
62
63
// if there are no tokens, delete parent node
64
if
(empty($children)) {
65
return
false
;
66
}
67
68
// the new set of children
69
$result
= array();
70
71
// whether or not parsed character data is allowed
72
// this controls whether or not we silently drop a tag
73
// or generate escaped HTML from it
74
$pcdata_allowed = isset($this->elements[
'#PCDATA'
]);
75
76
// a little sanity check to make sure it's not ALL whitespace
77
$all_whitespace =
true
;
78
79
$stack = array_reverse($children);
80
while
(!empty($stack)) {
81
$node = array_pop($stack);
82
if
(!empty($node->is_whitespace)) {
83
$result
[] = $node;
84
continue
;
85
}
86
$all_whitespace =
false
;
// phew, we're not talking about whitespace
87
88
if
(!isset($this->elements[$node->name])) {
89
// special case text
90
// XXX One of these ought to be redundant or something
91
if
($pcdata_allowed && $node instanceof
HTMLPurifier_Node_Text
) {
92
$result
[] = $node;
93
continue
;
94
}
95
// spill the child contents in
96
// ToDo: Make configurable
97
if
($node instanceof
HTMLPurifier_Node_Element
) {
98
for
(
$i
= count($node->children) - 1;
$i
>= 0;
$i
--) {
99
$stack[] = $node->children[
$i
];
100
}
101
continue
;
102
}
103
continue
;
104
}
105
$result
[] = $node;
106
}
107
if
(empty(
$result
)) {
108
return
false
;
109
}
110
if
($all_whitespace) {
111
$this->whitespace =
true
;
112
return
false
;
113
}
114
return
$result
;
115
}
116
}
117
118
// vim: et sw=4 sts=4
HTMLPurifier_Node_Element
Concrete element node class.
Definition:
Element.php:6
HTMLPurifier_ChildDef_Required
Definition that allows a set of elements, but disallows empty children.
Definition:
Required.php:6
$context
$context
Definition:
webdav.php:25
$config
$config
Definition:
bootstrap.php:15
$result
$result
Definition:
CleanUpTest.php:463
$keys
$keys
Definition:
memcacheSync.php:38
HTMLPurifier_ChildDef
Defines allowed child nodes and validates nodes against it.
Definition:
ChildDef.php:6
HTMLPurifier_ChildDef_Required\$type
$type
string
Definition:
Required.php:50
HTMLPurifier_ChildDef_Required\__construct
__construct($elements)
Definition:
Required.php:23
HTMLPurifier_ChildDef_Required\$whitespace
$whitespace
Whether or not the last passed node was all whitespace.
Definition:
Required.php:18
HTMLPurifier_Node_Text
Concrete text token class.
Definition:
Text.php:12
$i
$i
Definition:
disco.tpl.php:19
HTMLPurifier_ChildDef_Required\validateChildren
validateChildren($children, $config, $context)
Definition:
Required.php:58
php
$x
$x
Definition:
complexTest.php:9
HTMLPurifier_ChildDef_Required\$allow_empty
$allow_empty
bool
Definition:
Required.php:45
HTMLPurifier_ChildDef_Required\$elements
$elements
Lookup table of allowed elements.
Definition:
Required.php:12
libs
composer
vendor
ezyang
htmlpurifier
library
HTMLPurifier
ChildDef
Required.php
Generated on Thu Jan 16 2025 19:01:38 for ILIAS by
1.8.13 (using
Doxyfile
)