• Модуль: iblock
  • Путь к файлу: ~/bitrix/modules/iblock/lib/grid/column/elementpropertyprovider.php
  • Класс: BitrixIblockGridColumnElementPropertyProvider
  • Вызов: ElementPropertyProvider::prepareColumns
public function prepareColumns(): array
{
	$iblockId = $this->getIblockId();
	if ($iblockId === null)
	{
		return [];
	}

	$isNewCardEnabled = $this->isNewCardEnabled();

	$morePhotoId = $this->getPropertyMorePhotoId();

	$result = [];
	foreach ($this->getProperties() as $row)
	{
		$columnId = self::getColumnIdByPropertyId($row['ID']);
		$columnType = GridColumnType::TEXT;
		$multiple = $row['MULTIPLE'] === 'Y';
		$preventDefault = true; // TODO: what is this

		$description = [
			'type' => $columnType,
			'name' => $row['NAME'],
			'necessary' => false,
			'editable' => $multiple ? false : true,
			'multiple' => $multiple,
			'select' => [
				// EMPTY! Properties must be loaded separately due to multiple values.
			]
		];

		$extendedMorePhoto = $isNewCardEnabled && $row['ID'] === $morePhotoId;
		if ($extendedMorePhoto)
		{
			$columnId = self::COLUMN_ID_MORE_PHOTO;
			$columnType = GridColumnType::CUSTOM;

			$description['editable'] = new GridColumnEditableCustomConfig($columnId);
		}
		elseif (
			$row['PROPERTY_TYPE'] === PropertyTable::TYPE_FILE
			&& $multiple
			&& !$extendedMorePhoto
		)
		{
			$description['editable'] = false;
			$preventDefault = false;
		}

		if (!$multiple)
		{
			$description['sort'] = $columnId;
		}

		if (isset($row['USER_TYPE']))
		{
			$description['type'] = GridColumnType::CUSTOM;
			$description['editable'] = new GridColumnEditableCustomConfig($columnId);
		}
		elseif ($row['PROPERTY_TYPE'] === PropertyTable::TYPE_NUMBER)
		{
			$description['type'] = GridColumnType::NUMBER;
			$description['align'] = 'right';
		}
		elseif ($row['PROPERTY_TYPE'] === PropertyTable::TYPE_LIST)
		{
			$listItems = $this->getPropertyEnumValues($row['ID']);
			if (!empty($listItems))
			{
				$description['type'] =
					$multiple
						? GridColumnType::MULTISELECT
						: GridColumnType::DROPDOWN
				;
				$description['editable'] = new IblockGridColumnEditablePropertyEnumerationConfig(
					$columnId,
					$row,
					$listItems,
				);
			}
			else
			{
				$description['editable'] = false;
			}
			unset($listItems);
		}
		elseif ($row['PROPERTY_TYPE'] === PropertyTable::TYPE_ELEMENT)
		{
			$description['type'] = GridColumnType::CUSTOM;
			$description['editable'] = new GridColumnEditableCustomConfig($columnId);
		}
		elseif ($row['PROPERTY_TYPE'] === PropertyTable::TYPE_SECTION)
		{
			$description['type'] = GridColumnType::CUSTOM;
			$description['editable'] = new GridColumnEditableCustomConfig($columnId);
		}
		elseif ($row['PROPERTY_TYPE'] === PropertyTable::TYPE_FILE)
		{
			$description['type'] = GridColumnType::FILE;
		}

		$description['prevent_default'] = $preventDefault; // TODO: what is this

		$result[$columnId] = $description;
	}

	return $this->createColumns($result);
}