• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/component_ajax.php
  • Класс: CComponentAjax
  • Вызов: CComponentAjax::__construct
public function __construct($componentName, $componentTemplate, &$arParams, $parentComponent)
{
	/** @global CMain $APPLICATION */
	global $APPLICATION, $USER;

	if ($USER->IsAdmin())
	{
		$disableAjaxInGetParameter = $_GET['bitrix_disable_ajax'] ?? null;
		if ($disableAjaxInGetParameter === 'N')
		{
			unset(BitrixMainApplication::getInstance()->getSession()['bitrix_disable_ajax']);
		}

		if ($disableAjaxInGetParameter === 'Y' || BitrixMainApplication::getInstance()->getSession()['bitrix_disable_ajax'] == 'Y')
		{
			BitrixMainApplication::getInstance()->getSession()['bitrix_disable_ajax'] = 'Y';
			return;
		}
	}

	if ($parentComponent && $this->_checkParent($parentComponent))
		return;

	$this->componentName = $componentName;
	$this->componentTemplate = $componentTemplate;
	$this->arParams = $arParams;

	$this->bShadow = !isset($this->arParams['AJAX_OPTION_SHADOW']) || $this->arParams['AJAX_OPTION_SHADOW'] != 'N';
	$this->bJump = !isset($this->arParams['AJAX_OPTION_JUMP']) || $this->arParams['AJAX_OPTION_JUMP'] != 'N';
	$this->bStyle = !isset($this->arParams['AJAX_OPTION_STYLE']) || $this->arParams['AJAX_OPTION_STYLE'] != 'N';
	$this->bHistory = !isset($this->arParams['AJAX_OPTION_HISTORY']) || $this->arParams['AJAX_OPTION_HISTORY'] != 'N';

	if (!$this->CheckSession())
		return;

	CJSCore::Init(array('ajax'));

	$arParams['AJAX_ID'] = $this->componentID;

	if ($this->bAjaxSession)
	{
		// dirty hack: try to get breadcrumb call params
		for ($i = 0, $cnt = count($APPLICATION->buffer_content_type); $i < $cnt; $i++)
		{
			if (is_array($APPLICATION->buffer_content_type[$i]['F']) && $APPLICATION->buffer_content_type[$i]['F'][1] === 'GetNavChain')
			{
				$this->__nav_params = $APPLICATION->buffer_content_type[$i]['P'];
			}
		}

		$APPLICATION->RestartBuffer();

		define('PUBLIC_AJAX_MODE', 1);

		if (isset($_REQUEST['AJAX_CALL']))
		{
			$this->bIFrameMode = true;
		}
	}

	if ($this->bStyle)
		$this->arCSSList = $APPLICATION->sPath2css;

	$this->arHeadScripts = $APPLICATION->arHeadScripts;

	if (!$this->bAjaxSession)
		$APPLICATION->AddBufferContent(array($this, '__BufferDelimiter'));

	$this->buffer_start_counter = count($APPLICATION->buffer_content);

	$this->LocalRedirectHandlerId = AddEventHandler('main', 'OnBeforeLocalRedirect', array($this, "LocalRedirectHandler"));
	$this->RestartBufferHandlerId = AddEventHandler('main', 'OnBeforeRestartBuffer', array($this, 'RestartBufferHandler'));
}