• Модуль: landing
  • Путь к файлу: ~/bitrix/modules/landing/lib/update/block/domainua.php
  • Класс: BitrixLandingUpdateBlockDomainUa
  • Вызов: DomainUa::execute
public function execute(array &$result)
{
	$lastId = Option::get('landing', 'update_block_domainua', 0);

	if (!isset($result['steps']))
	{
		$result['steps'] = 0;
	}

	$finished = true;

	// gets common quantity
	$res = BlockTable::getList(array(
		'select' => array(
			new BitrixMainEntityExpressionField(
				'CNT', 'COUNT(*)'
			)
		),
		'filter' => [
			'CONTENT' => '%cdn.bitrix24.ua%',
		]
	));
	if ($row = $res->fetch())
	{
		$result['count'] = $row['CNT'];
	}

	// gets group for update
	$res = BlockTable::getList(array(
		'select' => array(
			'ID', 'CONTENT'
		),
		'filter' => array(
			'>ID' => $lastId,
			'CONTENT' => '%cdn.bitrix24.ua%',
		),
		'order' => array(
			'ID' => 'ASC'
		),
		'limit' => 10
	));
	while ($row = $res->fetch())
	{
		$lastId = $row['ID'];
		$result['steps']++;

		BlockTable::update($row['ID'], [
			'CONTENT' => str_replace(
				'cdn.bitrix24.ua',
				'cdn.bitrix24.eu',
				$row['CONTENT']
			)
		]);

		$finished = false;
	}

	// add files from blocks
	if (!$finished)
	{
		Option::set('landing', 'update_block_domainua', $lastId);
		return true;
	}
	else
	{
		Option::delete('landing', array('name' => 'update_block_domainua'));
		return false;
	}
}