ILIAS
trunk Revision v11.0_alpha-2658-ge2404539063
◀ ilDoc Overview
class.ilAccessibilityDocumentsContainsHtmlValidator.php
Go to the documentation of this file.
1
<?php
2
22
class
ilAccessibilityDocumentsContainsHtmlValidator
23
{
24
private
string
$text
;
25
26
public
function
__construct
(
string
$text)
27
{
28
$this->text =
$text
;
29
}
30
31
public
function
isValid():
bool
32
{
33
if
(!preg_match(
'/<[^>]+?>/'
, $this->text)) {
34
return
false
;
35
}
36
37
try
{
38
$dom =
new
DOMDocument
();
39
if
(!$dom->loadHTML($this->text)) {
40
return
false
;
41
}
42
43
$iter =
new
RecursiveIteratorIterator
(
44
new
ilHtmlDomNodeIterator
($dom),
45
RecursiveIteratorIterator::SELF_FIRST
46
);
47
foreach
($iter as $element) {
49
if
(in_array(strtolower($element->nodeName), [
'body'
])) {
50
continue
;
51
}
52
53
if
($element->nodeType === XML_ELEMENT_NODE) {
54
return
true
;
55
}
56
}
57
58
return
false
;
59
}
catch
(
Exception
|
Throwable
$e
) {
60
return
false
;
61
}
62
}
63
}
DOMDocument
ilAccessibilityDocumentsContainsHtmlValidator\__construct
__construct(string $text)
Definition:
class.ilAccessibilityDocumentsContainsHtmlValidator.php:26
ilAccessibilityDocumentsContainsHtmlValidator\$text
string $text
Definition:
class.ilAccessibilityDocumentsContainsHtmlValidator.php:24
Vendor\Package\$e
$e
Definition:
example_cleaned.php:49
ilHtmlDomNodeIterator
ilAccessibilityDocumentsContainsHtmlValidator
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition:
class.ilAccessibilityDocumentsContainsHtmlValidator.php:22
RecursiveIteratorIterator
Exception
Throwable
components
ILIAS
Accessibility
classes
Document
class.ilAccessibilityDocumentsContainsHtmlValidator.php
Generated on Tue Sep 2 2025 23:01:50 for ILIAS by
1.8.13 (using
Doxyfile
)