Beispiel #1
0
        private void FillSelectedPage(List <Post> posts, BlogsEngine engine)
        {
            if (posts == null || posts.Count == 0)
            {
                var emptyScreenControl = new EmptyScreenControl
                {
                    ImgSrc   = WebImageSupplier.GetAbsoluteWebPath("blog_icon.png", ASC.Blogs.Core.Constants.ModuleId),
                    Header   = BlogsResource.EmptyScreenBlogCaption,
                    Describe = BlogsResource.EmptyScreenBlogText
                };

                if (CommunitySecurity.CheckPermissions(new PersonalBlogSecObject(CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID)), ASC.Blogs.Core.Constants.Action_AddPost) &&
                    string.IsNullOrEmpty(UserID) && string.IsNullOrEmpty(Search))
                {
                    emptyScreenControl.ButtonHTML = String.Format("<a class='linkAddMediumText' href='addblog.aspx'>{0}</a>", BlogsResource.EmptyScreenBlogLink);
                }

                placeContent.Controls.Add(emptyScreenControl);
                return;
            }

            placeContent.Controls.Add(new Literal {
                Text = "<div>"
            });

            var post_with_comments = engine.GetPostsCommentsCount(posts);

            for (var i = 0; i < post_with_comments.Count; i++)
            {
                var post         = post_with_comments[i].Value1;
                var commentCount = post_with_comments[i].Value2;

                var sb = new StringBuilder();

                sb.Append("<div class=\"" + (i % 2 == 1 ? "tintLight" : "tintMedium") + " borderBase\" style=\"border-width: " + (i == 0 ? "1px" : "0") + " 0 1px 0;padding: 10px 14px;\">");

                sb.Append("<table class='BlogsTable' cellspacing='0' cellpadding='0' border='0'><tr><td valign='top'>");
                sb.Append("<div style='padding-top:4px;'>" + ImageHTMLHelper.GetLinkUserAvatar(post.UserID) + "</div>");
                sb.Append("</td><td><div class='longWordsBreak MainInfoBlock'>");

                sb.Append("<a href=\"viewblog.aspx?blogid=" + post.ID.ToString() + "\" class=\"linkHeaderLight\">" + HttpUtility.HtmlEncode(post.Title) + "</a>");

                sb.Append("<div class='BlockCreater'>");

                sb.Append("<a class='linkHeaderSmall' href='" + VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath) + "?userid=" + post.UserID + "'><span style='font-weight:normal;'>" + BlogsResource.BlogOfTitle + ":&nbsp;&nbsp;</span>" + DisplayUserSettings.GetFullUserName(post.UserID) + "</a>");

                sb.Append("</div>");
                sb.Append("<div >");
                sb.Append("<span class='textMediumDescribe' style='margin-right:5px;'>" + BlogsResource.PostedTitle + ":</span> " + CoreContext.UserManager.GetUsers(post.UserID).RenderProfileLink(Product.CommunityProduct.ID));
                sb.Append("<span class='textMediumDescribe'>&nbsp;&nbsp;" + post.Datetime.Ago() + "</span>");
                sb.Append("</div>");

                sb.Append("</div>");
                placeContent.Controls.Add(new Literal {
                    Text = sb.ToString()
                });


                sb = new StringBuilder();

                sb.Append("<div class='longWordsBreak ContentBlock'>");

                sb.Append(HtmlUtility.GetPreview(post.Content, "<div style='margin-top:15px;'><a style='text-decoration:none;' href=\"viewblog.aspx?blogid=" + post.ID.ToString() + "\"><font style='text-decoration:underline;'>" + ASC.Blogs.Core.Resources.BlogsResource.ReadMoreLink + "</font><font style='font-size:14px;text-decoration:none;'>&nbsp;&#8594</font></a></div>", Product.CommunityProduct.ID));

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


                sb.Append("<div class='clearFix CommentsBlock'>");
                if (post.TagList.Count > 0)
                {
                    sb.Append("<div class=\"textMediumDescribe TagsBlock\">");
                    sb.Append("<img class=\"TagsImgBlock\" src=\"" + WebImageSupplier.GetAbsoluteWebPath("tags.png", BlogsSettings.ModuleID) + "\">");

                    var j = 0;
                    foreach (var tag in post.TagList)
                    {
                        if (j != 0)
                        {
                            sb.Append(", ");
                        }
                        j++;
                        sb.Append("<a style='margin-left:5px;' class=\"linkDescribe\" href=\"./?tagname=" + HttpUtility.UrlEncode(tag.Content) + "\">" + HttpUtility.HtmlEncode(tag.Content) + "</a>");
                    }

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

                sb.Append("<div class='CommentsLinkBlock'>");
                sb.Append("<a href='viewblog.aspx?blogid=" + post.ID + "#comments'>" + BlogsResource.CommentsTitle + ": " + commentCount.ToString() + "</a>");
                sb.Append("</div>");

                sb.Append("</div></td></tr></table>");

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


                placeContent.Controls.Add(new Literal {
                    Text = sb.ToString()
                });
            }

            placeContent.Controls.Add(new Literal {
                Text = "</div>"
            });
        }