Your IP : 18.222.190.43
<?
use Bitrix\Main\Localization\Loc;
use Bitrix\Main\ErrorCollection;
use Bitrix\Main\Loader;
use Bitrix\Main\Error;
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true)
{
die();
}
Loc::loadMessages(__FILE__);
class CrmTrackingSourceUtmComponent extends \CBitrixComponent
{
/** @var ErrorCollection $errors */
protected $errors;
protected function checkRequiredParams()
{
return $this->errors->count() == 0;
}
protected function initParams()
{
$this->arParams['SET_TITLE'] = isset($this->arParams['SET_TITLE']) ? (bool) $this->arParams['SET_TITLE'] : true;
}
protected function preparePost()
{
LocalRedirect($this->request->getRequestUri());
}
protected function prepareResult()
{
if ($this->arParams['SET_TITLE'] == 'Y')
{
$GLOBALS['APPLICATION']->SetTitle(
$this->arParams['ID'] > 0
?
Loc::getMessage('CRM_ANALYTICS_SOURCE_UTM_TITLE_EDIT')
:
Loc::getMessage('CRM_ANALYTICS_SOURCE_UTM_TITLE_ADD')
);
}
if ($this->request->isPost())
{
$this->preparePost();
}
return true;
}
protected function printErrors()
{
foreach ($this->errors as $error)
{
ShowError($error);
}
}
public function executeComponent()
{
$this->errors = new \Bitrix\Main\ErrorCollection();
if (!Loader::includeModule('crm'))
{
$this->errors->setError(new Error('Module `crm` is not installed.'));
$this->printErrors();
return;
}
$this->initParams();
if (!$this->checkRequiredParams())
{
$this->printErrors();
return;
}
if (!$this->prepareResult())
{
$this->printErrors();
return;
}
$this->printErrors();
$this->includeComponentTemplate();
}
}