コード例 #1
0
ファイル: ForumLinkController.cs プロジェクト: zhdwwf/wojilu
        public void Update(int id)
        {
            ForumLink link = linkService.GetById(id, ctx.owner.obj);

            if (link == null)
            {
                echoRedirect(lang("exDataNotFound"));
                return;
            }

            link = ForumValidator.ValidateLink(link, ctx);
            if (errors.HasErrors)
            {
                run(Edit, id);
                return;
            }

            Result result = linkService.Update(link);

            if (result.HasErrors)
            {
                errors.Join(result);
                run(Edit, id);
                return;
            }

            logService.Add((User)ctx.viewer.obj, ctx.app.Id, alang("logEditLink") + ":" + link.Name, ctx.Ip);
            redirect(List);
        }
コード例 #2
0
        protected void SaveFriend_Click(object sender, EventArgs e)
        {
            int  num  = 0;
            bool flag = false;

            foreach (object current in this.DataGrid1.GetKeyIDArray())
            {
                int    displayorder = int.Parse(this.DataGrid1.GetControlValue(num, "displayorder"));
                string name         = this.DataGrid1.GetControlValue(num, "name").Trim();
                string url          = this.DataGrid1.GetControlValue(num, "url").Trim();
                string note         = this.DataGrid1.GetControlValue(num, "note").Trim();
                string logo         = this.DataGrid1.GetControlValue(num, "logo").Trim();

                var lnk = ForumLink.FindByID(int.Parse(current.ToString()));
                if (lnk != null)
                {
                    lnk.DisplayOrder = displayorder;
                    lnk.Name         = name;
                    lnk.Url          = url;
                    lnk.Note         = note;
                    lnk.Logo         = logo;
                    lnk.Save();

                    num++;
                }
            }
            AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "批量更新友情链接", "");
            XCache.Remove(CacheKeys.FORUM_FORUM_LINK_LIST);
            if (flag)
            {
                base.RegisterStartupScript("PAGE", "alert('某些信息不完整,未能更新!');window.location.href='global_forumlinksgrid.aspx';");
                return;
            }
            base.RegisterStartupScript("PAGE", "window.location.href='global_forumlinksgrid.aspx';");
        }
コード例 #3
0
ファイル: ForumLinkController.cs プロジェクト: zhdwwf/wojilu
        public void SaveSort()
        {
            int    id  = ctx.PostInt("id");
            String cmd = ctx.Post("cmd");

            ForumLink link = linkService.GetById(id, ctx.owner.obj);

            if (link == null)
            {
                echoRedirect(lang("exDataNotFound"));
                return;
            }

            List <ForumLink> list = linkService.GetByApp(ctx.app.Id, ctx.owner.Id);

            if (cmd == "up")
            {
                new SortUtil <ForumLink>(link, list).MoveUp();
                echoJsonOk();
            }
            else if (cmd == "down")
            {
                new SortUtil <ForumLink>(link, list).MoveDown();
                echoJsonOk();
            }
            else
            {
                echoError(lang("exUnknowCmd"));
            }
        }
コード例 #4
0
        private void DelRec_Click(object sender, EventArgs e)
        {
            if (base.CheckCookie())
            {
                if (Request["delid"] != "")
                {
                    //ForumLinks.DeleteForumLink(Request["delid"]);
                    //var ids = TypeConverter.StringToIntArray(Request["delid"]);
                    var ids = Request["delid"].SplitAsInt(",");
                    //var link = ForumLink.FindByID(WebHelper.RequestInt("delid"));
                    //if (link != null) link.Delete();
                    var links = ForumLink.FindAllByIds(ids);
                    if (links != null && links.Count > 0)
                    {
                        links.Delete();
                    }

                    AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "删除友情链接", "删除友情链接,ID为: " + Request["delid"].Replace("0 ", ""));
                    XCache.Remove(CacheKeys.FORUM_FORUM_LINK_LIST);
                    base.Response.Redirect("global_forumlinksgrid.aspx");
                    return;
                }
                base.RegisterStartupScript("", "<script>alert('您未选中任何选项');window.location.href='global_forumlinksgrid.aspx';</script>");
            }
        }
コード例 #5
0
        public void BindData()
        {
            this.DataGrid1.AllowCustomPaging = false;
            this.DataGrid1.TableHeaderName   = "友情链接列表";
            DataTable forumLinks = ForumLink.FindAllWithCache().ToDataTable();
            DataTable dataTable  = forumLinks.Clone();

            dataTable.Rows.Clear();
            string[] array = new string[]
            {
                "note",
                "logo",
                ""
            };
            string[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                string text = array2[i];
                foreach (DataRow dataRow in forumLinks.Rows)
                {
                    DataRow dataRow2 = dataTable.NewRow();
                    dataRow2.ItemArray = dataRow.ItemArray;
                    string a;
                    if ((a = text) != null)
                    {
                        if (!(a == "note"))
                        {
                            if (a == "logo")
                            {
                                if (!dataRow["logo"].ToString().IsNullOrEmpty() && String.IsNullOrEmpty(dataRow["note"].ToString().Trim()))
                                {
                                    dataTable.Rows.Add(dataRow2);
                                    continue;
                                }
                                continue;
                            }
                        }
                        else
                        {
                            if (!dataRow["note"].ToString().IsNullOrEmpty())
                            {
                                dataTable.Rows.Add(dataRow2);
                                continue;
                            }
                            continue;
                        }
                    }
                    if (String.IsNullOrEmpty(dataRow["logo"].ToString().Trim()) && String.IsNullOrEmpty(dataRow["note"].ToString().Trim()))
                    {
                        dataTable.Rows.Add(dataRow2);
                    }
                }
            }
            this.DataGrid1.BindData(dataTable);
        }
コード例 #6
0
ファイル: ForumLinkController.cs プロジェクト: zhdwwf/wojilu
        public void Delete(int id)
        {
            ForumLink link = linkService.GetById(id, ctx.owner.obj);

            if (link == null)
            {
                echoRedirect(lang("exDataNotFound"));
                return;
            }

            linkService.Delete(link);
            redirect(List);
        }
コード例 #7
0
        private static void updatePost(ForumLink post)
        {
            if (post.OwnerType != typeof(Site).FullName)
            {
                return;
            }

            IMember owner = Site.Instance;
            int     appId = post.AppId;

            //LayoutViewCacher.Update( owner, appId );
            IndexViewCacher.Update(owner, appId);
        }
コード例 #8
0
ファイル: ForumLinkController.cs プロジェクト: zhdwwf/wojilu
        public void Edit(int id)
        {
            view("New");
            ForumLink link = linkService.GetById(id, ctx.owner.obj);

            if (link == null)
            {
                echoRedirect(lang("exDataNotFound"));
                return;
            }

            bind("link", link);
            target(Update, id);
        }
コード例 #9
0
        public static ForumLink ValidateLink(ForumLink link, MvcContext ctx)
        {
            if (link == null)
            {
                link = new ForumLink();
            }

            String name        = ctx.Post("Name");
            String description = ctx.Post("Description");
            String url         = ctx.Post("Url");
            String logo        = ctx.Post("Logo");

            if (strUtil.IsNullOrEmpty(name))
            {
                ctx.errors.Add(lang.get("exName"));
            }

            if (strUtil.IsNullOrEmpty(url))
            {
                ctx.errors.Add(lang.get("exUrl"));
            }
            else if (!url.ToLower().StartsWith("http://"))
            {
                url = "http://" + url;
            }

            if (strUtil.IsNullOrEmpty(logo))
            {
                ctx.errors.Add(alang(ctx, "exLogo"));
            }
            else if (!logo.ToLower().StartsWith("http://"))
            {
                logo = "http://" + logo;
            }

            link.Name        = name;
            link.Description = description;
            link.Url         = url;
            link.Logo        = logo;
            link.AppId       = ctx.app.Id;
            link.OwnerId     = ctx.owner.Id;
            link.OwnerType   = ctx.owner.obj.GetType().FullName;

            return(link);
        }
コード例 #10
0
ファイル: ForumLinkController.cs プロジェクト: zhdwwf/wojilu
        public void Create()
        {
            ForumLink link = ForumValidator.ValidateLink(ctx);

            if (errors.HasErrors)
            {
                run(New);
                return;
            }

            Result result = linkService.Insert(link);

            if (result.HasErrors)
            {
                errors.Join(result);
                run(New);
                return;
            }

            logService.Add((User)ctx.viewer.obj, ctx.app.Id, alang("logAddLink") + ":" + link.Name, ctx.Ip);
            redirect(List);
        }
コード例 #11
0
        public List <ForumLink> getTalarLink()
        {
            var    url = $"https://www.ninisite.com/discussion";
            var    web = new HtmlWeb();
            var    doc = web.Load(url);
            string q1  =
                "//body//div[@class='discussion-section']//div[@class='adtube__content-wrapper']//div[@class='container forum-container text-xl-right']" +
                "//div[@class='row']" +
                "//div[@class='col-xl-9 col-lg-8 pull-xs-right m-b-1 ']";

            var section = doc.DocumentNode.SelectSingleNode(q1).InnerHtml;
            var doc1    = new HtmlDocument();

            doc1.LoadHtml(section);
            //var divs= doc1.DocumentNode.SelectNodes(q2);
            List <ForumLink> forumLinks = new List <ForumLink>();

            var childDivs = doc1.DocumentNode.SelectNodes("//a[@class='category--title']");

            for (int i = 0; i < childDivs.Count; i++)
            {
                ForumLink forumLink = new ForumLink();

                //talar.id = i;
                forumLink.Name = childDivs[i].InnerText.Replace("\r\n", "").Trim();
                forumLink.URL  = childDivs[i].Attributes["href"].Value;

                forumLink.URL = forumLink.URL.Replace("/discussion/forum/", "");
                int    iSlash = forumLink.URL.IndexOf("/");
                string fid    = forumLink.URL.Substring(0, iSlash);
                forumLink.URL     = $"https://www.ninisite.com/discussion/forum/{fid}/a";
                forumLink.ForumId = int.Parse(fid);
                forumLink.Count   = 0;

                forumLinks.Add(forumLink);
            }
            return(forumLinks);
        }
コード例 #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                this.BindData();
            }
            if (DNTRequest.GetString("displayorder") != "" && DNTRequest.GetString("name") != "")// Request["displayorder"].IsNullOrEmpty() && Request["name"].IsNullOrEmpty())
            {
                Regex regex = new Regex("(http|https)://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?");
                if (!regex.IsMatch(Request["url"].Replace("'", "''")))
                {
                    base.RegisterStartupScript("", "<script>alert('链接地址不是有效的网页地址.');</script>");
                    return;
                }
                try
                {
                    //ForumLinks.CreateForumLink(DNTRequest.GetInt("displayorder", 0), Request["name"], Request["url"], Request["note"], Request["logo"]);

                    var lnk = new ForumLink();
                    lnk.DisplayOrder = WebHelper.RequestInt("displayorder");
                    lnk.Name         = Request["name"];
                    lnk.Url          = Request["url"];
                    lnk.Note         = Request["note"];
                    lnk.Logo         = Request["logo"];
                    lnk.Save();

                    AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "添加友情链接", "添加友情链接,名称为: " + Request["name"]);
                    XCache.Remove(CacheKeys.FORUM_FORUM_LINK_LIST);
                    this.BindData();
                }
                catch
                {
                    base.RegisterStartupScript("", "<script>alert('无法更新数据库');window.location.href='global_forumlinksgrid.aspx';</script>");
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// Open The Dialog
        /// </summary>
        /// <param name="message">
        /// The message text.
        /// </param>
        /// <param name="title">
        /// The Message title.
        /// </param>
        /// <param name="okButton">
        /// The ok button.
        /// </param>
        /// <param name="cancelButton">
        /// The cancel button.
        /// </param>
        public void Show(
            [NotNull] string message,
            [NotNull] string title,
            [NotNull] DialogButton okButton,
            [NotNull] DialogButton cancelButton)
        {
            // Message Header
            this.Header.Text = !string.IsNullOrEmpty(title)
                                   ? title
                                   : this.GetText("COMMON", "MODAL_NOTIFICATION_HEADER");

            // Message Text
            this.MessageText.Text = message;

            // OK/Yes Message Button
            if (okButton != null)
            {
                this.OkButtonLink = okButton.ForumPageLink ??
                                    new ForumLink { ForumPage = YafContext.Current.ForumPageType };

                if (okButton.Text.IsSet())
                {
                    this.OkButton.Text = okButton.Text;
                }
                else
                {
                    okButton.Text = this.GetText("COMMON", "OK");
                }

                this.OkButton.CssClass = okButton.CssClass.IsSet() ? okButton.CssClass : "btn btn-primary";
            }

            // Cancel/No Message Button
            if (cancelButton != null)
            {
                this.CancelButtonLink = cancelButton.ForumPageLink ??
                                        new ForumLink { ForumPage = YafContext.Current.ForumPageType };

                this.CancelButton.Visible = true;

                this.CancelButton.Text = cancelButton.Text.IsSet()
                                             ? cancelButton.Text
                                             : this.GetText("COMMON", "CANCEL");

                this.CancelButton.CssClass = cancelButton.CssClass.IsSet() ? cancelButton.CssClass : "btn btn-secondary";

                if (this.CancelButtonLink.ForumPage.Equals(YafContext.Current.ForumPageType))
                {
                    this.CancelButton.OnClientClick =
                        "jQuery().YafModalDialog.Close({{ Dialog: '#{0}' }});return false;".FormatWith(
                            this.YafForumPageErrorPopup.ClientID);
                }
                else
                {
                    this.CancelButton.OnClientClick =
                        "jQuery().YafModalDialog.Close({{ Dialog: '#{0}' }});".FormatWith(
                            this.YafForumPageErrorPopup.ClientID);
                }
            }
            else
            {
                this.CancelButton.Visible = false;

                this.CancelButtonLink = new ForumLink { ForumPage = YafContext.Current.ForumPageType };
            }

            var script = new StringBuilder();

            script.Append("Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(ShowNotificationPopup);");

            script.AppendFormat(
                "function ShowNotificationPopup() {{ jQuery(document).ready(function() {{jQuery('#{0}').modal('show');return false; }});}}",
                this.YafForumPageErrorPopup.ClientID);

            this.PageContext.PageElements.RegisterJsBlockStartup(this.Page, "PopUp{0}".FormatWith(Guid.NewGuid()), script.ToString());

            if (this.OkButtonLink.ForumPage.Equals(YafContext.Current.ForumPageType))
            {
                this.OkButton.OnClientClick =
                    "jQuery('#{0}').modal('hide');return false;".FormatWith(
                        this.YafForumPageErrorPopup.ClientID);
            }
            else
            {
                this.OkButton.OnClientClick =
                    "jQuery('#{0}').modal('hide');".FormatWith(
                        this.YafForumPageErrorPopup.ClientID);
            }
        }
コード例 #14
0
ファイル: ForumValidator.cs プロジェクト: robin88/wojilu
        public static ForumLink ValidateLink( ForumLink link, MvcContext ctx )
        {
            if (link == null) link = new ForumLink();

            String name = ctx.Post( "Name" );
            String description = ctx.Post( "Description" );
            String url = ctx.Post( "Url" );
            String logo = ctx.Post( "Logo" );

            if (strUtil.IsNullOrEmpty( name )) ctx.errors.Add( lang.get( "exName" ) );

            if (strUtil.IsNullOrEmpty( url ))
                ctx.errors.Add( lang.get( "exUrl" ) );
            else if (!url.ToLower().StartsWith( "http://" ))
                url = "http://" + url;

            if (strUtil.IsNullOrEmpty( logo ))
                ctx.errors.Add( alang( ctx, "exLogo" ) );
            else if (!logo.ToLower().StartsWith( "http://" ))
                logo = "http://" + logo;

            link.Name = name;
            link.Description = description;
            link.Url = url;
            link.Logo = logo;
            link.AppId = ctx.app.Id;
            link.OwnerId = ctx.owner.Id;
            link.OwnerType = ctx.owner.obj.GetType().FullName;

            return link;
        }
コード例 #15
0
        private static void updatePost( ForumLink post )
        {
            if (post.OwnerType != typeof( Site ).FullName) return;

            IMember owner = Site.Instance;
            int appId = post.AppId;

            //LayoutViewCacher.Update( owner, appId );
            IndexViewCacher.Update( owner, appId );
        }
コード例 #16
0
ファイル: ForumLinkService.cs プロジェクト: zuhuizou/wojilu
 public virtual Result Update(ForumLink link)
 {
     return(db.update(link));
 }
コード例 #17
0
ファイル: ForumLinkService.cs プロジェクト: zuhuizou/wojilu
 public virtual Result Insert(ForumLink link)
 {
     return(db.insert(link));
 }
コード例 #18
0
ファイル: ForumLinkService.cs プロジェクト: robin88/wojilu
 public virtual Result Update( ForumLink link )
 {
     return db.update( link );
 }
コード例 #19
0
ファイル: ForumLinkService.cs プロジェクト: zuhuizou/wojilu
 public virtual void Delete(ForumLink link)
 {
     db.delete(link);
 }
コード例 #20
0
ファイル: ForumLinkService.cs プロジェクト: robin88/wojilu
 public virtual Result Insert( ForumLink link )
 {
     return db.insert( link );
 }
コード例 #21
0
ファイル: ForumLinkService.cs プロジェクト: robin88/wojilu
 public virtual void Delete( ForumLink link )
 {
     db.delete( link );
 }
コード例 #22
0
ファイル: DialogBox.ascx.cs プロジェクト: jongchan79/YAFNET
        /// <summary>
        /// Open The Dialog
        /// </summary>
        /// <param name="message">
        /// The message text.
        /// </param>
        /// <param name="title">
        /// The Message title.
        /// </param>
        /// <param name="icon">
        /// The Message icon.
        /// </param>
        /// <param name="okButton">
        /// The ok button.
        /// </param>
        /// <param name="cancelButton">
        /// The cancel button.
        /// </param>
        public void Show(
            [NotNull] string message,
            [NotNull] string title,
            [CanBeNull] DialogIcon icon,
            [NotNull] DialogButton okButton,
            [NotNull] DialogButton cancelButton) 
        {
            // Message Header
            this.Header.Text = !string.IsNullOrEmpty(title)
                                   ? title
                                   : this.GetText("COMMON", "MODAL_NOTIFICATION_HEADER");

            // Message Text
            this.MessageText.Text = message;

            // Message Icon
            if (!icon.IsNullOrEmptyDBField())
            {
                switch (icon)
                {
                    case DialogIcon.Mail:
                        this.ImageIcon.ImageUrl = YafForumInfo.GetURLToResource("icons/EmailBig.png");
                        break;
                    case DialogIcon.Info:
                        this.ImageIcon.ImageUrl = YafForumInfo.GetURLToResource("icons/InfoBig.png");
                        break;
                    case DialogIcon.Warning:
                        this.ImageIcon.ImageUrl = YafForumInfo.GetURLToResource("icons/WarningBig.png");
                        break;
                    case DialogIcon.Error:
                        this.ImageIcon.ImageUrl = YafForumInfo.GetURLToResource("icons/ErrorBig.png");
                        break;
                    case DialogIcon.Question:
                        this.ImageIcon.ImageUrl = YafForumInfo.GetURLToResource("icons/QuestionBig.png");
                        break;
                }

                this.ImageIcon.Visible = true;
            }
            else
            {
                this.ImageIcon.Visible = false;
            }

            // OK/Yes Message Button
            if (okButton != null)
            {
                this.OkButtonLink = okButton.ForumPageLink ??
                                    new ForumLink { ForumPage = YafContext.Current.ForumPageType };

                if (okButton.Text.IsSet())
                {
                    this.OkButton.Text = okButton.Text;
                }
                else
                {
                    okButton.Text = this.GetText("COMMON", "OK");
                }

                this.OkButton.CssClass = okButton.CssClass.IsSet() ? okButton.CssClass : "LoginButton";
            }

            // Cancel/No Message Button
            if (cancelButton != null)
            {
                this.CancelButtonLink = cancelButton.ForumPageLink ??
                                        new ForumLink { ForumPage = YafContext.Current.ForumPageType };

                this.CancelButton.Visible = true;

                this.CancelButton.Text = cancelButton.Text.IsSet()
                                             ? cancelButton.Text
                                             : this.GetText("COMMON", "CANCEL");

                this.CancelButton.CssClass = cancelButton.CssClass.IsSet() ? cancelButton.CssClass : "StandardButton CancelButton";

                if (this.CancelButtonLink.ForumPage.Equals(YafContext.Current.ForumPageType))
                {
                    this.CancelButton.OnClientClick =
                        "jQuery().YafModalDialog.Close({{ Dialog: '#{0}' }});return false;".FormatWith(
                            this.YafForumPageErrorPopup.ClientID);
                }
                else
                {
                    this.CancelButton.OnClientClick =
                        "jQuery().YafModalDialog.Close({{ Dialog: '#{0}' }});".FormatWith(
                            this.YafForumPageErrorPopup.ClientID);
                }
            }
            else
            {
                this.CancelButton.Visible = false;

                this.CancelButtonLink = new ForumLink { ForumPage = YafContext.Current.ForumPageType };
            }

            YafContext.Current.PageElements.RegisterJQuery();
            YafContext.Current.PageElements.RegisterJsResourceInclude("yafmodaldialog", "js/jquery.yafmodaldialog.js");
            YafContext.Current.PageElements.RegisterCssIncludeResource("css/jquery.yafmodaldialog.css");

            var sbScript = new StringBuilder();

            sbScript.Append("Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(ShowNotificationPopup);");

            sbScript.AppendFormat(
                "function ShowNotificationPopup() {{ jQuery(document).ready(function() {{jQuery().YafModalDialog.Show({{Dialog : '#{0}',ImagePath : '{1}'}});return false; }});}}",
                this.YafForumPageErrorPopup.ClientID,
                YafForumInfo.GetURLToResource("images/"));

            this.PageContext.PageElements.RegisterJsBlockStartup(this.Page, "PopUp{0}".FormatWith(Guid.NewGuid()), sbScript.ToString());

            if (this.OkButtonLink.ForumPage.Equals(YafContext.Current.ForumPageType))
            {
                this.OkButton.OnClientClick =
                    "jQuery().YafModalDialog.Close({{ Dialog: '#{0}' }});return false;".FormatWith(
                        this.YafForumPageErrorPopup.ClientID);
            }
            else
            {
                this.OkButton.OnClientClick =
                    "jQuery().YafModalDialog.Close({{ Dialog: '#{0}' }});".FormatWith(
                        this.YafForumPageErrorPopup.ClientID);
            }
        }
コード例 #23
0
ファイル: DialogBox.ascx.cs プロジェクト: wangyoutian/YAFNET
        /// <summary>
        /// Open The Dialog
        /// </summary>
        /// <param name="message">
        /// The message text.
        /// </param>
        /// <param name="title">
        /// The Message title.
        /// </param>
        /// <param name="okButton">
        /// The ok button.
        /// </param>
        /// <param name="cancelButton">
        /// The cancel button.
        /// </param>
        public void Show(
            [NotNull] string message,
            [NotNull] string title,
            [NotNull] DialogButton okButton,
            [NotNull] DialogButton cancelButton)
        {
            // Message Header
            this.Header.Text = !string.IsNullOrEmpty(title)
                                   ? title
                                   : this.GetText("COMMON", "MODAL_NOTIFICATION_HEADER");

            // Message Text
            this.MessageText.Text = message;

            // OK/Yes Message Button
            if (okButton != null)
            {
                this.OkButtonLink = okButton.ForumPageLink ??
                                    new ForumLink {
                    ForumPage = YafContext.Current.ForumPageType
                };

                if (okButton.Text.IsSet())
                {
                    this.OkButton.Text = okButton.Text;
                }
                else
                {
                    okButton.Text = this.GetText("COMMON", "OK");
                }

                this.OkButton.CssClass = okButton.CssClass.IsSet() ? okButton.CssClass : "btn btn-primary";
            }

            // Cancel/No Message Button
            if (cancelButton != null)
            {
                this.CancelButtonLink = cancelButton.ForumPageLink ??
                                        new ForumLink {
                    ForumPage = YafContext.Current.ForumPageType
                };

                this.CancelButton.Visible = true;

                this.CancelButton.Text = cancelButton.Text.IsSet()
                                             ? cancelButton.Text
                                             : this.GetText("COMMON", "CANCEL");

                this.CancelButton.CssClass = cancelButton.CssClass.IsSet() ? cancelButton.CssClass : "btn btn-secondary";

                if (this.CancelButtonLink.ForumPage.Equals(YafContext.Current.ForumPageType))
                {
                    this.CancelButton.OnClientClick =
                        "jQuery('#{0}').modal('hide');return false;".FormatWith(
                            this.YafForumPageErrorPopup.ClientID);
                }
                else
                {
                    this.CancelButton.OnClientClick =
                        "jQuery('#{0}').modal('hide');".FormatWith(
                            this.YafForumPageErrorPopup.ClientID);
                }
            }
            else
            {
                this.CancelButton.Visible = false;

                this.CancelButtonLink = new ForumLink {
                    ForumPage = YafContext.Current.ForumPageType
                };
            }

            var script = new StringBuilder();

            script.Append("Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(ShowNotificationPopup);");

            script.AppendFormat(
                "function ShowNotificationPopup() {{ jQuery(document).ready(function() {{jQuery('#{0}').modal('show');return false; }});}}",
                this.YafForumPageErrorPopup.ClientID);

            this.PageContext.PageElements.RegisterJsBlockStartup(this.Page, "PopUp{0}".FormatWith(Guid.NewGuid()), script.ToString());

            if (this.OkButtonLink.ForumPage.Equals(YafContext.Current.ForumPageType))
            {
                this.OkButton.OnClientClick =
                    "jQuery('#{0}').modal('hide');return false;".FormatWith(
                        this.YafForumPageErrorPopup.ClientID);
            }
            else
            {
                this.OkButton.OnClientClick =
                    "jQuery('#{0}').modal('hide');".FormatWith(
                        this.YafForumPageErrorPopup.ClientID);
            }
        }
コード例 #24
0
        /// <summary>
        /// Open The Dialog
        /// </summary>
        /// <param name="message">
        /// The message text.
        /// </param>
        /// <param name="title">
        /// The Message title.
        /// </param>
        /// <param name="icon">
        /// The Message icon.
        /// </param>
        /// <param name="okButton">
        /// The ok button.
        /// </param>
        /// <param name="cancelButton">
        /// The cancel button.
        /// </param>
        public void Show(
            [NotNull] string message,
            [NotNull] string title,
            [CanBeNull] DialogIcon icon,
            [NotNull] DialogButton okButton,
            [NotNull] DialogButton cancelButton)
        {
            // Message Header
            this.Header.Text = !string.IsNullOrEmpty(title)
                                   ? title
                                   : this.GetText("COMMON", "MODAL_NOTIFICATION_HEADER");

            // Message Text
            this.MessageText.Text = message;

            // Message Icon
            if (!icon.IsNullOrEmptyDBField())
            {
                switch (icon)
                {
                case DialogIcon.Mail:
                    this.ImageIcon.ImageUrl = YafForumInfo.GetURLToContent("icons/EmailBig.png");
                    break;

                case DialogIcon.Info:
                    this.ImageIcon.ImageUrl = YafForumInfo.GetURLToContent("icons/InfoBig.png");
                    break;

                case DialogIcon.Warning:
                    this.ImageIcon.ImageUrl = YafForumInfo.GetURLToContent("icons/WarningBig.png");
                    break;

                case DialogIcon.Error:
                    this.ImageIcon.ImageUrl = YafForumInfo.GetURLToContent("icons/ErrorBig.png");
                    break;

                case DialogIcon.Question:
                    this.ImageIcon.ImageUrl = YafForumInfo.GetURLToContent("icons/QuestionBig.png");
                    break;
                }

                this.ImageIcon.Visible = true;
            }
            else
            {
                this.ImageIcon.Visible = false;
            }

            // OK/Yes Message Button
            if (okButton != null)
            {
                this.OkButtonLink = okButton.ForumPageLink ??
                                    new ForumLink {
                    ForumPage = YafContext.Current.ForumPageType
                };

                if (okButton.Text.IsSet())
                {
                    this.OkButton.Text = okButton.Text;
                }
                else
                {
                    okButton.Text = this.GetText("COMMON", "OK");
                }

                this.OkButton.CssClass = okButton.CssClass.IsSet() ? okButton.CssClass : "LoginButton";
            }

            // Cancel/No Message Button
            if (cancelButton != null)
            {
                this.CancelButtonLink = cancelButton.ForumPageLink ??
                                        new ForumLink {
                    ForumPage = YafContext.Current.ForumPageType
                };

                this.CancelButton.Visible = true;

                this.CancelButton.Text = cancelButton.Text.IsSet()
                                             ? cancelButton.Text
                                             : this.GetText("COMMON", "CANCEL");

                this.CancelButton.CssClass = cancelButton.CssClass.IsSet() ? cancelButton.CssClass : "StandardButton CancelButton";

                if (this.CancelButtonLink.ForumPage.Equals(YafContext.Current.ForumPageType))
                {
                    this.CancelButton.OnClientClick =
                        "jQuery().YafModalDialog.Close({{ Dialog: '#{0}' }});return false;".FormatWith(
                            this.YafForumPageErrorPopup.ClientID);
                }
                else
                {
                    this.CancelButton.OnClientClick =
                        "jQuery().YafModalDialog.Close({{ Dialog: '#{0}' }});".FormatWith(
                            this.YafForumPageErrorPopup.ClientID);
                }
            }
            else
            {
                this.CancelButton.Visible = false;

                this.CancelButtonLink = new ForumLink {
                    ForumPage = YafContext.Current.ForumPageType
                };
            }

            var sbScript = new StringBuilder();

            sbScript.Append("Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(ShowNotificationPopup);");

            sbScript.AppendFormat(
                "function ShowNotificationPopup() {{ jQuery(document).ready(function() {{jQuery().YafModalDialog.Show({{Dialog : '#{0}',ImagePath : '{1}'}});return false; }});}}",
                this.YafForumPageErrorPopup.ClientID,
                YafForumInfo.GetURLToContent("images/"));

            this.PageContext.PageElements.RegisterJsBlockStartup(this.Page, "PopUp{0}".FormatWith(Guid.NewGuid()), sbScript.ToString());

            if (this.OkButtonLink.ForumPage.Equals(YafContext.Current.ForumPageType))
            {
                this.OkButton.OnClientClick =
                    "jQuery().YafModalDialog.Close({{ Dialog: '#{0}' }});return false;".FormatWith(
                        this.YafForumPageErrorPopup.ClientID);
            }
            else
            {
                this.OkButton.OnClientClick =
                    "jQuery().YafModalDialog.Close({{ Dialog: '#{0}' }});".FormatWith(
                        this.YafForumPageErrorPopup.ClientID);
            }
        }