- Модуль: landing
- Путь к файлу: ~/bitrix/modules/landing/lib/landing.php
- Класс: BitrixLandingLanding
- Вызов: Landing::copyAllBlocks
public function copyAllBlocks($lid, $replaceLinks = true, array &$references = [])
{
$landing = self::createInstance($lid);
if ($this->exist() && $landing->exist())
{
$oldNew = array();
// copy blocks
foreach ($landing->getBlocks() as $block)
{
$newBlock = Block::createFromRepository(
$this,
$block->getCode(),
array(
'ACTIVE' => $block->isActive() ? 'Y' : 'N',
'DESIGNED' => $block->isDesigned() ? 'Y' : 'N',
'PUBLIC' => $block->isPublic() ? 'Y' : 'N',
'ACCESS' => $block->getAccess(),
'SORT' => $block->getSort(),
'CONTENT' => $block->getContent(),
'SOURCE_PARAMS' => $block->getDynamicParams()
));
if ($newBlock)
{
$oldNew[$block->getId()] = $newBlock;
$references[$block->getId()] = $newBlock->getId();
$this->addBlockToCollection($newBlock);
}
}
// replace old id of blocks to the new one and clone files
foreach ($this->getBlocks() as $block)
{
$content = $block->getContent();
foreach ($oldNew as $oldId => $newBlock)
{
// clone files
File::addToBlock(
$newBlock->getId(),
File::getFilesFromBlockContent($oldId, $content)
);
// replace ids
if ($replaceLinks)
{
$content = str_replace(
'#block' . $oldId,
'#block' . $newBlock->getId(),
$content
);
$block->saveContent($content);
}
$block->save();
}
}
$this->touch();
}
$this->error->copyError($this->getError());
$this->error->copyError($landing->getError());
}