28 public static function onBuildSourceListHandler(Main\
Event $event)
31 $selector = $event->getParameter(
'SELECTOR');
35 $restrictions = $selector->getModuleRestrictions(
'iblock');
36 if (!empty($restrictions))
38 $getCatalogs = $selector->checkSiteMode([
Landing\
Source\Selector::SITE_MODE_STORE]);
39 if (!empty($restrictions[
'IBLOCK_ID']) && is_array($restrictions[
'IBLOCK_ID']))
41 $catalogs = static::getCatalogs($restrictions[
'IBLOCK_ID']);
42 if (!empty($catalogs))
43 $catalogs = array_fill_keys($catalogs,
true);
45 $filter = [
'ID' => $restrictions[
'IBLOCK_ID']];
46 if (!empty($restrictions[
'SITE_ID']))
48 $filter[
'SITE_ID'] = $restrictions[
'SITE_ID'];
50 $iterator = \CIBlock::GetList([
'SORT' =>
'ASC'], $filter,
false);
51 while ($row = $iterator->Fetch())
53 $row[
'ID'] = (int)$row[
'ID'];
54 if (!$getCatalogs && isset($catalogs[$row[
'ID']]))
60 'TITLE' => $row[
'NAME']
63 unset($row, $iterator);
68 if (empty($iblockList))
73 $elementFields = static::getElementFields();
74 $productFields = static::getProductFields();
77 foreach ($iblockList as $iblock)
79 $sourceId = self::SELECTOR_ENTITY.$iblock[
'ID'];
80 $path = $selector->getSourceFilterBaseUri(
'iblock', $sourceId);
81 $action = $selector->getResultAction();
83 switch ($action[
'TYPE'])
85 case Landing\Source\Selector::ACTION_TYPE_EVENT:
86 $resultActionType = Iblock\Component\Selector\Entity::RESULT_ACTION_TYPE_EVENT;
88 case Landing\Source\Selector::ACTION_TYPE_SLIDER:
89 $resultActionType = Iblock\Component\Selector\Entity::RESULT_ACTION_TYPE_SLIDER;
92 $resultActionType =
'';
95 if ($resultActionType ===
'')
98 $actionList = $selector->getDefaultLinkActions();
99 $fields = $elementFields;
100 if (isset($catalogs[$iblock[
'ID']]))
102 $fields = array_merge($fields, $productFields);
103 $actionList = array_merge($actionList, static::getProductActionList());
106 $properties = static::getIblockProperties($iblock[
'ID']);
107 if (!empty($properties))
108 $fields = array_merge($fields, $properties);
111 $fields = array_merge($fields, static::getLinkDefinition($actionList));
115 'ORDER' => static::getOrderFields($fields),
116 'FIELDS' => static::getShowedFields($fields)
120 'GRID_ID' =>
'iblock'.$sourceId.
'_selector',
121 'BASE_LINK' => $path->getUri(),
122 'IBLOCK_ID' => $iblock[
'ID'],
123 'MULTIPLE_SELECT' =>
'N',
124 'USE_MODE' => Iblock\Component\Selector\Entity::MODE_SLIDER,
125 'RESULT_ACTION_TYPE' => $resultActionType,
126 'RESULT_ACTION_NAME' => $action[
'NAME'],
127 'RESULT_DATA_TYPE' => Iblock\Component\Selector\Entity::RESULT_DATA_TYPE_FILTER,
128 'RESULT_DATA_SET_LIST' => [],
129 'PAGETITLE_FILTER' =>
'Y',
130 'SIMPLE_PRODUCTS' =>
'Y'
134 'SOURCE_ID' => $sourceId,
135 'TITLE' => $iblock[
'TITLE'],
136 'TYPE' => Landing\Source\Selector::SOURCE_TYPE_COMPONENT,
138 'COMPONENT_NAME' =>
'bitrix:iblock.selector.landing',
139 'COMPONENT_TEMPLATE_NAME' =>
'.default',
140 'COMPONENT_PARAMS' => $parameters,
142 'USE_PADDING' =>
false,
143 'PLAIN_VIEW' =>
false,
144 'USE_UI_TOOLBAR' =>
'N'
148 'IBLOCK_ID' => $iblock[
'ID'],
149 'ACTIVE_DATE' =>
'Y',
150 'CHECK_PERMISSIONS' =>
'Y',
151 'MIN_PERMISSION' =>
'R'
153 'DATA_SETTINGS' => $dataSettings,
154 'DATA_LOADER' =>
'\Bitrix\Iblock\LandingSource\DataLoader'
158 unset($sourceId, $path, $action, $dataSettings, $parameters, $row, $iblock);
173 if (self::$catalogIncluded ===
null)
175 if (self::$catalogIncluded)
178 if (!empty($iblocks))
179 $filter[
'@IBLOCK_ID'] = $iblocks;
181 $iterator = Catalog\CatalogIblockTable::getList([
182 'select' => [
'IBLOCK_ID'],
185 while ($row = $iterator->fetch())
186 $result[] = (int)$row[
'IBLOCK_ID'];
187 unset($row, $iterator, $filter);
202 'TYPE' => Node\Type::TEXT,
203 'ALLOWED' => self::FIELD_ALLOWED_ORDER
208 'TYPE' => Node\Type::TEXT,
209 'ALLOWED' => self::FIELD_ALLOWED_ALL
211 $result[
'PREVIEW_TEXT'] = [
212 'ID' =>
'PREVIEW_TEXT',
213 'NAME' =>
Loc::getMessage(
'IBLOCK_LANDING_SOURCE_ELEMENT_FIELD_PREVIEW_TEXT'),
214 'TYPE' => Node\Type::TEXT,
215 'ALLOWED' => self::FIELD_ALLOWED_SELECT
217 $result[
'PREVIEW_PICTURE'] = [
218 'ID' =>
'PREVIEW_PICTURE',
219 'NAME' =>
Loc::getMessage(
'IBLOCK_LANDING_SOURCE_ELEMENT_FIELD_PREVIEW_PICTURE'),
220 'TYPE' => Node\Type::IMAGE,
221 'ALLOWED' => self::FIELD_ALLOWED_SELECT
223 $result[
'DETAIL_TEXT'] = [
224 'ID' =>
'DETAIL_TEXT',
225 'NAME' =>
Loc::getMessage(
'IBLOCK_LANDING_SOURCE_ELEMENT_FIELD_DETAIL_TEXT'),
226 'TYPE' => Node\Type::TEXT,
227 'ALLOWED' => self::FIELD_ALLOWED_SELECT
229 $result[
'DETAIL_PICTURE'] = [
230 'ID' =>
'DETAIL_PICTURE',
231 'NAME' =>
Loc::getMessage(
'IBLOCK_LANDING_SOURCE_ELEMENT_FIELD_DETAIL_PICTURE'),
232 'TYPE' => Node\Type::IMAGE,
233 'ALLOWED' => self::FIELD_ALLOWED_SELECT
238 'TYPE' => Node\Type::TEXT,
239 'ALLOWED' => self::FIELD_ALLOWED_ORDER
252 $result[
'AVAILABLE'] = [
254 'NAME' =>
Loc::getMessage(
'IBLOCK_LANDING_SOURCE_ELEMENT_PRODUCT_FIELD_AVAILABLE'),
255 'TYPE' => Node\Type::TEXT,
256 'ALLOWED' => self::FIELD_ALLOWED_ALL
292 $listCodes = Iblock\Model\PropertyFeature::getListPageShowPropertyCodes($iblockId);
293 $detailCodes = Iblock\Model\PropertyFeature::getDetailPageShowPropertyCodes($iblockId);
294 if (empty($listCodes) && empty($detailCodes))
297 $allCodes = array_unique(array_merge($listCodes, $detailCodes));
298 $listCodes = array_fill_keys($listCodes,
true);
299 $detailCodes = array_fill_keys($detailCodes,
true);
301 $iterator = Iblock\PropertyTable::getList([
303 'ID',
'IBLOCK_ID',
'NAME',
'SORT',
'PROPERTY_TYPE',
304 'MULTIPLE',
'FILE_TYPE',
305 'USER_TYPE',
'USER_TYPE_SETTINGS_LIST'
308 '=IBLOCK_ID' => $iblockId,
312 'order' => [
'SORT' =>
'ASC',
'NAME' =>
'ASC']
314 while ($row = $iterator->fetch())
316 $id = (int)$row[
'ID'];
317 $index =
'PROPERTY_'.$row[
'ID'];
318 $titleCode =
'IBLOCK_LANDING_SOURCE_ELEMENT_PROPERTY_TITLE';
319 if (!isset($listCodes[$id]) || !isset($detailCodes[$id]))
321 $titleCode = (isset($listCodes[$id])
322 ?
'IBLOCK_LANDING_SOURCE_ELEMENT_PROPERTY_LIST_TITLE'
323 :
'IBLOCK_LANDING_SOURCE_ELEMENT_PROPERTY_DETAIL_TITLE'
328 [
'#NAME#' => $row[
'NAME']]
331 switch ($row[
'PROPERTY_TYPE'])
333 case Iblock\PropertyTable::TYPE_FILE:
334 if (self::checkImageProperty($row))
339 'TYPE' => Node\Type::IMAGE,
340 'ALLOWED' => self::FIELD_ALLOWED_SELECT
348 'TYPE' => Node\Type::TEXT,
349 'ALLOWED' => ($row[
'MULTIPLE'] ==
'Y' ? self::FIELD_ALLOWED_SELECT : self::FIELD_ALLOWED_ALL)
366 'name' =>
Loc::getMessage(
'IBLOCK_LANDING_SOURCE_ELEMENT_ACTION_TITLE_BUY')
369 'type' =>
'addToCart',
370 'name' =>
Loc::getMessage(
'IBLOCK_LANDING_SOURCE_ELEMENT_ACTION_TITLE_ADD_TO_CART')
385 'TYPE' => Node\Type::LINK,
386 'ACTIONS' => $actions,
387 'ALLOWED' => self::FIELD_ALLOWED_SELECT
400 foreach ($fields as $row)
402 if (($row[
'ALLOWED'] & self::FIELD_ALLOWED_ORDER) == 0)
406 'NAME' => $row[
'NAME']
422 foreach ($fields as $row)
424 if (($row[
'ALLOWED'] & self::FIELD_ALLOWED_SELECT) == 0)
427 unset($item[
'ALLOWED']);
441 if (empty($property[
'FILE_TYPE']))
443 $property[
'FILE_TYPE'] = mb_strtolower(str_replace(
' ',
'', trim($property[
'FILE_TYPE'])));
444 if (empty($property[
'FILE_TYPE']))
446 $rawFileTypes = explode(
',', $property[
'FILE_TYPE']);
447 if (empty($rawFileTypes))
449 $rawFileTypes = array_fill_keys($rawFileTypes,
true);
451 !isset($rawFileTypes[
'jpg'])
452 && !isset($rawFileTypes[
'gif'])
453 && !isset($rawFileTypes[
'png'])
454 && !isset($rawFileTypes[
'jpeg'])
static includeModule($moduleName)
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)