76 if ($this->sourceList !==
null)
80 $this->sourceList = [];
84 $this->config[
'SOURCE_EVENT_ID'],
87 'RESTRICTIONS' => $this->restrictions
91 $resultList = $event->getResults();
92 if (!empty($resultList))
94 foreach ($resultList as $eventResult)
96 if ($eventResult->getType() != Main\EventResult::SUCCESS)
100 $module = (string)$eventResult->getModuleId();
101 $list = $eventResult->getParameters();
102 if (empty($list) || !is_array($list))
106 foreach ($list as $row)
116 $this->sourceList[$source[
'INDEX']] = $source;
119 unset($source, $row, $list, $module);
120 unset($eventResult, $resultList);
122 if (!empty($this->sourceList))
124 Main\Type\Collection::sortByColumn(
126 [
'TYPE' => SORT_ASC,
'TITLE' => SORT_ASC],
146 $uri->addParams($this->
getBaseUrlParams(static::getSourceIndex($module, $sourceId)));
159 if (empty($this->sourceList))
164 foreach ($this->sourceList as $source)
167 'detailPage' => $source[
'SYSTEM_SETTINGS'][
'DETAIL_PAGE']
172 'id' => $source[
'INDEX'],
173 'name' => $source[
'TITLE'],
174 'sort' => $source[
'DATA_SETTINGS'][
'ORDER'],
175 'references' => $source[
'DATA_SETTINGS'][
'FIELDS'],
176 'settings' => $systemSettings
178 switch ($source[
'TYPE'])
182 'filter' => $uri->getUri()
186 $row[
'filter'] = $source[
'SETTINGS'][
'FILTER'];
189 $result[$source[
'INDEX']] = $row;
191 unset($row, $source);
206 if (!is_string($index) || $index ===
'')
211 return isset($this->sourceList[$index]) ? $this->sourceList[$index] :
null;
230 switch ($source[
'TYPE'])
233 $APPLICATION->IncludeComponent(
234 'bitrix:ui.sidepanel.wrapper',
237 'POPUP_COMPONENT_NAME' => $source[
'SETTINGS'][
'COMPONENT_NAME'],
238 'POPUP_COMPONENT_TEMPLATE_NAME' => $source[
'SETTINGS'][
'COMPONENT_TEMPLATE_NAME'],
239 'POPUP_COMPONENT_PARAMS' => $source[
'SETTINGS'][
'COMPONENT_PARAMS'],
240 ] + $source[
'SETTINGS'][
'WRAPPER']
253 $request = Main\Context::getCurrent()->getRequest();
254 $sourceIndex = (string)$request->get(
'SOURCE_ID');
256 if ($sourceIndex ===
'')
269 public function getDataLoader($index, array $parameters, array $options = [])
277 $parameters[
'internal_filter'] = $source[
'SOURCE_FILTER'];
280 $result =
new $source[
'DATA_LOADER'];
281 $result->setConfig($parameters);
282 $result->setOptions($options);
295 $selector =
new static(
$config);
296 return $selector->getSourcesDescription();
308 $selector =
new static(
$config);
309 $selector->initSourceList();
310 foreach ($selector->sourceList as $source)
312 $result[$source[
'INDEX']] = $source[
'TITLE'];
336 $this->siteMode === self::SITE_MODE_SYSTEM
337 || in_array($this->siteMode, $modeList,
true)
349 $module = (string)$module;
354 if (isset($this->restrictions[$module]))
356 return $this->restrictions[$module];
358 if (isset($this->restrictions[
'all']))
360 return $this->restrictions[
'all'];
374 return (
string)$module.
':'.(string)$sourceId;
383 'TYPE' => $this->config[
'RESULT_ACTION_TYPE'],
384 'NAME' => $this->config[
'RESULT_ACTION_NAME']
418 $this->config = array_merge($this->config,
$config);
435 foreach (
$config as $field => $value)
441 if (is_string($value))
443 $value = preg_replace(
'/[^a-zA-Z0-9_:\\[\\]]/',
'', trim($value));
445 $checked = (is_string($value) && $value !==
'');
447 case 'SOURCE_EVENT_ID':
448 if (is_string($value))
450 $value = preg_replace(
'/[^a-zA-Z0-9]/',
'', trim($value));
452 $checked = (is_string($value) && $value !==
'');
454 case 'RESULT_ACTION_TYPE':
455 case 'RESULT_ACTION_NAME':
456 if (is_string($value))
458 $value = preg_replace(
'/[^a-zA-Z0-9_]/',
'', trim($value));
460 $checked = (is_string($value) && $value !==
'');
463 if (is_string($value))
465 $value = trim($value);
468 $checked = (is_string($value) && $value !==
'');
473 $result[$field] = $value;
478 if (!isset($result[
'ID']))
480 $result[
'ID'] = preg_replace(
'/[^a-zA-Z0-9_:\\[\\]]/',
'', get_called_class());
494 return ($value !==
null);
505 if ($siteType ===
'')
534 $this->restrictions = [];
536 $siteId = (defined(
'SITE_ID') ? SITE_ID :
null);
539 $this->restrictions[
'all'] = [
'SITE_ID' => $siteId];
540 $this->restrictions[
'iblock'] = $this->restrictions[
'all'];
541 $this->restrictions[
'socialnetwork'] = $this->restrictions[
'all'];
545 if ($iblockId !==
'')
547 $iblockId = explode(
',', $iblockId);
552 Hook\Page\Settings::getDataForSite()[
'IBLOCK_ID']
555 $this->restrictions[
'iblock'][
'IBLOCK_ID'] = $iblockId;
567 if (empty($parameters) || !is_array($parameters))
572 if (!isset($parameters[
'SOURCE_ID']))
576 $parameters[
'SOURCE_ID'] = (string)$parameters[
'SOURCE_ID'];
577 if ($parameters[
'SOURCE_ID'] ===
'')
582 if (!isset($parameters[
'TITLE']))
586 $parameters[
'TITLE'] = trim((
string)$parameters[
'TITLE']);
587 if ($parameters[
'TITLE'] ===
'')
594 if (!preg_match(
'/^[a-z][a-z.]+:[A-Za-z][A-Za-z0-9]*$/', $index, $prepared))
602 'SOURCE_ID' => $parameters[
'SOURCE_ID'],
603 'TITLE' => $parameters[
'TITLE']
606 if (!isset($parameters[
'TYPE']))
610 $parameters[
'TYPE'] = (string)$parameters[
'TYPE'];
612 $parameters[
'TYPE'] !== self::SOURCE_TYPE_COMPONENT
613 && $parameters[
'TYPE'] !== self::SOURCE_TYPE_PRESET
619 $result[
'TYPE'] = $parameters[
'TYPE'];
621 if (empty($parameters[
'SETTINGS']) || !is_array($parameters[
'SETTINGS']))
628 $result[
'SETTINGS'] = [];
631 switch ($parameters[
'TYPE'])
640 if ($settings ===
null)
644 $result[
'SETTINGS'] = $settings;
647 if (empty($parameters[
'DATA_SETTINGS']) || !is_array($parameters[
'DATA_SETTINGS']))
652 if ($settings ===
null)
656 $result[
'DATA_SETTINGS'] = $settings;
659 if (empty($parameters[
'DATA_LOADER']))
663 if (!is_string($parameters[
'DATA_LOADER'])
664 || !is_subclass_of($parameters[
'DATA_LOADER'],
'\Bitrix\Landing\Source\DataLoader'))
668 $result[
'DATA_LOADER'] = $parameters[
'DATA_LOADER'];
670 $result[
'SOURCE_FILTER'] = [];
671 if (!empty($parameters[
'SOURCE_FILTER']) && is_array($parameters[
'SOURCE_FILTER']))
673 $result[
'SOURCE_FILTER'] = $parameters[
'SOURCE_FILTER'];
688 'DETAIL_PAGE' => true
691 if (isset($settings[
'DETAIL_PAGE']) && is_bool($settings[
'DETAIL_PAGE']))
693 $result[
'DETAIL_PAGE'] = $settings[
'DETAIL_PAGE'];
707 if (!isset($settings[
'COMPONENT_NAME']))
711 $settings[
'COMPONENT_NAME'] = (string)$settings[
'COMPONENT_NAME'];
712 if ($settings[
'COMPONENT_NAME'] ===
'')
717 if (!isset($settings[
'COMPONENT_TEMPLATE_NAME']))
721 $settings[
'COMPONENT_TEMPLATE_NAME'] = (string)$settings[
'COMPONENT_TEMPLATE_NAME'];
723 if (!isset($settings[
'COMPONENT_PARAMS']) || !is_array($settings[
'COMPONENT_PARAMS']))
730 return array_intersect_key(
733 'COMPONENT_NAME' =>
true,
734 'COMPONENT_TEMPLATE_NAME' =>
true,
735 'COMPONENT_PARAMS' =>
true,
749 if (empty($settings[
'FILTER']) || !is_array($settings[
'FILTER']))
754 $preset = array_filter($settings[
'FILTER'], [
'\Bitrix\Landing\Source\BlockFilter',
'checkPreparedRow']);
774 'USE_PADDING' =>
false,
775 'PLAIN_VIEW' =>
false,
776 'USE_UI_TOOLBAR' =>
'N'
779 if (isset($settings[
'WRAPPER']) && is_array($settings[
'WRAPPER']))
781 $rawData = $settings[
'WRAPPER'];
782 if (isset($rawData[
'USE_PADDING']) && is_bool($rawData[
'USE_PADDING']))
784 $result[
'USE_PADDING'] = $rawData[
'USE_PADDING'];
786 if (isset($rawData[
'PLAIN_VIEW']) && is_bool($rawData[
'PLAIN_VIEW']))
788 $result[
'PLAIN_VIEW'] = $rawData[
'PLAIN_VIEW'];
791 isset($rawData[
'USE_UI_TOOLBAR'])
792 && ($rawData[
'USE_UI_TOOLBAR'] ===
'Y' || $rawData[
'USE_UI_TOOLBAR'] ===
'N')
795 $result[
'USE_UI_TOOLBAR'] = $rawData[
'USE_UI_TOOLBAR'];
803 isset($settings[
'USE_UI_TOOLBAR'])
804 && ($settings[
'USE_UI_TOOLBAR'] ===
'Y' || $settings[
'USE_UI_TOOLBAR'] ===
'N')
807 $result[
'USE_UI_TOOLBAR'] = $settings[
'USE_UI_TOOLBAR'];
822 if (empty($settings))
829 if (!is_array($settings[
'ORDER']))
833 $settings[
'ORDER'] = array_filter($settings[
'ORDER'], [__CLASS__,
'isNotEmptyField']);
834 if (empty($settings[
'ORDER']))
839 foreach ($settings[
'ORDER'] as $row)
853 $result[
'ORDER'] = $list;
856 if (!is_array($settings[
'FIELDS']))
860 $settings[
'FIELDS'] = array_filter($settings[
'FIELDS'], [__CLASS__,
'isNotEmptyField']);
861 if (empty($settings[
'FIELDS']))
866 foreach ($settings[
'FIELDS'] as $row)
880 $result[
'FIELDS'] = $list;
896 'SOURCE_ID' => $index
910 'lang' => LANGUAGE_ID
912 if (defined(
'SITE_ID'))
914 $result[
'site'] = SITE_ID;
916 if (defined(
'SITE_TEMPLATE_ID'))
918 $result[
'template'] = SITE_TEMPLATE_ID;
920 $request = Main\Context::getCurrent()->getRequest();
921 if ($request->isAdminSection())
923 $result[
'admin_section'] =
'Y';
935 return (!empty($item) && is_array($item));
944 $field = array_change_key_case($field, CASE_LOWER);
948 if (empty($field[
'id']) || empty($field[
'name']))
954 'id' => $field[
'id'],
955 'name' => $field[
'name']
966 if (empty($row[$name]) || !is_string($row[$name]))
970 $row[$name] = trim($row[$name]);
971 if ($row[$name] ===
'')
static getOption($code, $default=null)
checkSystemSettings(array $settings)
prepareConfig(array $config)
checkComponentSettings(array $settings)
const SITE_MODE_KNOWLEDGE
prepareStringValue(array $row, $name)
checkWrapperSettings(array $settings)
static getSourceNames(array $config=[])
checkSiteMode(array $modeList)
static getSourceIndex($module, $sourceId)
getSourceFilterBaseUri($module, $sourceId)
checkDataSettings(array $settings)
checkPresetSettings(array $settings)
const SOURCE_TYPE_COMPONENT
prepareSourceParameters($module, $parameters)
prepareOrderField(array $field)
getModuleRestrictions($module)
static isNotEmptyField($item)
__construct(array $config=[])
const EVENT_BUILD_SOURCE_LIST
static getSources(array $config=[])
showSourceFilterByRequest()
static getMessage($code, $replace=null, $language=null)