Beispiel #1
0
    private void Load_Comments()
    {
        StringBuilder str = new StringBuilder();
        // store comment flags
        int TotalPages = 1;

        if (this.TotalComments > this.PageSize)
        {
            TotalPages = (int)Math.Ceiling((double)this.TotalComments / this.PageSize);
        }
        str.Append("<span style=\"display:none;\" id=\"cmt_tcmts\">" + this.TotalComments + "</span>\n"); // store total pages info in <span>
        str.Append("<span style=\"display:none;\" id=\"cmt_tpages\">" + TotalPages + "</span>\n");        // store total pages info in <span>
        str.Append("<span style=\"display:none;\" id=\"cmt_psize\">" + PageSize + "</span>\n");           // store page size infor in <span>
        str.Append("<span style=\"display:none;\" id=\"cmt_pnum\">1</span>\n");                           // current page index <span>
        if (this.TotalComments == 0)
        {
            str.Append("<div class=\"bx_msg\">");
            str.Append("<h4>Be the first to post comment on this " + ContentType.ToLower() + "!</h4>");
            str.Append("</div>");
            lst.InnerHtml = str.ToString();
            return;
        }
        // check for comments
        List <Comment_Struct> _list = CommentsBLL.Fetch_Comments_V2(this.ContentID, this.ProfileID, this.Type, this.PageNumber, this.PageSize, this.Order, this.ShowAuthorPhoto);

        if (_list.Count > 0)
        {
            // load comments
            int i = 0;

            str.Append("<div class=\"item\">");
            for (i = 0; i <= _list.Count - 1; i++)
            {
                // set post layout
                CmtItem postitem = new CmtItem();
                postitem.Height = 50;
                postitem.Width  = 50;

                postitem.ShowDate        = true;
                postitem.ShowAuthor      = true;
                postitem.ShowAuthorImage = this.ShowAuthorPhoto;
                postitem.Height          = this.Height;
                postitem.Width           = this.Width;
                postitem.isAdmin         = this.isAdmin;
                postitem.isHoverEffect   = true;
                postitem.isRoundCorners  = false;
                postitem.LeftWidth       = 8;  // %
                postitem.RightWidth      = 91; // %
                postitem.ShowReplyLink   = true;
                postitem.ShowVotes       = true;
                postitem.AuthorUserName  = this.AuthorUserName; // Author Of Post
                string PosterUserName = "";
                if (Page.User.Identity.IsAuthenticated)
                {
                    PosterUserName = Page.User.Identity.Name;
                }
                postitem.PosterUserName = PosterUserName; // Currently logged in User
                postitem.ShowReplyLink  = this.ShowReplyLink;
                postitem.ShowVotes      = this.ShowVoteLink;

                postitem.isHoverEffect = this.HoverEffect;
                postitem.TemplateID    = this.TemplateID;
                str.Append(postitem.Process(_list[i]));
            }
            if (this.PaginationType == 1)
            {
                str.Append("<div id=\"cmt_load_cnt\"></div>\n"); // load more comment container
            }
            str.Append("<div id=\"cmt_loading\"></div>\n");      // show loading progres
            str.Append("<div class=\"clear\"></div>");           // clear floating items


            str.Append("</div>");
            // ********************************************
            // PAGINATION SCRIPT
            // ********************************************
            pg.Visible  = false;
            apg.Visible = false;
            if (TotalPages > 1)
            {
                switch (this.PaginationType)
                {
                case 0:
                    // jquery ajax pagination
                    apg.Visible = true;
                    apagination1.TotalRecords        = this.TotalComments;
                    apagination1.PageSize            = this.PageSize;
                    apagination1.PageNumber          = this.PageNumber;
                    apagination1.LoadHandler         = Config.GetUrl("modules/comments/hdr/load.ashx");
                    apagination1.LoadParams          = this.Load_Params;
                    apagination1.LoadContainer       = lst.ClientID;
                    apagination1.LoadStatusContainer = "cmt_loading";
                    apagination1.BindPagination();
                    break;

                case 1:
                    // jquery load more pagination
                    str.Append("<div id=\"cmt_more\" class=\"item_pad_4 bx_br_both\" style=\"padding:5px 0px;\">\n");
                    str.Append("<span class=\"ui-icon ui-icon-triangle-1-s\" style=\"float: left; margin-right: .3em;\"></span><a id=\"cmt_ld_more\"  href=\"#\" class=\"bold\" title=\"load more comments\">Load more...</a>\n");
                    str.Append("</div>\n");
                    break;

                case 2:
                    // normal pagination
                    pg.Visible = true;
                    pagination1.TotalRecords   = this.TotalComments;
                    pagination1.PageSize       = this.PageSize;
                    pagination1.PageNumber     = this.PageNumber;
                    pagination1.Default_Url    = this.DefaultUrl;
                    pagination1.Pagination_Url = this.PaginationUrl;
                    pagination1.BindPagination();
                    break;
                }
            }
        }
        else
        {
            str.Append("<div class=\"bx_msg\">");
            str.Append("<h4>Be the first to post comment on this " + ContentType.ToLower() + "!</h4>");
            str.Append("</div>");
        }
        lst.InnerHtml = str.ToString();
    }