28 private array $entity;
29 private string $propertyType;
30 private ?
string $userType;
39 public function __construct(
string $propertyType, ?
string $userType, array $entityFields)
41 $this->propertyType = $propertyType;
42 $this->userType = $userType;
43 $this->entity = $entityFields;
45 $this->initEntityDefaultValues();
48 private function initEntityDefaultValues(): void
51 foreach ($fields as $field)
53 $name = $field[
'name'];
54 if (array_key_exists($name, $this->entity))
59 if (isset($field[
'default_value']))
61 $this->entity[$name] = $field[
'default_value'];
63 elseif ($field[
'type'] ===
'boolean')
65 $this->entity[$name] =
'N';
72 return $this->entity[
'ID'] ??
null;
77 return $this->entity[
'IBLOCK_ID'] ??
null;
82 $values = $this->entity;
84 $setValues = $this->getPropertyTypeSettings()->getSetValues();
85 if (!empty($setValues))
87 $values = array_merge($values, $setValues);
97 'name' =>
'PROPERTY_TYPE',
98 'title' =>
Loc::getMessage(
'IBLOCK_ENTITY_EDITOR_PROPERTY_PROPERTY_TYPE'),
101 'items' => $this->getPropertyTypeItems(),
121 'default_value' => 100,
128 'default_value' =>
'Y',
131 'name' =>
'MULTIPLE',
136 'name' =>
'IS_REQUIRED',
137 'title' =>
Loc::getMessage(
'IBLOCK_ENTITY_EDITOR_PROPERTY_IS_REQUIRED'),
141 'name' =>
'SEARCHABLE',
142 'title' =>
Loc::getMessage(
'IBLOCK_ENTITY_EDITOR_PROPERTY_SEARCHABLE'),
147 return $this->clearHiddenFields($fields);
154 'name' =>
'FILTRABLE',
155 'title' =>
Loc::getMessage(
'IBLOCK_ENTITY_EDITOR_PROPERTY_FILTERABLE_MSGVER_1'),
159 'name' =>
'WITH_DESCRIPTION',
160 'title' =>
Loc::getMessage(
'IBLOCK_ENTITY_EDITOR_PROPERTY_WITH_DESCRIPTION'),
164 'name' =>
'MULTIPLE_CNT',
165 'title' =>
Loc::getMessage(
'IBLOCK_ENTITY_EDITOR_PROPERTY_MULTIPLE_CNT'),
174 'name' =>
'SECTION_PROPERTY',
175 'title' =>
Loc::getMessage(
'IBLOCK_ENTITY_EDITOR_PROPERTY_SECTION_PROPERTY'),
179 'name' =>
'SMART_FILTER',
180 'title' =>
Loc::getMessage(
'IBLOCK_ENTITY_EDITOR_PROPERTY_SMART_FILTER'),
184 'name' =>
'DISPLAY_TYPE',
185 'title' =>
Loc::getMessage(
'IBLOCK_ENTITY_EDITOR_PROPERTY_DISPLAY_TYPE'),
188 'items' => $this->getDisplayTypeItems(),
192 'name' =>
'DISPLAY_EXPANDED',
193 'title' =>
Loc::getMessage(
'IBLOCK_ENTITY_EDITOR_PROPERTY_DISPLAY_EXPANDED'),
197 'name' =>
'FILTER_HINT',
198 'title' =>
Loc::getMessage(
'IBLOCK_ENTITY_EDITOR_PROPERTY_FILTER_HINT'),
199 'type' =>
'textarea',
202 'name' =>
'ROW_COUNT',
207 'name' =>
'COL_COUNT',
212 'name' =>
'FILE_TYPE',
217 'name' =>
'LINK_IBLOCK_ID',
218 'title' =>
Loc::getMessage(
'IBLOCK_ENTITY_EDITOR_PROPERTY_LINK_IBLOCK_ID'),
221 'items' => $this->getLinkIblockIdItems(),
225 'name' =>
'LIST_TYPE',
229 'items' => $this->getListTypeItems(),
234 if (Option::get(
'iblock',
'show_xml_id') ===
'Y')
244 $html = $this->getPropertyTypeSettings()->getDefaultValueHtml();
248 'name' =>
'DEFAULT_VALUE',
249 'title' =>
Loc::getMessage(
'IBLOCK_ENTITY_EDITOR_PROPERTY_DEFAULT_VALUE'),
259 'name' =>
'DEFAULT_VALUE',
260 'title' =>
Loc::getMessage(
'IBLOCK_ENTITY_EDITOR_PROPERTY_DEFAULT_VALUE'),
266 $futureFields = $this->getPropertyFeatureEditorFields();
267 if ($futureFields->isHasFields())
269 array_push($fields, ... $futureFields->getEntityFields());
272 return $this->clearHiddenFields($fields);
275 private function clearHiddenFields(array $fields): array
279 function(array $item)
283 && $this->getPropertyTypeSettings()->isShownField($item[
'name'])
291 return $this->getPropertyTypeSettings()->getSettingsHtml();
305 return $this->futureEditor;
313 private function getPropertyTypeSettings(): PropertyTypeSettings
315 if (isset($this->typeSettings))
317 return $this->typeSettings;
320 if (isset($this->userType))
326 $this->typeSettings =
new PropertyTypeSettings($this->propertyType,
null);
329 return $this->typeSettings;
337 private function getDisplayTypeItems(): array
341 $types = CIBlockSectionPropertyLink::getDisplayTypes($this->propertyType, $this->userType);
342 foreach ($types as $type => $name)
353 private function hideSkuProperty(): bool
360 if (!Loader::includeModule(
'catalog'))
366 if ($iblockId ===
null)
371 $catalog = \CCatalogSku::GetInfoByProductIBlock($iblockId);
372 if (!empty($catalog))
377 $catalog = \CCatalogSku::GetInfoByOfferIBlock($iblockId);
378 if (!empty($catalog))
380 return (
int)$catalog[
'SKU_PROPERTY_ID'] > 0;
391 private function getPropertyTypeItems(): array
395 $baseTypes = Property::getBaseTypeList(
true);
396 foreach ($baseTypes as $type => $name)
404 $userTypes = CIBlockProperty::GetUserType();
405 if ($this->hideSkuProperty())
409 Collection::sortByColumn($userTypes, [
410 'DESCRIPTION' => SORT_STRING,
413 foreach ($userTypes as $type => $item)
416 'NAME' => $item[
'DESCRIPTION'],
417 'VALUE' =>
"{$item['PROPERTY_TYPE']}:{$type}",
429 private function getListTypeItems(): array
434 'NAME' =>
Loc::getMessage(
'IBLOCK_ENTITY_EDITOR_PROPERTY_LIST_TYPE_CHECKBOX'),
438 'NAME' =>
Loc::getMessage(
'IBLOCK_ENTITY_EDITOR_PROPERTY_LIST_TYPE_LISTBOX'),
450 private function getLinkIblockIdItems(): array
458 $iblockId = ($this->entity[
'IBLOCK_ID'] ?? 0);
461 $filter[
'!=ID'] = $iblockId;
468 'TYPE_NAME' =>
'TYPE.LANG_MESSAGE.NAME',
472 foreach ($rows as $row)
475 'NAME' =>
"{$row['TYPE_NAME']}. {$row['NAME']}",
476 'VALUE' => $row[
'ID'],
483 #region not used parent methods
505 #endregion not used parent methods
static getMessage($code, $replace=null, $language=null)
static getList(array $parameters=array())