• Модуль: landing
  • Путь к файлу: ~/bitrix/modules/landing/lib/landing.php
  • Класс: BitrixLandingLanding
  • Вызов: Landing::view
public function view(array $params = array())
{
	$blockEditMode = $this->getEditMode();
	$editMode = $this->mainInstance && $blockEditMode;

	if (!isset($params['parse_link']))
	{
		$params['parse_link'] = true;
	}

	if (!isset($params['apply_template']))
	{
		$params['apply_template'] = true;
	}

	if (!isset($params['check_permissions']))
	{
		$params['check_permissions'] = true;
	}

	if (!$params['check_permissions'])
	{
		Rights::setOff();
	}

	// title
	if ($this->mainInstance)
	{
		Manager::setPageTitle(
			htmlspecialcharsbx($this->title)
		);
	}

	// add chain item if need
	if ($this->mainInstance)
	{
		if ($this->folderId)
		{
			$chains = Folder::getBreadCrumbs($this->folderId, $this->siteId);
			foreach ($chains as $chain)
			{
				Manager::getApplication()->addChainItem(
					$chain['TITLE'],
					$chain['INDEX_ID'] ? '#landing' . $chain['INDEX_ID'] : '#'
				);
			}
		}
		else if (($this->siteRow['LANDING_ID_INDEX'] ?? 0) != $this->id)
		{
			Manager::getApplication()->addChainItem(
				$this->title,
				'#landing' . $this->id
			);
		}
	}

	// assets
	if ($editMode)
	{
		$options = array(
			'site_id' => $this->siteId,
			'server_name' => $_SERVER['SERVER_NAME'],
			'xml_id' => $this->xmlId,
			'blocks' => Block::getRepository(),
			'style' => Block::getStyle(),
			'attrs' => Block::getAttrs(),
			'mainOptions' => [
				'saveOriginalFileName' => Option::get('main', 'save_original_file_name') === 'Y'
			],
		);
		// event for redefine $options
		$event = new Event('landing', 'onLandingView', array(
			'options' => $options
		));
		$event->send();
		foreach ($event->getResults() as $result)
		{
			if ($result->getResultType() != EventResult::ERROR)
			{
				if (($modified = $result->getModified()))
				{
					if (isset($modified['options']) && is_array($modified['options']))
					{
						$options = array_merge($options, $modified['options']);
					}
				}
			}
		}
		// output js
		Asset::getInstance()->addString(
			''
		);
	}

	$content = '';

	// templates part - first
	if ($params['apply_template'] && $this->mainInstance)
	{
		if (!TemplateRef::landingIsArea($this->id))
		{
			$content = $this->applyTemplate();
		}
		else
		{
			$content = '
' . '#CONTENT#' . '
'; } } // then content ob_start(); LandingSeo::beforeLandingView(); foreach ($this->blocks as $block) { $block->view($blockEditMode, $this); } LandingSeo::afterLandingView(); if ($this->mainInstance) { $this->execHooks(); } $contentMain = ob_get_contents(); ob_end_clean(); $replace = []; if (!$content) { $content = $contentMain; } if (mb_strpos($content, '#CONTENT#') !== false) { $replace['#CONTENT#'] = '' . $contentMain; } if (mb_strpos($content . $contentMain, '#crm') !== false) { $replace = array_merge($replace, ConnectorCrm::getReplacesForContent($this->siteId, !$blockEditMode)); } if ($replace) { $content = str_replace( array_keys($replace), array_values($replace), $content ); } // breadcrumb (see chain_template.php in tpl) and title if (!$blockEditMode && $this->mainInstance) { ob_start(); echo Manager::getApplication()->getNavChain( false, 0, false, true ); $breadcrumb = ob_get_contents(); ob_end_clean(); $content = str_replace( array( '#breadcrumb#', '#title#' ), array( $breadcrumb, Manager::getApplication()->getTitle() ), $content ); } // parse links between landings if ($params['parse_link'] === true && !$blockEditMode) { echo $this->parseLocalUrl($content); } else { echo $content; } if (!$params['check_permissions']) { Rights::setOn(); } }