コード例 #1
0
ファイル: polledit.ascx.cs プロジェクト: ggagnaux/YAFNET
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            this.PollExpire.Attributes.Add("style", "width:50px");

            this.InitializeVariables();

            this.PollObjectRow1.Visible = (this.PageContext.IsAdmin || this.Get <YafBoardSettings>().AllowUsersImagedPoll) &&
                                          this.PageContext.ForumPollAccess;

            if (int.TryParse(this.PollExpire.Text.Trim(), out this._daysPollExpire))
            {
                this._datePollExpire = DateTime.UtcNow.AddDays(this._daysPollExpire);
            }

            if (this.IsPostBack)
            {
                return;
            }

            this.AddPageLinks();

            // Admin can attach an existing group if it's a new poll - this.pollID <= 0
            if (!this.PageContext.IsAdmin && !this.PageContext.ForumModeratorAccess)
            {
                return;
            }

            var pollGroup =
                LegacyDb.PollGroupList(this.PageContext.PageUserID, null, this.PageContext.PageBoardID).Distinct(
                    new AreEqualFunc <TypedPollGroup>((id1, id2) => id1.PollGroupID == id2.PollGroupID)).ToList();

            pollGroup.Insert(0, new TypedPollGroup(string.Empty, -1));

            this.PollGroupListDropDown.Items.AddRange(
                pollGroup.Select(x => new ListItem(x.Question, x.PollGroupID.ToString())).ToArray());

            this.PollGroupListDropDown.DataBind();
            this.PollGroupList.Visible = true;
        }
コード例 #2
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>();

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