/// <summary> /// Assign the culture that is set as default content culture to the current site. /// </summary> private void HandleReAssigningCulture() { if (RequestHelper.IsPostBack()) { string arg = ValidationHelper.GetString(Control.Page.Request[Page.postEventArgumentID], String.Empty); if (arg.EqualsCSafe(ASSIGN_ARGUMENT_NAME)) { string culture = CultureHelper.GetDefaultCultureCode(siteInfo.SiteName); // Only default content culture is allowed to be assigned to the site in case there is no multilingual license CultureSiteInfoProvider.RemoveSiteCultures(siteInfo.SiteName); CultureSiteInfoProvider.AddCultureToSite(culture, siteInfo.SiteName); // Get info object of the default content culture to set value of the UniSelector CultureInfo ci = CultureInfoProvider.GetCultureInfoForCulture(culture); if (ci != null) { Control.Value = Convert.ToString(ci.CultureID); reloadData = true; } Control.ShowChangesSaved(); } } }
/// <summary> /// OkClick Handler. /// </summary> protected void btnOk_Click(object sender, EventArgs e) { string culture = ValidationHelper.GetString(cultureSelector.Value, ""); if ((culture != "") && ((currentCulture.ToLowerCSafe() != culture.ToLowerCSafe()) || chkDocuments.Checked)) { // Set new culture SiteInfo si = SiteInfo.Provider.Get(siteId); if (si != null) { try { // Set default culture and change current culture label SettingsKeyInfoProvider.SetValue("CMSDefaultCultureCode", si.SiteName, culture.Trim()); if (PageRoutingHelper.HideLanguagePrefixForDefaultCultureUrl(si.SiteName)) { new PageUrlPathCultureFormatChanger(siteId).ChangeForCulture(currentCulture, PageRoutingUrlCultureFormatEnum.LanguagePrefix); new PageUrlPathCultureFormatChanger(siteId).ChangeForCulture(culture, PageRoutingUrlCultureFormatEnum.DomainDriven); } // Change culture of documents if (chkDocuments.Checked) { // Change culture of the documents TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); tree.ChangeCulture(si.SiteName, currentCulture, culture); } if (!LicenseHelper.CheckFeature(RequestContext.CurrentDomain, FeatureEnum.Multilingual)) { // If not multilingual, remove all cultures from the site and assign new culture CultureSiteInfoProvider.RemoveSiteCultures(si.SiteName); CultureSiteInfoProvider.AddCultureToSite(culture, si.SiteName); } ltlScript.Text = ScriptHelper.GetScript("wopener.ChangeCulture('" + chkDocuments.Checked + "'); CloseDialog();"); } catch (Exception ex) { LogAndShowError("Sites", "ChangeDefaultCulture", ex); } } } else { ltlScript.Text = ScriptHelper.GetScript("CloseDialog();"); } }