Esempio n. 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) {
             $culture = CultureTable::getRow(array('filter' => array("=FORMAT_DATE" => LANGUAGE_ID == "en" ? "MM/DD/YYYY" : "DD.MM.YYYY", "=FORMAT_DATETIME" => LANGUAGE_ID == "en" ? "MM/DD/YYYY H:MI:SS 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"))));
             if ($culture) {
                 $cultureId = $culture["ID"];
             } else {
                 $addResult = CultureTable::add(array("NAME" => $site_id, "CODE" => $site_id, "FORMAT_DATE" => LANGUAGE_ID == "en" ? "MM/DD/YYYY" : "DD.MM.YYYY", "FORMAT_DATETIME" => LANGUAGE_ID == "en" ? "MM/DD/YYYY H:MI:SS 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")));
                 $cultureId = $addResult->getId();
             }
             $arFields = array("LID" => $site_id, "ACTIVE" => "Y", "SORT" => 100, "DEF" => "N", "NAME" => $defSiteName, "DIR" => $wizard->GetVar("siteFolder"), "SITE_NAME" => $defSiteName, "SERVER_NAME" => $_SERVER["SERVER_NAME"], "EMAIL" => COption::GetOptionString("main", "email_from"), "LANGUAGE_ID" => LANGUAGE_ID, "DOC_ROOT" => "", "CULTURE_ID" => $cultureId);
             $obSite = new CSite();
             $result = $obSite->Add($arFields);
             if (!$result) {
                 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();
         $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();
         $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") {
         $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);
     } 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]");
 }
Esempio n. 2
0
 function InstallService($serviceID, $serviceStage)
 {
     $wizard =& $this->GetWizard();
     $siteID = WizardServices::GetCurrentSiteID($wizard->GetVar("siteID"));
     define("WIZARD_SITE_ID", $siteID);
     define("WIZARD_SITE_ROOT_PATH", $_SERVER["DOCUMENT_ROOT"]);
     $rsSites = CSite::GetByID($siteID);
     if ($arSite = $rsSites->Fetch()) {
         define("WIZARD_SITE_DIR", $arSite["DIR"]);
     } else {
         define("WIZARD_SITE_DIR", "/");
     }
     define("WIZARD_SITE_PATH", str_replace("//", "/", WIZARD_SITE_ROOT_PATH . "/" . WIZARD_SITE_DIR . "/"));
     $wizardPath = $wizard->GetPath();
     define("WIZARD_RELATIVE_PATH", $wizardPath);
     define("WIZARD_ABSOLUTE_PATH", $_SERVER["DOCUMENT_ROOT"] . $wizardPath);
     $templatesPath = WizardServices::GetTemplatesPath(WIZARD_RELATIVE_PATH . "/site");
     $arTemplates = WizardServices::GetTemplates($templatesPath);
     $templateID = $wizard->GetVar("templateID");
     define("WIZARD_TEMPLATE_ID", $templateID);
     define("WIZARD_TEMPLATE_RELATIVE_PATH", $templatesPath . "/" . WIZARD_TEMPLATE_ID);
     define("WIZARD_TEMPLATE_ABSOLUTE_PATH", $_SERVER["DOCUMENT_ROOT"] . WIZARD_TEMPLATE_RELATIVE_PATH);
     $themeID = $wizard->GetVar($templateID . "_themeID");
     $arThemes = WizardServices::GetThemes(WIZARD_TEMPLATE_RELATIVE_PATH . "/themes");
     define("WIZARD_THEME_ID", $themeID);
     define("WIZARD_THEME_RELATIVE_PATH", WIZARD_TEMPLATE_RELATIVE_PATH . "/themes/" . WIZARD_THEME_ID);
     define("WIZARD_THEME_ABSOLUTE_PATH", $_SERVER["DOCUMENT_ROOT"] . WIZARD_THEME_RELATIVE_PATH);
     $servicePath = WIZARD_RELATIVE_PATH . "/site/services/" . $serviceID;
     define("WIZARD_SERVICE_RELATIVE_PATH", $servicePath);
     define("WIZARD_SERVICE_ABSOLUTE_PATH", $_SERVER["DOCUMENT_ROOT"] . $servicePath);
     define("WIZARD_IS_RERUN", $_SERVER["PHP_SELF"] != "/index.php");
     define("WIZARD_SITE_LOGO", intval($wizard->GetVar("siteLogo")));
     define("WIZARD_INSTALL_DEMO_DATA", $wizard->GetVar("installDemoData") == "Y");
     define("WIZARD_REINSTALL_DATA", false);
     define("WIZARD_FIRST_INSTAL", $firstStep = COption::GetOptionString("main", "wizard_first" . substr($wizard->GetID(), 7) . "_" . $wizard->GetVar("siteID"), false, $wizard->GetVar("siteID")));
     $dbUsers = CGroup::GetList($by = "id", $order = "asc", array("ACTIVE" => "Y"));
     while ($arUser = $dbUsers->Fetch()) {
         define("WIZARD_" . $arUser["STRING_ID"] . "_GROUP", $arUser["ID"]);
     }
     if (!file_exists(WIZARD_SERVICE_ABSOLUTE_PATH . "/" . $serviceStage)) {
         return false;
     }
     if (LANGUAGE_ID != "en" && LANGUAGE_ID != "ru") {
         if (file_exists($fname = WIZARD_SERVICE_ABSOLUTE_PATH . "/lang/" . LangSubst(LANGUAGE_ID) . "/" . $serviceStage)) {
             __IncludeLang($fname, false, true);
         }
     }
     if (file_exists($fname = WIZARD_SERVICE_ABSOLUTE_PATH . "/lang/" . LANGUAGE_ID . "/" . $serviceStage)) {
         __IncludeLang($fname, false, true);
     }
     @set_time_limit(3600);
     global $DB, $DBType, $APPLICATION, $USER, $CACHE_MANAGER;
     include WIZARD_SERVICE_ABSOLUTE_PATH . "/" . $serviceStage;
 }
Esempio n. 3
0
    function ShowStep()
    {
        $wizard =& $this->GetWizard();
        $templateID = $wizard->GetVar("templateID");
        $templatesPath = WizardServices::GetTemplatesPath("/bitrix/modules/intranet/install");
        $arThemes = WizardServices::GetThemes($templatesPath . "/" . $templateID . "/themes", $wizard->GetPath(), $templateID);
        if (empty($arThemes)) {
            return;
        }
        $themeVarName = $templateID . "_themeID";
        $defaultThemeID = COption::GetOptionString("main", "wizard_" . $templateID . "_theme_id", "", $wizard->GetVar("siteID"));
        if (strlen($defaultThemeID) > 0 && array_key_exists($defaultThemeID, $arThemes)) {
            $wizard->SetDefaultVar($themeVarName, $defaultThemeID);
        } else {
            $defaultThemeID = "";
        }
        global $SHOWIMAGEFIRST;
        $SHOWIMAGEFIRST = true;
        $this->content .= '<table width="100%" cellspacing="4" cellpadding="8">';
        foreach ($arThemes as $themeID => $arTheme) {
            if ($defaultThemeID == "") {
                $defaultThemeID = $themeID;
                $wizard->SetDefaultVar($themeVarName, $defaultThemeID);
            }
            $this->content .= "<tr>";
            $this->content .= "<td width=\"25\">" . $this->ShowRadioField($themeVarName, $themeID, array("id" => $themeVarName . "_" . $themeID)) . "</td>";
            global $SHOWIMAGEFIRST;
            $SHOWIMAGEFIRST = true;
            if ($arTheme["SCREENSHOT"] && $arTheme["PREVIEW"]) {
                $this->content .= '<td valign="top" width="160">' . CFile::Show2Images($arTheme["PREVIEW"], $arTheme["SCREENSHOT"], 150, 150, ' border="0"') . "</td>";
            } else {
                $this->content .= '<td valign="top" width="160">' . CFile::ShowImage($arTheme["SCREENSHOT"], 150, 150, ' border="0"', "", true) . "</td>";
            }
            $this->content .= '<td valign="top"><label for="' . $themeVarName . "_" . $themeID . '"><b>' . $arTheme["NAME"] . "</b><p>" . $arTheme["DESCRIPTION"] . "</p></label></td>";
            $this->content .= "</tr>";
            $this->content .= "<tr><td><br /></td></tr>";
        }
        $this->content .= "</table>";
        $this->content .= '<script>
			function ImgShw(ID, width, height, alt)
			{
				var scroll = "no";
				var top=0, left=0;
				if(width > screen.width-10 || height > screen.height-28) scroll = "yes";
				if(height < screen.height-28) top = Math.floor((screen.height - height)/2-14);
				if(width < screen.width-10) left = Math.floor((screen.width - width)/2-5);
				width = Math.min(width, screen.width-10);
				height = Math.min(height, screen.height-28);
				var wnd = window.open("","","scrollbars="+scroll+",resizable=yes,width="+width+",height="+height+",left="+left+",top="+top);
				wnd.document.write(
					"<html><head>"+
						"<"+"script type=\\"text/javascript\\">"+
						"function KeyPress()"+
						"{"+
						"	if(window.event.keyCode == 27) "+
						"		window.close();"+
						"}"+
						"</"+"script>"+
						"<title></title></head>"+
						"<body topmargin=\\"0\\" leftmargin=\\"0\\" marginwidth=\\"0\\" marginheight=\\"0\\" onKeyPress=\\"KeyPress()\\">"+
						"<img src=\\""+ID+"\\" border=\\"0\\" alt=\\""+alt+"\\" />"+
						"</body></html>"
				);
				wnd.document.close();
			}
		</script>';
    }