/// <summary> /// The bind data. /// </summary> private void BindData() { int forumId = 0; this.CategoryList.DataSource = DB.category_list(PageContext.PageBoardID, null); this.CategoryList.DataBind(); if (Request.QueryString.GetFirstOrDefault("f") != null && int.TryParse(Request.QueryString.GetFirstOrDefault("f"), out forumId)) { this.AccessList.DataSource = DB.forumaccess_list(forumId); this.AccessList.DataBind(); } // Load forum's combo this.BindParentList(); // Load forum's themes var listheader = new ListItem(); listheader.Text = "Choose a theme"; listheader.Value = string.Empty; this.AccessMaskID.DataBind(); this.ThemeList.DataSource = StaticDataHelper.Themes(); this.ThemeList.DataTextField = "Theme"; this.ThemeList.DataValueField = "FileName"; this.ThemeList.DataBind(); this.ThemeList.Items.Insert(0, listheader); }
/// <summary> /// Binds the data. /// </summary> private void BindData() { var forumId = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefaultAsInt("fa") ?? this.Get <HttpRequestBase>().QueryString.GetFirstOrDefaultAsInt("copy"); this.CategoryList.DataSource = this.GetRepository <Category>().List(); this.CategoryList.DataBind(); if (forumId.HasValue) { this.AccessList.DataSource = this.GetRepository <ForumAccess>().GetForumAccessList(forumId.Value).Select( i => new { GroupID = i.Item2.ID, GroupName = i.Item2.Name, i.Item1.AccessMaskID }); this.AccessList.DataBind(); } else { this.AccessList.DataSource = BoardContext.Current.GetRepository <Group>().GetByBoardId() .Select(i => new { GroupID = i.ID, GroupName = i.Name, AccessMaskID = 0 }); this.AccessList.DataBind(); } // Load forum's combo this.BindParentList(); // Load forum's themes var listItem = new ListItem { Text = this.GetText("ADMIN_EDITFORUM", "CHOOSE_THEME"), Value = string.Empty }; this.ThemeList.DataSource = StaticDataHelper.Themes(); this.ThemeList.DataBind(); this.ThemeList.Items.Insert(0, listItem); }
/// <summary> /// Binds the data. /// </summary> private void BindData() { var forumId = this.Get <HttpRequestBase>().QueryString.GetFirstOrDefaultAsInt("fa") ?? this.Get <HttpRequestBase>().QueryString.GetFirstOrDefaultAsInt("copy"); this.CategoryList.DataSource = this.GetRepository <Category>().List(); this.CategoryList.DataBind(); if (forumId.HasValue) { this.AccessList.DataSource = this.GetRepository <ForumAccess>().GetForumAccessList(forumId.Value); this.AccessList.DataBind(); } // Load forum's combo this.BindParentList(); // Load forum's themes var listheader = new ListItem { Text = this.GetText("ADMIN_EDITFORUM", "CHOOSE_THEME"), Value = string.Empty }; this.AccessMaskID.DataBind(); this.ThemeList.DataSource = StaticDataHelper.Themes(); this.ThemeList.DataBind(); this.ThemeList.Items.Insert(0, listheader); }
/// <summary> /// Binds the data. /// </summary> private void BindData() { var forumId = this.GetQueryStringAsInt("fa") ?? this.GetQueryStringAsInt("copy"); this.CategoryList.DataSource = this.GetRepository <Category>().List(); this.CategoryList.DataBind(); if (forumId.HasValue) { this.AccessList.DataSource = LegacyDb.forumaccess_list(forumId.Value); this.AccessList.DataBind(); } // Load forum's combo this.BindParentList(); // Load forum's themes var listheader = new ListItem { Text = this.GetText("ADMIN_EDITFORUM", "CHOOSE_THEME"), Value = string.Empty }; this.AccessMaskID.DataBind(); this.ThemeList.DataSource = StaticDataHelper.Themes(); this.ThemeList.DataTextField = "Theme"; this.ThemeList.DataValueField = "FileName"; this.ThemeList.DataBind(); this.ThemeList.Items.Insert(0, listheader); }
/// <summary> /// Sets the theme class up for usage /// </summary> /// <exception cref="CantLoadThemeException"><c>CantLoadThemeException</c>.</exception> private void InitTheme() { if (this._initTheme) { return; } if (this.BeforeInit != null) { this.BeforeInit(this, new EventArgs()); } string themeFile; if (YafContext.Current.Page != null && YafContext.Current.Page["ThemeFile"] != null && YafContext.Current.BoardSettings.AllowUserTheme) { // use user-selected theme themeFile = YafContext.Current.Page["ThemeFile"].ToString(); } else if (YafContext.Current.Page != null && YafContext.Current.Page["ForumTheme"] != null) { themeFile = YafContext.Current.Page["ForumTheme"].ToString(); } else { themeFile = YafContext.Current.BoardSettings.Theme; } if (!YafTheme.IsValidTheme(themeFile)) { themeFile = StaticDataHelper.Themes().Rows[0][1].ToString(); } // create the theme class this.Theme = new YafTheme(themeFile); // make sure it's valid again... if (!YafTheme.IsValidTheme(this.Theme.ThemeFile)) { // can't load a theme... throw an exception. throw new CantLoadThemeException( @"Unable to find a theme to load. Last attempted to load ""{0}"" but failed.".FormatWith(themeFile)); } if (this.AfterInit != null) { this.AfterInit(this, new EventArgs()); } }
/// <summary> /// Gets the user theme file. /// </summary> /// <param name="userId">The user id.</param> /// <param name="boardID">The board identifier.</param> /// <param name="allowUserTheme">if set to <c>true</c> [allow user theme].</param> /// <param name="theme">The theme.</param> /// <returns> /// Returns User theme /// </returns> public static string GetUserThemeFile(int userId, int boardID, bool allowUserTheme, string theme) { DataRow row = UserMembershipHelper.GetUserRowForID(userId, boardID); var themeFile = (row != null && row["ThemeFile"] != DBNull.Value && allowUserTheme) ? row["ThemeFile"].ToString() : theme; if (!YafTheme.IsValidTheme(themeFile)) { themeFile = StaticDataHelper.Themes().Rows[0][1].ToString(); } return(themeFile); }
/// <summary> /// Gets the user theme file. /// </summary> /// <param name="userId">The user id.</param> /// <returns>Returns User theme</returns> public static string GetUserThemeFile(int userId) { DataRow row = UserMembershipHelper.GetUserRowForID(userId); var themeFile = row != null && row["ThemeFile"] != DBNull.Value && YafContext.Current.Get <YafBoardSettings>().AllowUserTheme ? row["ThemeFile"].ToString() : YafContext.Current.Get <YafBoardSettings>().Theme; if (!YafTheme.IsValidTheme(themeFile)) { themeFile = StaticDataHelper.Themes().Rows[0][1].ToString(); } return(themeFile); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { if (this.IsPostBack) { return; } var boardSettings = this.Get <YafBoardSettings>(); this.PageLinks.AddLink(boardSettings.Name, YafBuildLink.GetLink(ForumPages.forum)); this.PageLinks.AddLink( this.GetText("ADMIN_ADMIN", "Administration"), YafBuildLink.GetLink(ForumPages.admin_admin)); this.PageLinks.AddLink(this.GetText("ADMIN_BOARDSETTINGS", "TITLE"), string.Empty); this.Page.Header.Title = "{0} - {1}".FormatWith( this.GetText("ADMIN_ADMIN", "Administration"), this.GetText("ADMIN_BOARDSETTINGS", "TITLE")); this.Save.Text = this.GetText("COMMON", "SAVE"); // create list boxes by populating datasources from Data class var themeData = StaticDataHelper.Themes().AsEnumerable().Where(x => !x.Field <bool>("IsMobile")); if (themeData.Any()) { this.Theme.DataSource = themeData.CopyToDataTable(); this.Theme.DataTextField = "Theme"; this.Theme.DataValueField = "FileName"; } var mobileThemeData = StaticDataHelper.Themes().AsEnumerable().Where(x => x.Field <bool>("IsMobile")); if (mobileThemeData.Any()) { var mobileThemes = mobileThemeData.CopyToDataTable(); // Add Dummy Disabled Mobile Theme Item to allow disabling the Mobile Theme DataRow dr = mobileThemes.NewRow(); dr["Theme"] = "[ {0} ]".FormatWith(this.GetText("ADMIN_COMMON", "DISABLED")); dr["FileName"] = string.Empty; dr["IsMobile"] = false; mobileThemes.Rows.InsertAt(dr, 0); this.MobileTheme.DataSource = mobileThemes; this.MobileTheme.DataTextField = "Theme"; this.MobileTheme.DataValueField = "FileName"; } this.Culture.DataSource = StaticDataHelper.Cultures() .AsEnumerable() .OrderBy(x => x.Field <string>("CultureNativeName")) .CopyToDataTable(); this.Culture.DataTextField = "CultureNativeName"; this.Culture.DataValueField = "CultureTag"; this.ShowTopic.DataSource = StaticDataHelper.TopicTimes(); this.ShowTopic.DataTextField = "TopicText"; this.ShowTopic.DataValueField = "TopicValue"; this.FileExtensionAllow.DataSource = StaticDataHelper.AllowDisallow(); this.FileExtensionAllow.DataTextField = "Text"; this.FileExtensionAllow.DataValueField = "Value"; this.JqueryUITheme.DataSource = StaticDataHelper.JqueryUIThemes(); this.JqueryUITheme.DataTextField = "Theme"; this.JqueryUITheme.DataValueField = "Theme"; this.BindData(); // bind poll group list var pollGroup = LegacyDb.PollGroupList(this.PageContext.PageUserID, null, this.PageContext.PageBoardID) .Distinct(new AreEqualFunc <TypedPollGroup>((v1, v2) => v1.PollGroupID == v2.PollGroupID)) .ToList(); pollGroup.Insert(0, new TypedPollGroup(string.Empty, -1)); // TODO: vzrus needs some work, will be in polls only until feature is debugged there. this.PollGroupListDropDown.Items.AddRange(pollGroup.Select(x => new ListItem(x.Question, x.PollGroupID.ToString())).ToArray()); // population default notification setting options... var items = EnumHelper.EnumToDictionary <UserNotificationSetting>(); if (!boardSettings.AllowNotificationAllPostsAllTopics) { // remove it... items.Remove(UserNotificationSetting.AllTopics.ToInt()); } var notificationItems = items.Select(x => new ListItem(HtmlHelper.StripHtml(this.GetText("CP_SUBSCRIPTIONS", x.Value)), x.Key.ToString())).ToArray(); this.DefaultNotificationSetting.Items.AddRange(notificationItems); SetSelectedOnList(ref this.JqueryUITheme, boardSettings.JqueryUITheme); // Get first default full culture from a language file tag. string langFileCulture = StaticDataHelper.CultureDefaultFromFile(boardSettings.Language) ?? "en-US"; SetSelectedOnList(ref this.Theme, boardSettings.Theme); SetSelectedOnList(ref this.MobileTheme, boardSettings.MobileTheme); // If 2-letter language code is the same we return Culture, else we return a default full culture from language file /* SetSelectedOnList( * ref this.Culture, * langFileCulture.Substring(0, 2) == this.Get<YafBoardSettings>().Culture * ? this.Get<YafBoardSettings>().Culture * : langFileCulture);*/ SetSelectedOnList(ref this.Culture, boardSettings.Culture); if (this.Culture.SelectedIndex == 0) { // If 2-letter language code is the same we return Culture, else we return a default full culture from language file SetSelectedOnList( ref this.Culture, langFileCulture.Substring(0, 2) == boardSettings.Culture ? boardSettings.Culture : langFileCulture); } SetSelectedOnList(ref this.ShowTopic, boardSettings.ShowTopicsDefault.ToString()); SetSelectedOnList( ref this.FileExtensionAllow, boardSettings.FileExtensionAreAllowed ? "0" : "1"); SetSelectedOnList( ref this.DefaultNotificationSetting, boardSettings.DefaultNotificationSetting.ToInt().ToString()); this.NotificationOnUserRegisterEmailList.Text = boardSettings.NotificationOnUserRegisterEmailList; this.AllowThemedLogo.Checked = boardSettings.AllowThemedLogo; this.EmailModeratorsOnModeratedPost.Checked = boardSettings.EmailModeratorsOnModeratedPost; this.EmailModeratorsOnReportedPost.Checked = boardSettings.EmailModeratorsOnReportedPost; this.AllowDigestEmail.Checked = boardSettings.AllowDigestEmail; this.DefaultSendDigestEmail.Checked = boardSettings.DefaultSendDigestEmail; this.ForumEmail.Text = boardSettings.ForumEmail; this.ForumBaseUrlMask.Text = boardSettings.BaseUrlMask; this.CopyrightRemovalKey.Text = boardSettings.CopyrightRemovalDomainKey; this.DigestSendEveryXHours.Text = boardSettings.DigestSendEveryXHours.ToString(); if (boardSettings.BoardPollID > 0) { this.PollGroupListDropDown.SelectedValue = boardSettings.BoardPollID.ToString(); } else { this.PollGroupListDropDown.SelectedIndex = 0; } this.PollGroupList.Visible = true; // Copyright Linkback Algorithm // Please keep if you haven't purchased a removal or commercial license. this.CopyrightHolder.Visible = true; }
/// <summary> /// The bind data. /// </summary> private void BindData() { this.TimeZones.DataSource = StaticDataHelper.TimeZones(); if (this.Get <YafBoardSettings>().AllowUserTheme) { this.Theme.DataSource = StaticDataHelper.Themes(); this.Theme.DataTextField = "Theme"; this.Theme.DataValueField = "FileName"; } if (this.Get <YafBoardSettings>().AllowUserLanguage) { this.Culture.DataSource = StaticDataHelper.Cultures(); this.Culture.DataValueField = "CultureTag"; this.Culture.DataTextField = "CultureNativeName"; } this.Country.DataSource = StaticDataHelper.Country(); this.Country.DataValueField = "Value"; this.Country.DataTextField = "Name"; if (this.UserData.Profile.Country.IsSet()) { this.LookForNewRegionsBind(this.UserData.Profile.Country); } if (this.Get <YafBoardSettings>().AllowUsersTextEditor) { this.ForumEditor.DataSource = this.Get <IModuleManager <ForumEditor> >().ActiveAsDataTable("Editors"); this.ForumEditor.DataValueField = "Value"; this.ForumEditor.DataTextField = "Name"; } this.DataBind(); if (this.Get <YafBoardSettings>().UseFarsiCalender&& this.CurrentCultureInfo.IsFarsiCulture()) { this.Birthday.Text = this.UserData.Profile.Birthday > DateTimeHelper.SqlDbMinTime() || this.UserData.Profile.Birthday.IsNullOrEmptyDBField() ? PersianDateConverter.ToPersianDate(this.UserData.Profile.Birthday) .ToString("d") : PersianDateConverter.ToPersianDate(PersianDate.MinValue).ToString("d"); } else { this.Birthday.Text = this.UserData.Profile.Birthday > DateTimeHelper.SqlDbMinTime() || this.UserData.Profile.Birthday.IsNullOrEmptyDBField() ? this.UserData.Profile.Birthday.Date.ToString( this.CurrentCultureInfo.DateTimeFormat.ShortDatePattern, CultureInfo.InvariantCulture) : DateTimeHelper.SqlDbMinTime() .Date.ToString( this.CurrentCultureInfo.DateTimeFormat.ShortDatePattern, CultureInfo.InvariantCulture); } this.Birthday.ToolTip = this.GetText("COMMON", "CAL_JQ_TT"); this.DisplayName.Text = this.UserData.DisplayName; this.City.Text = this.UserData.Profile.City; this.Location.Text = this.UserData.Profile.Location; this.HomePage.Text = this.UserData.Profile.Homepage; this.Email.Text = this.UserData.Email; this.Realname.Text = this.UserData.Profile.RealName; this.Occupation.Text = this.UserData.Profile.Occupation; this.Interests.Text = this.UserData.Profile.Interests; this.Weblog.Text = this.UserData.Profile.Blog; this.WeblogUrl.Text = this.UserData.Profile.BlogServiceUrl; this.WeblogID.Text = this.UserData.Profile.BlogServicePassword; this.WeblogUsername.Text = this.UserData.Profile.BlogServiceUsername; this.MSN.Text = this.UserData.Profile.MSN; this.YIM.Text = this.UserData.Profile.YIM; this.AIM.Text = this.UserData.Profile.AIM; this.ICQ.Text = this.UserData.Profile.ICQ; this.Facebook.Text = ValidationHelper.IsNumeric(this.UserData.Profile.Facebook) ? "https://www.facebook.com/profile.php?id={0}".FormatWith( this.UserData.Profile.Facebook) : this.UserData.Profile.Facebook; this.Twitter.Text = this.UserData.Profile.Twitter; this.Google.Text = this.UserData.Profile.Google; this.Xmpp.Text = this.UserData.Profile.XMPP; this.Skype.Text = this.UserData.Profile.Skype; this.Gender.SelectedIndex = this.UserData.Profile.Gender; if (this.UserData.Profile.Country.IsSet()) { ListItem countryItem = this.Country.Items.FindByValue(this.UserData.Profile.Country.Trim()); if (countryItem != null) { countryItem.Selected = true; } } if (this.UserData.Profile.Region.IsSet()) { ListItem regionItem = this.Region.Items.FindByValue(this.UserData.Profile.Region.Trim()); if (regionItem != null) { regionItem.Selected = true; } } ListItem timeZoneItem = this.TimeZones.Items.FindByValue(this.UserData.TimeZone.ToString()); if (timeZoneItem != null) { timeZoneItem.Selected = true; } this.DSTUser.Checked = this.UserData.DSTUser; this.HideMe.Checked = this.UserData.IsActiveExcluded && (this.Get <YafBoardSettings>().AllowUserHideHimself || this.PageContext.IsAdmin); if (this.Get <YafBoardSettings>().MobileTheme.IsSet() && UserAgentHelper.IsMobileDevice(HttpContext.Current.Request.UserAgent) || HttpContext.Current.Request.Browser.IsMobileDevice) { this.UseMobileThemeRow.Visible = true; this.UseMobileTheme.Checked = this.UserData.UseMobileTheme; } if (this.Get <YafBoardSettings>().AllowUserTheme&& this.Theme.Items.Count > 0) { // Allows to use different per-forum themes, // While "Allow User Change Theme" option in hostsettings is true string themeFile = this.Get <YafBoardSettings>().Theme; if (this.UserData.ThemeFile.IsSet()) { themeFile = this.UserData.ThemeFile; } ListItem themeItem = this.Theme.Items.FindByValue(themeFile); if (themeItem != null) { themeItem.Selected = true; } } if (this.Get <YafBoardSettings>().AllowUsersTextEditor&& this.ForumEditor.Items.Count > 0) { // Text editor string textEditor = this.UserData.TextEditor.IsSet() ? this.UserData.TextEditor : this.Get <YafBoardSettings>().ForumEditor; ListItem editorItem = this.ForumEditor.Items.FindByValue(textEditor); if (editorItem != null) { editorItem.Selected = true; } } if (!this.Get <YafBoardSettings>().AllowUserLanguage || this.Culture.Items.Count <= 0) { return; } // If 2-letter language code is the same we return Culture, else we return a default full culture from language file ListItem foundCultItem = this.Culture.Items.FindByValue(this.GetCulture(true)); if (foundCultItem != null) { foundCultItem.Selected = true; } if (!Page.IsPostBack) { this.Realname.Focus(); } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { if (this.IsPostBack) { return; } var boardSettings = this.Get <BoardSettings>(); this.CdvVersion.Text = boardSettings.CdvVersion.ToString(); // create list boxes by populating data sources from Data class var themeData = StaticDataHelper.Themes(); if (themeData.Any()) { this.Theme.DataSource = themeData; } this.Culture.DataSource = StaticDataHelper.Cultures().AsEnumerable() .OrderBy(x => x.Field <string>("CultureNativeName")).CopyToDataTable(); this.Culture.DataTextField = "CultureNativeName"; this.Culture.DataValueField = "CultureTag"; this.ShowTopic.DataSource = StaticDataHelper.TopicTimes(); this.ShowTopic.DataTextField = "TopicText"; this.ShowTopic.DataValueField = "TopicValue"; this.BindData(); // bind poll group list var pollGroup = this.GetRepository <Poll>() .PollGroupList(this.PageContext.PageUserID, null, this.PageContext.PageBoardID).Distinct( new AreEqualFunc <TypedPollGroup>((v1, v2) => v1.PollGroupID == v2.PollGroupID)).ToList(); pollGroup.Insert(0, new TypedPollGroup(this.GetText("NONE"), -1)); // TODO: vzrus needs some work, will be in polls only until feature is debugged there. this.PollGroupListDropDown.Items.AddRange( pollGroup.Select(x => new ListItem(x.Question, x.PollGroupID.ToString())).ToArray()); // population default notification setting options... var items = EnumHelper.EnumToDictionary <UserNotificationSetting>(); if (!boardSettings.AllowNotificationAllPostsAllTopics) { // remove it... items.Remove(UserNotificationSetting.AllTopics.ToInt()); } var notificationItems = items.Select( x => new ListItem( HtmlHelper.StripHtml(this.GetText("SUBSCRIPTIONS", x.Value)), x.Key.ToString())) .ToArray(); this.DefaultNotificationSetting.Items.AddRange(notificationItems); // Get first default full culture from a language file tag. var langFileCulture = StaticDataHelper.CultureDefaultFromFile(boardSettings.Language) ?? "en-US"; if (boardSettings.Theme.Contains(".xml")) { SetSelectedOnList(ref this.Theme, "yaf"); } else { SetSelectedOnList(ref this.Theme, boardSettings.Theme); } // If 2-letter language code is the same we return Culture, else we return a default full culture from language file /* SetSelectedOnList( * ref this.Culture, * langFileCulture.Substring(0, 2) == this.Get<BoardSettings>().Culture * ? this.Get<BoardSettings>().Culture * : langFileCulture);*/ SetSelectedOnList(ref this.Culture, boardSettings.Culture); if (this.Culture.SelectedIndex == 0) { // If 2-letter language code is the same we return Culture, else we return a default full culture from language file SetSelectedOnList( ref this.Culture, langFileCulture.Substring(0, 2) == boardSettings.Culture ? boardSettings.Culture : langFileCulture); } SetSelectedOnList(ref this.ShowTopic, boardSettings.ShowTopicsDefault.ToString()); SetSelectedOnList( ref this.DefaultNotificationSetting, boardSettings.DefaultNotificationSetting.ToInt().ToString()); this.FileExtensionAllow.Checked = boardSettings.FileExtensionAreAllowed; this.NotificationOnUserRegisterEmailList.Text = boardSettings.NotificationOnUserRegisterEmailList; this.EmailModeratorsOnModeratedPost.Checked = boardSettings.EmailModeratorsOnModeratedPost; this.EmailModeratorsOnReportedPost.Checked = boardSettings.EmailModeratorsOnReportedPost; this.AllowDigestEmail.Checked = boardSettings.AllowDigestEmail; this.DefaultSendDigestEmail.Checked = boardSettings.DefaultSendDigestEmail; this.ForumEmail.Text = boardSettings.ForumEmail; this.ForumBaseUrlMask.Text = boardSettings.BaseUrlMask; var item = this.BoardLogo.Items.FindByText(boardSettings.ForumLogo); if (item != null) { item.Selected = true; } this.CopyrightRemovalKey.Text = boardSettings.CopyrightRemovalDomainKey; this.DigestSendEveryXHours.Text = boardSettings.DigestSendEveryXHours.ToString(); if (boardSettings.BoardPollID > 0) { this.PollGroupListDropDown.SelectedValue = boardSettings.BoardPollID.ToString(); } else { this.PollGroupListDropDown.SelectedIndex = 0; } this.PollGroupList.Visible = true; // Copyright Link-back Algorithm // Please keep if you haven't purchased a removal or commercial license. this.CopyrightHolder.Visible = true; // Render board Announcement // add items to the dropdown this.BoardAnnouncementUntilUnit.Items.Add(new ListItem(this.GetText("PROFILE", "MONTH"), "3")); this.BoardAnnouncementUntilUnit.Items.Add(new ListItem(this.GetText("PROFILE", "DAYS"), "1")); this.BoardAnnouncementUntilUnit.Items.Add(new ListItem(this.GetText("PROFILE", "HOURS"), "2")); // select hours this.BoardAnnouncementUntilUnit.SelectedIndex = 0; // default number of hours to suspend user for this.BoardAnnouncementUntil.Text = "1"; if (boardSettings.BoardAnnouncement.IsNotSet()) { return; } this.CurrentAnnouncement.Visible = true; this.CurrentMessage.Text = $"{this.GetText("ANNOUNCEMENT_CURRENT")}: {boardSettings.BoardAnnouncementUntil}"; this.BoardAnnouncementType.SelectedValue = boardSettings.BoardAnnouncementType; this.BoardAnnouncement.Text = boardSettings.BoardAnnouncement; }
/// <summary> /// Binds the data. /// </summary> private void BindData() { var board = this.GetRepository <Board>().GetById(this.PageContext.PageBoardID); using (var dt = new DataTable("Files")) { dt.Columns.Add("FileName", typeof(string)); dt.Columns.Add("Description", typeof(string)); var dr = dt.NewRow(); dr["FileName"] = BoardInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry dr["Description"] = this.GetText("BOARD_LOGO_SELECT"); dt.Rows.Add(dr); var dir = new DirectoryInfo( this.Get <HttpRequestBase>() .MapPath($"{BoardInfo.ForumServerFileRoot}{BoardFolders.Current.Logos}")); var files = dir.GetFiles("*.*"); dt.AddImageFiles(files, BoardFolders.Current.Logos); this.BoardLogo.DataSource = dt; this.BoardLogo.DataValueField = "FileName"; this.BoardLogo.DataTextField = "Description"; this.BoardLogo.DataBind(); } this.Name.Text = board.Name; var boardSettings = this.Get <BoardSettings>(); this.CdvVersion.Text = boardSettings.CdvVersion.ToString(); // create list boxes by populating data sources from Data class var themeData = StaticDataHelper.Themes(); if (themeData.Any()) { this.Theme.DataSource = themeData; this.Theme.DataBind(); } this.Culture.DataSource = StaticDataHelper.Cultures().OrderBy(x => x.CultureNativeName); this.Culture.DataTextField = "CultureNativeName"; this.Culture.DataValueField = "CultureTag"; this.Culture.DataBind(); this.ShowTopic.DataSource = StaticDataHelper.TopicTimes(); this.ShowTopic.DataTextField = "Name"; this.ShowTopic.DataValueField = "Value"; this.ShowTopic.DataBind(); // population default notification setting options... var items = EnumHelper.EnumToDictionary <UserNotificationSetting>(); if (!boardSettings.AllowNotificationAllPostsAllTopics) { // remove it... items.Remove(UserNotificationSetting.AllTopics.ToInt()); } var notificationItems = items.Select( x => new ListItem( HtmlHelper.StripHtml(this.GetText("SUBSCRIPTIONS", x.Value)), x.Key.ToString())) .ToArray(); this.DefaultNotificationSetting.Items.AddRange(notificationItems); // Get first default full culture from a language file tag. var langFileCulture = StaticDataHelper.CultureDefaultFromFile(boardSettings.Language) ?? "en-US"; if (boardSettings.Theme.Contains(".xml")) { SetSelectedOnList(ref this.Theme, "yaf"); } else { SetSelectedOnList(ref this.Theme, boardSettings.Theme); } SetSelectedOnList(ref this.Culture, boardSettings.Culture); if (this.Culture.SelectedIndex == 0) { // If 2-letter language code is the same we return Culture, else we return a default full culture from language file SetSelectedOnList( ref this.Culture, langFileCulture.Substring(0, 2) == boardSettings.Culture ? boardSettings.Culture : langFileCulture); } SetSelectedOnList(ref this.ShowTopic, boardSettings.ShowTopicsDefault.ToString()); SetSelectedOnList( ref this.DefaultNotificationSetting, boardSettings.DefaultNotificationSetting.ToInt().ToString()); this.NotificationOnUserRegisterEmailList.Text = boardSettings.NotificationOnUserRegisterEmailList; this.EmailModeratorsOnModeratedPost.Checked = boardSettings.EmailModeratorsOnModeratedPost; this.EmailModeratorsOnReportedPost.Checked = boardSettings.EmailModeratorsOnReportedPost; this.AllowDigestEmail.Checked = boardSettings.AllowDigestEmail; this.DefaultSendDigestEmail.Checked = boardSettings.DefaultSendDigestEmail; this.ForumEmail.Text = boardSettings.ForumEmail; this.ForumBaseUrlMask.Text = boardSettings.BaseUrlMask; var item = this.BoardLogo.Items.FindByText(boardSettings.ForumLogo); if (item != null) { item.Selected = true; } this.CopyrightRemovalKey.Text = boardSettings.CopyrightRemovalDomainKey; this.DigestSendEveryXHours.Text = boardSettings.DigestSendEveryXHours.ToString(); // Copyright Link-back Algorithm // Please keep if you haven't purchased a removal or commercial license. this.CopyrightHolder.Visible = true; }
/// <summary> /// The page_ load. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e) { if (!this.IsPostBack) { this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum)); this.PageLinks.AddLink("Administration", YafBuildLink.GetLink(ForumPages.admin_admin)); this.PageLinks.AddLink("Board Settings", string.Empty); // create list boxes by populating datasources from Data class var themeData = StaticDataHelper.Themes().AsEnumerable().Where(x => !x.Field <bool>("IsMobile")); if (themeData.Any()) { this.Theme.DataSource = themeData.CopyToDataTable(); this.Theme.DataTextField = "Theme"; this.Theme.DataValueField = "FileName"; } var mobileThemeData = StaticDataHelper.Themes().AsEnumerable().Where(x => x.Field <bool>("IsMobile")); if (mobileThemeData.Any()) { this.MobileTheme.DataSource = mobileThemeData.CopyToDataTable(); this.MobileTheme.DataTextField = "Theme"; this.MobileTheme.DataValueField = "FileName"; } this.Culture.DataSource = StaticDataHelper.Cultures().AsEnumerable().OrderBy(x => x.Field <string>("CultureNativeName")).CopyToDataTable( ); this.Culture.DataTextField = "CultureNativeName"; this.Culture.DataValueField = "CultureTag"; this.ShowTopic.DataSource = StaticDataHelper.TopicTimes(); this.ShowTopic.DataTextField = "TopicText"; this.ShowTopic.DataValueField = "TopicValue"; this.FileExtensionAllow.DataSource = StaticDataHelper.AllowDisallow(); this.FileExtensionAllow.DataTextField = "Text"; this.FileExtensionAllow.DataValueField = "Value"; this.BindData(); // bind poll group list var pollGroup = DB.PollGroupList(this.PageContext.PageUserID, null, this.PageContext.PageBoardID).Distinct( new AreEqualFunc <TypedPollGroup>((v1, v2) => v1.PollGroupID == v2.PollGroupID)).ToList(); pollGroup.Insert(0, new TypedPollGroup(String.Empty, -1)); // TODO: vzrus needs some work, will be in polls only until feature is debugged there. this.PollGroupListDropDown.Items.AddRange( pollGroup.Select(x => new ListItem(x.Question, x.PollGroupID.ToString())).ToArray()); // population default notification setting options... var items = EnumHelper.EnumToDictionary <UserNotificationSetting>(); if (!this.PageContext.BoardSettings.AllowNotificationAllPostsAllTopics) { // remove it... items.Remove(UserNotificationSetting.AllTopics.ToInt()); } var notificationItems = items.Select( x => new ListItem( HtmlHelper.StripHtml(this.PageContext.Localization.GetText("CP_SUBSCRIPTIONS", x.Value)), x.Key.ToString())) .ToArray(); this.DefaultNotificationSetting.Items.AddRange(notificationItems); // Get first default full culture from a language file tag. string langFileCulture = StaticDataHelper.CultureDefaultFromFile(this.PageContext.BoardSettings.Language) ?? "en"; SetSelectedOnList(ref this.Theme, this.PageContext.BoardSettings.Theme); SetSelectedOnList(ref this.MobileTheme, this.PageContext.BoardSettings.MobileTheme); // If 2-letter language code is the same we return Culture, else we return a default full culture from language file SetSelectedOnList( ref this.Culture, langFileCulture.Substring(0, 2) == this.PageContext.BoardSettings.Culture ? this.PageContext.BoardSettings.Culture : langFileCulture); SetSelectedOnList(ref this.ShowTopic, this.PageContext.BoardSettings.ShowTopicsDefault.ToString()); SetSelectedOnList( ref this.FileExtensionAllow, this.PageContext.BoardSettings.FileExtensionAreAllowed ? "0" : "1"); SetSelectedOnList( ref this.DefaultNotificationSetting, this.PageContext.BoardSettings.DefaultNotificationSetting.ToInt().ToString()); this.NotificationOnUserRegisterEmailList.Text = this.PageContext.BoardSettings.NotificationOnUserRegisterEmailList; this.AllowThemedLogo.Checked = this.PageContext.BoardSettings.AllowThemedLogo; this.EmailModeratorsOnModeratedPost.Checked = this.PageContext.BoardSettings.EmailModeratorsOnModeratedPost; this.AllowDigestEmail.Checked = this.PageContext.BoardSettings.AllowDigestEmail; this.DefaultSendDigestEmail.Checked = this.PageContext.BoardSettings.DefaultSendDigestEmail; if (this.PageContext.BoardSettings.BoardPollID > 0) { this.PollGroupListDropDown.SelectedValue = this.PageContext.BoardSettings.BoardPollID.ToString(); } else { this.PollGroupListDropDown.SelectedIndex = 0; } this.PollGroupList.Visible = true; } }
/// <summary> /// The bind data. /// </summary> private void BindData() { this.TimeZones.DataSource = StaticDataHelper.TimeZones(); if (this.PageContext.BoardSettings.AllowUserTheme) { this.Theme.DataSource = StaticDataHelper.Themes(); this.Theme.DataTextField = "Theme"; this.Theme.DataValueField = "FileName"; } if (this.PageContext.BoardSettings.AllowUserLanguage) { this.Culture.DataSource = StaticDataHelper.Cultures(); this.Culture.DataValueField = "CultureTag"; this.Culture.DataTextField = "CultureNativeName"; } this.DataBind(); if (this.PageContext.BoardSettings.EnableDNACalendar) { this.datePicker.LocID = this.PageContext.Localization.GetText("COMMON", "CAL_JQ_CULTURE"); this.datePicker.AnotherFormatString = this.PageContext.Localization.GetText("COMMON", "CAL_JQ_CULTURE_DFORMAT"); this.datePicker.DateFormatString = Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern; this.datePicker.Value = this.UserData.Profile.Birthday > DateTime.MinValue ? this.UserData.Profile.Birthday.Date : DateTime.MinValue.Date; this.datePicker.ToolTip = this.PageContext.Localization.GetText("COMMON", "CAL_JQ_TT"); this.datePicker.DefaultDateString = string.Empty; } else { this.datePicker.Enabled = false; this.datePicker.Visible = false; this.BirthdayLabel.Visible = false; } this.DisplayName.Text = this.UserData.DisplayName; this.Location.Text = this.UserData.Profile.Location; this.HomePage.Text = this.UserData.Profile.Homepage; this.Email.Text = this.UserData.Email; this.Realname.Text = this.UserData.Profile.RealName; this.Occupation.Text = this.UserData.Profile.Occupation; this.Interests.Text = this.UserData.Profile.Interests; this.Weblog.Text = this.UserData.Profile.Blog; this.WeblogUrl.Text = this.UserData.Profile.BlogServiceUrl; this.WeblogID.Text = this.UserData.Profile.BlogServicePassword; this.WeblogUsername.Text = this.UserData.Profile.BlogServiceUsername; this.MSN.Text = this.UserData.Profile.MSN; this.YIM.Text = this.UserData.Profile.YIM; this.AIM.Text = this.UserData.Profile.AIM; this.ICQ.Text = this.UserData.Profile.ICQ; this.Xmpp.Text = this.UserData.Profile.XMPP; this.Skype.Text = this.UserData.Profile.Skype; this.Gender.SelectedIndex = this.UserData.Profile.Gender; ListItem timeZoneItem = this.TimeZones.Items.FindByValue(this.UserData.TimeZone.ToString()); if (timeZoneItem != null) { timeZoneItem.Selected = true; } this.DSTUser.Checked = this.UserData.DSTUser; this.HideMe.Checked = this.UserData.IsActiveExcluded && (this.PageContext.BoardSettings.AllowUserHideHimself || this.PageContext.IsAdmin); if (YafContext.Current.BoardSettings.MobileTheme.IsSet() && UserAgentHelper.IsMobileDevice(HttpContext.Current.Request.UserAgent) || HttpContext.Current.Request.Browser.IsMobileDevice) { this.UseMobileThemeRow.Visible = true; this.UseMobileTheme.Checked = this.UserData.UseMobileTheme; } if (this.PageContext.BoardSettings.AllowUserTheme && this.Theme.Items.Count > 0) { // Allows to use different per-forum themes, // While "Allow User Change Theme" option in hostsettings is true string themeFile = this.PageContext.BoardSettings.Theme; if (!string.IsNullOrEmpty(this.UserData.ThemeFile)) { themeFile = this.UserData.ThemeFile; } ListItem themeItem = this.Theme.Items.FindByValue(themeFile); if (themeItem != null) { themeItem.Selected = true; } } if (!this.PageContext.BoardSettings.AllowUserLanguage || this.Culture.Items.Count <= 0) { return; } string languageFile = this.PageContext.BoardSettings.Language; string culture4tag = this.PageContext.BoardSettings.Culture; if (!string.IsNullOrEmpty(this.UserData.LanguageFile)) { languageFile = this.UserData.LanguageFile; } if (!string.IsNullOrEmpty(this.UserData.CultureUser)) { culture4tag = this.UserData.CultureUser; } // Get first default full culture from a language file tag. string langFileCulture = StaticDataHelper.CultureDefaultFromFile(languageFile); // If 2-letter language code is the same we return Culture, else we return a default full culture from language file ListItem foundCultItem = this.Culture.Items.FindByValue((langFileCulture.Substring(0, 2) == culture4tag.Substring(0, 2) ? culture4tag : langFileCulture)); if (foundCultItem != null) { foundCultItem.Selected = true; } }