Esempio n. 1
0
        public static ManagerData GetManagerData(User manager)
        {
            var imgSrc      = "/Root/Global/images/orgc-missinguser.png?dynamicThumbnail=1&width=48&height=48";
            var managerName = "No manager associated";
            var manUrl      = string.Empty;

            if (manager != null)
            {
                managerName = manager.FullName;
                var managerC = SenseNet.ContentRepository.Content.Create(manager);
                manUrl = Actions.ActionUrl(managerC, "Profile");

                var imgField = managerC.Fields["Avatar"] as SenseNet.ContentRepository.Fields.ImageField;
                imgField.GetData(); // initialize image field
                var param = SenseNet.ContentRepository.Fields.ImageField.GetSizeUrlParams(imgField.ImageMode, 48, 48);
                if (!string.IsNullOrEmpty(imgField.ImageUrl))
                {
                    imgSrc = imgField.ImageUrl + param;
                }
            }

            return(new ManagerData {
                ManagerName = managerName, ManagerUrl = manUrl, ManagerImgPath = imgSrc
            });
        }
        public static string GetCommentMarkup(string markupStr, DateTime creationDate, User user, string text, int commentId, LikeInfo likeInfo, Node commentNode)
        {
            if (markupStr == null)
            {
                return(null);
            }

            markupStr = ReplaceResources(markupStr);

            markupStr = markupStr.Replace("{{commentid}}", commentId.ToString());
            markupStr = markupStr.Replace("{{avatar}}", UITools.GetAvatarUrl(user));
            markupStr = markupStr.Replace("{{username}}", user.FullName);
            markupStr = markupStr.Replace("{{userlink}}", Actions.ActionUrl(Content.Create(user), "Profile"));
            markupStr = markupStr.Replace("{{text}}", text);
            markupStr = markupStr.Replace("{{date}}", creationDate.ToString());
            markupStr = markupStr.Replace("{{friendlydate}}", UITools.GetFriendlyDate(creationDate));
            markupStr = markupStr.Replace("{{likeboxdisplay}}", likeInfo.Count > 0 ? "inline" : "none");
            markupStr = markupStr.Replace("{{likes}}", likeInfo.GetShortMarkup());
            markupStr = markupStr.Replace("{{ilikedisplay}}", !likeInfo.iLike ? "inline" : "none");
            markupStr = markupStr.Replace("{{iunlikedisplay}}", likeInfo.iLike ? "inline" : "none");

            // user interaction allowed
            var haspermission = WallHelper.HasLikePermission(commentNode);

            markupStr = markupStr.Replace("{{interactdisplay}}", haspermission ? "inline" : "none");
            // show 'like' icon for comment likes if user does not have permission -> in this case like icon would not appear since like link is hidden
            markupStr = markupStr.Replace("{{interactclass}}", haspermission ? string.Empty : "sn-commentlike");
            return(markupStr);
        }
Esempio n. 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 = 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 contextGc = contextNode as GenericContent;

            markupStr = markupStr.Replace("{{shareicon}}", IconHelper.ResolveIconPath(contextGc.Icon, 32));
            markupStr = markupStr.Replace("{{sharedisplayname}}", contextGc.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)
            {
                markupStr = markupStr.Replace("{{sharetargetdefaultpath}}", ws.Path);
                markupStr = markupStr.Replace("{{sharetargetdefaultname}}", ws.DisplayName);
                markupStr = markupStr.Replace("{{workspacepath}}", ws.Path);
                markupStr = markupStr.Replace("{{workspacename}}", ws.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);
        }
Esempio n. 4
0
        /// <summary>
        /// Gets markup for an item in the list of people who liked an item
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public static string GetLikeListItemMarkup(User user)
        {
            var markupStr = GetMarkupString("/Root/Global/renderers/Wall/LikeListItem.html");

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

            markupStr = markupStr.Replace("{{avatar}}", UITools.GetAvatarUrl(user));
            markupStr = markupStr.Replace("{{username}}", user.Name);
            markupStr = markupStr.Replace("{{userlink}}", Actions.ActionUrl(Content.Create(user), "Profile"));

            return(markupStr);
        }
        public static string GetContentCardMarkup(Node sharedContent, string contextPath)
        {
            var markupStr = WallHelper.GetMarkupString("$skin/renderers/Wall/ContentCard.html");

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

            markupStr = ReplaceResources(markupStr);

            var shareContent = Content.Create(sharedContent);
            var sharedGc     = sharedContent as GenericContent;

            markupStr = markupStr.Replace("{{shareicon}}", IconHelper.ResolveIconPath(sharedGc.Icon, 32));
            markupStr = markupStr.Replace("{{sharedisplayname}}", shareContent.DisplayName);
            markupStr = markupStr.Replace("{{sharecontenttype}}", sharedGc.NodeType.Name);

            var user = sharedContent as User;

            if (user == null)
            {
                markupStr = markupStr.Replace("{{sharepath}}", sharedGc.Path);

                var wsRelPath = sharedGc.Path;
                if (sharedGc.Path.StartsWith(contextPath) && sharedGc.Path != contextPath)
                {
                    wsRelPath = sharedGc.Path.Substring(contextPath.Length);
                }

                markupStr = markupStr.Replace("{{shareworkspacerelativepath}}", wsRelPath);
            }
            else
            {
                var path = Actions.ActionUrl(Content.Create(user), "Profile");

                markupStr = markupStr.Replace("{{sharepath}}", path);
                markupStr = markupStr.Replace("{{shareworkspacerelativepath}}", path);
            }

            return(markupStr);
        }
Esempio n. 6
0
        public static ManagerData GetManagerData(User manager)
        {
            var imgSrc      = "/Root/Global/images/orgc-missinguser.png?width=48&height=48";
            var managerName = "No manager associated";
            var manUrl      = string.Empty;

            if (manager != null)
            {
                managerName = manager.FullName;
                var managerC = Content.Create(manager);
                manUrl = Actions.ActionUrl(managerC, "Profile");

                var imgUrl = UITools.GetAvatarUrl(manager, 48, 48);
                if (!string.IsNullOrEmpty(imgUrl))
                {
                    imgSrc = imgUrl;
                }
            }

            return(new ManagerData {
                ManagerName = managerName, ManagerUrl = manUrl, ManagerImgPath = imgSrc
            });
        }
        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);
        }