/// <summary>
    /// Returns DataSet according to filter settings.
    /// </summary>
    private DataSet GetCultures()
    {
        string filterText         = SqlHelper.EscapeLikeText(SqlHelper.EscapeQuotes(txtFilter.Text.Trim()));
        string sqlSafeCultureCode = SqlHelper.EscapeQuotes(selectedCultureCode);
        string columns            = "CultureName, CultureCode";

        string where = null;
        string orderBy = String.Format(@"CASE WHEN CultureCode = '{0}' THEN 1 WHEN CultureCode = '{1}' THEN 2 ELSE 3 END, CultureName",
                                       CultureHelper.DefaultUICultureCode, sqlSafeCultureCode);

        switch (rbCultures.SelectedValue)
        {
        case "allcultures":
            where = String.Format("CultureCode = '{0}' OR CultureCode = '{1}' OR CultureName LIKE '%{2}%'",
                                  CultureHelper.DefaultUICultureCode, sqlSafeCultureCode, filterText);
            break;

        case "uicultures":
            where = String.Format("CultureCode = '{0}' OR CultureCode = '{1}' OR (CultureIsUICulture = 1 AND CultureName LIKE '%{2}%')",
                                  CultureHelper.DefaultUICultureCode, sqlSafeCultureCode, filterText);
            break;

        case "sitecultures":
            where = String.Format("(CultureName LIKE '%{0}%' AND CultureID IN (SELECT CultureID FROM CMS_SiteCulture WHERE SiteID = {1})) OR CultureCode = '{2}'",
                                  filterText, SiteContext.CurrentSiteID, CultureHelper.DefaultUICultureCode);
            break;
        }

        return(CultureInfoProvider.GetCultures(where, orderBy, columns: columns));
    }
Esempio n. 2
0
    /// <summary>
    /// Gets and bulk updates cultures. Called when the "Get and bulk update cultures" button is pressed.
    /// Expects the CreateCulture method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateCultures()
    {
        // Prepare the parameters
        string where = "CultureCode LIKE N'MyNewCulture%'";

        // Get the data
        DataSet cultures = CultureInfoProvider.GetCultures(where, null);

        if (!DataHelper.DataSourceIsEmpty(cultures))
        {
            // Loop through the individual items
            foreach (DataRow cultureDr in cultures.Tables[0].Rows)
            {
                // Create object from DataRow
                CultureInfo modifyCulture = new CultureInfo(cultureDr);

                // Update the properties
                modifyCulture.CultureName = modifyCulture.CultureName.ToUpper();

                // Update the culture
                CultureInfoProvider.SetCultureInfo(modifyCulture);
            }

            return(true);
        }

        return(false);
    }
 /// <summary>
 /// Returns list of current culture identifiers.
 /// </summary>
 private IList <int> GetCurrentCultureIds()
 {
     return(CultureInfoProvider.GetCultures()
            .Column("CultureID")
            .WhereIn("CultureID", CultureSiteInfoProvider.GetCultureSites()
                     .Column("CultureID")
                     .WhereEquals("SiteID", siteInfo.SiteID))
            .GetListResult <int>());
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get the site info
        si = SiteInfoProvider.GetSiteInfo(QueryHelper.GetInteger("siteId", 0));
        if (si != null)
        {
            bool multilingual  = LicenseHelper.CheckFeature(URLHelper.GetDomainName(si.DomainName), FeatureEnum.Multilingual);
            bool cultureOnSite = CultureInfoProvider.IsCultureOnSite(CultureHelper.GetDefaultCulture(si.SiteName), si.SiteName);
            if (!multilingual && !cultureOnSite)
            {
                lnkAssignDefault.Text    = GetString("sitecultures.assigntodefault");
                lnkAssignDefault.Visible = true;
                plcAll.Visible           = false;
            }
            else
            {
                // Redirect only if cultures not exceeded => to be able to unassign
                if (!CultureInfoProvider.LicenseVersionCheck(si.DomainName, FeatureEnum.Multilingual, VersionActionEnum.Edit))
                {
                    LicenseHelper.CheckFeatureAndRedirect(URLHelper.GetDomainName(si.DomainName), FeatureEnum.Multilingual);
                }
            }

            lblAvialable.Text = GetString("site_edit_cultures.culturetitle");


            siteName = si.SiteName;

            // Store default culture (it can't be removed)
            defaultCulture = CultureHelper.GetDefaultCulture(siteName);

            // 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"));
            }

            if (!RequestHelper.IsPostBack())
            {
                uniSelector.Value = currentValues;
            }
        }

        uniSelector.ReturnColumnName    = "CultureCode";
        uniSelector.OnSelectionChanged += uniSelector_OnSelectionChanged;
    }
Esempio n. 5
0
    /// <summary>
    /// Page load event handling.
    /// </summary>
    /// <param name="sender">Sender object</param>
    /// <param name="e">Event argument</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (siteInfo == null)
        {
            return;
        }

        HandleReAssigningCulture();

        Control.Visible = true;
        bool multilingual  = LicenseHelper.CheckFeature(URLHelper.GetDomainName(siteInfo.DomainName), FeatureEnum.Multilingual);
        bool cultureOnSite = CultureSiteInfoProvider.IsCultureOnSite(CultureHelper.GetDefaultCultureCode(siteInfo.SiteName), siteInfo.SiteName);

        if (!multilingual && !cultureOnSite)
        {
            Control.Visible = false;

            // Add link that assign the default content culture to the site
            LocalizedHyperlink linkButton = new LocalizedHyperlink()
            {
                ResourceString = "sitecultures.assigntodefault",
                NavigateUrl    = "javascript:" + ControlsHelper.GetPostBackEventReference(Control.Page, ASSIGN_ARGUMENT_NAME) + ";"
            };

            Control.Parent.Controls.Add(linkButton);
        }
        else
        {
            // Redirect only if cultures not exceeded => to be able to unassign
            if (!CultureSiteInfoProvider.LicenseVersionCheck(siteInfo.DomainName, FeatureEnum.Multilingual, ObjectActionEnum.Edit))
            {
                LicenseHelper.CheckFeatureAndRedirect(URLHelper.GetDomainName(siteInfo.DomainName), FeatureEnum.Multilingual);
            }
        }

        // Get the active cultures from DB
        DataSet ds = CultureInfoProvider.GetCultures("CultureID IN (SELECT CultureID FROM CMS_SiteCulture WHERE SiteID = " + siteInfo.SiteID + ")", null, 0, "CultureID");

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            currentValues = TextHelper.Join(";", DataHelper.GetStringValues(ds.Tables[0], "CultureID"));
        }
    }
Esempio n. 6
0
        public static void OverrideGetPageEvent(object sender, GetPageEventArgs args)
        {
            string cultureCode = args.Culture;

            //Occasionally the culture code may come out as full text such as English - United Kingdom, using this info we can fetch the culture code
            if (args.Culture.Length > 5)
            {
                cultureCode = CultureInfoProvider.GetCultures().Where(a => a.CultureName == args.Culture).First().CultureCode;
            }
            UpdateCacheItem <string>("CurrentRelUrl", args.RelativeUrl);
            UpdateCacheItem <string>("CultureCode", cultureCode);
            if (args.FoundPage == null)
            {
                try
                {
                    args.FoundPage = CacheHelper.Cache <TreeNode>(cs =>
                    {
                        //TODO: ADD Culture
                        DataTable PossibleUrlPatterns = GetPossibleUrls(args.RelativeUrl, cultureCode);
                        if (PossibleUrlPatterns.Rows.Count > 0)
                        {
                            var matchedUrl = GetUrlMatch(args.RelativeUrl, cultureCode, PossibleUrlPatterns);
                            if (matchedUrl == null || !matchedUrl.HasMatch)
                            {
                                return(null);
                            }
                            DocumentQuery Query = DocumentHelper.GetDocuments(matchedUrl.UrlBreakdown.KenticoData.ClassName).WhereEquals("NodeId", matchedUrl.UrlBreakdown.KenticoData.NodeId).CombineWithAnyCulture();

                            if (args.PreviewEnabled)
                            {
                                Query.LatestVersion(true).Published(false);
                            }
                            else
                            {
                                Query.PublishedVersion(true);
                            }

                            TreeNode page = Query.FirstOrDefault();

                            if (cs.Cached)
                            {
                                if (page != null)
                                {
                                    cs.CacheDependency = CacheHelper.GetCacheDependency(new string[] { $"{WildcardUrlInfo.OBJECT_TYPE}|all", "documentid|" + page.DocumentID });
                                }
                                else
                                {
                                    cs.CacheDependency = CacheHelper.GetCacheDependency(new string[] { $"{WildcardUrlInfo.OBJECT_TYPE}dynamicrouting.wildcards|all" });
                                }
                            }
                            return(page);
                        }
                        else
                        {
                            return(null);
                        }
                    }, new CacheSettings(args.PreviewEnabled ? 0 : 1440, "DynamicRouting.GetPage", args.RelativeUrl, cultureCode, args.DefaultCulture, args.SiteName, args.PreviewEnabled, args.ColumnsVal));
                }
                catch (Exception ex)
                {
                    args.ExceptionOnLookup = ex;
                }
                if (args.FoundPage == null)
                {
                    HttpContext.Current.Response.StatusCode = 404;
                }
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!RequestHelper.IsPostBack())
        {
            string preferredCultureCode = CMSContext.PreferredCultureCode;
            string currentSiteName      = CMSContext.CurrentSiteName;
            string where = "CultureCode IN (SELECT DocumentCulture FROM View_CMS_Tree_Joined WHERE NodeID = " + Node.NodeID + ")";
            DataSet documentCultures = CultureInfoProvider.GetCultures(where, null, 0, "CultureCode");

            // Get site cultures
            DataSet siteCultures = CultureInfoProvider.GetSiteCultures(currentSiteName);
            if (!DataHelper.DataSourceIsEmpty(siteCultures) && !DataHelper.DataSourceIsEmpty(documentCultures))
            {
                string suffixNotTranslated = GetString("SplitMode.NotTranslated");

                foreach (DataRow row in siteCultures.Tables[0].Rows)
                {
                    string cultureCode = ValidationHelper.GetString(row["CultureCode"], null);
                    string cultureName = ResHelper.LocalizeString(ValidationHelper.GetString(row["CultureName"], null));

                    string suffix = string.Empty;

                    // Compare with preferred culture
                    if (CMSString.Compare(preferredCultureCode, cultureCode, true) == 0)
                    {
                        suffix = GetString("SplitMode.Current");
                    }
                    else
                    {
                        // Find culture
                        DataRow[] findRows = documentCultures.Tables[0].Select("CultureCode = '" + cultureCode + "'");
                        if (findRows.Length == 0)
                        {
                            suffix = suffixNotTranslated;
                        }
                    }

                    // Add new item
                    ListItem item = new ListItem(cultureName + " " + suffix, cultureCode);
                    drpCultures.Items.Add(item);
                }
            }

            drpCultures.SelectedValue = CMSContext.SplitModeCultureCode;
            drpCultures.Attributes.Add("onchange", "if (parent.CheckChanges('frame2')) { parent.FSP_ChangeCulture(this); }");
        }

        // Image URL and tooltip
        helpElem.IconUrl       = GetImageUrl("Design/Controls/SplitView/splitviewhelpicon.png");
        imgHorizontal.ImageUrl = UIHelper.GetImageUrl(Page, HorizontalImageUrl);
        imgVertical.ImageUrl   = UIHelper.GetImageUrl(Page, VerticalImageUrl);
        imgClose.ImageUrl      = UIHelper.GetImageUrl(Page, CloseImageUrl);
        imgHorizontal.ToolTip  = GetString("splitmode.horizontallayout");
        imgVertical.ToolTip    = GetString("splitmode.verticallayout");
        imgClose.ToolTip       = GetString("splitmode.closesplitmode");

        // Set css class
        switch (CMSContext.SplitMode)
        {
        case SplitModeEnum.Horizontal:
            divHorizontal.Attributes["class"] = buttonSelectedClass;
            divVertical.Attributes["class"]   = buttonClass;
            break;

        case SplitModeEnum.Vertical:
            divHorizontal.Attributes["class"] = buttonClass;
            divVertical.Attributes["class"]   = buttonSelectedClass;
            break;

        default:
            divHorizontal.Attributes["class"] = buttonClass;
            divVertical.Attributes["class"]   = buttonClass;
            break;
        }

        string checkedSyncUrl   = UIHelper.GetImageUrl(Page, mSyncCheckedImageUrl);
        string uncheckedSyncUrl = UIHelper.GetImageUrl(Page, mSyncUncheckedImageUrl);

        // Synchronize image
        string tooltip = GetString("splitmode.scrollbarsynchronization");

        imgSync.AlternateText = tooltip;
        imgSync.ToolTip       = tooltip;
        imgSync.ImageUrl      = CMSContext.SplitModeSyncScrollbars ? checkedSyncUrl : uncheckedSyncUrl;

        StringBuilder script = new StringBuilder();

        script.Append(@"
function FSP_Layout(vertical, frameName, cssClassName)
{
    if ((frameName != null) && parent.CheckChanges(frameName)) {
        if (cssClassName != null) {
            var element = document.getElementById('", pnlMain.ClientID, @"');
            if (element != null) {
                element.setAttribute(""class"", 'SplitToolbar ' + cssClassName);
                element.setAttribute(""className"", 'SplitToolbar ' + cssClassName);
            }
        }
        var divRight = document.getElementById('", divRight.ClientID, @"');
        if (vertical) {
            divRight.setAttribute(""class"", 'RightAlign');
            parent.FSP_VerticalLayout();
        }
        else {
            divRight.setAttribute(""class"", '');
            parent.FSP_HorizontalLayout();
        }
    }
}");

        script.Append(@"
function FSP_Close() { if (parent.CheckChanges()) { parent.FSP_CloseSplitMode(); } }"
                      );

        ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "toolbarScript_" + ClientID, ScriptHelper.GetScript(script.ToString()));

        // Register js events
        imgHorizontal.Attributes.Add("onclick", "javascript:FSP_Layout(false,'frame1Vertical','Horizontal');");
        imgHorizontal.AlternateText = GetString("SplitMode.Horizontal");
        imgVertical.Attributes.Add("onclick", "javascript:FSP_Layout('true','frame1','Vertical');");
        imgVertical.AlternateText = GetString("SplitMode.Vertical");
        imgClose.Attributes.Add("onclick", "javascript:FSP_Close();");
        imgSync.Attributes.Add("onclick", "javascript:parent.FSP_SynchronizeToolbar()");
        imgClose.Style.Add("cursor", "pointer");

        // Set layout
        if (CMSContext.SplitMode == SplitModeEnum.Horizontal)
        {
            pnlMain.CssClass             = "SplitToolbar Horizontal";
            divRight.Attributes["class"] = null;
        }
        else if (CMSContext.SplitMode == SplitModeEnum.Vertical)
        {
            pnlMain.CssClass = "SplitToolbar Vertical";
        }

        // Register Init script - FSP_ToolbarInit(selectorId, checkboxId)
        StringBuilder initScript = new StringBuilder();

        initScript.Append("parent.FSP_ToolbarInit('", drpCultures.ClientID, "','", imgSync.ClientID, "','", checkedSyncUrl, "','", uncheckedSyncUrl,
                          "','", divHorizontal.ClientID, "','", divVertical.ClientID, "');");

        // Register js scripts
        ScriptHelper.RegisterJQuery(Page);
        ScriptHelper.RegisterStartupScript(Page, typeof(string), "FSP_initToolbar", ScriptHelper.GetScript(initScript.ToString()));
    }
Esempio n. 8
0
    /// <summary>
    /// Handles OnSelectionChanged event of the UniSelector.
    /// </summary>
    /// <param name="sender">Sender object</param>
    /// <param name="e">Event argument</param>
    protected void Control_OnSelectionChanged(object sender, EventArgs e)
    {
        if (siteInfo == null)
        {
            return;
        }

        bool reloadNeeded = false;

        // Remove old items
        string newValues       = ValidationHelper.GetString(Control.Value, String.Empty);
        string removedCultures = DataHelper.GetNewItemsInList(newValues, currentValues);

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

                // Add all new items to site
                foreach (string cultureID in removedCultureIDs)
                {
                    CultureInfo ci = CultureInfoProvider.GetCultureInfo(ValidationHelper.GetInteger(cultureID, 0));
                    if (ci != null)
                    {
                        // Get the documents assigned to the culture being removed
                        DataSet nodes = tree.SelectNodes(siteInfo.SiteName, "/%", ci.CultureCode, false, null, null, null, -1, false);
                        if (DataHelper.DataSourceIsEmpty(nodes))
                        {
                            CultureSiteInfoProvider.RemoveCultureFromSite(ci.CultureCode, siteInfo.SiteName);
                        }
                        else
                        {
                            reloadNeeded = true;
                            Control.AddError(String.Format(ResHelper.GetString("site_edit_cultures.errorremoveculturefromsite"), ci.CultureCode) + '\n', null);
                        }
                    }
                }
            }
        }

        // Catch license limitations Exception
        try
        {
            // Add new items
            string newCultures = DataHelper.GetNewItemsInList(currentValues, newValues);
            if (!String.IsNullOrEmpty(newCultures))
            {
                string[] newCultureIDs = newCultures.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                if (newCultureIDs != null)
                {
                    // Add all new items to site
                    foreach (string cultureID in newCultureIDs)
                    {
                        int id = ValidationHelper.GetInteger(cultureID, 0);
                        CultureSiteInfoProvider.AddCultureToSite(id, siteInfo.SiteID);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            reloadNeeded = true;
            Control.ShowError(ex.Message);
        }

        if (reloadNeeded)
        {
            // Get the active cultures from DB
            DataSet ds = CultureInfoProvider.GetCultures("CultureID IN (SELECT CultureID FROM CMS_SiteCulture WHERE SiteID = " + siteInfo.SiteID + ")", null, 0, "CultureID");
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                currentValues = TextHelper.Join(";", DataHelper.GetStringValues(ds.Tables[0], "CultureID"));
                Control.Value = currentValues;
                Control.Reload(true);
            }
        }
    }
Esempio n. 9
0
    /// <summary>
    /// Handles btnOK's OnClick event - Update resource info.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        // finds whether required fields are not empty
        string result = new Validator()
                        .NotEmpty(txtCultureName.Text.Trim(), rfvCultureName.ErrorMessage)
                        .NotEmpty(txtCultureCode.Text.Trim(), rfvCultureCode.ErrorMessage)
                        .Result;

        if (txtCultureCode.Text.Trim().Length > 10)
        {
            result = GetString("Culture.MaxLengthError");
        }

        try
        {
            // Chech if global culture exists
            if (new System.Globalization.CultureInfo(txtCultureCode.Text.Trim()) == null)
            {
                result = GetString("Culture.ErrorNoGlobalCulture");
            }
        }
        catch
        {
            result = GetString("Culture.ErrorNoGlobalCulture");
        }

        txtCultureAlias.Text = URLHelper.GetSafeUrlPart(txtCultureAlias.Text.Trim(), String.Empty);
        string cultureAlias = txtCultureAlias.Text.Trim().Replace("'", "''");

        // Check whether culture alias is unique
        if (!string.IsNullOrEmpty(cultureAlias))
        {
            string where = string.Format("(CultureCode = N'{0} 'OR CultureAlias = N'{0}') AND CultureID <> {1}", cultureAlias, culture.CultureID);
            DataSet cultures = CultureInfoProvider.GetCultures(where, null, 1, "CultureID");
            if ((!DataHelper.DataSourceIsEmpty(cultures)) ||
                (CMSString.Equals(cultureAlias, txtCultureCode.Text.Trim(), true)))
            {
                result = GetString("Culture.AliasNotUnique");
            }
        }

        if (result != string.Empty)
        {
            ShowError(result);
            return;
        }

        // finds if the culture code is unique
        CultureInfo uniqueCulture = CultureInfoProvider.GetCultureInfoForCulture(txtCultureCode.Text.Trim());

        // if culture code already exists and it is just editing culture -> update
        if ((uniqueCulture == null) || (uniqueCulture.CultureID == culture.CultureID))
        {
            UpdateCulture();
        }
        // if culture code already exists and it is another culture -> error
        else
        {
            ShowError(GetString("Culture_New.CultureExists"));
        }
    }
    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);
            }
        }
    }
Esempio n. 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!RequestHelper.IsPostBack())
        {
            string preferredCultureCode = LocalizationContext.PreferredCultureCode;
            string currentSiteName      = SiteContext.CurrentSiteName;
            string where = "CultureCode IN (SELECT DocumentCulture FROM View_CMS_Tree_Joined WHERE NodeID = " + Node.NodeID + ")";
            DataSet documentCultures = CultureInfoProvider.GetCultures(where, null, 0, "CultureCode");

            // Get site cultures
            DataSet siteCultures = CultureSiteInfoProvider.GetSiteCultures(currentSiteName);
            if (!DataHelper.DataSourceIsEmpty(siteCultures) && !DataHelper.DataSourceIsEmpty(documentCultures))
            {
                string suffixNotTranslated = GetString("SplitMode.NotTranslated");

                foreach (DataRow row in siteCultures.Tables[0].Rows)
                {
                    string cultureCode = ValidationHelper.GetString(row["CultureCode"], null);
                    string cultureName = ResHelper.LocalizeString(ValidationHelper.GetString(row["CultureName"], null));

                    string suffix = string.Empty;

                    // Compare with preferred culture
                    if (CMSString.Compare(preferredCultureCode, cultureCode, true) == 0)
                    {
                        suffix = GetString("SplitMode.Current");
                    }
                    else
                    {
                        // Find culture
                        DataRow[] findRows = documentCultures.Tables[0].Select("CultureCode = '" + cultureCode + "'");
                        if (findRows.Length == 0)
                        {
                            suffix = suffixNotTranslated;
                        }
                    }

                    // Add new item
                    ListItem item = new ListItem(cultureName + " " + suffix, cultureCode);
                    drpCultures.Items.Add(item);
                }
            }

            drpCultures.SelectedValue = UIContext.SplitModeCultureCode;
            drpCultures.Attributes.Add("onchange", "if (parent.CheckChanges('frame2')) { parent.FSP_ChangeCulture(this); }");
        }

        buttons.Actions.Add(new CMSButtonGroupAction {
            Name = "close", UseIconButton = true, OnClientClick = "FSP_Close();return false;", IconCssClass = "icon-l-list-titles", ToolTip = GetString("splitmode.closelayout")
        });
        buttons.Actions.Add(new CMSButtonGroupAction {
            Name = "vertical", UseIconButton = true, OnClientClick = "FSP_Layout('true','frame1','Vertical');return false;", IconCssClass = "icon-l-cols-2 js-split-vertical", ToolTip = GetString("splitmode.verticallayout")
        });
        buttons.Actions.Add(new CMSButtonGroupAction {
            Name = "horizontal", UseIconButton = true, OnClientClick = "FSP_Layout(false,'frame1Vertical','Horizontal');;return false;", IconCssClass = "icon-l-rows-2 js-split-horizontal", ToolTip = GetString("splitmode.horizontallayout")
        });

        // Set css class
        switch (UIContext.SplitMode)
        {
        case SplitModeEnum.Horizontal:
            buttons.SelectedActionName = "horizontal";
            break;

        case SplitModeEnum.Vertical:
            buttons.SelectedActionName = "vertical";
            break;

        default:
            buttons.SelectedActionName = "close";
            break;
        }

        // Synchronize image
        chckScroll.Checked = UIContext.SplitModeSyncScrollbars;

        StringBuilder script = new StringBuilder();

        script.Append(
            @"
function FSP_Layout(vertical, frameName, cssClassName)
{
    if ((frameName != null) && parent.CheckChanges(frameName)) {
        if (cssClassName != null) {
            var element = document.getElementById('", pnlMain.ClientID, @"');
            if (element != null) {
                element.setAttribute(""class"", 'SplitToolbar ' + cssClassName);
                element.setAttribute(""className"", 'SplitToolbar ' + cssClassName);
            }
        }
        var divRight = document.getElementById('", divRight.ClientID, @"');
        if (vertical) {
            divRight.setAttribute(""class"", 'RightAlign');
            parent.FSP_VerticalLayout();
        }
        else {
            divRight.setAttribute(""class"", '');
            parent.FSP_HorizontalLayout();
        }
    }
}

function FSP_Close() { 
    if (parent.CheckChanges()) { 
        parent.FSP_CloseSplitMode(); 
    }
}
");

        ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "toolbarScript_" + ClientID, ScriptHelper.GetScript(script.ToString()));

        chckScroll.Attributes.Add("onchange", "javascript:parent.FSP_SynchronizeToolbar()");

        // Set layout
        if (UIContext.SplitMode == SplitModeEnum.Horizontal)
        {
            pnlMain.CssClass             = "SplitToolbar Horizontal";
            divRight.Attributes["class"] = null;
        }
        else if (UIContext.SplitMode == SplitModeEnum.Vertical)
        {
            pnlMain.CssClass = "SplitToolbar Vertical";
        }

        // Register Init script - FSP_ToolbarInit(selectorId, checkboxId)
        StringBuilder initScript = new StringBuilder();

        initScript.Append("parent.FSP_ToolbarInit('", drpCultures.ClientID, "','", chckScroll.ClientID, "');");

        // Register js scripts
        ScriptHelper.RegisterJQuery(Page);
        ScriptHelper.RegisterStartupScript(Page, typeof(string), "FSP_initToolbar", ScriptHelper.GetScript(initScript.ToString()));
    }