예제 #1
0
        /// <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>
        /// 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;
        }
예제 #3
0
        /// <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>();

            // create list boxes by populating datasources 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.FileExtensionAllow.DataSource     = StaticDataHelper.AllowDisallow();
            this.FileExtensionAllow.DataTextField  = "Text";
            this.FileExtensionAllow.DataValueField = "Value";

            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(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);

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