• Модуль: landing
  • Путь к файлу: ~/bitrix/modules/landing/lib/site/cookies.php
  • Класс: BitrixLandingSiteCookies
  • Вызов: Cookies::isSiteIncludesScript
static function isSiteIncludesScript(int $siteId): bool
{
	if (!$siteId)
	{
		return false;
	}

	// first check if site includes script
	$res = HookDataTable::getList([
		'select' => [
			'ID'
		],
		'filter' => [
			'=HOOK' => 'HEADBLOCK',
			'=CODE' => 'CODE',
			'=ENTITY_ID' => $siteId,
			'=ENTITY_TYPE' => Hook::ENTITY_TYPE_SITE,
			'=PUBLIC' => 'N',
			'VALUE' => '%fetch())
	{
		return true;
	}

	// then check if any page of this site includes script
	$res = HookDataTable::getList([
		'select' => [
			'ID'
		],
		'filter' => [
			'=HOOK' => 'HEADBLOCK',
			'=CODE' => 'CODE',
			'=ENTITY_TYPE' => Hook::ENTITY_TYPE_LANDING,
			'=LANDING.SITE_ID' => $siteId,
			'=PUBLIC' => 'N',
			'VALUE' => '% [
			new BitrixMainEntityReferenceField(
				'LANDING',
				'BitrixLandingInternalsLandingTable',
				['=this.ENTITY_ID' => 'ref.ID']
			)
		]
	]);
	if ($res->fetch())
	{
		return true;
	}

	// then check any blocks on the pages of the site
	$res = BlockTable::getList([
		'select' => [
			'ID'
		],
		'filter' => [
			'=CODE' => 'html',
			'=PUBLIC' => 'N',
			'=ACTIVE' => 'Y',
			'=LANDING.SITE_ID' => $siteId,
			'CONTENT' => '%<script%'
		],
		'runtime' => [
			new BitrixMainEntityReferenceField(
				'LANDING',
				'BitrixLandingInternalsLandingTable',
				['=this.LID' => 'ref.ID']
			)
		]
	]);
	if ($res->fetch())
	{
		return true;
	}

	return false;
}