• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/main.php
  • Класс: CAllMain
  • Вызов: CAllMain::IncludeComponent
public function IncludeComponent($componentName, $componentTemplate, $arParams = array(), $parentComponent = null, $arFunctionParams = array(), $returnResult = false)
{
	/** @global CMain $APPLICATION */
	global $APPLICATION, $USER;

	if(is_array($this->arComponentMatch))
	{
		$skipComponent = true;
		foreach($this->arComponentMatch as $cValue)
		{
			if(mb_strpos($componentName, $cValue) !== false)
			{
				$skipComponent = false;
				break;
			}
		}
		if($skipComponent)
			return false;
	}

	$componentRelativePath = CComponentEngine::MakeComponentPath($componentName);
	if ($componentRelativePath == '')
		return false;

	$debug = null;
	$bShowDebug = MainApplication::getInstance()->getKernelSession()["SESS_SHOW_INCLUDE_TIME_EXEC"]=="Y"
		&& (
			$USER->CanDoOperation('edit_php')
			|| MainApplication::getInstance()->getKernelSession()["SHOW_SQL_STAT"]=="Y"
		)
		&& !defined("PUBLIC_AJAX_MODE")
	;
	if($bShowDebug || $APPLICATION->ShowIncludeStat)
	{
		$debug = new CDebugInfo();
		$debug->Start($componentName);
	}

	if (is_object($parentComponent))
	{
		if (!($parentComponent instanceof cbitrixcomponent))
			$parentComponent = null;
	}

	$bDrawIcons = ((!isset($arFunctionParams["HIDE_ICONS"]) || $arFunctionParams["HIDE_ICONS"] <> "Y") && $APPLICATION->GetShowIncludeAreas());

	if($bDrawIcons)
		echo $this->IncludeStringBefore();

	$result = null;
	$bComponentEnabled = (!isset($arFunctionParams["ACTIVE_COMPONENT"]) || $arFunctionParams["ACTIVE_COMPONENT"] <> "N");

	$component = new CBitrixComponent();
	if($component->InitComponent($componentName))
	{
		$obAjax = null;
		if($bComponentEnabled)
		{
			if(($arParams['AJAX_MODE'] ?? '') == 'Y')
				$obAjax = new CComponentAjax($componentName, $componentTemplate, $arParams, $parentComponent);

			$this->__componentStack[] = $component;
			$result = $component->IncludeComponent($componentTemplate, $arParams, $parentComponent, $returnResult);

			array_pop($this->__componentStack);
		}

		if($bDrawIcons)
		{
			$panel = new CComponentPanel($component, $componentName, $componentTemplate, $parentComponent, $bComponentEnabled);
			$arIcons = $panel->GetIcons();

			echo $s = $this->IncludeStringAfter($arIcons["icons"], $arIcons["parameters"]);
		}

		if($bComponentEnabled && $obAjax)
		{
			$obAjax->Process();
		}
	}

	if($bShowDebug)
		echo $debug->Output($componentName, "/bitrix/components".$componentRelativePath."/component.php", ($arParams["CACHE_TYPE"] ?? '') . ($arParams["MENU_CACHE_TYPE"] ?? ''));
	elseif(isset($debug))
		$debug->Stop($componentName, "/bitrix/components".$componentRelativePath."/component.php", ($arParams["CACHE_TYPE"] ?? '') . ($arParams["MENU_CACHE_TYPE"] ?? ''));


	return $result;
}