1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
attributes.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Main\Html
;
4
5
use
Bitrix\Main\Text\HtmlFilter
;
6
use
Bitrix\Main\Web\Json
;
7
11
final
class
Attributes
12
{
17
private
array
$attributes = [];
18
29
public
function
set
(
string
$name
, $value): self
30
{
31
$this->attributes[
$name
] = $value;
32
33
return
$this;
34
}
35
46
public
function
setData
(
string
$name
, $value): self
47
{
48
$this->
set
(
'data-'
. $name, $value);
49
50
return
$this;
51
}
52
60
public
function
get
(
string
$name
)
61
{
62
return
$this->attributes[
$name
] ??
null
;
63
}
64
72
public
function
remove
(
string
$name
)
73
{
74
try
75
{
76
return
$this->
get
(
$name
);
77
}
78
finally
79
{
80
unset($this->attributes[
$name
]);
81
}
82
}
83
89
public
function
__toString
()
90
{
91
$result
=
''
;
92
93
if
(!empty($this->attributes))
94
{
95
$result
=
' '
;
96
foreach
($this->attributes as
$name
=> $value)
97
{
98
if
(!isset($value))
99
{
100
continue
;
101
}
102
103
$escapedName = HtmlFilter::encode(
$name
);
104
105
$isDataAttribute = stripos(
$name
,
'data-'
) === 0;
106
if
($isDataAttribute)
107
{
108
if
(is_array($value))
109
{
110
$escapedValue =
'('
. HtmlFilter::encode(Json::encode($value)) .
')'
;
111
}
112
elseif
(is_bool($value))
113
{
114
$escapedValue = $value ?
'true'
:
'false'
;
115
}
116
else
117
{
118
$escapedValue = HtmlFilter::encode((
string
)$value);
119
}
120
}
121
else
122
{
123
$escapedValue = HtmlFilter::encode((
string
)$value);
124
}
125
126
$result
.= $escapedName .
'="'
. $escapedValue .
'"'
;
127
}
128
129
$result
.=
' '
;
130
}
131
132
return
$result
;
133
}
134
}
Bitrix\Main\Html\Attributes
Определения
attributes.php:12
Bitrix\Main\Html\Attributes\__toString
__toString()
Определения
attributes.php:89
Bitrix\Main\Html\Attributes\setData
setData(string $name, $value)
Определения
attributes.php:46
Bitrix\Main\Text\HtmlFilter
Определения
htmlfilter.php:11
Bitrix\Main\Web\Json
Определения
json.php:9
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
$name
$name
Определения
menu_edit.php:35
Bitrix\Main\Html
Определения
attributes.php:3
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
bitrix
modules
main
lib
html
attributes.php
Создано системой
1.14.0