• Модуль: landing
  • Путь к файлу: ~/bitrix/modules/landing/lib/site/update/chatsales.php
  • Класс: BitrixLandingSiteUpdateChatSales
  • Вызов: ChatSales::replaceFooterLinks
static function replaceFooterLinks(int $footerId, int $siteId): void
{
	$replaceCodes = array_keys(self::FOOTER_LINKS_MAP);
	$replaces = [];

	$landings = Landing::getList([
		'select' => ['ID', 'TPL_CODE'],
		'filter' => ['SITE_ID' => $siteId],
	]);
	while ($landing = $landings->fetch())
	{
		$tpl = $landing['TPL_CODE'];
		if (in_array($tpl, $replaceCodes, true))
		{
			$replaces['"' . self::FOOTER_LINKS_MAP[$tpl] . '"'] = '"#landing' . $landing['ID'] . '"';
		}
	}

	if (!empty($replaces))
	{
		$blocks = BlockTable::getList([
			'select' => ['ID', 'CONTENT'],
			'filter' => [
				'LID' => $footerId,
				'CODE' => self::FOOTER_BLOCK_CODE,
			],
		]);
		while ($block = $blocks->fetch())
		{
			$newContent = str_replace(
				array_keys($replaces),
				array_values($replaces),
				$block['CONTENT']
			);
			BlockTable::update($block['ID'], [
				'CONTENT' => $newContent
			]);
		}
	}
}