Beispiel #1
0
        /// <summary>
        /// Gets markup for a Comment control
        /// </summary>
        /// <returns></returns>
        public static string GetCommentControlMarkup(Node contextNode, string hiddenCommentsMarkup, string commentsMarkup, int commentCount, LikeInfo likeInfo)
        {
            var markupStr = WallHelper.GetMarkupString("$skin/renderers/Wall/CommentControl.html");

            if (markupStr == null)
            {
                return(null);
            }

            markupStr = ReplaceResources(markupStr);

            markupStr = markupStr.Replace("{{postid}}", contextNode.Id.ToString());
            markupStr = markupStr.Replace("{{hiddencomments}}", hiddenCommentsMarkup);
            markupStr = markupStr.Replace("{{comments}}", commentsMarkup);
            markupStr = markupStr.Replace("{{hiddencommentboxdisplay}}", commentCount > 2 ? "block" : "none");
            markupStr = markupStr.Replace("{{commentcount}}", commentCount.ToString());
            markupStr = markupStr.Replace("{{likeboxdisplay}}", likeInfo.Count > 0 ? "block" : "none");
            markupStr = markupStr.Replace("{{likes}}", likeInfo.GetLongMarkup());
            markupStr = markupStr.Replace("{{ilikedisplay}}", !likeInfo.iLike ? "inline" : "none");
            markupStr = markupStr.Replace("{{iunlikedisplay}}", likeInfo.iLike ? "inline" : "none");

            // user interaction allowed
            markupStr = markupStr.Replace("{{interactdisplay}}", WallHelper.HasWallPermission(contextNode.Path, contextNode) ? "block" : "none");

            return(markupStr);
        }
Beispiel #2
0
        public ActionResult Like(string itemId, string contextPath, bool fullMarkup, string rnd)
        {
            AssertPermission();

            SetCurrentWorkspace(contextPath);
            var parentId = 0;

            DataLayer.CreateLike(itemId, contextPath, out parentId);

            var likeInfo = new LikeInfo(parentId);

            return(Json(fullMarkup ? likeInfo.GetLongMarkup() : likeInfo.GetShortMarkup(), JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
        public static string GetContentWallMarkup(string markupStr, Node contextNode, string hiddenCommentsMarkup, string commentsMarkup, int commentCount, LikeInfo likeInfo, string postsMarkup)
        {
            if (markupStr == null)
            {
                return(null);
            }

            markupStr = ReplaceResources(markupStr);

            markupStr = markupStr.Replace("{{postid}}", contextNode.Id.ToString());
            markupStr = markupStr.Replace("{{hiddencomments}}", hiddenCommentsMarkup);
            markupStr = markupStr.Replace("{{comments}}", commentsMarkup);
            markupStr = markupStr.Replace("{{hiddencommentboxdisplay}}", commentCount > 2 ? "block" : "none");
            markupStr = markupStr.Replace("{{commentcount}}", commentCount.ToString());
            markupStr = markupStr.Replace("{{likeboxdisplay}}", likeInfo.Count > 0 ? "block" : "none");
            markupStr = markupStr.Replace("{{likes}}", likeInfo.GetLongMarkup());
            markupStr = markupStr.Replace("{{ilikedisplay}}", !likeInfo.iLike ? "inline" : "none");
            markupStr = markupStr.Replace("{{iunlikedisplay}}", likeInfo.iLike ? "inline" : "none");

            var content   = Content.Create(contextNode);
            var contextGc = contextNode as GenericContent;

            markupStr = markupStr.Replace("{{shareicon}}", IconHelper.ResolveIconPath(contextGc.Icon, 32));
            markupStr = markupStr.Replace("{{sharedisplayname}}", content.DisplayName);
            markupStr = markupStr.Replace("{{sharecontenttype}}", contextGc.NodeType.Name);
            markupStr = markupStr.Replace("{{sharepath}}", contextGc.Path);

            var ws = Workspace.GetWorkspaceWithWallForNode(contextNode);

            if (ws == null)
            {
                ws = Workspace.GetWorkspaceForNode(contextNode);
            }

            if (ws != null)
            {
                var wsContent = Content.Create(ws);

                markupStr = markupStr.Replace("{{sharetargetdefaultpath}}", ws.Path);
                markupStr = markupStr.Replace("{{sharetargetdefaultname}}", wsContent.DisplayName);
                markupStr = markupStr.Replace("{{workspacepath}}", ws.Path);
                markupStr = markupStr.Replace("{{workspacename}}", wsContent.DisplayName);
            }
            else
            {
                markupStr = markupStr.Replace("{{sharetargetdefaultpath}}", string.Empty);
                markupStr = markupStr.Replace("{{sharetargetdefaultname}}", string.Empty);
            }

            // always include profile link - it will be created if not yet exists
            var currentUser = User.Current as User;

            markupStr = markupStr.Replace("{{mywallpath}}", Actions.ActionUrl(Content.Create(currentUser), "Profile"));
            markupStr = markupStr.Replace("{{mywallname}}", "My wall");
            markupStr = markupStr.Replace("{{mywalldisplay}}", "inline");

            markupStr = markupStr.Replace("{{workspacedisplay}}", ws != null ? "inline" : "none");

            markupStr = markupStr.Replace("{{posts}}", postsMarkup);

            // user interaction allowed
            markupStr = markupStr.Replace("{{interactdisplay}}", WallHelper.HasWallPermission(contextNode.Path, contextNode) ? "block" : "none");

            return(markupStr);
        }
Beispiel #4
0
        public static string GetPostMarkup(string markupStr, string commentSectionStr, PostInfo postInfo, string contextPath, string hiddenCommentsMarkup, string commentsMarkup, int commentCount, LikeInfo likeInfo, bool drawBoundary)
        {
            if (markupStr == null)
            {
                return(null);
            }

            if (commentSectionStr == null)
            {
                return(null);
            }

            markupStr = ReplaceResources(markupStr);

            markupStr = markupStr.Replace("{{commentsection}}", commentSectionStr);
            markupStr = markupStr.Replace("{{postid}}", postInfo.ClientId.ToString());
            markupStr = markupStr.Replace("{{avatar}}", UITools.GetAvatarUrl(postInfo.CreatedBy));
            markupStr = markupStr.Replace("{{username}}", postInfo.CreatedBy.FullName);
            markupStr = markupStr.Replace("{{userlink}}", Actions.ActionUrl(Content.Create(postInfo.CreatedBy), "Profile"));

            var text = postInfo.Text;

            if (text != null)
            {
                text = text.Replace("{{path}}", postInfo.LastPath ?? string.Empty);
            }

            var haspermission = WallHelper.HasWallPermission(contextPath);

            markupStr = markupStr.Replace("{{text}}", text);
            markupStr = markupStr.Replace("{{date}}", postInfo.CreationDate.ToString());
            markupStr = markupStr.Replace("{{friendlydate}}", UITools.GetFriendlyDate(postInfo.CreationDate));
            markupStr = markupStr.Replace("{{hiddencomments}}", hiddenCommentsMarkup);
            markupStr = markupStr.Replace("{{comments}}", commentsMarkup);
            markupStr = markupStr.Replace("{{commentboxdisplay}}", (commentCount > 0) && haspermission ? "block" : "none");
            markupStr = markupStr.Replace("{{hiddencommentboxdisplay}}", commentCount > 2 ? "block" : "none");
            markupStr = markupStr.Replace("{{commentcount}}", commentCount.ToString());
            markupStr = markupStr.Replace("{{likeboxdisplay}}", likeInfo.Count > 0 ? "block" : "none");
            markupStr = markupStr.Replace("{{likes}}", likeInfo.GetLongMarkup());
            markupStr = markupStr.Replace("{{ilikedisplay}}", !likeInfo.iLike ? "inline" : "none");
            markupStr = markupStr.Replace("{{iunlikedisplay}}", likeInfo.iLike ? "inline" : "none");

            // content card - only manualposts count here, journals don't have this markup
            if (postInfo.Type == PostType.BigPost && postInfo.SharedContent != null)
            {
                markupStr = markupStr.Replace("{{contentcard}}", WallHelper.GetContentCardMarkup(postInfo.SharedContent, contextPath));
            }
            else
            {
                markupStr = markupStr.Replace("{{contentcard}}", string.Empty);
            }

            // small post icon
            var smallposticon = "/Root/Global/images/icons/16/add.png";

            if (postInfo.Type == PostType.JournalModified)
            {
                smallposticon = "/Root/Global/images/icons/16/edit.png";
            }
            if (postInfo.Type == PostType.JournalDeletedPhysically)
            {
                smallposticon = "/Root/Global/images/icons/16/delete.png";
            }
            if (postInfo.Type == PostType.JournalMoved)
            {
                smallposticon = "/Root/Global/images/icons/16/move.png";
            }
            if (postInfo.Type == PostType.JournalCopied)
            {
                smallposticon = "/Root/Global/images/icons/16/copy.png";
            }
            markupStr = markupStr.Replace("{{smallposticon}}", smallposticon);

            markupStr = markupStr.Replace("{{postboundaryclass}}", drawBoundary ? "sn-post-boundary" : string.Empty);

            markupStr = markupStr.Replace("{{action}}", postInfo.Action);

            // small post details
            markupStr = markupStr.Replace("{{detailsdisplay}}", string.IsNullOrEmpty(postInfo.Details) ? "none" : "inline");
            markupStr = markupStr.Replace("{{detailssection}}", ReplaceResources(postInfo.Details));

            // user interaction allowed
            markupStr = markupStr.Replace("{{interactdisplay}}", haspermission ? "inline" : "none");

            return(markupStr);
        }