/// <summary>
    /// Removes all cultures from sites and assignes back default site culture.
    /// </summary>
    protected void AssignDefaultCulture(object sender, EventArgs e)
    {
        string culture = CultureHelper.GetDefaultCulture(si.SiteName);

        CultureInfoProvider.RemoveSiteCultures(si.SiteName);
        CultureInfoProvider.AddCultureToSite(culture, si.SiteName);
        lnkAssignDefault.Visible = false;
        ShowChangesSaved();
    }
Пример #2
0
 /// <summary>
 /// Removes all cultures from sites and assignes back default site culture.
 /// </summary>
 protected void AssignDefaultCulture(object sender, EventArgs e)
 {
     string culture = CultureHelper.GetDefaultCulture(si.SiteName);
     CultureInfoProvider.RemoveSiteCultures(si.SiteName);
     CultureInfoProvider.AddCultureToSite(culture, si.SiteName);
     lnkAssignDefault.Visible = false;
     lblInfo.Text = GetString("general.ok");
     lblInfo.Visible = true;
 }
Пример #3
0
    /// <summary>
    /// OkClick Handler.
    /// </summary>
    protected void btnOk_Click(object sender, EventArgs e)
    {
        string culture = ValidationHelper.GetString(cultureSelector.Value, "");

        if ((culture != "") && ((currentCulture.ToLower() != culture.ToLower()) || chkDocuments.Checked))
        {
            // Set new culture
            SiteInfo si = SiteInfoProvider.GetSiteInfo(siteId);
            if (si != null)
            {
                try
                {
                    // Set default culture and change current culture label
                    ObjectHelper.SetSettingsKeyValue(si.SiteName + ".CMSDefaultCultureCode", culture.Trim());

                    // Change culture of documents
                    if (chkDocuments.Checked)
                    {
                        // Change culture of the documents
                        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);
                        tree.ChangeCulture(si.SiteName, currentCulture, culture);
                    }

                    if (!LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.Multilingual))
                    {
                        // If not multilingual, remove all cultures from the site and assign new culture
                        CultureInfoProvider.RemoveSiteCultures(si.SiteName);
                        CultureInfoProvider.AddCultureToSite(culture, si.SiteName);
                    }

                    ltlScript.Text = ScriptHelper.GetScript("wopener.ChangeCulture('" + chkDocuments.Checked.ToString() + "'); window.close();");
                }
                catch (Exception ex)
                {
                    EventLogProvider ev = new EventLogProvider();
                    ev.LogEvent("SiteManager", "ChangeDefaultCulture", ex);
                }
            }
        }
        else
        {
            ltlScript.Text = ScriptHelper.GetScript("window.close();");
        }
    }
Пример #4
0
    protected void SaveSites()
    {
        // Remove old items
        string newValues        = ValidationHelper.GetString(usSites.Value, null);
        string items            = DataHelper.GetNewItemsInList(newValues, currentValues);
        bool   somethingChanged = false;
        bool   hasErrors        = false;

        if (!string.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items to site
                foreach (string item in newItems)
                {
                    int siteId = ValidationHelper.GetInteger(item, 0);

                    SiteInfo    si = SiteInfoProvider.GetSiteInfo(siteId);
                    CultureInfo ci = CultureInfoProvider.GetCultureInfo(culture.CultureID);
                    if ((si != null) && (ci != null))
                    {
                        // Check if site does not contain document from this culture
                        TreeProvider tree  = new TreeProvider(CMSContext.CurrentUser);
                        DataSet      nodes = tree.SelectNodes(si.SiteName, "/%", ci.CultureCode, false, null, null, null, -1, false, 1, "NodeID");
                        if (DataHelper.DataSourceIsEmpty(nodes))
                        {
                            CultureInfoProvider.RemoveCultureFromSite(culture.CultureID, siteId);
                            somethingChanged = true;
                        }
                        else
                        {
                            hasErrors = true;
                            ShowError(string.Format(GetString("Culture_Edit_Sites.ErrorRemoveSiteFromCulture"), si.DisplayName));
                            continue;
                        }
                    }
                }
            }
        }

        // Add new items
        items = DataHelper.GetNewItemsInList(currentValues, newValues);
        if (!string.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items to site
                foreach (string item in newItems)
                {
                    int siteId = ValidationHelper.GetInteger(item, 0);

                    // Add cullture to site
                    SiteInfo si = SiteInfoProvider.GetSiteInfo(siteId);
                    if (si != null)
                    {
                        if (CultureInfoProvider.LicenseVersionCheck(si.DomainName, FeatureEnum.Multilingual, VersionActionEnum.Insert))
                        {
                            CultureInfoProvider.AddCultureToSite(culture.CultureID, siteId);
                            somethingChanged = true;
                        }
                        else
                        {
                            hasErrors = true;
                            ShowError(GetString("licenselimitation.siteculturesexceeded"));
                            break;
                        }
                    }
                }
            }
        }

        // If there were some errors, reload uniselector
        if (hasErrors)
        {
            usSites.Value = GetCultureSites();
            usSites.Reload(true);
        }

        if (somethingChanged)
        {
            ShowInformation(GetString("General.ChangesSaved"));
        }
    }
    protected void uniSelector_OnSelectionChanged(object sender, EventArgs e)
    {
        bool relaodNeeded = false;

        // Remove old items
        string newValues = ValidationHelper.GetString(uniSelector.Value, null);
        string items     = DataHelper.GetNewItemsInList(newValues, currentValues);

        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Initialize tree provider
                TreeProvider tree = new TreeProvider();

                // Add all new items to site
                foreach (string item in newItems)
                {
                    string cultureCode = ValidationHelper.GetString(item, "");

                    // Get the documents assigned to the culture being removed
                    DataSet nodes = tree.SelectNodes(siteName, "/%", cultureCode, false, null, null, null, -1, false);
                    if (DataHelper.DataSourceIsEmpty(nodes))
                    {
                        CultureInfoProvider.RemoveCultureFromSite(cultureCode, siteName);

                        ShowChangesSaved();
                    }
                    else
                    {
                        relaodNeeded = true;

                        AddError(String.Format(GetString("site_edit_cultures.errorremoveculturefromsite"), cultureCode) + '\n', null);
                    }
                }
            }
        }

        // Catch license limitations Exception
        try
        {
            // Add new items
            items = DataHelper.GetNewItemsInList(currentValues, newValues);
            if (!String.IsNullOrEmpty(items))
            {
                string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                if (newItems != null)
                {
                    // Add all new items to site
                    foreach (string item in newItems)
                    {
                        string cultureCode = ValidationHelper.GetString(item, "");
                        CultureInfoProvider.AddCultureToSite(cultureCode, siteName);
                    }
                }

                ShowChangesSaved();
            }
        }
        catch (Exception ex)
        {
            relaodNeeded = true;
            ShowError(ex.Message);
        }

        if (relaodNeeded)
        {
            // Get the active cultures from DB
            DataSet ds = CultureInfoProvider.GetCultures("CultureID IN (SELECT CultureID FROM CMS_SiteCulture WHERE SiteID = " + si.SiteID + ")", null, 0, "CultureCode");
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                currentValues     = TextHelper.Join(";", SystemDataHelper.GetStringValues(ds.Tables[0], "CultureCode"));
                uniSelector.Value = currentValues;
                uniSelector.Reload(true);
            }
        }
    }