1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
helper.php
См. документацию.
1
<?php
7
namespace
Bitrix\Iblock\Template;
13
class
Helper
14
{
23
public
static
function
splitTemplate
(
$template
)
24
{
25
if
(preg_match(
"/\\/(l|t.?)+\$/"
,
$template
, $match))
26
{
27
return
array
(mb_substr(
$template
, 0, -mb_strlen($match[0])), mb_substr($match[0], 1));
28
}
29
else
30
{
31
return
array
(
$template
,
""
);
32
}
33
}
34
42
public
static
function
splitModifiers
($modifiers)
43
{
44
if
(preg_match_all(
"/(l|t.?)/"
, $modifiers, $match))
45
return
$match[0];
46
else
47
return
array
();
48
}
49
57
public
static
function
convertArrayToModifiers
(
array
$template
)
58
{
59
$TEMPLATE =
$template
[
"TEMPLATE"
] ??
''
;
60
$modifiers =
""
;
61
if
(isset(
$template
[
"LOWER"
]) &&
$template
[
"LOWER"
] ===
"Y"
)
62
{
63
$modifiers .=
"l"
;
64
}
65
if
(isset(
$template
[
"TRANSLIT"
]) &&
$template
[
"TRANSLIT"
] ===
"Y"
)
66
{
67
$modifiers .=
"t"
;
68
if
(isset(
$template
[
"SPACE"
]) && is_string(
$template
[
"SPACE"
]) &&
$template
[
"SPACE"
] !==
""
)
69
{
70
$modifiers .=
$template
[
"SPACE"
];
71
}
72
}
73
if
($modifiers !==
""
)
74
{
75
$modifiers =
"/"
. $modifiers;
76
}
77
78
return
$TEMPLATE.$modifiers;
79
}
80
90
public
static
function
convertModifiersToArray
(
array
$template
=
null
)
91
{
92
if
(
$template
===
null
)
93
{
94
$template
=
array
(
95
"TEMPLATE"
=>
""
,
96
);
97
}
98
99
$TEMPLATE =
$template
[
"TEMPLATE"
];
100
$LOWER =
"N"
;
101
$TRANSLIT =
"N"
;
102
$SPACE =
""
;
103
104
[$TEMPLATE, $modifiers] =
self::splitTemplate
($TEMPLATE);
105
foreach
(self::splitModifiers($modifiers) as
$mod
)
106
{
107
if
(
$mod
==
"l"
)
108
{
109
$LOWER =
"Y"
;
110
}
111
else
112
{
113
$TRANSLIT =
"Y"
;
114
$SPACE = mb_substr(
$mod
, 1);
115
}
116
}
117
118
$template
[
"TEMPLATE"
] = $TEMPLATE;
119
$template
[
"LOWER"
] = $LOWER;
120
$template
[
"TRANSLIT"
] = $TRANSLIT;
121
$template
[
"SPACE"
] = $SPACE;
122
123
return
$template
;
124
}
125
136
public
static
function
makeFileName
(
137
\
Bitrix
\
Iblock
\
InheritedProperty
\BaseTemplate $ipropTemplates,
138
string
$templateName,
139
array
$fields
,
140
array
$file
141
): string
142
{
143
if
(!isset($file[
'name'
]))
144
{
145
return
''
;
146
}
147
148
if
(preg_match(
"/^(.+)(\\.[a-zA-Z0-9]+)\$/"
, $file[
"name"
],
$fileName
))
149
{
150
if
(!isset(
$fields
[
"IPROPERTY_TEMPLATES"
]) || (
string
)(
$fields
[
"IPROPERTY_TEMPLATES"
][$templateName] ??
''
) ===
''
)
151
{
152
$templates = $ipropTemplates->findTemplates();
153
$TEMPLATE = ($templates[$templateName][
"TEMPLATE"
] ??
''
);
154
}
155
else
156
{
157
$TEMPLATE =
$fields
[
"IPROPERTY_TEMPLATES"
][$templateName];
158
}
159
160
if
($TEMPLATE !=
""
)
161
{
162
[
$template
, $modifiers] = Helper::splitTemplate($TEMPLATE);
163
if
(
$template
!=
""
)
164
{
165
$values = $ipropTemplates->getValuesEntity();
166
$entity
= $values->createTemplateEntity();
167
$entity
->setFields(
$fields
);
168
return \Bitrix\Iblock\Template\Engine::process(
$entity
, $TEMPLATE).$fileName[2];
169
}
170
elseif
($modifiers !=
""
)
171
{
172
$simpleTemplate =
new
NodeRoot
;
173
$simpleTemplate->
addChild
(
new
NodeText
(
$fileName
[1]));
174
$simpleTemplate->setModifiers($modifiers);
175
$baseEntity =
new
Entity\Base
(0);
176
return
$simpleTemplate->process($baseEntity).$fileName[2];
177
}
178
}
179
}
180
181
return
$file[
"name"
];
182
}
183
}
Bitrix\Iblock\Iblock
Определения
iblock.php:18
Bitrix\Iblock\Template\Helper
Определения
helper.php:14
Bitrix\Iblock\Template\Helper\makeFileName
static makeFileName(\Bitrix\Iblock\InheritedProperty\BaseTemplate $ipropTemplates, string $templateName, array $fields, array $file)
Определения
helper.php:136
Bitrix\Iblock\Template\Helper\convertArrayToModifiers
static convertArrayToModifiers(array $template)
Определения
helper.php:57
Bitrix\Iblock\Template\Helper\convertModifiersToArray
static convertModifiersToArray(array $template=null)
Определения
helper.php:90
Bitrix\Iblock\Template\Helper\splitModifiers
static splitModifiers($modifiers)
Определения
helper.php:42
Bitrix\Iblock\Template\Helper\splitTemplate
static splitTemplate($template)
Определения
helper.php:23
Bitrix\Iblock\Template\NodeRoot
Определения
engine.php:256
Bitrix\Iblock\Template\NodeRoot\addChild
addChild(NodeBase $child)
Определения
engine.php:268
Bitrix\Iblock\Template\NodeText
Определения
engine.php:333
$mod
if($childrenCount<=0) $mod
Определения
sync.php:11
$template
$template
Определения
file_edit.php:49
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$entity
$entity
Определения
group_bizproc_workflow_delete.php:17
Bitrix\Iblock\InheritedProperty
Определения
basetemplate.php:7
Bitrix\Sale\Services\Base
Определения
concreteproductrestriction.php:3
Bitrix
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$fileName
$fileName
Определения
quickway.php:305
$fields
$fields
Определения
yandex_run.php:501
bitrix
modules
iblock
lib
template
helper.php
Создано системой
1.14.0