1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
usertypesection.php
См. документацию.
1
<?php
2
3
use
Bitrix\Iblock\UserField\Types\SectionType
;
4
use
Bitrix\Main\Loader
;
5
use
Bitrix\Main\Localization\Loc
;
6
7
Loc::loadMessages(__FILE__);
8
14
class
CUserTypeIBlockSection
extends
CUserTypeEnum
15
{
16
public
static
function
getUserTypeDescription
()
17
{
18
if
(self::isIblockIncluded())
19
{
20
return
SectionType::getUserTypeDescription();
21
}
22
23
return
[
24
'USER_TYPE_ID'
=>
'iblock_section'
,
25
'CLASS_NAME'
=>
'CUserTypeIBlockSection'
,
26
'DESCRIPTION'
=> Loc::getMessage(
'USER_TYPE_IBSEC_DESCRIPTION'
),
27
'BASE_TYPE'
=>
'int'
,
28
'VIEW_CALLBACK'
=>
array
(__CLASS__,
'GetPublicView'
),
29
'EDIT_CALLBACK'
=>
array
(__CLASS__,
'GetPublicEdit'
),
30
];
31
}
32
33
function
prepareSettings
($userField)
34
{
35
if
(self::isIblockIncluded())
36
{
37
return
SectionType::prepareSettings($userField);
38
}
39
40
$height = (int)$userField[
'SETTINGS'
][
'LIST_HEIGHT'
];
41
42
$disp = $userField[
'SETTINGS'
][
'DISPLAY'
];
43
if
($disp !=
'CHECKBOX'
&& $disp !=
'LIST'
)
44
{
45
$disp =
'LIST'
;
46
}
47
48
$iblock_id = (int)$userField[
'SETTINGS'
][
'IBLOCK_ID'
];
49
if
($iblock_id <= 0)
50
{
51
$iblock_id =
''
;
52
}
53
54
$section_id = (int)$userField[
'SETTINGS'
][
'DEFAULT_VALUE'
];
55
if
($section_id <= 0)
56
{
57
$section_id =
''
;
58
}
59
60
$active_filter = ($userField[
'SETTINGS'
][
'ACTIVE_FILTER'
] ===
'Y'
?
'Y'
:
'N'
);
61
62
return
[
63
'DISPLAY'
=> $disp,
64
'LIST_HEIGHT'
=> ($height < 1 ? 1 : $height),
65
'IBLOCK_ID'
=> $iblock_id,
66
'DEFAULT_VALUE'
=> $section_id,
67
'ACTIVE_FILTER'
=> $active_filter,
68
];
69
}
70
71
function
getSettingsHtml
($userField, $additionalParameters, $varsFromForm)
72
{
73
if
(self::isIblockIncluded())
74
{
75
return
SectionType::getSettingsHtml($userField, $additionalParameters, $varsFromForm);
76
}
77
78
$result
=
''
;
79
80
if
($varsFromForm)
81
{
82
$iblock_id =
$GLOBALS
[$additionalParameters[
'NAME'
]][
'IBLOCK_ID'
];
83
}
84
elseif
(is_array($userField))
85
{
86
$iblock_id = $userField[
'SETTINGS'
][
'IBLOCK_ID'
];
87
}
88
else
89
{
90
$iblock_id =
''
;
91
}
92
93
$result
.=
'
94
<tr>
95
<td>'
. Loc::getMessage(
'USER_TYPE_IBSEC_DISPLAY'
) .
':</td>
96
<td>
97
<input type="text" size="6" name="'
. $additionalParameters[
'NAME'
] .
'[IBLOCK_ID]" value="'
.
htmlspecialcharsbx
($value) .
'">
98
</td>
99
</tr>
100
'
;
101
102
if
($varsFromForm)
103
{
104
$ACTIVE_FILTER = (
$GLOBALS
[$additionalParameters[
'NAME'
]][
'ACTIVE_FILTER'
] ===
'Y'
?
'Y'
:
'N'
);
105
}
106
elseif
(is_array($userField))
107
{
108
$ACTIVE_FILTER = $userField[
'SETTINGS'
][
'ACTIVE_FILTER'
] ===
'Y'
?
'Y'
:
'N'
;
109
}
110
else
111
{
112
$ACTIVE_FILTER =
'N'
;
113
}
114
115
if
($varsFromForm)
116
{
117
$value =
$GLOBALS
[$additionalParameters[
'NAME'
]][
'DEFAULT_VALUE'
];
118
}
119
elseif
(is_array($userField))
120
{
121
$value = $userField[
'SETTINGS'
][
'DEFAULT_VALUE'
];
122
}
123
else
124
{
125
$value =
''
;
126
}
127
128
$result
.=
'
129
<tr>
130
<td>'
. Loc::getMessage(
'USER_TYPE_IBSEC_DEFAULT_VALUE'
) .
':</td>
131
<td>
132
<input type="text" size="8" name="'
. $additionalParameters[
"NAME"
] .
'[DEFAULT_VALUE]" value="'
.
htmlspecialcharsbx
($value) .
'">
133
</td>
134
</tr>
135
'
;
136
137
if
($varsFromForm)
138
{
139
$value =
$GLOBALS
[$additionalParameters[
'NAME'
]][
'DISPLAY'
];
140
}
141
elseif
(is_array($userField))
142
{
143
$value = $userField[
'SETTINGS'
][
'DISPLAY'
];
144
}
145
else
146
{
147
$value =
'LIST'
;
148
}
149
$result
.=
'
150
<tr>
151
<td class="adm-detail-valign-top">'
. Loc::getMessage(
'USER_TYPE_ENUM_DISPLAY'
) .
':</td>
152
<td>
153
<label><input type="radio" name="'
. $additionalParameters[
'NAME'
] .
'[DISPLAY]" value="LIST" '
. (
"LIST"
== $value ?
'checked="checked"'
:
''
) .
'>'
. Loc::getMessage(
'USER_TYPE_IBSEC_LIST'
) .
'</label><br>
154
<label><input type="radio" name="'
. $additionalParameters[
'NAME'
] .
'[DISPLAY]" value="CHECKBOX" '
. (
"CHECKBOX"
== $value ?
'checked="checked"'
:
''
) .
'>'
. Loc::getMessage(
'USER_TYPE_IBSEC_CHECKBOX'
) .
'</label><br>
155
</td>
156
</tr>
157
'
;
158
159
if
($varsFromForm)
160
{
161
$value = (int)
$GLOBALS
[$additionalParameters[
'NAME'
]][
'LIST_HEIGHT'
];
162
}
163
elseif
(is_array($userField))
164
{
165
$value = (int)$userField[
'SETTINGS'
][
'LIST_HEIGHT'
];
166
}
167
else
168
{
169
$value = 5;
170
}
171
172
$result
.=
'
173
<tr>
174
<td>'
. Loc::getMessage(
'USER_TYPE_IBSEC_LIST_HEIGHT'
) .
':</td>
175
<td>
176
<input type="text" name="'
. $additionalParameters[
'NAME'
] .
'[LIST_HEIGHT]" size="10" value="'
. $value .
'">
177
</td>
178
</tr>
179
'
;
180
181
$result
.=
'
182
<tr>
183
<td>'
. Loc::getMessage(
'USER_TYPE_IBSEC_ACTIVE_FILTER'
) .
':</td>
184
<td>
185
<input type="checkbox" name="'
. $additionalParameters[
'NAME'
] .
'[ACTIVE_FILTER]" value="Y" '
. ($ACTIVE_FILTER ===
'Y'
?
'checked="checked"'
:
''
) .
'>
186
</td>
187
</tr>
188
'
;
189
190
return
$result
;
191
}
192
193
function
checkFields
($userField, $value)
194
{
195
if
(self::isIblockIncluded())
196
{
197
return
SectionType::checkFields($userField, $value);
198
}
199
return
[];
200
}
201
202
public
static
function
getList
($userField)
203
{
204
if
(self::isIblockIncluded())
205
{
206
return
SectionType::getList($userField);
207
}
208
209
return
false
;
210
}
211
212
protected
static
function
getEnumList
(&$userField, $additionalParameters =
array
())
213
{
214
if
(self::isIblockIncluded())
215
{
216
SectionType::getEnumList($userField, $additionalParameters);
217
}
218
return
false
;
219
}
220
221
function
onSearchIndex
($userField)
222
{
223
if
(self::isIblockIncluded())
224
{
225
return
SectionType::onSearchIndex($userField);
226
}
227
228
return
''
;
229
}
230
231
public
static
function
isIblockIncluded
(): bool
232
{
233
return
Loader::includeModule(
'iblock'
);
234
}
235
}
236
237
class
CIBlockSectionEnum
extends
CDBResult
238
{
239
public
static
function
getTreeList
(
$iblockId
, $activeFilter=
'N'
)
240
{
241
$result
=
false
;
242
243
if
(CModule::IncludeModule(
'iblock'
))
244
{
245
$filter
= [
'IBLOCK_ID'
=>
$iblockId
];
246
if
($activeFilter ===
'Y'
)
247
{
248
$filter
[
'GLOBAL_ACTIVE'
] =
'Y'
;
249
}
250
251
$result
= CIBlockSection::GetList(
252
[
'left_margin'
=>
'asc'
],
253
$filter
,
254
false
,
255
[
'ID'
,
'DEPTH_LEVEL'
,
'NAME'
,
'SORT'
,
'XML_ID'
,
'ACTIVE'
,
'IBLOCK_SECTION_ID'
]
256
);
257
258
if
(
$result
)
259
{
260
$result
=
new
CIBlockSectionEnum
(
$result
);
261
}
262
}
263
264
return
$result
;
265
}
266
267
function
getNext
($textHtmlAuto=
true
, $useTilda=
true
)
268
{
269
$result
= parent::getNext($textHtmlAuto, $useTilda);
270
271
if
(
$result
)
272
{
273
$result
[
'VALUE'
] = str_repeat(
' . '
,
$result
[
'DEPTH_LEVEL'
]) .
$result
[
'NAME'
];
274
}
275
276
return
$result
;
277
}
278
}
Bitrix\Iblock\UserField\Types\SectionType
Определения
sectiontype.php:18
Bitrix\Main\Loader
Определения
loader.php:13
Bitrix\Main\Localization\Loc
Определения
loc.php:12
CAllDBResult\$result
$result
Определения
dbresult.php:16
CDBResult
Определения
dbresult.php:88
CIBlockSectionEnum
Определения
usertypesection.php:238
CIBlockSectionEnum\getTreeList
static getTreeList($iblockId, $activeFilter='N')
Определения
usertypesection.php:239
CIBlockSectionEnum\getNext
getNext($textHtmlAuto=true, $useTilda=true)
Определения
usertypesection.php:267
CUserTypeEnum
Определения
usertypeenum.php:18
CUserTypeIBlockSection
Определения
usertypesection.php:15
CUserTypeIBlockSection\getUserTypeDescription
static getUserTypeDescription()
Определения
usertypesection.php:16
CUserTypeIBlockSection\getList
static getList($userField)
Определения
usertypesection.php:202
CUserTypeIBlockSection\getSettingsHtml
getSettingsHtml($userField, $additionalParameters, $varsFromForm)
Определения
usertypesection.php:71
CUserTypeIBlockSection\getEnumList
static getEnumList(&$userField, $additionalParameters=array())
Определения
usertypesection.php:212
CUserTypeIBlockSection\onSearchIndex
onSearchIndex($userField)
Определения
usertypesection.php:221
CUserTypeIBlockSection\isIblockIncluded
static isIblockIncluded()
Определения
usertypesection.php:231
CUserTypeIBlockSection\prepareSettings
prepareSettings($userField)
Определения
usertypesection.php:33
CUserTypeIBlockSection\checkFields
checkFields($userField, $value)
Определения
usertypesection.php:193
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
$iblockId
$iblockId
Определения
iblock_catalog_edit.php:30
$filter
$filter
Определения
iblock_catalog_list.php:54
htmlspecialcharsbx
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения
tools.php:2701
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$GLOBALS
$GLOBALS['_____370096793']
Определения
update_client.php:1
bitrix
modules
main
classes
general
usertypesection.php
Создано системой
1.14.0