- Модуль: landing
- Путь к файлу: ~/bitrix/modules/landing/lib/block.php
- Класс: BitrixLandingBlock
- Вызов: Block::getBlockContent
static function getBlockContent($id, $editMode = false, array $params = array())
{
if (!isset($params['wrapper_show']))
{
$params['wrapper_show'] = true;
}
if ($editMode)
{
$params['force_unactive'] = true;
}
$params['skip_system_script'] = true;
ob_start();
$id = intval($id);
$block = new self($id);
$extContent = '';
if (($ext = $block->getExt()))
{
$extContent = CUtil::initJSCore($ext, true);
$extContent = preg_replace(
'##is',
'',
$extContent
);
}
$landing = Landing::createInstance(
$block->getLandingId(),
[
'skip_blocks' => true
]
);
if ($editMode)
{
Cache::disableCache();
}
$block->view(
$editMode,
$landing->exist() ? $landing : null,
$params
);
if ($editMode)
{
Cache::enableCache();
}
$content = ob_get_contents();
$content = self::replaceMetaMarkers($content);
if ($landing->exist() && mb_strpos($content, '#crm') !== false)
{
$replace = ConnectorCrm::getReplacesForContent($landing->getSiteId(), false);
$content = str_replace(
array_keys($replace),
array_values($replace),
$content
);
}
ob_end_clean();
if ($block->exist())
{
Manager::getApplication()->restartBuffer();
$availableJS = !$editMode || !$block->getRepoId();
$manifest = $block->getManifest();
if (
!isset($manifest['requiredUserAction']) &&
$block->getRuntimeRequiredUserAction()
)
{
$manifest['requiredUserAction'] = $block->getRuntimeRequiredUserAction();
}
$sections = (array)(($manifest['block']['section']) ?? null);
$return = array(
'id' => $id,
'sections' => implode(',', $sections),
'active' => $block->isActive(),
'access' => $block->getAccess(),
'anchor' => $block->getLocalAnchor(),
'php' => mb_strpos($block->getContent(), '') !== false,
'designed' => $block->isDesigned(),
'repoId' => $block->repoId ? (int)$block->repoId : null,
'content' => $content,
'content_ext' => $extContent,
'css' => $block->getCSS(),
'js' => $availableJS ? $block->getJS() : array(),
'manifest' => $manifest,
'dynamicParams' => $block->dynamicParams
);
if (
$editMode &&
isset($return['manifest']['requiredUserAction'])
)
{
$return['requiredUserAction'] = $return['manifest']['requiredUserAction'];
}
// add ajax initiated assets to output
$ajaxAssets = self::getAjaxInitiatedAssets();
$return['js'] = array_merge($return['js'], $ajaxAssets['js']);
$return['css'] = array_merge($return['css'], $ajaxAssets['css']);
// todo: what about strings, langs?
// todo: what about core.js in strings. And etc relative extensions, which already init
return $return;
}
else
{
return array();
}
}