• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/ui/webpack/button.php
  • Класс: Bitrix\Crm\UI\Webpack\Button
  • Вызов: Button::getHelloData
protected function getHelloData()
{
	$widgetOrderList = array(
		SiteButton\Manager::ENUM_TYPE_OPEN_LINE,
		SiteButton\Manager::ENUM_TYPE_OPEN_LINE . '_livechat',
		SiteButton\Manager::ENUM_TYPE_CALLBACK,
		SiteButton\Manager::ENUM_TYPE_CRM_FORM,
	);
	$showWidgetId = '';
	$widgetIdList = [];
	$widgets = $this->getWidgets();
	foreach ($widgets as $widget)
	{
		$widgetIdList[] = $widget['id'];
	}

	foreach ($widgetOrderList as $widgetOrderId)
	{
		if (in_array($widgetOrderId, $widgetIdList))
		{
			$showWidgetId = $widgetOrderId;
			break;
		}
	}

	if (!$showWidgetId && $widgetIdList[0])
	{
		$showWidgetId = $widgetIdList[0];
	}

	$buttonData = $this->button->getData();
	$settings = is_array($buttonData['SETTINGS']) ? $buttonData['SETTINGS'] : array();
	$hello = is_array($settings['HELLO']) ? $settings['HELLO'] : array();
	$hello['CONDITIONS'] = is_array($hello['CONDITIONS']) ? $hello['CONDITIONS'] : array();
	$conditions = array();

	if ($hello['ACTIVE'])
	{
		foreach ($hello['CONDITIONS'] as $condition)
		{
			if ($condition['PAGES'] && is_array($condition['PAGES']['LIST']))
			{
				$condition['PAGES']['LIST'] = array_values($condition['PAGES']['LIST']);
			}

			$conditions[] = array(
				'icon' => $condition['ICON'],
				'name' => $condition['NAME'],
				'text' => $condition['TEXT'],
				'pages' => $condition['PAGES'],
				'delay' => $condition['DELAY'],
			);
		}

		if ($hello['MODE'] == 'INCLUDE' && isset($conditions[0]))
		{
			unset($conditions[0]);
			sort($conditions);
		}
	}

	return array(
		'delay' => 1,
		'showWidgetId' => $showWidgetId,
		'conditions' => $conditions
	);
}