Exemple #1
0
        protected override void CreateChildControls()
        {
            if (this.ContextNode == null)
            {
                return;
            }

            if (ShowExecutionTime)
            {
                Timer.Start();
            }

            // gather posts for this content
            List <PostInfo> posts;

            posts = DataLayer.GetPostsForContent(this.ContextNode).ToList();

            string postsMarkup;

            postsMarkup = WallHelper.GetWallPostsMarkup(this.ContextNode.Path, posts);

            CommentInfo contentCommentInfo;
            LikeInfo    contentLikeInfo;

            var settings = new QuerySettings()
            {
                EnableAutofilters = FilterStatus.Disabled
            };
            var allCommentsAndLikes = ContentQuery.Query(ContentRepository.SafeQueries.InTreeAndTypeIs, settings,
                                                         this.ContextNode.Path, new[] { "Comment", "Like" }).Nodes.ToList();

            var commentNodeTypeId = NodeType.GetByName("Comment").Id;
            var likeTypeId        = NodeType.GetByName("Like").Id;

            var commentsForPost         = allCommentsAndLikes.Where(c => c.NodeTypeId == commentNodeTypeId).ToList();
            var likesForPostAndComments = allCommentsAndLikes.Where(l => l.NodeTypeId == likeTypeId).ToList();
            var likesForPost            = likesForPostAndComments.Where(l => RepositoryPath.GetParentPath(RepositoryPath.GetParentPath(l.Path)) == this.ContextNode.Path).ToList();

            var commentMarkupStr = WallHelper.GetCommentMarkupStr();

            // get comments for this content
            contentCommentInfo = new CommentInfo(commentsForPost, likesForPostAndComments, commentMarkupStr);

            // get likes for this content
            contentLikeInfo = new LikeInfo(likesForPost, this.ContextNode.Id);

            var markupStr = WallHelper.GetContentWallMarkup(
                this.ContextNode,
                contentCommentInfo.HiddenCommentsMarkup,
                contentCommentInfo.CommentsMarkup,
                contentCommentInfo.CommentCount,
                contentLikeInfo,
                postsMarkup);

            this.Controls.Add(new Literal {
                Text = markupStr
            });

            if (ShowExecutionTime)
            {
                Timer.Stop();
            }

            base.CreateChildControls();
            this.ChildControlsCreated = true;
        }
Exemple #2
0
        protected override void CreateChildControls()
        {
            if (this.ContextNode == null)
            {
                return;
            }

            if (ShowExecutionTime)
            {
                Timer.Start();
            }

            // gather posts for this content
            List <PostInfo> posts;

            using (new OperationTrace("Wall - Gather posts"))
            {
                posts = DataLayer.GetPostsForContent(this.ContextNode).ToList();
            }
            string postsMarkup;

            using (new OperationTrace("Wall - Posts markup"))
            {
                postsMarkup = WallHelper.GetWallPostsMarkup(this.ContextNode.Path, posts);
            }

            CommentInfo contentCommentInfo;
            LikeInfo    contentLikeInfo;

            using (new OperationTrace("Wall - Gather content comments"))
            {
                var commentsAndLikesQuery = "+TypeIs:(Comment Like) +InTree:\"" + this.ContextNode.Path + "\"";
                var settings = new QuerySettings()
                {
                    EnableAutofilters = false
                };
                var allCommentsAndLikes = ContentQuery.Query(commentsAndLikesQuery, settings).Nodes.ToList();

                var commentNodeTypeId = NodeType.GetByName("Comment").Id;
                var likeTypeId        = NodeType.GetByName("Like").Id;

                var commentsForPost         = allCommentsAndLikes.Where(c => c.NodeTypeId == commentNodeTypeId).ToList();
                var likesForPostAndComments = allCommentsAndLikes.Where(l => l.NodeTypeId == likeTypeId).ToList();
                var likesForPost            = likesForPostAndComments.Where(l => RepositoryPath.GetParentPath(RepositoryPath.GetParentPath(l.Path)) == this.ContextNode.Path).ToList();

                var commentMarkupStr = WallHelper.GetCommentMarkupStr();

                // get comments for this content
                contentCommentInfo = new CommentInfo(commentsForPost, likesForPostAndComments, commentMarkupStr);

                // get likes for this content
                contentLikeInfo = new LikeInfo(likesForPost, this.ContextNode.Id);
            }

            using (new OperationTrace("Wall - Content comments markup"))
            {
                var markupStr = WallHelper.GetContentWallMarkup(
                    this.ContextNode,
                    contentCommentInfo.HiddenCommentsMarkup,
                    contentCommentInfo.CommentsMarkup,
                    contentCommentInfo.CommentCount,
                    contentLikeInfo,
                    postsMarkup);

                this.Controls.Add(new Literal {
                    Text = markupStr
                });
            }

            if (ShowExecutionTime)
            {
                Timer.Stop();
            }

            base.CreateChildControls();
            this.ChildControlsCreated = true;
        }