GetCommentMarkup() public static method

Gets markup for a comment.
public static GetCommentMarkup ( System.DateTime creationDate, User user, string text, int commentId, LikeInfo likeInfo, Node commentNode ) : string
creationDate System.DateTime Date when the comment was created
user SenseNet.ContentRepository.User User who created the comment.
text string Text of the comment.
commentId int
likeInfo LikeInfo
commentNode Node
return string
コード例 #1
0
        public CommentInfo(int itemId)
        {
            var comments       = new StringBuilder();
            var hiddenComments = new StringBuilder();
            var commentsResult = DataLayer.GetComments(itemId);

            if (commentsResult == null)
            {
                return;
            }

            var index = 0;

            foreach (var comment in commentsResult.Nodes)
            {
                var commentGc       = comment as GenericContent;
                var commentLikeInfo = new LikeInfo(commentGc.Id);
                var commentMarkup   = WallHelper.GetCommentMarkup(commentGc.CreationDate, commentGc.CreatedBy as User, commentGc.Description, commentGc.Id, commentLikeInfo, comment);

                // if it is one of the last two comments, add it to visible comments list, otherwise to hidden comments list
                if (index < commentsResult.Count - 2)
                {
                    hiddenComments.Append(commentMarkup);
                }
                else
                {
                    comments.Append(commentMarkup);
                }
                index++;
            }

            CommentsMarkup       = comments.ToString();
            HiddenCommentsMarkup = hiddenComments.ToString();
            CommentCount         = commentsResult.Count;
        }
コード例 #2
0
        public CommentInfo(List <Node> comments, List <Node> likesForComments, string markupStr)
        {
            var commentsMarkup = new StringBuilder();
            var hiddenComments = new StringBuilder();

            var index = 0;

            foreach (var comment in comments)
            {
                var likesForComment = likesForComments.Where(l => RepositoryPath.GetParentPath(RepositoryPath.GetParentPath(l.Path)) == comment.Path).ToList();

                var commentGc       = comment as GenericContent;
                var commentLikeInfo = new LikeInfo(likesForComment, commentGc.Id);
                var commentMarkup   = WallHelper.GetCommentMarkup(markupStr, commentGc.CreationDate, commentGc.CreatedBy as User, commentGc.Description, commentGc.Id, commentLikeInfo, comment);

                // if it is one of the last two comments, add it to visible comments list, otherwise to hidden comments list
                if (index < comments.Count - 2)
                {
                    hiddenComments.Append(commentMarkup);
                }
                else
                {
                    commentsMarkup.Append(commentMarkup);
                }
                index++;
            }

            CommentsMarkup       = commentsMarkup.ToString();
            HiddenCommentsMarkup = hiddenComments.ToString();
            CommentCount         = comments.Count;
        }
コード例 #3
0
ファイル: WallController.cs プロジェクト: pchaozhong/FlexNet
        public ActionResult CreateComment(string postId, string contextPath, string text, string rnd)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }

            AssertPermission();

            var comment = DataLayer.CreateComment(postId, contextPath, text);

            var commentMarkup = WallHelper.GetCommentMarkup(comment.CreationDate, SenseNet.ContentRepository.User.Current as User, text, comment.Id, new LikeInfo(), comment);

            return(Json(commentMarkup, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
        public static string CreateComment(Content content, string postId, string text)
        {
            AssertPermission(PlaceholderPath);
            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }

            SetCurrentWorkspace(content.Path);
            var comment = DataLayer.CreateComment(postId, content.Path, text);

            var commentMarkup = WallHelper.GetCommentMarkup(comment.CreationDate, User.Current as User, text, comment.Id, new LikeInfo(), comment);

            return(commentMarkup);
        }