using System; using System.Collections.Generic; using System.Data; using System.Text; using System.Web.UI; using CMS.CMSHelper; using CMS.GlobalHelper; using CMS.PortalControls; using CMS.PortalEngine; using CMS.SettingsProvider; using CMS.SiteProvider; using CMS.DocumentEngine; using CMS.URLRewritingEngine; public partial class CMSWebParts_Localization_languageselectiondropdown : CMSAbstractLanguageWebPart { #region "Public properties" /// /// Gets or sets the value than indicates whether culture names are displayed. /// public bool ShowCultureNames { get { return ValidationHelper.GetBoolean(GetValue("ShowCultureNames"), true); } set { SetValue("ShowCultureNames", value); } } /// /// Gets or sets the value than indicates whether the control is shown. /// public bool HideIfOneCulture { get { return ValidationHelper.GetBoolean(GetValue("HideIfOneCulture"), true); } set { SetValue("HideIfOneCulture", value); } } #endregion #region "Methods" /// /// OnPreRender event handler. /// /// Event argument protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); SetupControl(); } /// /// Initializes the control properties. /// protected void SetupControl() { if (StopProcessing) { // Do nothing } else { // If there is only one culture on site and hiding is enabled hide webpart if (HideIfOneCulture && !CultureInfoProvider.IsSiteMultilignual(CMSContext.CurrentSiteName)) { Visible = false; return; } // Get list of cultures List cultures = GetCultures(); // Check whether exists more than one culture if ((cultures != null) && ((cultures.Count > 1) || (HideCurrentCulture && (cultures.Count > 0)))) { // Add CSS Stylesheet CSSHelper.RegisterCSSLink(Page, URLHelper.ResolveUrl("~/CMSWebparts/Localization/languageselectiondropdown_files/langselector.css")); string imgFlagIcon = String.Empty; StringBuilder result = new StringBuilder(); result.Append(""); ltlLanguages.Text = result.ToString(); } else if (HideIfOneCulture) { Visible = false; } } } /// /// Reloads data for partial caching. /// public override void ReloadData() { base.ReloadData(); SetupControl(); } #endregion }