Example #1
0
        /// <summary>
        /// Initializes the language link.
        /// Checks the number of available and enabled languages. If more than two,
        /// populates a dropdown-menu with the available and enabled languages.
        /// Otherwise sets the link to the not currently active language.
        /// </summary>
        private void SetLanguage()
        {
            PageDataCollection languageBranches = DataFactory.Instance.GetLanguageBranches(CurrentPage.PageLink);

            if (languageBranches == null)
            {
                return;
            }

            if (languageBranches.Count > 2)
            {
                LanguageList.Visible = LanguageListLabel.Visible = LanguageButton.Visible = LanguageList.Parent.Visible = true;

                foreach (PageData languageBranch in languageBranches)
                {
                    if (languageBranch.LanguageID != CurrentPage.LanguageID && LanguageBranch.Load(languageBranch.LanguageID).Enabled)
                    {
                        LanguageList.Items.Add(new System.Web.UI.WebControls.ListItem(new CultureInfo(languageBranch.LanguageID).NativeName, languageBranch.LanguageID));
                    }
                }
            }
            else
            {
                foreach (PageData languageBranch in languageBranches)
                {
                    if (languageBranch.LanguageID != CurrentPage.LanguageID && LanguageBranch.Load(languageBranch.LanguageID).Enabled)
                    {
                        Language.Visible     = Language.Parent.Visible = true;
                        Language.NavigateUrl = EPiServer.UriSupport.AddLanguageSelection(languageBranch.LinkURL, languageBranch.LanguageID);
                        Language.Text        = Translate(new CultureInfo(languageBranch.LanguageID).NativeName);
                        break;
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Initializes the language link.
        /// Checks the number of available and enabled languages. If more than two,
        /// populates a dropdown-menu with the available and enabled languages.
        /// Otherwise sets the link to the not currently active language.
        /// </summary>
        private void SetLanguage()
        {
            PageDataCollection languageBranches = DataFactory.Instance.GetLanguageBranches(CurrentPage.PageLink);

            //Filter so pages with Replacement language is filtered away.
            new FilterReplacementLanguage().Filter(languageBranches);

            if (languageBranches.Count > 2)
            {
                LanguageList.Visible = LanguageListLabel.Visible = LanguageButton.Visible = LanguageList.Parent.Visible = true;
                foreach (PageData languageBranch in languageBranches.Where(p => p.LanguageID != CurrentPage.LanguageID && LanguageBranch.Load(p.LanguageID).Enabled))
                {
                    LanguageList.Items.Add(new System.Web.UI.WebControls.ListItem(new CultureInfo(languageBranch.LanguageID).NativeName, languageBranch.LanguageID));
                }
            }
            else
            {
                foreach (PageData languageBranch in languageBranches.Where(p => p.LanguageID != CurrentPage.LanguageID && LanguageBranch.Load(p.LanguageID).Enabled))
                {
                    Language.Visible     = Language.Parent.Visible = true;
                    Language.NavigateUrl = EPiServer.UriSupport.AddLanguageSelection(languageBranch.LinkURL, languageBranch.LanguageID);
                    Language.Text        = Translate(new CultureInfo(languageBranch.LanguageID).NativeName);
                    break;
                }
            }
        }