Exemplo n.º 1
0
        private static string GetHTMLComment(Comment comment, bool isPreview)
        {
            var info = new CommentInfo
            {
                CommentID    = comment.ID.ToString(),
                UserID       = comment.UserID,
                TimeStamp    = comment.Datetime,
                TimeStampStr = comment.Datetime.Ago(),
                IsRead       = true,
                Inactive     = comment.Inactive,
                CommentBody  = comment.Content,
                UserFullName = DisplayUserSettings.GetFullUserName(comment.UserID),
                UserAvatar   = ImageHTMLHelper.GetHTMLUserAvatar(comment.UserID),
                UserPost     = CoreContext.UserManager.GetUsers(comment.UserID).Title
            };

            if (!isPreview)
            {
                info.IsEditPermissions = CommunitySecurity.CheckPermissions(comment, Constants.Action_EditRemoveComment);

                info.IsResponsePermissions = CommunitySecurity.CheckPermissions(comment.Post, Constants.Action_AddComment);
            }
            var defComment = new CommentsList();

            ConfigureComments(defComment, 0, null);

            return(CommentsHelper.GetOneCommentHtmlWithContainer(
                       defComment,
                       info,
                       comment.IsRoot(),
                       false));
        }
Exemplo n.º 2
0
        private static List <CommentInfo> BuildCommentsList(Post post, List <Comment> loaded, Guid parentId)
        {
            var result = new List <CommentInfo>();

            foreach (var comment in Comment.SelectChildLevel(parentId, loaded))
            {
                var info = new CommentInfo
                {
                    CommentID             = comment.ID.ToString(),
                    UserID                = comment.UserID,
                    TimeStamp             = comment.Datetime,
                    TimeStampStr          = comment.Datetime.Ago(),
                    IsRead                = true,
                    Inactive              = comment.Inactive,
                    CommentBody           = comment.Content,
                    UserFullName          = DisplayUserSettings.GetFullUserName(comment.UserID),
                    UserAvatar            = ImageHTMLHelper.GetHTMLUserAvatar(comment.UserID),
                    UserPost              = CoreContext.UserManager.GetUsers(comment.UserID).Title,
                    IsEditPermissions     = CommunitySecurity.CheckPermissions(comment, Constants.Action_EditRemoveComment),
                    IsResponsePermissions = CommunitySecurity.CheckPermissions(post, Constants.Action_AddComment),
                    CommentList           = BuildCommentsList(post, loaded, comment.ID)
                };

                result.Add(info);
            }
            return(result);
        }
Exemplo n.º 3
0
        private void FillSelectedPage(List <Post> posts, BlogsEngine engine)
        {
            var currentUser = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);

            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(currentUser), ASC.Blogs.Core.Constants.Action_AddPost) &&
                    string.IsNullOrEmpty(UserID) && string.IsNullOrEmpty(Search))
                {
                    emptyScreenControl.ButtonHTML = String.Format("<a class='link underline blue plus' 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);

            if (!String.IsNullOrEmpty(UserID))
            {
                var post = post_with_comments[0].Item1;
                var st   = new StringBuilder();

                st.Append("<div class=\"BlogsHeaderBlock header-with-menu\" style=\"margin-bottom:16px;\">");
                st.Append("<span class=\"header\">" + CoreContext.UserManager.GetUsers(post.UserID).DisplayUserName() + "</span>");
                st.Append("</div>");

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

            for (var i = 0; i < post_with_comments.Count; i++)
            {
                var post         = post_with_comments[i].Item1;
                var commentCount = post_with_comments[i].Item2;
                var sb           = new StringBuilder();
                var user         = CoreContext.UserManager.GetUsers(post.UserID);

                sb.Append("<div class=\"container-list\">");
                sb.Append("<div class=\"header-list\">");

                sb.Append("<div class=\"avatar-list\">");
                sb.Append("<a href=\"viewblog.aspx?blogid=" + post.ID.ToString() + "\">" + ImageHTMLHelper.GetHTMLUserAvatar(user.ID) + "</a>");
                sb.Append("</div><div class=\"describe-list\">");
                sb.Append("<div class=\"title-list\">");
                sb.Append("<a href=\"viewblog.aspx?blogid=" + post.ID.ToString() + "\">" + HttpUtility.HtmlEncode(post.Title) + "</a>");
                sb.Append("</div>");

                sb.Append("<div class=\"info-list\">");
                sb.Append("<span class=\"caption-list\">" + BlogsResource.PostedTitle + ":</span>");
                sb.Append(user.RenderCustomProfileLink("name-list", "link"));
                sb.Append("</div>");

                if (String.IsNullOrEmpty(UserID))
                {
                    sb.Append("<div class=\"info-list\">");
                    sb.Append("<a class=\"link gray-text\" href=\"" + VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath) + "?userid=" + post.UserID + "\">" + BlogsResource.AllRecordsOfTheAutor + "</a>");
                    sb.Append("</div>");
                }

                sb.Append("<div class=\"date-list\">");
                sb.AppendFormat("{0}<span class=\"time-list\">{1}</span>", post.Datetime.ToString("d"), post.Datetime.ToString("t"));
                sb.Append("</div></div></div>");

                sb.Append("<div class=\"content-list\">");

                sb.Append(HtmlUtility.GetFull(post.Content, false));
                sb.Append("<div id=\"postIndividualLink\" class=\"display-none\">viewblog.aspx?blogid=" + post.ID.ToString() + "</div>");
                sb.Append("<div class=\"comment-list\">");
                sb.Append("<a href=\"viewblog.aspx?blogid=" + post.ID + "#comments\">" + BlogsResource.CommentsTitle + ": " + commentCount.ToString() + "</a>");
                if (!currentUser.IsOutsider())
                {
                    sb.Append("<a href=\"viewblog.aspx?blogid=" + post.ID + "#addcomment\">" + BlogsResource.CommentsAddButtonTitle + "</a>");
                }
                sb.Append("</div></div></div>");

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

            placeContent.Controls.Add(new Literal {
                Text = "</div>"
            });
        }
Exemplo n.º 4
0
        private string FillData(List <BlogInfo> ratings)
        {
            var sb = new StringBuilder();
            var i  = 0;

            sb.Append("<table class=\"tableContainer\" cellspacing=\"0\" cellpadding=\"0\">");

            sb.Append("<tr>");

            var sortImg  = "<img style='margin:0 0 -4px 2px;' src='" + WebImageSupplier.GetAbsoluteWebPath(this.direction.Equals(SortDirection.Descending) ? "sort_down.png" : "sort_up.png") + "'/>";
            var blankImg = "<img style='margin:0 0 -4px 2px;' width='12' src='" + WebImageSupplier.GetAbsoluteWebPath("blank.gif") + "' >";


            sb.AppendFormat("<th class=\"columnFirst\" style=\"width: 40%; text-align:left;padding: 0 0 16px 10px;\"><a class=\"header\" href=\"javascript:BlogsManager.BlogTblSort(0);\">{0}</a>{1}</th>", ASC.Blogs.Core.Resources.BlogsResource.AddonName, (sortedFiledID == 0 ? sortImg : blankImg));
            sb.AppendFormat("<th style=\"width: 20%;text-align:center;padding:0 0 16px;\"><a class=\"header\" href=\"javascript:BlogsManager.BlogTblSort(1);\">{0}</a>{1}</th>", ASC.Blogs.Core.Resources.BlogsResource.PostsTitle, (sortedFiledID == 1 ? sortImg : blankImg));
            sb.AppendFormat("<th style=\"width: 20%;text-align:center;padding:0 0 16px;\"><a class=\"header\" href=\"javascript:BlogsManager.BlogTblSort(2);\">{0}</a>{1}</th>", ASC.Blogs.Core.Resources.BlogsResource.ViewsTitle, (sortedFiledID == 2 ? sortImg : blankImg));
            sb.AppendFormat("<th style=\"width: 20%;text-align:center;padding:0 0 16px;\"><a class=\"header\" href=\"javascript:BlogsManager.BlogTblSort(3);\">{0}</a>{1}</th></tr>", ASC.Blogs.Core.Resources.BlogsResource.CommentsTitle, (sortedFiledID == 3 ? sortImg : blankImg));


            foreach (var info in ratings)
            {
                sb.Append("<tr " + (i % 2 == 0 ? " class=\"even\" " : " class=\"odd\" ") + " >");
                sb.Append("<td class=\"columnFirst\" style=\"width: 40%;\" ><div class=\"clearFix\"><div style=\"float: left;\">" + ImageHTMLHelper.GetHTMLUserAvatar(info.ID) + "</div>");
                sb.Append("<div style=\"padding-left:45px;padding-top: 4px; width:400px;word-wrap: break-word;\"><a class=\"linkHeaderLight\" href=\"./?userid=" + info.ID + "\">" + DisplayUserSettings.GetFullUserName(info.ID) + "</a>");

                sb.Append("<td class=\"headerBase\" style=\"width: 20%;\">" + info.BlogsCount + "</td><td class=\"headerBase\" style=\"width: 20%;\">" + info.ReviewCount + "</td><td class=\"headerBase\" style=\"width: 20%;\">" + info.CommentsCount + "</td></tr>");
                i++;
            }
            if (ratings.Count % 2 == 1)
            {
                sb.Append("<tr><td colspan='4' style='font-size:1px;padding:0px;'>&nbsp;</td></tr>");
            }

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

            return(sb.ToString());
        }