219 Loader::includeModule(
'fileman');
223 $listImageSize = Main\Config\Option::get(
'iblock',
'list_image_size');
224 $minImageSize = [
'W' => 1,
'H' => 1];
225 $maxImageSize = [
'W' => $listImageSize,
'H' => $listImageSize];
226 unset($listImageSize);
228 $binaryStates = $this->getBinaryDictionary();
230 $allowedSets = Catalog\Config\Feature::isProductSetsEnabled();
234 $viewedColumns = $this->getDataFields();
235 $selectedFields = [];
236 $selectedProperties = [];
237 foreach ($viewedColumns as $columnId)
239 if (strncmp($columnId,
'PROPERTY_', 9) == 0)
241 if (isset($this->elementProperties[$columnId]))
243 $selectedProperties[] = $this->elementProperties[$columnId][
'ID'];
248 $selectedFields[] = $columnId;
249 if ($columnId ==
'TYPE')
250 $selectedFields[] =
'BUNDLE';
254 if (!in_array(
'ID', $selectedFields))
255 $selectedFields[] =
'ID';
257 $viewedColumns = array_fill_keys($viewedColumns,
true);
259 $iblockId = (int)$this->getStorageItem(self::STORAGE_ENTITY_IBLOCK,
'IBLOCK_ID');
260 $needProperties = $iblockId > 0 && !empty($selectedProperties);
262 $productTypeList = [];
263 if ($this->catalogIncluded)
264 $productTypeList = Catalog\ProductTable::getProductTypes(
true);
268 $iterator = \CIBlockElement::GetList(
270 $this->getDataFilter(),
272 $this->getGridNavigationParams(),
275 $iterator->bShowAll =
false;
276 while ($row = $iterator->Fetch())
278 $row[
'ID'] = (int)$row[
'ID'];
280 if (isset($viewedColumns[
'ACTIVE']))
281 $row[
'ACTIVE'] = ($row[
'ACTIVE'] ==
'Y' ? $binaryStates[
'Y'] : $binaryStates[
'N']);
282 if (isset($viewedColumns[
'NAME']))
283 $row[
'NAME'] = htmlspecialcharsEx((
string)$row[
'NAME']);
284 if (isset($viewedColumns[
'SORT']))
285 $row[
'SORT'] = (
int)$row[
'SORT'];
286 if (isset($viewedColumns[
'CODE']))
287 $row[
'CODE'] = htmlspecialcharsbx((
string)$row[
'CODE']);
288 if (isset($viewedColumns[
'XML_ID']))
289 $row[
'XML_ID'] = htmlspecialcharsbx((
string)$row[
'XML_ID']);
290 if (isset($viewedColumns[
'ACTIVE_FROM']))
291 $row[
'ACTIVE_FROM'] = htmlspecialcharsbx((
string)$row[
'ACTIVE_FROM']);
292 if (isset($viewedColumns[
'ACTIVE_TO']))
293 $row[
'ACTIVE_TO'] = htmlspecialcharsbx((
string)$row[
'ACTIVE_TO']);
295 if (isset($viewedColumns[
'TYPE']))
297 if ($row[
'TYPE'] ===
null)
299 $row[
'TYPE'] =
Loc::getMessage(
'IBLOCK_SELECTOR_ELEMENT_MESS_IS_NOT_PRODUCT');
303 $productType = (int)$row[
'TYPE'];
304 if (isset($productTypeList[$productType]))
306 $row[
'TYPE'] = $productTypeList[$productType];
310 $row[
'TYPE'] =
Loc::getMessage(
'IBLOCK_SELECTOR_ELEMENT_MESS_BAD_PRODUCT_TYPE');
312 if ($allowedSets && $row[
'BUNDLE'] ==
'Y')
315 'IBLOCK_SELECTOR_ELEMENT_MESS_TYPE_DESCRIPTION',
316 [
'#TYPE#' => $row[
'TYPE']]
320 unset($row[
'BUNDLE']);
322 if (isset($viewedColumns[
'AVAILABLE']))
323 $row[
'AVAILABLE'] = ($row[
'AVAILABLE'] ==
'Y' ? $binaryStates[
'Y'] : $binaryStates[
'N']);
326 $row[
'PROPERTIES'] = [];
327 $this->rows[$row[
'ID']] = $row;
328 $listIds[] = $row[
'ID'];
332 if (!empty($this->rows) && $needProperties)
334 \CIBlockElement::GetPropertyValuesArray(
338 [
'ID' => $selectedProperties],
340 'USE_PROPERTY_ID' =>
'Y',
341 'PROPERTY_FIELDS' => [
'ID'],
342 'GET_RAW_DATA' =>
'Y'
349 foreach ($listIds as $id)
351 foreach ($selectedProperties as $propertyId)
354 $index =
'PROPERTY_'.$propertyId;
355 if (isset($this->rows[$id][
'PROPERTIES'][$propertyId]))
357 $property = $this->elementProperties[$index];
358 $value = $this->rows[$id][
'PROPERTIES'][$propertyId];
359 $complexValue = is_array($value[
'VALUE']);
361 ($complexValue && !empty($value[
'VALUE']))
362 || (!$complexValue && (
string)$value[
'VALUE'] !==
'')
367 $userType = $property[
'PROPERTY_USER_TYPE'];
368 if (isset($userType[
'GetAdminListViewHTML']))
370 $rawValue = $value[
'VALUE'];
371 if ($property[
'MULTIPLE'] ==
'N' || !$complexValue)
372 $rawValue = [$rawValue];
373 foreach ($rawValue as $item)
375 $itemValue = (string)call_user_func_array(
376 $userType[
'GetAdminListViewHTML'],
384 'MODE' =>
'iblock_element_admin',
389 if ($itemValue !==
'')
390 $assembly[] = $itemValue;
395 $rawValue = $value[
'VALUE'];
397 $rawValue = [$rawValue];
399 switch ($this->elementProperties[$index][
'PROPERTY_TYPE'])
401 case Iblock\PropertyTable::TYPE_STRING:
402 case Iblock\PropertyTable::TYPE_NUMBER:
403 case Iblock\PropertyTable::TYPE_LIST:
404 $assembly = $rawValue;
406 case Iblock\PropertyTable::TYPE_ELEMENT:
407 foreach ($rawValue as $item)
409 if (!isset($elementCache[$item]))
411 $elementCache[$item] =
'';
412 $valueIterator = Iblock\ElementTable::getList([
413 'select' => [
'ID',
'NAME'],
414 'filter' => [
'=ID' => $item]
416 $valueRow = $valueIterator->fetch();
417 if (!empty($valueRow))
418 $elementCache[$item] =
'['.$valueRow[
'ID'].
'] '.$valueRow[
'NAME'];
419 unset($valueRow, $valueIterator);
421 if ($elementCache[$item] !==
'')
422 $assembly[] = $elementCache[$item];
425 case Iblock\PropertyTable::TYPE_SECTION:
426 foreach ($rawValue as $item)
428 if (!isset($sectionCache[$item]))
430 $sectionCache[$item] =
'';
431 $valueIterator = Iblock\SectionTable::getList([
432 'select' => [
'ID',
'NAME'],
433 'filter' => [
'=ID' => $item]
435 $valueRow = $valueIterator->fetch();
436 if (!empty($valueRow))
437 $sectionCache[$item] =
'['.$valueRow[
'ID'].
'] '.$valueRow[
'NAME'];
438 unset($valueRow, $valueIterator);
440 if ($sectionCache[$item] !==
'')
441 $assembly[] = $sectionCache[$item];
444 case Iblock\PropertyTable::TYPE_FILE:
473 'file_dialog' =>
false,
476 'description' => false
483 'IMAGE_POPUP' =>
'Y',
484 'MAX_SIZE' => $maxImageSize,
485 'MIN_SIZE' => $minImageSize,
487 if ($property[
'MULTIPLE'] ==
'Y')
489 $assembly = \CFileInput::ShowMultiple(
499 $rawValue = reset($rawValue);
500 $assembly = \CFileInput::Show(
510 if (!empty($assembly))
512 $viewedValue = ($direct ? $assembly : htmlspecialcharsbx(implode(
' / ', $assembly)));
514 unset($direct, $assembly);
517 $this->rows[$id][$index] = $viewedValue;
520 unset($this->rows[$id][
'PROPERTIES']);
523 unset($sectionCache, $elementCache);
525 if (!empty($this->rows))
526 $this->rows = array_values($this->rows);
528 $this->setImplicitNavigationData($iterator);
750 Iblock\PropertyTable::TYPE_STRING => [
754 Iblock\PropertyTable::TYPE_NUMBER => [
761 Iblock\PropertyTable::TYPE_LIST => [
765 Iblock\PropertyTable::TYPE_ELEMENT => [
769 Iblock\PropertyTable::TYPE_SECTION => [
775 $list = array_filter($list, [__CLASS__,
'isFilterableProperty']);
776 foreach ($list as $id => $row)
779 $type = $row[
'PROPERTY_TYPE'];
781 $row[
'USER_TYPE'] !==
''
782 && isset($row[
'PROPERTY_USER_TYPE'][
'GetUIFilterProperty'])
783 && is_callable($row[
'PROPERTY_USER_TYPE'][
'GetUIFilterProperty'])
793 'name' => $row[
'NAME'],
797 if (isset($operators[$row[
'PROPERTY_TYPE']]))
798 $field[
'operators'] = $operators[$row[
'PROPERTY_TYPE']];
799 call_user_func_array(
800 $row[
'PROPERTY_USER_TYPE'][
'GetUIFilterProperty'],
803 [
'VALUE' => $id,
'FORM_NAME' =>
'main-ui-filter'],
808 case Iblock\PropertyTable::TYPE_STRING:
811 'name' => $row[
'NAME'],
813 'operators' => $operators[Iblock\PropertyTable::TYPE_STRING],
816 case Iblock\PropertyTable::TYPE_NUMBER:
819 'name' => $row[
'NAME'],
821 'operators' => $operators[Iblock\PropertyTable::TYPE_NUMBER]
824 case Iblock\PropertyTable::TYPE_LIST:
826 $valueIterator = Iblock\PropertyEnumerationTable::getList([
827 'select' => [
'ID',
'VALUE',
'SORT'],
828 'filter' => [
'=PROPERTY_ID' => $row[
'ID']],
829 'order' => [
'SORT' =>
'ASC',
'VALUE' =>
'ASC']
831 while ($value = $valueIterator->fetch())
832 $list[$value[
'ID']] = $value[
'VALUE'];
833 unset($value, $valueIterator);
838 'name' => $row[
'NAME'],
841 'params' => [
'multiple' =>
'Y'],
842 'operators' => $operators[Iblock\PropertyTable::TYPE_LIST]
847 case Iblock\PropertyTable::TYPE_ELEMENT:
848 $row[
'LINK_IBLOCK_ID'] = (int)$row[
'LINK_IBLOCK_ID'];
849 if ($row[
'LINK_IBLOCK_ID'] > 0)
852 $valueIterator = \CIBlockElement::GetList(
853 [
'SORT' =>
'ASC',
'NAME' =>
'ASC'],
854 [
'IBLOCK_ID' => $row[
'LINK_IBLOCK_ID'],
'CHECK_PERMISSIONS' =>
'Y',
'MIN_PERMISSION' =>
'R'],
857 [
'ID',
'IBLOCK_ID',
'NAME',
'SORT']
859 while ($value = $valueIterator->Fetch())
860 $list[$value[
'ID']] =
'['.$value[
'ID'].
'] '.$value[
'NAME'];
861 unset($value, $valueIterator);
866 'name' => $row[
'NAME'],
869 'params' => [
'multiple' =>
'Y'],
870 'operators' => $operators[Iblock\PropertyTable::TYPE_ELEMENT]
876 case Iblock\PropertyTable::TYPE_SECTION:
877 $row[
'LINK_IBLOCK_ID'] = (int)$row[
'LINK_IBLOCK_ID'];
878 if ($row[
'LINK_IBLOCK_ID'] > 0)
881 $valueIterator = \CIBlockSection::GetList(
883 'LEFT_MARGIN' =>
'ASC',
886 'IBLOCK_ID' => $row[
'LINK_IBLOCK_ID'],
887 'CHECK_PERMISSIONS' =>
'Y',
888 'MIN_PERMISSION' =>
'R',
899 while ($value = $valueIterator->Fetch())
901 $margin = max((
int)$value[
'DEPTH_LEVEL'], 1) - 1;
902 $list[$value[
'ID']] =
903 str_repeat(
'. ', $margin)
904 .
'[' . $value[
'ID'] .
'] '. $value[
'NAME']
907 unset($value, $valueIterator);
912 'name' => $row[
'NAME'],
915 'operators' => $operators[Iblock\PropertyTable::TYPE_SECTION]
923 $result[$id] = $field;
925 unset($id, $row, $iterator);