depage-forms
v2.0.0
html forms made easy
Toggle main menu visibility
Loading...
Searching...
No Matches
Html.php
Go to the documentation of this file.
1
<?php
2
10
11
namespace
Depage\HtmlForm\Elements;
12
13
use Depage\HtmlForm\Abstracts\HtmlDom as HtmlSanitizer;
14
37
class
Html
38
{
42
private
$htmlString;
46
private
$sanitize =
true
;
50
private
$allowedTags =
null
;
51
58
public
function
__construct
(
string
$htmlString, $parameters = [])
59
{
60
$this->htmlString = $htmlString;
61
62
if
(isset($parameters[
'sanitize'
]) && is_bool($parameters[
'sanitize'
])) {
63
$this->sanitize = $parameters[
'sanitize'
];
64
}
65
if
(isset($parameters[
'allowedTags'
]) && is_array($parameters[
'allowedTags'
])) {
66
$this->allowedTags = $parameters[
'allowedTags'
];
67
}
68
}
69
75
public
function
__toString
(): string
76
{
77
if
($this->sanitize && class_exists(HtmlSanitizer::class)) {
78
$sanitizer =
new
HtmlSanitizer();
79
$sanitizer->loadHTML($this->htmlString);
80
$sanitizer->cleanHTML($this->allowedTags,
null
,
false
);
81
82
if
(function_exists(
'mb_trim'
)) {
83
return
(
string
) mb_trim($sanitizer);
84
}
85
86
return
(
string
) trim($sanitizer);
87
}
88
89
return
(
string
) $this->htmlString;
90
}
91
}
92
93
/* vim:set ft=php sw=4 sts=4 fdm=marker et : */
Depage\HtmlForm\Elements\Html
Can be used to insert custom HTML between rendered HTML elements.
Definition
Html.php:38
Depage\HtmlForm\Elements\Html\__construct
__construct(string $htmlString, $parameters=[])
html class constructor
Definition
Html.php:58
Depage\HtmlForm\Elements\Html\__toString
__toString()
Renders element to sanitized HTML.
Definition
Html.php:75
Elements
Html.php
Generated on
for depage-forms by
doxygen
1.18.0
For an overview of all docs, go to
docs.depage.net