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); }
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)); }