• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/wizard_site.php
  • Класс: CWizard
  • Вызов: CWizard::__Install
function __Install()
{
	//Create wizard
	$wizardName = (array_key_exists("NAME", $this->arDescription) ? $this->arDescription["NAME"] : "");
	$this->wizard = new CWizardBase($wizardName, $this);
	$this->__SetTemplate();
	$this->__InitVariables();

	$wizard = $this->wizard;

	//Welcome step
	if ($this->__GetUserStep("welcome", $userWelcome))
		$step = $userWelcome;
	else
		$step = new CPackageWelcome($this);

	$wizard->AddStep($step, BX_WIZARD_WELCOME_ID);
	$this->_SetNextStep($step, BX_WIZARD_WELCOME_ID, "select");
	$this->__SetStepDescription($step, "WELCOME");
	$step->SetCancelStep(BX_WIZARD_CANCEL_ID);
	$lastStepID = $step->GetStepID();

	//#NEW
	if ($this->_InitSubStep("static", $this->arDescription["STEPS_SETTINGS"]["WELCOME"]) )
	{
		$lastStepID = $this->__obLastStep->GetStepID();
		$this->_SetNextStep($this->__obLastStep, BX_WIZARD_WELCOME_ID, "select");
		$this->__obFirstStep->SetPrevStep(BX_WIZARD_WELCOME_ID);
		$step->SetNextStep($this->__obFirstStep->GetStepID());
	}
	//

	//License step
	if ($this->licenseExists)
	{
		$step = new CPackageLicense($this);
		$wizard->AddStep($step, BX_WIZARD_LICENSE_ID);
		$this->_SetNextStep($step, BX_WIZARD_LICENSE_ID, "select");
		$this->__SetStepDescription($step, "LICENSE");
		$step->SetPrevStep($lastStepID);
		$lastStepID = $step->GetStepID();

		//Add custom steps to wizard
		if (/*$this->siteSelected &&*/ $this->_InitSubStep("static", $this->arDescription["STEPS_SETTINGS"]["LICENSE"]) )
		{
			$lastStepID = $this->__obLastStep->GetStepID();
			$this->_SetNextStep($this->__obLastStep, BX_WIZARD_LICENSE_ID, "select");
			$this->__obFirstStep->SetPrevStep(BX_WIZARD_LICENSE_ID);
			$step->SetNextStep($this->__obFirstStep->GetStepID());
		}
	}

	$siteID = $this->siteID;
	$templateID = $this->templateID;
	$arServices = $this->serviceID;
	$structureID = $this->structureID;

	//Select site step
	if ($this->siteExists)
	{
		$step = new CPackageSelectSite($this);
		$wizard->AddStep($step, BX_WIZARD_SELECT_SITE_ID);
		$this->_SetNextStep($step, BX_WIZARD_SELECT_SITE_ID, "select");
		$this->__SetStepDescription($step, "SELECT_SITE");
		$step->SetPrevStep($lastStepID);
		$lastStepID = $step->GetStepID();

		//Add custom steps to wizard
		if ($this->siteSelected && $this->_InitSubStep("select", $this->arSites[$siteID]) )
		{
			$lastStepID = $this->__obLastStep->GetStepID();
			$this->_SetNextStep($this->__obLastStep, BX_WIZARD_SELECT_SITE_ID, "select");
			$this->__obFirstStep->SetPrevStep(BX_WIZARD_SELECT_SITE_ID);
			$step->SetNextStep($this->__obFirstStep->GetStepID());
		}
	}

	//Select group step
	if ($this->groupExists && $this->templateExists)
	{
		$step = new CPackageSelectGroup($this);
		$wizard->AddStep($step, BX_WIZARD_SELECT_GROUP_ID);
		$this->_SetNextStep($step, BX_WIZARD_SELECT_GROUP_ID, "select");
		$this->__SetStepDescription($step, "SELECT_GROUP");
		$step->SetPrevStep($lastStepID);
		$lastStepID = $step->GetStepID();
	}

	//Select template step
	if ($this->templateExists)
	{
		$step = new CPackageSelectTemplate($this);
		$wizard->AddStep($step, BX_WIZARD_SELECT_TEMPLATE_ID);
		$this->_SetNextStep($step, BX_WIZARD_SELECT_TEMPLATE_ID, "select");
		$this->__SetStepDescription($step, "SELECT_TEMPLATE");
		$step->SetPrevStep($lastStepID);
		$lastStepID = $step->GetStepID();

		//Add custom steps to wizard
		if ($this->templateSelected && $this->_InitSubStep("select", $this->arTemplates[$templateID]))
		{
			$lastStepID = $this->__obLastStep->GetStepID();
			$this->_SetNextStep($this->__obLastStep, BX_WIZARD_SELECT_TEMPLATE_ID, "select");
			$this->__obFirstStep->SetPrevStep(BX_WIZARD_SELECT_TEMPLATE_ID);
			$step->SetNextStep($this->__obFirstStep->GetStepID());
		}
	}

	//Select service step
	if ($this->serviceExists)
	{
		$step = new CPackageSelectService($this);
		$wizard->AddStep($step, BX_WIZARD_SELECT_SERVICE_ID);
		$this->_SetNextStep($step, BX_WIZARD_SELECT_SERVICE_ID, "select");
		//$step->SetNextStep("__start_install");
		$step->SetPrevStep($lastStepID);
		$this->__SetStepDescription($step, "SELECT_SERVICE");
		$lastStepID = $step->GetStepID();

		if ($this->serviceSelected)
		{
			foreach ($arServices as $service)
			{
				if (!array_key_exists($service, $this->arServices))
					continue;

				//Add custom steps to wizard
				if ($this->_InitSubStep("select", $this->arServices[$service]))
				{
					$this->__obFirstStep->SetPrevStep($lastStepID);

					//$this->__obLastStep->SetNextStep("__start_install");
					$this->_SetNextStep($this->__obLastStep, BX_WIZARD_SELECT_SERVICE_ID, "select");
					$lastStepID = $this->__obLastStep->GetStepID();

					$step->SetNextStep($this->__obFirstStep->GetStepID());
					$step = $this->__obLastStep;
				}
			}
		}
	}

	//Select structure
	if ($this->structureExists)
	{
		$step = new CPackageSelectStructure($this);
		$wizard->AddStep($step, BX_WIZARD_SELECT_STRUCTURE_ID);
		$this->_SetNextStep($step, BX_WIZARD_SELECT_STRUCTURE_ID, "select");
		$this->__SetStepDescription($step, "SELECT_STRUCTURE");
		$step->SetPrevStep($lastStepID);
		$lastStepID = $step->GetStepID();

		//#NEW
		if ($this->_InitSubStep("select", $this->arStructure["SETTINGS"]))
		{
			$lastStepID = $this->__obLastStep->GetStepID();
			$this->_SetNextStep($this->__obLastStep, BX_WIZARD_SELECT_STRUCTURE_ID, "select");
			$this->__obFirstStep->SetPrevStep(BX_WIZARD_SELECT_STRUCTURE_ID);
			$step->SetNextStep($this->__obFirstStep->GetStepID());
		}
	}

	//Start installation step
	$arSelected = Array(
		"siteID" => ($this->siteSelected ? $siteID : null),
		"templateID" => ($this->templateSelected ? $templateID : null),
		"arServices" => ($this->serviceSelected ? $arServices : Array()),
	);

	if ($this->__GetUserStep("start_install", $userStartInstall))
		$step = $userStartInstall;
	else
		$step = new CPackageStartInstall($this, $arSelected);

	$wizard->AddStep($step, BX_WIZARD_START_INSTALL_ID);
	$step->SetPrevStep($lastStepID);
	$step->SetCancelStep(BX_WIZARD_CANCEL_ID);
	$this->__SetStepDescription($step, "START_INSTALL");
	$this->_SetNextStep($step, BX_WIZARD_START_INSTALL_ID, "install");

	//#NEW
	if ($this->_InitSubStep("static", $this->arDescription["STEPS_SETTINGS"]["START_INSTALL"]) )
	{
		$lastStepID = $this->__obLastStep->GetStepID();
		$this->_SetNextStep($this->__obLastStep, BX_WIZARD_START_INSTALL_ID, "install");
		$this->__obFirstStep->SetPrevStep(BX_WIZARD_START_INSTALL_ID);
		$step->SetNextStep($this->__obFirstStep->GetStepID());
	}
	//

	//Site installation step
	if ($this->siteSelected)
	{
		$step = new CPackageInstallSite($this, $siteID);
		$wizard->AddStep($step, BX_WIZARD_INSTALL_SITE_ID);
		$this->_SetNextStep($step, BX_WIZARD_INSTALL_SITE_ID, "install");
		$this->__SetStepDescription($step, "INSTALL_SITE");

		if ($this->_InitSubStep("install", $this->arSites[$siteID]))
		{
			$this->_SetNextStep($this->__obLastStep, BX_WIZARD_INSTALL_SITE_ID, "install");
			$step->SetNextStep($this->__obFirstStep->GetStepID());
		}
	}

	//Template installation step
	if ($this->templateSelected)
	{
		$step = new CPackageInstallTemplate($this, $templateID);
		$wizard->AddStep($step, BX_WIZARD_INSTALL_TEMPLATE_ID);
		$this->_SetNextStep($step, BX_WIZARD_INSTALL_TEMPLATE_ID, "install");
		$this->__SetStepDescription($step, "INSTALL_TEMPLATE");

		if ($this->_InitSubStep("install", $this->arTemplates[$templateID]))
		{
			$this->_SetNextStep($this->__obLastStep, BX_WIZARD_INSTALL_TEMPLATE_ID, "install");
			$step->SetNextStep($this->__obFirstStep->GetStepID());
		}
	}

	//Service installation step
	if ($this->serviceSelected)
	{
		$obLastStep = null;
		$number = "";
		foreach ($arServices as $service)
		{
			if (!array_key_exists($service, $this->arServices))
				continue;

			if ($obLastStep !== null)
				$obLastStep->SetNextStep(BX_WIZARD_INSTALL_SERVICE_ID.$number);

			$step = new CPackageInstallService($this, $service);
			$wizard->AddStep($step, BX_WIZARD_INSTALL_SERVICE_ID.$number);
			$this->__SetStepDescription($step, "INSTALL_SERVICE");

			if ($this->_InitSubStep("install", $this->arServices[$service]))
			{
				//$this->__obLastStep->SetNextStep("__finish");
				$this->_SetNextStep($this->__obLastStep, BX_WIZARD_INSTALL_SERVICE_ID, "install");
				$obLastStep = $this->__obLastStep;
				$step->SetNextStep($this->__obFirstStep->GetStepID());
			}
			else
			{
				$obLastStep = $step;
				//$step->SetNextStep("__finish");
				$this->_SetNextStep($step, BX_WIZARD_INSTALL_SERVICE_ID, "install");
			}

			(int)$number++;
		}
	}

	//Structure installation step
	if ($this->structureSelected)
	{
		$step = new CPackageInstallStructure($structureID);
		$wizard->AddStep($step, BX_WIZARD_INSTALL_STRUCTURE_ID);
		$this->_SetNextStep($step, BX_WIZARD_INSTALL_STRUCTURE_ID, "install");
		$this->__SetStepDescription($step, "INSTALL_STRUCTURE");

		//#NEW
		if ($this->_InitSubStep("install", $this->arStructure["SETTINGS"]))
		{
			$this->_SetNextStep($this->__obLastStep, BX_WIZARD_INSTALL_STRUCTURE_ID, "install");
			$step->SetNextStep($this->__obFirstStep->GetStepID());
		}
	}

	//Finish step
	$isUserStep = false;
	if ($this->__GetUserStep("finish", $userFinish))
	{
		$step = $userFinish;
		$isUserStep = true;
	}
	else
		$step = new CPackageFinish($this);

	$wizard->AddStep($step, BX_WIZARD_FINISH_ID);
	$this->__SetStepDescription($step, "FINISH");

	if (!$isUserStep)
		$step->SetCancelStep(BX_WIZARD_FINISH_ID);

	//#NEW
	if ($this->_InitSubStep("end", $this->arDescription["STEPS_SETTINGS"]["FINISH"]) )
	{
		$this->__obFirstStep->SetPrevStep(BX_WIZARD_FINISH_ID);
		$step->SetNextStep($this->__obFirstStep->GetStepID());
	}

	//Cancel step
	$isUserStep = false;
	if ($this->__GetUserStep("cancel", $userCancel))
	{
		$isUserStep = true;
		$step = $userCancel;
	}
	else
		$step = new CPackageCancel($this);

	$wizard->AddStep($step, BX_WIZARD_CANCEL_ID);
	$this->__SetStepDescription($step, "CANCEL");

	if (!$isUserStep)
		$step->SetCancelStep(BX_WIZARD_CANCEL_ID);

	//#NEW
	if ($this->_InitSubStep("end", $this->arDescription["STEPS_SETTINGS"]["CANCEL"]) )
	{
		$this->__obFirstStep->SetPrevStep(BX_WIZARD_CANCEL_ID);
		$step->SetNextStep($this->__obFirstStep->GetStepID());
	}

	$wizard->Display();
}