1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
propertytypesettings.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Iblock\Property\Type
;
4
5
use
Bitrix\Iblock\PropertyTable
;
6
use CIBlockProperty;
7
8
final
class
PropertyTypeSettings
9
{
10
private
string
$propertyType;
11
private
?
string
$userType;
12
private
array
$setValues = [];
13
private
array
$showedFields = [];
14
private
array
$hiddenFields = [];
15
private
?
string
$settingsHtml =
null
;
16
private
?
string
$defaultValueHtml =
null
;
17
22
public
function
__construct
(
string
$propertyType, ?
string
$userType =
null
)
23
{
24
$this->propertyType = $propertyType;
25
$this->userType = $userType;
26
27
$this->initHiddenFields();
28
}
29
37
public
function
getPropertyType
(): string
38
{
39
return
$this->propertyType;
40
}
41
47
public
function
getUserType
(): ?string
48
{
49
return
$this->userType;
50
}
51
57
private
function
initHiddenFields(): void
58
{
59
if
($this->propertyType ===
PropertyTable::TYPE_ELEMENT
)
60
{
61
$this->hiddenFields[] =
'SEARCHABLE'
;
62
$this->hiddenFields[] =
'WITH_DESCRIPTION'
;
63
$this->hiddenFields[] =
'COL_COUNT'
;
64
$this->hiddenFields[] =
'DEFAULT_VALUE'
;
65
}
66
elseif
($this->propertyType ===
PropertyTable::TYPE_SECTION
)
67
{
68
$this->hiddenFields[] =
'SEARCHABLE'
;
69
$this->hiddenFields[] =
'WITH_DESCRIPTION'
;
70
$this->hiddenFields[] =
'COL_COUNT'
;
71
$this->hiddenFields[] =
'DEFAULT_VALUE'
;
72
}
73
elseif
($this->propertyType ===
PropertyTable::TYPE_LIST
)
74
{
75
$this->hiddenFields[] =
'WITH_DESCRIPTION'
;
76
$this->hiddenFields[] =
'MULTIPLE_CNT'
;
77
$this->hiddenFields[] =
'COL_COUNT'
;
78
$this->hiddenFields[] =
'DEFAULT_VALUE'
;
79
}
80
elseif
($this->propertyType ===
PropertyTable::TYPE_FILE
)
81
{
82
$this->hiddenFields[] =
'FILTERABLE'
;
83
$this->hiddenFields[] =
'MULTIPLE_CNT'
;
84
$this->hiddenFields[] =
'SMART_FILTER'
;
85
$this->hiddenFields[] =
'DISPLAY_TYPE'
;
86
$this->hiddenFields[] =
'DISPLAY_EXPANDED'
;
87
$this->hiddenFields[] =
'FILTER_HINT'
;
88
$this->hiddenFields[] =
'DEFAULT_VALUE'
;
89
$this->hiddenFields[] =
'ROW_COUNT'
;
90
}
91
elseif
($this->userType ===
PropertyTable::USER_TYPE_HTML
)
92
{
93
$this->hiddenFields[] =
'MULTIPLE'
;
94
}
95
96
// hidden for NOT need type
97
98
if
($this->propertyType !==
PropertyTable::TYPE_LIST
)
99
{
100
$this->hiddenFields[] =
'LIST_TYPE'
;
101
}
102
103
if
($this->propertyType !==
PropertyTable::TYPE_FILE
)
104
{
105
$this->hiddenFields[] =
'FILE_TYPE'
;
106
}
107
108
if
(
109
!in_array($this->propertyType, [
PropertyTable::TYPE_SECTION
,
PropertyTable::TYPE_ELEMENT
],
true
)
110
&& $this->userType !==
PropertyTable::USER_TYPE_SKU
111
)
112
{
113
$this->hiddenFields[] =
'LINK_IBLOCK_ID'
;
114
}
115
}
116
117
public
function
appendShowedFields
(
array
$fields
): void
118
{
119
array_push($this->showedFields, ...
$fields
);
120
}
121
122
public
function
appendHiddenFields
(
array
$fields
): void
123
{
124
foreach
(
$fields
as
$name
)
125
{
126
$this->hiddenFields[] =
$name
;
127
128
if
(
$name
===
'SMART_FILTER'
)
129
{
130
$this->hiddenFields[] =
'DISPLAY_TYPE'
;
131
$this->hiddenFields[] =
'DISPLAY_EXPANDED'
;
132
$this->hiddenFields[] =
'FILTER_HINT'
;
133
}
134
}
135
}
136
147
public
static
function
createByUserType
(
string
$propertyType,
string
$userType,
array
$propertyFields
, ?
string
$htmlName =
'USER_TYPE_SETTINGS'
): self
148
{
149
$self =
new
self
($propertyType, $userType);
150
$userTypeFields = CIBlockProperty::GetUserType($userType);
151
152
$excludeSettingsHtmlUserTypes = [
153
PropertyTable::USER_TYPE_DIRECTORY
,
154
];
155
156
if
(
157
isset($userTypeFields[
"GetSettingsHTML"
])
158
&& !in_array($userType, $excludeSettingsHtmlUserTypes,
true
)
159
&& is_callable($userTypeFields[
"GetSettingsHTML"
])
160
)
161
{
162
$config
= [];
163
$htmlCode = call_user_func_array(
164
$userTypeFields[
"GetSettingsHTML"
],
165
[
166
$propertyFields
,
167
[
168
'NAME'
=> $htmlName,
169
],
170
&
$config
,
171
]
172
);
173
174
if
(!empty($htmlCode) && is_string($htmlCode))
175
{
176
$self->settingsHtml = $htmlCode;
177
}
178
179
if
(isset(
$config
[
'SHOW'
]) && is_array(
$config
[
'SHOW'
]))
180
{
181
$self->appendShowedFields(
$config
[
'SHOW'
]);
182
}
183
184
if
(isset(
$config
[
'HIDE'
]) && is_array(
$config
[
'HIDE'
]))
185
{
186
$self->appendHiddenFields(
$config
[
'HIDE'
]);
187
}
188
189
if
(isset(
$config
[
'SET'
]) && is_array(
$config
[
'SET'
]))
190
{
191
$self->setValues =
$config
[
'SET'
];
192
}
193
}
194
195
if
(isset($userTypeFields[
"GetPropertyFieldHtml"
]) && is_callable($userTypeFields[
"GetPropertyFieldHtml"
]))
196
{
197
$htmlCode = call_user_func_array(
198
$userTypeFields[
"GetPropertyFieldHtml"
],
199
[
200
$propertyFields
,
201
[
202
'VALUE'
=>
$propertyFields
[
'DEFAULT_VALUE'
] ??
null
,
203
'DESCRIPTION'
=>
''
,
204
],
205
[
206
'VALUE'
=>
'DEFAULT_VALUE'
,
207
'DESCRIPTION'
=>
''
,
208
'MODE'
=>
'EDIT_FORM'
,
209
'FORM_NAME'
=>
''
,
210
],
211
]
212
);
213
214
if
(!empty($htmlCode) && is_string($htmlCode))
215
{
216
$self->defaultValueHtml = $htmlCode;
217
}
218
}
219
220
return
$self;
221
}
222
230
public
function
isShownField
(
string
$fieldName): bool
231
{
232
$hide =
false
;
233
234
if
(!empty($this->hiddenFields))
235
{
236
$hide =
237
in_array($fieldName, $this->hiddenFields,
true
)
238
&& !in_array($fieldName, $this->showedFields,
true
)
239
;
240
}
241
242
return
!$hide;
243
}
244
245
public
function
getSettingsHtml
(): ?string
246
{
247
return
$this->settingsHtml;
248
}
249
250
public
function
getDefaultValueHtml
(): ?string
251
{
252
return
$this->defaultValueHtml;
253
}
254
255
public
function
getSetValues
():
array
256
{
257
return
$this->setValues;
258
}
259
}
Bitrix\Iblock\Property\Type\PropertyTypeSettings
Определения
propertytypesettings.php:9
Bitrix\Iblock\Property\Type\PropertyTypeSettings\getSettingsHtml
getSettingsHtml()
Определения
propertytypesettings.php:245
Bitrix\Iblock\Property\Type\PropertyTypeSettings\appendShowedFields
appendShowedFields(array $fields)
Определения
propertytypesettings.php:117
Bitrix\Iblock\Property\Type\PropertyTypeSettings\createByUserType
static createByUserType(string $propertyType, string $userType, array $propertyFields, ?string $htmlName='USER_TYPE_SETTINGS')
Определения
propertytypesettings.php:147
Bitrix\Iblock\Property\Type\PropertyTypeSettings\getPropertyType
getPropertyType()
Определения
propertytypesettings.php:37
Bitrix\Iblock\Property\Type\PropertyTypeSettings\getUserType
getUserType()
Определения
propertytypesettings.php:47
Bitrix\Iblock\Property\Type\PropertyTypeSettings\getSetValues
getSetValues()
Определения
propertytypesettings.php:255
Bitrix\Iblock\Property\Type\PropertyTypeSettings\__construct
__construct(string $propertyType, ?string $userType=null)
Определения
propertytypesettings.php:22
Bitrix\Iblock\Property\Type\PropertyTypeSettings\appendHiddenFields
appendHiddenFields(array $fields)
Определения
propertytypesettings.php:122
Bitrix\Iblock\Property\Type\PropertyTypeSettings\isShownField
isShownField(string $fieldName)
Определения
propertytypesettings.php:230
Bitrix\Iblock\Property\Type\PropertyTypeSettings\getDefaultValueHtml
getDefaultValueHtml()
Определения
propertytypesettings.php:250
Bitrix\Iblock\PropertyTable
Определения
propertytable.php:61
Bitrix\Iblock\PropertyTable\USER_TYPE_HTML
const USER_TYPE_HTML
Определения
propertytable.php:79
Bitrix\Iblock\PropertyTable\TYPE_ELEMENT
const TYPE_ELEMENT
Определения
propertytable.php:68
Bitrix\Iblock\PropertyTable\TYPE_FILE
const TYPE_FILE
Определения
propertytable.php:67
Bitrix\Iblock\PropertyTable\USER_TYPE_SKU
const USER_TYPE_SKU
Определения
propertytable.php:83
Bitrix\Iblock\PropertyTable\TYPE_LIST
const TYPE_LIST
Определения
propertytable.php:70
Bitrix\Iblock\PropertyTable\TYPE_SECTION
const TYPE_SECTION
Определения
propertytable.php:69
Bitrix\Iblock\PropertyTable\USER_TYPE_DIRECTORY
const USER_TYPE_DIRECTORY
Определения
propertytable.php:93
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$name
$name
Определения
menu_edit.php:35
Bitrix\Iblock\Property\Type
Определения
propertytypesettings.php:3
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$config
$config
Определения
quickway.php:69
$propertyFields
$propertyFields
Определения
yandex_run.php:558
$fields
$fields
Определения
yandex_run.php:501
bitrix
modules
iblock
lib
property
type
propertytypesettings.php
Создано системой
1.14.0