コード例 #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));
        }
コード例 #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);
        }
コード例 #3
0
ファイル: Default.aspx.cs プロジェクト: Wifisoft/teamlab.v6.5
        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>"
            });
        }
コード例 #4
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>"
            });
        }
コード例 #5
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());
        }