示例#1
0
 function OnPostForm()
 {
     $wizard =& $this->GetWizard();
     $serviceID = $wizard->GetVar("nextStep");
     $serviceStage = $wizard->GetVar("nextStepStage");
     if ($serviceID == "finish") {
         $wizard->SetCurrentStep("finish");
         return;
     }
     $defSiteName = GetMessage("wiz_site_default_name");
     if (GetMessage("wiz_site_name") != "") {
         $defSiteName = GetMessage("wiz_site_name");
     } elseif ($wizard->wizardName != "") {
         $defSiteName = $wizard->wizardName;
     }
     $res = false;
     $site_id = $wizard->GetVar("siteID");
     if ($site_id != "") {
         $db_res = CSite::GetList($by = "sort", $order = "desc", array("LID" => $site_id));
         if ($db_res) {
             $res = $db_res->Fetch();
         }
     }
     if ($wizard->GetVar("siteCreate") == "Y") {
         if (!$res) {
             $arFields = array("LID" => $site_id, "ACTIVE" => "Y", "SORT" => 100, "DEF" => "N", "NAME" => $defSiteName, "DIR" => $wizard->GetVar("siteFolder"), "FORMAT_DATE" => LANGUAGE_ID == "en" ? "MM/DD/YYYY" : "DD.MM.YYYY", "FORMAT_DATETIME" => LANGUAGE_ID == "en" ? "MM/DD/YYYY H:MI T" : "DD.MM.YYYY HH:MI:SS", "FORMAT_NAME" => CSite::GetDefaultNameFormat(), "CHARSET" => defined("BX_UTF") ? "UTF-8" : (LANGUAGE_ID == "ru" ? "windows-1251" : "ISO-8859-1"), "SITE_NAME" => $defSiteName, "SERVER_NAME" => $_SERVER["SERVER_NAME"], "EMAIL" => COption::GetOptionString("main", "email_from"), "LANGUAGE_ID" => LANGUAGE_ID, "DOC_ROOT" => "");
             $obSite = new CSite();
             $result = $obSite->Add($arFields);
             if ($result) {
             } else {
                 echo $obSite->LAST_ERROR;
                 die;
             }
         }
         $wizard->SetVar("siteCreate", "N");
     }
     $pattern = '/^(.*):(.*)\\((.*)\\)/';
     preg_match($pattern, $res["NAME"], $matches);
     if ($res && (count($matches) > 0 || $res["NAME"] == $site_id) && $site_id != "s1") {
         $templateID = $wizard->GetVar("templateID");
         $themeVarName = $templateID . "_themeID";
         $themeID = $wizard->GetVar($themeVarName);
         $templatesPath = WizardServices::GetTemplatesPath($wizard->GetPath() . "/site");
         $arTemplates = WizardServices::GetTemplates($templatesPath);
         $templatesPath = WizardServices::GetTemplatesPath($wizard->GetPath() . "/site");
         $arThemes = WizardServices::GetThemes($templatesPath . "/" . $templateID . "/themes", $templatesPath . "/" . $templateID);
         $siteNemNew = $defSiteName . ": " . $arTemplates[$templateID]["NAME"] . ' (' . $arThemes[$themeID]["NAME"] . ')';
         $obSite = new CSite();
         $result = $obSite->Update($site_id, array("NAME" => $siteNemNew, "SITE_NAME" => $siteNemNew));
     } elseif ($res["NAME"] == GetMessage("MAIN_DEFAULT_SITE_NAME")) {
         $SiteNAME = $defSiteName . " (" . GetMessage("MAIN_DEFAULT_SITE_NAME") . ")";
         $obSite = new CSite();
         $result = $obSite->Update($site_id, array("NAME" => $SiteNAME, "SITE_NAME" => $defSiteName));
     }
     CModule::IncludeModule('fileman');
     COption::SetOptionString("fileman", "different_set", "Y");
     $arMenuTypes = GetMenuTypes($site_id);
     if (count($arMenuTypes) == 0) {
         $arMenuTypes = array('left' => GetMessage("WIZ_MENU_LEFT"), 'top' => GetMessage("WIZ_MENU_TOP"), 'bottom' => GetMessage("WIZ_MENU_BOTTOM"));
     } else {
         if (!$arMenuTypes['left'] || $arMenuTypes['left'] == GetMessage("WIZ_MENU_LEFT_DEFAULT")) {
             $arMenuTypes['left'] = GetMessage("WIZ_MENU_LEFT");
         }
         if (!$arMenuTypes['top'] || $arMenuTypes['top'] == GetMessage("WIZ_MENU_TOP_DEFAULT")) {
             $arMenuTypes['top'] = GetMessage("WIZ_MENU_TOP");
         }
         if (!$arMenuTypes['bottom']) {
             $arMenuTypes['bottom'] = GetMessage("WIZ_MENU_BOTTOM");
         }
     }
     SetMenuTypes($arMenuTypes, $site_id);
     $arServices = WizardServices::GetServices($_SERVER["DOCUMENT_ROOT"] . $wizard->GetPath(), "/site/services/");
     $this->CorrectServices($arServices);
     if ($serviceStage == "skip") {
         $success = true;
     } else {
         $success = $this->InstallService($serviceID, $serviceStage);
     }
     if (!$this->repeatCurrentService) {
         list($nextService, $nextServiceStage, $stepsComplete, $status) = $this->GetNextStep($arServices, $serviceID, $serviceStage);
     }
     if ($nextService == "finish") {
         $formName = $wizard->GetFormName();
         $response = "window.ajaxForm.StopAjax(); window.ajaxForm.SetStatus('100'); window.ajaxForm.Post('" . $nextService . "', '" . $nextServiceStage . "','" . $status . "');";
         COption::SetOptionString("main", "wizard_first" . substr($wizard->GetID(), 7) . "_" . $wizard->GetVar("siteID"), "Y", false, $siteID);
     } else {
         $arServiceID = array_keys($arServices);
         $lastService = array_pop($arServiceID);
         $stepsCount = $arServices[$lastService]["POSITION"];
         if (array_key_exists("STAGES", $arServices[$lastService]) && is_array($arServices[$lastService])) {
             $stepsCount += count($arServices[$lastService]["STAGES"]) - 1;
         }
         $percent = round($stepsComplete / $stepsCount * 100);
         $response = "window.ajaxForm.SetStatus('" . $percent . "'); window.ajaxForm.Post('" . $nextService . "', '" . $nextServiceStage . "','" . $status . "');";
     }
     die("[response]" . $response . "[/response]");
 }
示例#2
0
    function ShowStep()
    {
        $wizard =& $this->GetWizard();
        $arServices = WizardServices::GetServices($_SERVER["DOCUMENT_ROOT"] . $wizard->GetPath(), "/site/services/");
        list($firstService, $stage, $status) = $this->GetFirstStep($arServices);
        /*$this->content .= '
        			<table border="0" cellspacing="0" cellpadding="2" width="100%">
        				<tr>
        					<td colspan="2"><div id="status"></div></td>
        				</tr>
        				<tr>
        					<td width="90%" height="10">
        						<div style="border:1px solid #B9CBDF; width:100%;"><div id="indicator" style="height:10px; width:0%; background-color:#B9CBDF"></div></div>
        					</td>
        					<td width="10%">&nbsp;<span id="percent">0%</span></td>
        				</tr>
        			</table>
        			<div id="wait" align=center>
        			<br />
        			<table width=200 cellspacing=0 cellpadding=0 border=0 style="border:1px solid #EFCB69" bgcolor="#FFF7D7">
        				<tr>
        					<td height=50 width="50" valign="middle" align=center><img src="'.$wizard->GetPath().'/images/wait.gif"></td>
        					<td height=50 width=150>'.GetMessage("WIZARD_WAIT_WINDOW_TEXT").'</td>
        				</tr>
        			</table>
        		</div><br />
        			<br />
        			<div id="error_container" style="display:none">
        				<div id="error_notice"><span style="color:red;">'.GetMessage("INST_ERROR_OCCURED").'<br />'.GetMessage("INST_TEXT_ERROR").':</span></div>
        				<div id="error_text"></div>
        				<div><span style="color:red;">'.GetMessage("INST_ERROR_NOTICE").'</span></div>
        				<div id="error_buttons" align="center">
        				<br /><input type="button" value="'.GetMessage("INST_RETRY_BUTTON").'" id="error_retry_button" onclick="" />&nbsp;<input type="button" id="error_skip_button" value="'.GetMessage("INST_SKIP_BUTTON").'" onclick="" />&nbsp;</div>
        			</div>
        
        		'.$this->ShowHiddenField("nextStep", $firstService).'
        		'.$this->ShowHiddenField("nextStepStage", $stage).'
        		<iframe style="display:none;" id="iframe-post-form" name="iframe-post-form" src="javascript:\'\'"></iframe>';*/
        $this->content .= '
		<div class="instal-load-block" id="result">
			<div class="instal-load-label" id="status"></div>
			<div class="instal-progress-bar-outer" style="width: 670px;">
				<div class="instal-progress-bar-alignment">
					<div class="instal-progress-bar-inner" id="indicator">
						<div class="instal-progress-bar-inner-text" style="width: 670px;" id="percent"></div>
					</div>
					<span id="percent2">0%</span>
				</div>
			</div>
		</div>
		<div id="error_container" style="display:none">
			<div id="error_notice">
				<div class="inst-note-block inst-note-block-red">
					<div class="inst-note-block-icon"></div>
					<div class="inst-note-block-label">' . GetMessage("INST_ERROR_OCCURED") . '</div><br />
					<div class="inst-note-block-text">' . GetMessage("INST_ERROR_NOTICE") . '<div id="error_text"></div></div>
				</div>
			</div>

			<div id="error_buttons" align="center">
			<br /><input type="button" value="' . GetMessage("INST_RETRY_BUTTON") . '" id="error_retry_button" onclick="" class="instal-btn instal-btn-inp" />&nbsp;<input type="button" id="error_skip_button" value="' . GetMessage("INST_SKIP_BUTTON") . '" onclick="" class="instal-btn instal-btn-inp" />&nbsp;</div>
		</div>

		' . $this->ShowHiddenField("nextStep", "main") . '
		' . $this->ShowHiddenField("nextStepStage", "database") . '
		<iframe style="display:none;" id="iframe-post-form" name="iframe-post-form" src="javascript:\'\'"></iframe>
		';
        $wizard =& $this->GetWizard();
        $formName = $wizard->GetFormName();
        $NextStepVarName = $wizard->GetRealName("nextStep");
        $this->content .= '
		<script type="text/javascript">
			var ajaxForm = new CAjaxForm("' . $formName . '", "iframe-post-form", "' . $NextStepVarName . '");
			ajaxForm.Post("' . $firstService . '", "' . $stage . '", "' . $status . '");
		</script>';
    }