protected override void CreateChildControls() { if (this.ContextNode == null) { return; } if (ShowExecutionTime) { Timer.Start(); } var control = Page.LoadControl("/Root/Global/renderers/Wall/Wall.ascx"); this.Controls.Add(control); _workspaceIsWallContainer = control.FindControlRecursive("WorkspaceIsWallContainer") as PlaceHolder; var portletContextNodeLink = control.FindControlRecursive("PortletContextNodeLink") as System.Web.UI.WebControls.HyperLink; var configureWorkspaceWall = control.FindControlRecursive("ConfigureWorkspaceWall") as Button; if (_workspaceIsWallContainer != null && configureWorkspaceWall != null) { _workspaceIsWallContainer.Visible = false; var ws = this.ContextNode as Workspace; if (ws != null && !ws.IsWallContainer && ws.Security.HasPermission(PermissionType.Save)) { _workspaceIsWallContainer.Visible = true; if (portletContextNodeLink != null) { portletContextNodeLink.Text = ws.DisplayName; portletContextNodeLink.NavigateUrl = ws.Path; } configureWorkspaceWall.Click += ConfigureWorkspaceWall_Click; } } var postsPlaceholder = control.FindControlRecursive("Posts"); List <PostInfo> posts; using (new OperationTrace("Wall - Gather posts")) { var postInfos = GatherPosts(); posts = postInfos == null ? new List <PostInfo>() : postInfos.Take(PageSize).ToList(); } using (new OperationTrace("Wall - Posts markup")) { postsPlaceholder.Controls.Add(new Literal { Text = WallHelper.GetWallPostsMarkup(this.ContextNode.Path, posts) }); } if (ShowExecutionTime) { Timer.Stop(); } base.CreateChildControls(); this.ChildControlsCreated = true; }
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; }
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; }
protected override void CreateChildControls() { if (this.ContextNode == null) { return; } if (ShowExecutionTime) { Timer.Start(); } System.Web.UI.Control control = null; try { var viewHead = NodeHead.Get(ControlPath); if (viewHead != null && SecurityHandler.HasPermission(viewHead, PermissionType.RunApplication)) { control = Page.LoadControl(ControlPath); this.Controls.Add(control); } } catch (Exception ex) { SnLog.WriteException(ex); this.Controls.Add(new System.Web.UI.LiteralControl(ex.Message)); return; } if (control == null) { return; } _workspaceIsWallContainer = control.FindControlRecursive("WorkspaceIsWallContainer") as PlaceHolder; var portletContextNodeLink = control.FindControlRecursive("PortletContextNodeLink") as System.Web.UI.WebControls.HyperLink; var configureWorkspaceWall = control.FindControlRecursive("ConfigureWorkspaceWall") as Button; if (_workspaceIsWallContainer != null && configureWorkspaceWall != null) { _workspaceIsWallContainer.Visible = false; var ws = this.ContextNode as Workspace; if (ws != null && !ws.IsWallContainer && ws.Security.HasPermission(PermissionType.Save)) { _workspaceIsWallContainer.Visible = true; if (portletContextNodeLink != null) { portletContextNodeLink.Text = System.Web.HttpUtility.HtmlEncode(Content.Create(ws).DisplayName); portletContextNodeLink.NavigateUrl = ws.Path; } configureWorkspaceWall.Click += ConfigureWorkspaceWall_Click; } } var postsPlaceholder = control.FindControlRecursive("Posts"); List <PostInfo> posts; var postInfos = GatherPosts(); posts = postInfos == null ? new List <PostInfo>() : postInfos.Take(PageSize).ToList(); postsPlaceholder.Controls.Add(new Literal { Text = WallHelper.GetWallPostsMarkup(this.ContextNode.Path, posts) }); if (ShowExecutionTime) { Timer.Stop(); } base.CreateChildControls(); this.ChildControlsCreated = true; }