Beispiel #1
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="EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (this.IsPostBack)
            {
                return;
            }

            this.LoadingImage.ImageUrl = YafForumInfo.GetURLToContent("images/loader.gif");

            // Check and see if it should make panels enable or not
            this.PanelReindex.Visible      = LegacyDb.PanelReindex;
            this.PanelShrink.Visible       = LegacyDb.PanelShrink;
            this.PanelRecoveryMode.Visible = LegacyDb.PanelRecoveryMode;
            this.PanelGetStats.Visible     = LegacyDb.PanelGetStats;

            this.Shrink.ReturnConfirmText       = this.GetText("ADMIN_REINDEX", "CONFIRM_SHRINK");
            this.Reindex.ReturnConfirmText      = this.GetText("ADMIN_REINDEX", "CONFIRM_REINDEX");
            this.RecoveryMode.ReturnConfirmText = this.GetText("ADMIN_REINDEX", "CONFIRM_RECOVERY");

            this.RadioButtonList1.Items.Add(new ListItem(this.GetText("ADMIN_REINDEX", "RECOVERY1")));
            this.RadioButtonList1.Items.Add(new ListItem(this.GetText("ADMIN_REINDEX", "RECOVERY2")));
            this.RadioButtonList1.Items.Add(new ListItem(this.GetText("ADMIN_REINDEX", "RECOVERY3")));

            this.RadioButtonList1.SelectedIndex = 0;

            this.BindData();
        }
Beispiel #2
0
        /// <summary>
        /// Gets all jQuery-UI Themes
        /// </summary>
        /// <returns>
        /// Returns a Data Table with all jQuery-UI Themes
        /// </returns>
        public static DataTable JqueryUIThemes()
        {
            using (var dt = new DataTable("JqueryUIThemes"))
            {
                dt.Columns.Add("Theme", typeof(string));

                var themeDir = new DirectoryInfo(HttpContext.Current.Request.MapPath(YafForumInfo.GetURLToResource("css/jquery-ui-themes")));

                foreach (DirectoryInfo dir in themeDir.GetDirectories())
                {
                    try
                    {
                        DataRow dr = dt.NewRow();
                        dr["Theme"] = dir.Name;

                        dt.Rows.Add(dr);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                }

                return(dt);
            }
        }
Beispiel #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="EventArgs" /> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Type csType = typeof(Page);

                if (!YafContext.Current.Get <YafBoardSettings>().ShowRelativeTime)
                {
                    return;
                }

                var uRLToResource = Config.JQueryFile;

                if (!uRLToResource.StartsWith("http"))
                {
                    uRLToResource = YafForumInfo.GetURLToResource(Config.JQueryFile);
                }

                ScriptManager.RegisterClientScriptInclude(this, csType, "JQuery", uRLToResource);

                ScriptManager.RegisterClientScriptInclude(
                    this, csType, "jqueryTimeagoscript", YafForumInfo.GetURLToResource("js/jquery.timeago.js"));

                ScriptManager.RegisterStartupScript(this, csType, "timeagoloadjs", JavaScriptBlocks.TimeagoLoadJs, true);
            }
            catch (Exception)
            {
                this.Response.Redirect("~/forum/install/default.aspx");
            }
        }
Beispiel #4
0
        /// <summary>
        /// The On PreRender event.
        /// </summary>
        /// <param name="e">
        /// the Event Arguments
        /// </param>
        protected override void OnPreRender([NotNull] EventArgs e)
        {
            this.LoadingImage.ImageUrl      = YafForumInfo.GetURLToContent("images/loader.gif");
            this.LoadingImage.AlternateText = this.Get <ILocalization>().GetText("COMMON", "LOADING");
            this.LoadingImage.ToolTip       = this.Get <ILocalization>().GetText("COMMON", "LOADING");

            base.OnPreRender(e);
        }
        /// <summary>
        /// The on pre render.
        /// </summary>
        /// <param name="e">
        /// The e.
        /// </param>
        protected override void OnPreRender([NotNull] EventArgs e)
        {
            this._okayButton.Text = this.GetText("COMMON", "OK");

            // add js for client-side error settings...
            string jsFunction;

            if (this.Get <YafBoardSettings>().MessageNotificationSystem.Equals(0))
            {
                // Show as Modal Dialog
                jsFunction =
                    @"function {2}(newErrorStr, newErrorType) {{  if (newErrorStr != null && newErrorStr != """" && {4}('#{1}') != null) {{
                     {4}('#{1}').html(newErrorStr);
                     {4}().YafModalDialog.Show({{Dialog : '#{0}',ImagePath : '{3}', Type : newErrorType}});
                }} }}"
                    .FormatWith(
                        this.ClientID,
                        this.MainTextClientID,
                        this.ShowModalFunction,
                        YafForumInfo.GetURLToContent("images/"),
                        Config.JQueryAlias);
            }
            else
            {
                // Show as Notification Bar
                jsFunction =
                    @"function {2}(newErrorStr, newErrorType) {{ if (newErrorStr != null && newErrorStr != """") {{
                      showNotification({{
                            type : newErrorType,
                            message: newErrorStr,
                            autoClose: true,
                            duration: {4},
                            imagepath : '{3}'
                        }});}} }}"
                    .FormatWith(
                        this.ClientID,
                        this.MainTextClientID,
                        this.ShowModalFunction,
                        YafForumInfo.GetURLToContent("icons/"),
                        this.Get <YafBoardSettings>().MessageNotifcationDuration,
                        Config.JQueryAlias);
            }

            // Override Notification Setting if Mobile Device is used
            if (this.Get <YafBoardSettings>().NotifcationNativeOnMobile&& this.Get <HttpRequestBase>().Browser.IsMobileDevice)
            {
                // Show as Modal Dialog
                jsFunction =
                    @"function {2}(newErrorStr) {{  if (newErrorStr != null && newErrorStr != """") {{ 
                                                    alert(newErrorStr);
                      }} }}"
                    .FormatWith(this.ClientID, this.MainTextClientID, this.ShowModalFunction);
            }

            YafContext.Current.PageElements.RegisterJsBlock(this, this.ShowModalFunction, jsFunction);

            base.OnPreRender(e);
        }
Beispiel #6
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)
            {
                return;
            }

            this.LoadingImage.ImageUrl = YafForumInfo.GetURLToContent("images/loader.gif");

            // Check and see if it should make panels enable or not
            this.PanelReindex.Visible      = LegacyDb.PanelReindex;
            this.PanelShrink.Visible       = LegacyDb.PanelShrink;
            this.PanelRecoveryMode.Visible = LegacyDb.PanelRecoveryMode;
            this.PanelGetStats.Visible     = LegacyDb.PanelGetStats;

            // Get the name of buttons
            this.btnReindex.Text =
                "<i class=\"fa fa-database fa-fw\"></i>&nbsp;{0}".FormatWith(
                    this.GetText("ADMIN_REINDEX", "REINDEXTBL_BTN"));
            this.btnGetStats.Text =
                "<i class=\"fa fa-database fa-fw\"></i>&nbsp;{0}".FormatWith(
                    this.GetText("ADMIN_REINDEX", "TBLINDEXSTATS_BTN"));
            this.btnShrink.Text =
                "<i class=\"fa fa-database fa-fw\"></i>&nbsp;{0}".FormatWith(
                    this.GetText("ADMIN_REINDEX", "SHRINK_BTN"));
            this.btnRecoveryMode.Text =
                "<i class=\"fa fa-database fa-fw\"></i>&nbsp;{0}".FormatWith(
                    this.GetText("ADMIN_REINDEX", "SETRECOVERY_BTN"));

            this.btnShrink.OnClientClick =
                "return confirm('{0}');".FormatWith(this.GetText("ADMIN_REINDEX", "CONFIRM_SHRINK"));

            this.btnReindex.OnClientClick =
                "return confirm('{0}');".FormatWith(this.GetText("ADMIN_REINDEX", "CONFIRM_REINDEX"));

            this.btnRecoveryMode.OnClientClick =
                "return confirm('{0}');".FormatWith(this.GetText("ADMIN_REINDEX", "CONFIRM_RECOVERY"));

            this.PageLinks.AddLink(this.PageContext.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_REINDEX", "TITLE"), string.Empty);

            this.Page.Header.Title = "{0} - {1}".FormatWith(
                this.GetText("ADMIN_ADMIN", "Administration"),
                this.GetText("ADMIN_REINDEX", "TITLE"));

            this.RadioButtonList1.Items.Add(new ListItem(this.GetText("ADMIN_REINDEX", "RECOVERY1")));
            this.RadioButtonList1.Items.Add(new ListItem(this.GetText("ADMIN_REINDEX", "RECOVERY2")));
            this.RadioButtonList1.Items.Add(new ListItem(this.GetText("ADMIN_REINDEX", "RECOVERY3")));

            this.RadioButtonList1.SelectedIndex = 0;

            this.BindData();
        }
Beispiel #7
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="EventArgs" /> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.IsPostBack)
            {
                this.BindData();

                if (this.Request.QueryString.GetFirstOrDefault("r") != null)
                {
                    var rankId = this.Request.QueryString.GetFirstOrDefaultAs <int>("r");


                    var rank = this.GetRepository <Rank>()
                               .GetSingle(r => r.ID == rankId);

                    var flags = new RankFlags(rank.Flags);
                    this.Name.Text           = rank.Name;
                    this.IsStart.Checked     = flags.IsStart;
                    this.IsLadder.Checked    = flags.IsLadder;
                    this.MinPosts.Text       = rank.MinPosts.ToString();
                    this.PMLimit.Text        = rank.PMLimit.ToString();
                    this.Style.Text          = rank.Style;
                    this.RankPriority.Text   = rank.SortOrder.ToString();
                    this.UsrAlbums.Text      = rank.UsrAlbums.ToString();
                    this.UsrAlbumImages.Text = rank.UsrAlbumImages.ToString();
                    this.UsrSigChars.Text    = rank.UsrSigChars.ToString();
                    this.UsrSigBBCodes.Text  = rank.UsrSigBBCodes;
                    this.UsrSigHTMLTags.Text = rank.UsrSigHTMLTags;
                    this.Description.Text    = rank.Description;

                    var item = this.RankImage.Items.FindByText(rank.RankImage);

                    if (item != null)
                    {
                        item.Selected    = true;
                        this.Preview.Src = "{0}{1}/{2}".FormatWith(
                            YafForumInfo.ForumClientFileRoot,
                            YafBoardFolders.Current.Ranks,
                            rank.RankImage);
                    }
                    else
                    {
                        this.Preview.Src =
                            YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry
                    }
                }
                else
                {
                    this.Preview.Src = YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry
                }
            }

            this.RankImage.Attributes["onchange"] =
                "getElementById('{2}').src='{0}{1}/' + this.value".FormatWith(
                    YafForumInfo.ForumClientFileRoot, YafBoardFolders.Current.Ranks, this.Preview.ClientID);
        }
Beispiel #8
0
        /// <summary>
        /// The page_ load.
        /// </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;
            }

            if (Config.IsAnyPortal)
            {
                this.ImportUsers.Visible = false;
                this.SyncUsers.Visible   = false;
            }

            // intialize since filter items
            this.InitSinceDropdown();

            // set since filter to last item "All time"
            this.Since.SelectedIndex   = this.Since.Items.Count - 1;
            this.LoadingImage.ImageUrl = YafForumInfo.GetURLToContent("images/loader.gif");

            // get list of user groups for filtering
            var groups = this.GetRepository <Group>().List(boardId: this.PageContext.PageBoardID);

            groups.Insert(0, new Group {
                Name = this.GetText("FILTER_NO"), ID = 0
            });

            this.group.DataTextField  = "Name";
            this.group.DataValueField = "ID";

            this.group.DataBind();

            // get list of user ranks for filtering
            using (var dt = LegacyDb.rank_list(this.PageContext.PageBoardID, null))
            {
                // add empty for for no filtering
                var newRow = dt.NewRow();
                newRow["Name"]   = this.GetText("FILTER_NO");
                newRow["RankID"] = 0;
                dt.Rows.InsertAt(newRow, 0);

                this.rank.DataSource     = dt;
                this.rank.DataTextField  = "Name";
                this.rank.DataValueField = "RankID";
                this.rank.DataBind();
            }

            // TODO : page size difinable?
            this.PagerTop.PageSize = 25;

            // Hide "New User" & Sync Button on DotNetNuke
            this.ImportAndSyncHolder.Visible = !Config.IsDotNetNuke;

            this.BindData();
        }
        /// <summary>
        /// Registers a Javascript resource include using the script manager.
        /// </summary>
        /// <param name="thisControl">
        /// The this Control.
        /// </param>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="relativeResourceUrl">
        /// The relative Resource Url.
        /// </param>
        public void RegisterJsResourceInclude(Control thisControl, string name, string relativeResourceUrl)
        {
            if (this.PageElementExists(name))
            {
                return;
            }

            ScriptManager.RegisterClientScriptInclude(
                thisControl, thisControl.GetType(), name, YafForumInfo.GetURLToResource(relativeResourceUrl));
            this.AddPageElement(name);
        }
Beispiel #10
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="EventArgs" /> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.IsPostBack)
            {
                this.BindData();

                if (this.Request.QueryString.GetFirstOrDefault("r") != null)
                {
                    using (
                        var dt = LegacyDb.rank_list(
                            this.PageContext.PageBoardID, this.Request.QueryString.GetFirstOrDefault("r")))
                    {
                        var row   = dt.Rows[0];
                        var flags = new RankFlags(row["Flags"]);
                        this.Name.Text           = (string)row["Name"];
                        this.IsStart.Checked     = flags.IsStart;
                        this.IsLadder.Checked    = flags.IsLadder;
                        this.MinPosts.Text       = row["MinPosts"].ToString();
                        this.PMLimit.Text        = row["PMLimit"].ToString();
                        this.Style.Text          = row["Style"].ToString();
                        this.RankPriority.Text   = row["SortOrder"].ToString();
                        this.UsrAlbums.Text      = row["UsrAlbums"].ToString();
                        this.UsrAlbumImages.Text = row["UsrAlbumImages"].ToString();
                        this.UsrSigChars.Text    = row["UsrSigChars"].ToString();
                        this.UsrSigBBCodes.Text  = row["UsrSigBBCodes"].ToString();
                        this.UsrSigHTMLTags.Text = row["UsrSigHTMLTags"].ToString();
                        this.Description.Text    = row["Description"].ToString();

                        var item = this.RankImage.Items.FindByText(row["RankImage"].ToString());

                        if (item != null)
                        {
                            item.Selected    = true;
                            this.Preview.Src = "{0}{1}/{2}".FormatWith(
                                YafForumInfo.ForumClientFileRoot, YafBoardFolders.Current.Ranks, row["RankImage"]);
                        }
                        else
                        {
                            this.Preview.Src = YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry
                        }
                    }
                }
                else
                {
                    this.Preview.Src = YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry
                }
            }

            this.RankImage.Attributes["onchange"] =
                "getElementById('{2}').src='{0}{1}/' + this.value".FormatWith(
                    YafForumInfo.ForumClientFileRoot, YafBoardFolders.Current.Ranks, this.Preview.ClientID);
        }
Beispiel #11
0
        /// <summary>
        /// The add script reference.
        /// </summary>
        /// <param name="name">
        /// The name.
        /// </param>
        /// <param name="path">
        /// The path.
        /// </param>
        public void AddScriptReference(string name, string path)
        {
            ScriptManager.ScriptResourceMapping.AddDefinition(
                name,
                new ScriptResourceDefinition
            {
                Path = YafForumInfo.GetURLToScripts(path)
            });

            this.AddScriptReference(new ScriptReference {
                Name = name
            });
        }
Beispiel #12
0
        /// <summary>
        /// The On PreRender event.
        /// </summary>
        /// <param name="e">
        /// the Event Arguments
        /// </param>
        protected override void OnPreRender([NotNull] EventArgs e)
        {
            this.LoadingImage.ImageUrl      = YafForumInfo.GetURLToContent("images/loader.gif");
            this.LoadingImage.AlternateText = this.Get <ILocalization>().GetText("COMMON", "LOADING");
            this.LoadingImage.ToolTip       = this.Get <ILocalization>().GetText("COMMON", "LOADING");

            this.LoadingText.Text = this.Get <ILocalization>().GetText("COMMON", "LOADING");

            // Setup Pagination js
            YafContext.Current.PageElements.RegisterJsBlock("paginationloadjs", JavaScriptBlocks.PaginationLoadJs);

            base.OnPreRender(e);
        }
Beispiel #13
0
        /// <summary>
        /// Add Flag Images to Items
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        protected override void Render(HtmlTextWriter writer)
        {
            foreach (ListItem item in this.Items.Cast <ListItem>().Where(item => item.Value.IsSet()))
            {
                item.Attributes.Add("data-class", "customicon");
                item.Attributes.Add(
                    "data-style",
                    "background-image: url('{0}');".FormatWith(
                        YafForumInfo.GetURLToContent("images/flags/{0}.png").FormatWith(item.Value)));
            }

            base.Render(writer);
        }
Beispiel #14
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)
        {
            this.PageContext.PageElements.RegisterJQuery();
            this.PageContext.PageElements.RegisterJsResourceInclude("blockUIJs", "js/jquery.blockUI.js");

            if (!this.IsPostBack)
            {
                // create page links
                this.CreatePageLinks();

                // intialize since filter items
                this.InitSinceDropdown();

                // set since filter to last item "All time"
                this.Since.SelectedIndex   = this.Since.Items.Count - 1;
                this.LoadingImage.ImageUrl = YafForumInfo.GetURLToResource("images/loading-white.gif");

                // get list of user groups for filtering
                using (DataTable dt = DB.group_list(this.PageContext.PageBoardID, null))
                {
                    // add empty item for no filtering
                    DataRow newRow = dt.NewRow();
                    newRow["Name"]    = string.Empty;
                    newRow["GroupID"] = DBNull.Value;
                    dt.Rows.InsertAt(newRow, 0);
                    this.group.DataSource     = dt;
                    this.group.DataTextField  = "Name";
                    this.group.DataValueField = "GroupID";
                    this.group.DataBind();
                }

                // get list of user ranks for filtering
                using (DataTable dt = DB.rank_list(this.PageContext.PageBoardID, null))
                {
                    // add empty for for no filtering
                    DataRow newRow = dt.NewRow();
                    newRow["Name"]   = string.Empty;
                    newRow["RankID"] = DBNull.Value;
                    dt.Rows.InsertAt(newRow, 0);

                    this.rank.DataSource     = dt;
                    this.rank.DataTextField  = "Name";
                    this.rank.DataValueField = "RankID";
                    this.rank.DataBind();
                }

                // TODO : page size difinable?
                this.PagerTop.PageSize = 25;
            }
        }
Beispiel #15
0
        /// <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)
        {
            PageContext.PageElements.RegisterJQuery();
            PageContext.PageElements.RegisterJsResourceInclude("blockUIJs", "js/jquery.blockUI.js");

            if (!IsPostBack)
            {
                this.LoadingImage.ImageUrl = YafForumInfo.GetURLToResource("images/loading-white.gif");

                this.PageLinks.AddLink(PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                this.PageLinks.AddLink("Administration", YafBuildLink.GetLink(ForumPages.admin_admin));
                this.PageLinks.AddLink("Forums", string.Empty);

                BindData();
            }
        }
Beispiel #16
0
        /// <summary>
        /// Register the CSS Files in the header.
        /// </summary>
        /// <param name="version">
        /// The version.
        /// </param>
        private void RegisterCssFiles(int version)
        {
            var element = YafContext.Current.CurrentForumPage.TopPageControl;

            element.Controls.Add(
                ControlHelper.MakeCssIncludeControl(
                    $"{this.Get<ITheme>().BuildThemePath("bootstrap-forum.min.css")}?v={version}"));

            // make the style sheet link controls.
            element.Controls.Add(
                ControlHelper.MakeCssIncludeControl(
                    YafForumInfo.GetURLToContent(
                        this.PageContext.CurrentForumPage.IsAdminPage
                            ? $"forum-admin.min.css?v={version}"
                            : $"forum.min.css?v={version}")));
        }
Beispiel #17
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            DataRow row;

            using (var dt = this.GetRepository <Board>().List(this.PageContext.PageBoardID))
            {
                row = dt.Rows[0];
            }

            using (var dt = new DataTable("Files"))
            {
                dt.Columns.Add("FileID", typeof(long));
                dt.Columns.Add("FileName", typeof(string));
                dt.Columns.Add("Description", typeof(string));
                var dr = dt.NewRow();
                dr["FileID"]      = 0;
                dr["FileName"]    = YafForumInfo.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.Request.MapPath($"{YafForumInfo.ForumServerFileRoot}{YafBoardFolders.Current.Logos}"));
                var  files  = dir.GetFiles("*.*");
                long fileID = 1;

                foreach (var file in from file in files
                         let extension = file.Extension.ToLower()
                                         where extension == ".png" || extension == ".gif" || extension == ".jpg" || extension == ".svg"
                                         select file)
                {
                    dr                = dt.NewRow();
                    dr["FileID"]      = fileID++;
                    dr["FileName"]    = $"{YafForumInfo.ForumClientFileRoot}{YafBoardFolders.Current.Logos}/{file.Name}";
                    dr["Description"] = file.Name;
                    dt.Rows.Add(dr);
                }

                this.BoardLogo.DataSource     = dt;
                this.BoardLogo.DataValueField = "FileName";
                this.BoardLogo.DataTextField  = "Description";
            }

            this.DataBind();
            this.Name.Text             = row["Name"].ToString();
            this.AllowThreaded.Checked = Convert.ToBoolean(row["AllowThreaded"]);
        }
Beispiel #18
0
        /// <summary>
        /// Registers the jQuery script library.
        /// </summary>
        private void RegisterJQuery()
        {
            var element = YafContext.Current.CurrentForumPage.TopPageControl;

            if (YafContext.Current.PageElements.PageElementExists("jquery") || Config.DisableJQuery)
            {
                return;
            }

            var registerJQuery = true;

            const string Key = "JQuery-Javascripts";

            // check to see if DotNetAge is around and has registered jQuery for us...
            if (HttpContext.Current.Items[Key] != null)
            {
                var collection = HttpContext.Current.Items[Key] as StringCollection;

                if (collection != null && collection.Contains("jquery"))
                {
                    registerJQuery = false;
                }
            }
            else if (Config.IsDotNetNuke)
            {
                // latest version of DNN (v5) should register jQuery for us...
                registerJQuery = false;
            }

            if (registerJQuery)
            {
                string jqueryUrl;

                // Check if override file is set ?
                if (Config.JQueryOverrideFile.IsSet())
                {
                    jqueryUrl = !Config.JQueryOverrideFile.StartsWith("http") &&
                                !Config.JQueryOverrideFile.StartsWith("//")
                                    ? YafForumInfo.GetURLToScripts(Config.JQueryOverrideFile)
                                    : Config.JQueryOverrideFile;
                }
                else
                {
                    jqueryUrl = YafContext.Current.Get <YafBoardSettings>().JqueryCDNHosted
                                    ? "//ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.4.min.js"
#if DEBUG
                                    : YafForumInfo.GetURLToScripts("jquery-2.1.4.js");
Beispiel #19
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)
        {
            this.PageContext.PageElements.RegisterJQuery();
            this.PageContext.PageElements.RegisterJsResourceInclude("blockUIJs", "js/jquery.blockUI.js");

            if (this.IsPostBack)
            {
                return;
            }

            this.LoadingImage.ImageUrl = YafForumInfo.GetURLToResource("images/loader.gif");

            this.PageLinks.AddRoot();
            this.PageLinks.AddLink(
                this.GetText("ADMIN_ADMIN", "Administration"), YafBuildLink.GetLink(ForumPages.admin_admin));

            this.PageLinks.AddLink(this.GetText("TEAM", "FORUMS"), YafBuildLink.GetLink(ForumPages.admin_forums));
            this.PageLinks.AddLink(this.GetText("ADMIN_DELETEFORUM", "TITLE"), string.Empty);

            this.Page.Header.Title = "{0} - {1} - {2}".FormatWith(
                this.GetText("ADMIN_ADMIN", "Administration"),
                this.GetText("TEAM", "FORUMS"),
                this.GetText("ADMIN_DELETEFORUM", "TITLE"));

            this.Delete.Text = this.GetText("ADMIN_DELETEFORUM", "DELETE_FORUM");
            this.Cancel.Text = this.GetText("CANCEL");

            this.Delete.Attributes["onclick"] =
                "return (confirm('{0}') && confirm('{1}'));".FormatWith(
                    this.GetText("ADMIN_FORUMS", "CONFIRM_DELETE"),
                    this.GetText("ADMIN_FORUMS", "CONFIRM_DELETE_POSITIVE"));

            this.BindData();

            var forumId = this.GetQueryStringAsInt("fa");

            using (DataTable dt = LegacyDb.forum_list(this.PageContext.PageBoardID, forumId.Value))
            {
                DataRow row = dt.Rows[0];

                this.ForumNameTitle.Text = (string)row["Name"];

                // populate parent forums list with forums according to selected category
                this.BindParentList();
            }
        }
Beispiel #20
0
        /// <summary>
        /// Register the JQuery UI library in the header.
        /// </summary>
        /// <param name="element">
        /// Control element to put in
        /// </param>
        public void RegisterJQueryUILanguageFile(Control element)
        {
            // If registered or told not to register, don't bother
            if (this.PageElementExists("datepickerlang"))
            {
                return;
            }

            var url = !Config.JQueryUILangFile.StartsWith("http") && !Config.JQueryUILangFile.StartsWith("//")
                      ? YafForumInfo.GetURLToResource(Config.JQueryUILangFile)
                      : Config.JQueryUILangFile;

            // load jQuery UI from google...
            element.Controls.Add(
                ControlHelper.MakeJsIncludeControl(url));

            this.AddPageElement("datepickerlang");
        }
Beispiel #21
0
        /// <summary>
        /// Inserts the CSS refresh.
        /// </summary>
        /// <param name="addTo">The control to add.</param>
        protected void InsertCssRefresh([NotNull] Control addTo)
        {
            // make the style sheet link controls.
            addTo.Controls.Add(ControlHelper.MakeCssIncludeControl(YafForumInfo.GetURLToResource("css/forum.css")));
            addTo.Controls.Add(ControlHelper.MakeCssIncludeControl(this.Get <ITheme>().BuildThemePath("theme.css")));

            if (this.RefreshURL == null || this.RefreshTime < 0)
            {
                return;
            }

            var refresh = new HtmlMeta
            {
                HttpEquiv = "Refresh", Content = "{1};url={0}".FormatWith(this.RefreshURL, this.RefreshTime)
            };

            addTo.Controls.Add(refresh);
        }
        /// <summary>
        /// Gets HTML IMG code representing given log event icon.
        /// </summary>
        /// <param name="dataRow">
        /// Data row containing event log entry data.
        /// </param>
        /// <returns>
        /// return HTML code of event log entry image
        /// </returns>
        protected string EventImageCode([NotNull] object dataRow)
        {
            // cast object to the DataRowView
            var row = (DataRowView)dataRow;

            // set defaults
            string imageType = Enum.GetName(typeof(EventLogTypes), (int)row["Type"]);

            if (imageType.IsNotSet())
            {
                imageType = "Error";
            }

            // return HTML code of event log entry image
            return
                (@"<img src=""{0}"" alt=""{1}"" title=""{1}"" />".FormatWith(
                     YafForumInfo.GetURLToContent("icons/{0}.png".FormatWith(imageType.ToLowerInvariant())), imageType));
        }
        /// <summary>
        /// The render.
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        protected override void Render([NotNull] HtmlTextWriter writer)
        {
            if (!this.Visible)
            {
                return;
            }

            var sb = new StringBuilder();

            sb.AppendFormat(
                @"<div class=""AttachmentListMenu dropdown-item"" id=""{0}"">",
                this.ClientID);

            sb.Append("<div id=\"AttachmentsListBox\" class=\"content\">");

            sb.Append("<div id=\"AttachmentsListPager\"></div>");
            sb.Append("<div id=\"PostAttachmentLoader\">");
            sb.AppendFormat(
                "<p style=\"text-align:center\"><span>{1}</span><br /><img title=\"{1}\" src=\"{0}\" alt=\"{1}\" /></p>",
                YafForumInfo.GetURLToContent("images/loader.gif"),
                this.Get <ILocalization>().GetText("COMMON", "LOADING"));
            sb.Append("</div>");
            sb.Append("<div id=\"AttachmentsListBox\" class=\"content\">");
            sb.AppendFormat(
                "<div id=\"PostAttachmentListPlaceholder\" data-url=\"{0}\" data-userid=\"{1}\" data-notext=\"{2}\" style=\"clear: both;\">",
                YafForumInfo.ForumClientFileRoot,
                YafContext.Current.PageUserID,
                this.Get <ILocalization>().GetText("ATTACHMENTS", "NO_ATTACHMENTS"));
            sb.Append("<ul class=\"AttachmentList\">");
            sb.Append("</ul>");
            sb.Append("</div>");
            sb.Append("<div class=\"m-x-auto OpenUploadDialog\">");
            sb.AppendFormat(
                "<button type=\"button\" class=\"btn btn-primary btn-sm\" data-toggle=\"modal\" data-target=\".UploadDialog\">{0}</button>",
                this.Get <ILocalization>().GetText("ATTACHMENTS", "UPLOAD_NEW"));
            sb.Append("</div>");

            sb.Append("</div>");
            sb.AppendFormat("</div>");

            writer.WriteLine(sb.ToString());

            base.Render(writer);
        }
Beispiel #24
0
        /// <summary>
        /// The create images data table.
        /// </summary>
        protected void CreateImagesDataTable()
        {
            using (var dt = new DataTable("Files"))
            {
                dt.Columns.Add("FileID", typeof(long));
                dt.Columns.Add("FileName", typeof(string));
                dt.Columns.Add("Description", typeof(string));
                var dr = dt.NewRow();
                dr["FileID"]   = 0;
                dr["FileName"] =
                    YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry
                dr["Description"] = this.GetText("COMMON", "NONE");
                dt.Rows.Add(dr);

                var dir = new DirectoryInfo(
                    this.Request.MapPath($"{YafForumInfo.ForumServerFileRoot}{YafBoardFolders.Current.Forums}"));
                if (dir.Exists)
                {
                    var  files  = dir.GetFiles("*.*");
                    long fileId = 1;

                    var filesList = from file in files
                                    let sExt = file.Extension.ToLower()
                                               where sExt == ".png" || sExt == ".gif" || sExt == ".jpg"
                                               select file;

                    filesList.ForEach(
                        file =>
                    {
                        dr             = dt.NewRow();
                        dr["FileID"]   = fileId++;
                        dr["FileName"] =
                            $"{YafForumInfo.ForumClientFileRoot}{YafBoardFolders.Current.Forums}/{file.Name}";
                        dr["Description"] = file.Name;
                        dt.Rows.Add(dr);
                    });
                }

                this.ForumImages.DataSource     = dt;
                this.ForumImages.DataValueField = "FileName";
                this.ForumImages.DataTextField  = "Description";
                this.ForumImages.DataBind();
            }
        }
Beispiel #25
0
        /// <summary>
        /// Change Smiley Image Preview
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void ChangePreview(object sender, EventArgs e)
        {
            if (this.Icon.SelectedValue == null)
            {
                return;
            }

            this.Icon.ImageLocation = "{0}{1}/{2}".FormatWith(
                YafForumInfo.ForumClientFileRoot,
                YafBoardFolders.Current.Emoticons,
                "{0}");

            this.Preview.Src = this.Icon.SelectedValue.IsSet()
                                   ? "{0}{1}/{2}".FormatWith(
                YafForumInfo.ForumClientFileRoot,
                YafBoardFolders.Current.Emoticons,
                this.Icon.SelectedValue)
                                   : YafForumInfo.GetURLToContent("images/spacer.gif");
        }
Beispiel #26
0
        /// <summary>
        /// Select image in dropdown list and sets appropriate preview.
        /// </summary>
        /// <param name="list">
        /// DropDownList where to search.
        /// </param>
        /// <param name="preview">
        /// Preview image.
        /// </param>
        /// <param name="imageUrl">
        /// URL to search for.
        /// </param>
        private void SelectImage([NotNull] DropDownList list, [NotNull] HtmlImage preview, [NotNull] string imageUrl)
        {
            // try to find item in a list
            var item = list.Items.FindByText(imageUrl);

            if (item != null)
            {
                // select found item
                item.Selected = true;

                // set preview image
                preview.Src = $"{YafForumInfo.ForumClientFileRoot}{YafBoardFolders.Current.Medals}/{imageUrl}";
            }
            else
            {
                // if we found nothing, set blank image as preview
                preview.Src = YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry
            }
        }
        /// <summary>
        /// Register jQuery
        /// </summary>
        /// <param name="element">
        /// The element.
        /// </param>
        public void RegisterJQuery(Control element)
        {
            if (this.PageElementExists("jquery") || Config.DisableJQuery)
            {
                return;
            }

            bool registerJQuery = true;

            const string Key = "JQuery-Javascripts";

            // check to see if DotNetAge is around and has registered jQuery for us...
            if (HttpContext.Current.Items[Key] != null)
            {
                var collection = HttpContext.Current.Items[Key] as StringCollection;

                if (collection != null && collection.Contains("jquery"))
                {
                    registerJQuery = false;
                }
            }
            else if (Config.IsDotNetNuke)
            {
                // latest version of DNN (v5) should register jQuery for us...
                registerJQuery = false;
            }

            if (registerJQuery)
            {
                var url = Config.JQueryFile;

                if (!url.StartsWith("http") && !url.StartsWith("//"))
                {
                    url = YafForumInfo.GetURLToResource(Config.JQueryFile);
                }

                // load jQuery
                element.Controls.Add(ControlHelper.MakeJsIncludeControl(url));
            }

            this.AddPageElement("jquery");
        }
Beispiel #28
0
        /// <summary>
        /// The create images data table.
        /// </summary>
        protected void CreateImagesDataTable()
        {
            using (var dt = new DataTable("Files"))
            {
                dt.Columns.Add("FileID", typeof(long));
                dt.Columns.Add("FileName", typeof(string));
                dt.Columns.Add("Description", typeof(string));
                DataRow dr = dt.NewRow();
                dr["FileID"]      = 0;
                dr["FileName"]    = YafForumInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry
                dr["Description"] = "None";
                dt.Rows.Add(dr);

                var dir =
                    new DirectoryInfo(
                        this.Request.MapPath(
                            "{0}{1}".FormatWith(YafForumInfo.ForumServerFileRoot, YafBoardFolders.Current.Categories)));
                if (dir.Exists)
                {
                    FileInfo[] files   = dir.GetFiles("*.*");
                    long       nFileID = 1;

                    foreach (FileInfo file in from file in files
                             let sExt = file.Extension.ToLower()
                                        where sExt == ".png" || sExt == ".gif" || sExt == ".jpg"
                                        select file)
                    {
                        dr                = dt.NewRow();
                        dr["FileID"]      = nFileID++;
                        dr["FileName"]    = file.Name;
                        dr["Description"] = file.Name;
                        dt.Rows.Add(dr);
                    }
                }

                this.CategoryImages.DataSource     = dt;
                this.CategoryImages.DataValueField = "FileName";
                this.CategoryImages.DataTextField  = "Description";
                this.CategoryImages.DataBind();
            }
        }
Beispiel #29
0
        /// <summary>
        /// Handles the PreRender event of the CurrentForumPage control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void CurrentForumPagePreRender([NotNull] object sender, [NotNull] EventArgs e)
        {
            this.RegisterJQuery();

            if (this.PageContext.Vars.ContainsKey("yafForumExtensions"))
            {
                return;
            }

            var version = this.Get <YafBoardSettings>().CdvVersion;

            ScriptManager.ScriptResourceMapping.AddDefinition(
                "yafForumAdminExtensions",
                new ScriptResourceDefinition
            {
                Path      = YafForumInfo.GetURLToScripts($"jquery.ForumAdminExtensions.min.js?v={version}"),
                DebugPath = YafForumInfo.GetURLToScripts($"jquery.ForumAdminExtensions.js?v={version}")
            });

            ScriptManager.ScriptResourceMapping.AddDefinition(
                "yafForumExtensions",
                new ScriptResourceDefinition
            {
                Path      = YafForumInfo.GetURLToScripts($"jquery.ForumExtensions.min.js?v={version}"),
                DebugPath = YafForumInfo.GetURLToScripts($"jquery.ForumExtensions.js?v={version}")
            });

            ScriptManager.ScriptResourceMapping.AddDefinition(
                "FileUploadScript",
                new ScriptResourceDefinition
            {
                Path      = YafForumInfo.GetURLToScripts("jquery.fileupload.comb.min.js"),
                DebugPath = YafForumInfo.GetURLToScripts("jquery.fileupload.comb.js")
            });

            YafContext.Current.PageElements.AddScriptReference(
                this.PageContext.CurrentForumPage.IsAdminPage ? "yafForumAdminExtensions" : "yafForumExtensions");

            this.PageContext.Vars["yafForumExtensions"] = true;
        }
        /// <summary>
        /// The render.
        /// </summary>
        /// <param name="writer">
        /// The writer.
        /// </param>
        protected override void Render([NotNull] HtmlTextWriter writer)
        {
            if (!this.Visible)
            {
                return;
            }

            var sb = new StringBuilder();

            sb.AppendFormat(
                @"<div class=""yafpopupmenu AttachmentListMenu"" id=""{0}"" style=""position:absolute;z-index:100;left:0;top:0;display:none;"">",
                this.ClientID);

            sb.Append("<div id=\"AttachmentsListBox\" class=\"content\">");

            sb.Append("<div id=\"AttachmentsListPager\"></div>");
            sb.Append("<div id=\"PostAttachmentLoader\">");
            sb.AppendFormat(
                "<p style=\"text-align:center\"><span>{1}</span><br /><img title=\"{1}\" src=\"{0}\" alt=\"{1}\" /></p>",
                YafForumInfo.GetURLToContent("images/loader.gif"),
                this.Get <ILocalization>().GetText("COMMON", "LOADING"));
            sb.Append("</div>");
            sb.Append("<div id=\"AttachmentsListBox\" class=\"content\">");
            sb.AppendFormat(
                "<div id=\"PostAttachmentListPlaceholder\" data-url=\"{0}\" style=\"clear: both;\">",
                YafForumInfo.ForumClientFileRoot);
            sb.Append("<ul class=\"AttachmentList\">");
            sb.Append("</ul>");
            sb.Append("</div>");
            sb.AppendFormat(
                "<span class=\"UploadNewFileLine\"><a class=\"OpenUploadDialog yaflittlebutton\" onclick=\"jQuery('.UploadDialog').dialog('open');\"><span>{0}</span></a></span>",
                this.Get <ILocalization>().GetText("ATTACHMENTS", "UPLOAD_NEW"));

            sb.Append("</div>");
            sb.AppendFormat("</div>");

            writer.WriteLine(sb.ToString());

            base.Render(writer);
        }