コード例 #1
0
        private void AppendChildsComments(ref List <CommentInfo> commentsInfo, IList <Comment> comments)
        {
            foreach (var comment in comments)
            {
                var info = new CommentInfo
                {
                    CommentID             = comment.Id.ToString(),
                    UserID                = new Guid(comment.UserID),
                    TimeStampStr          = comment.Timestamp.Ago(),
                    IsRead                = SecurityContext.DemoMode || comment.IsRead,
                    Inactive              = comment.Inactive,
                    CommentBody           = comment.Text,
                    UserFullName          = DisplayUserSettings.GetFullUserName(new Guid(comment.UserID)),
                    UserAvatar            = ImageHTMLHelper.GetHTMLImgUserAvatar(new Guid(comment.UserID)),
                    UserPost              = CoreContext.UserManager.GetUsers(new Guid(comment.UserID)).Title,
                    IsEditPermissions     = CommunitySecurity.CheckPermissions(image, PhotoConst.Action_EditRemoveComment),
                    IsResponsePermissions = CommunitySecurity.CheckPermissions(PhotoConst.Action_AddComment)
                };

                // postParser.Parse(comment.Text);

                var tempComments = new List <CommentInfo>();

                AppendChildsComments(ref tempComments, comment.Comments);

                info.CommentList = tempComments;

                commentsInfo.Add(info);
            }
        }
コード例 #2
0
        private string GetHTMLComment(Comment comment, bool isPreview)
        {
            var info = new CommentInfo
            {
                CommentID    = comment.Id.ToString(),
                UserID       = new Guid(comment.UserID),
                TimeStamp    = comment.Timestamp,
                TimeStampStr = comment.Timestamp.Ago(),
                IsRead       = true,
                Inactive     = comment.Inactive,
                CommentBody  = comment.Text,
                UserFullName = DisplayUserSettings.GetFullUserName(new Guid(comment.UserID)),
                UserAvatar   = ImageHTMLHelper.GetHTMLImgUserAvatar(new Guid(comment.UserID)),
                UserPost     = CoreContext.UserManager.GetUsers(new Guid(comment.UserID)).Title
            };

            if (!isPreview)
            {
                info.IsEditPermissions = CommunitySecurity.CheckPermissions(image, PhotoConst.Action_EditRemoveComment);

                info.IsResponsePermissions = CommunitySecurity.CheckPermissions(PhotoConst.Action_AddComment);
            }

            var defComment = new CommentsList();

            ConfigureCommentsList(defComment, null);

            return(Web.Controls.CommentInfoHelper.CommentsHelper.GetOneCommentHtmlWithContainer(defComment, info, comment.ParentId <= 0, false));
        }
コード例 #3
0
        public AjaxResponse AddComment(string parrentCommentID, string photoID, string text, string pid)
        {
            var resp = new AjaxResponse {
                rs1 = parrentCommentID
            };

            CommunitySecurity.DemandPermissions(PhotoConst.Action_AddComment);

            var storage = StorageFactory.GetStorage();

            image = storage.GetAlbumItem(Convert.ToInt64(photoID));

            var newComment = new Comment(image.Id)
            {
                Text      = text,
                Timestamp = ASC.Core.Tenants.TenantUtil.DateTimeNow(),
                UserID    = SecurityContext.CurrentAccount.ID.ToString()
            };

            if (!string.IsNullOrEmpty(parrentCommentID))
            {
                newComment.ParentId = Convert.ToInt64(parrentCommentID);
            }

            var count = storage.SaveComment(image, newComment);

            storage.ReadAlbumItem(newComment.ItemID, SecurityContext.CurrentAccount.ID.ToString());

            var odd = count % 2 == 1;

            var comment = newComment;

            var info = new CommentInfo
            {
                CommentID             = comment.Id.ToString(),
                UserID                = new Guid(comment.UserID),
                TimeStampStr          = comment.Timestamp.Ago(),
                IsRead                = true,
                Inactive              = comment.Inactive,
                CommentBody           = comment.Text,
                UserFullName          = DisplayUserSettings.GetFullUserName(new Guid(comment.UserID)),
                UserAvatar            = ImageHTMLHelper.GetHTMLImgUserAvatar(new Guid(comment.UserID)),
                UserPost              = CoreContext.UserManager.GetUsers(new Guid(comment.UserID)).Title,
                IsEditPermissions     = CommunitySecurity.CheckPermissions(image, PhotoConst.Action_EditRemoveComment),
                IsResponsePermissions = CommunitySecurity.CheckPermissions(PhotoConst.Action_AddComment)
            };

            //postParser.Parse(comment.Text);

            var defComment = new CommentsList();

            ConfigureCommentsList(defComment, image);

            resp.rs2 = CommentsHelper.GetOneCommentHtmlWithContainer(defComment, info, newComment.ParentId == 0, odd);


            return(resp);
        }
コード例 #4
0
        private void RenderImagesList(IList <AlbumItem> list)
        {
            var sb      = new StringBuilder();
            var storage = StorageFactory.GetStorage();
            var i       = 0;
            var store   = Data.Storage.StorageFactory.GetStorage(TenantProvider.CurrentTenantID.ToString(), "photo");

            sb.Append("<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\" class=\"borderBase\" width='100%' style=\"border-right:none;border-left:none;border-bottom:none;\">");

            foreach (var image in list)
            {
                var limit = ImageHTMLHelper.GetImageSizeLimit(image, 75);
                //var comments = storage.GetComments(image.Id);
                var count      = image.CommentsCount;
                var countViews = image.ViewsCount;


                sb.Append("<tr " + (i % 2 == 0 ? "class='tintMedium'" : "") + " valign='top'><td class=\"borderBase\" style=\"border-top:none; border-right:none; border-left:none; width:105px;\"><div style='padding:15px 10px;'>");
                sb.Append("<a href=\"" + PhotoConst.PAGE_PHOTO_DETAILS + "?" + PhotoConst.PARAM_PHOTO + "=" + image.Id + "\"><img style='border: 0px solid;' " + limit + "  title=\"" + HttpUtility.HtmlEncode(image.Name) + "\" src=\"" + ImageHTMLHelper.GetImageUrl(image.ExpandedStoreThumb, store) + "\" /></a></div></td>");
                sb.Append("<td class=\"borderBase\" style=\"border-top:none; border-right:none; border-left:none;\"><div style='padding-top:10px;padding-bottom:10px;width: 620px;word-wrap: break-word;overflow: hidden;'>");
                sb.Append("<a class='linkHeaderLight' href=\"" + PhotoConst.PAGE_PHOTO_DETAILS + "?" + PhotoConst.PARAM_PHOTO + "=" + image.Id + "\">" + HttpUtility.HtmlEncode(image.Name) + "</a></span>");
                sb.Append("<div style='margin-top:5px;'><span class='textMediumDescribe'>" + PhotoManagerResource.PostedToTitle + ":&nbsp;&nbsp;<a class='linkDescribe' href=\"" + PhotoConst.PAGE_DEFAULT + "?" + PhotoConst.PARAM_EVENT + "=" + image.Album.Event.Id + "\">" + HttpUtility.HtmlEncode(image.Album.Event.Name) + "</a><span class='textMediumDescribe'>,&nbsp;</span>");
                sb.Append("<a class='linkDescribe' href=\"" + PhotoConst.PAGE_PHOTO + "?" + PhotoConst.PARAM_ALBUM + "=" + image.Album.Id + "\">" + DisplayUserSettings.GetFullUserName(new Guid(image.UserID)) + "</a></div>");
                sb.Append("<div style='margin-top:15px;' class=\"textBigDescribe\">" + Grammatical.ViewsCount(countViews) + " <span class='splitter'>|</span>" + Grammatical.CommentsCount(count) + "</div>");

                var comments = storage.GetLatestCommentsByImage(image.Id, 5);

                foreach (var comment in comments)
                {
                    //Comment comment = comments[j];
                    sb.Append("<div style='padding:30px 0px 0px;'>");
                    sb.Append("<table cellpadding='0' cellspacing='0' border='0'>");
                    sb.Append("<tr><td valign='top' width='34' rowspan='2'>");
                    sb.Append(ImageHTMLHelper.GetHTMLImgUserAvatar(new Guid(comment.UserID)));
                    sb.Append("</td>");
                    sb.Append("<td>");
                    sb.Append("<div style='margin-left:15px;'><a class='linkHeaderSmall' href='" + CommonLinkUtility.GetUserProfile(new Guid(comment.UserID), Product.CommunityProduct.ID) + "'>" + DisplayUserSettings.GetFullUserName(new Guid(comment.UserID)) + "</a>");
                    sb.Append("<span class='textMediumDescribe' style='padding-left:10px;'>" + PhotoManagerResource.SaidTitle + ":</span></div>");
                    sb.Append("<div class='textMediumDescribe' style='margin:5px 0px 0px 15px;'>" + comment.Timestamp.AgoSentence() + "</div>");
                    sb.Append("</td>");
                    sb.Append("</tr>");

                    sb.Append("<tr>");
                    sb.Append("<td>");
                    sb.Append("<div style='margin:15px 0px 0px 15px;'>" + comment.Text + "</div>");
                    sb.Append("</td>");
                    sb.Append("</tr>");

                    sb.Append("</table>");
                    sb.Append("</div>");
                }
                i++;
                sb.Append("<div style='float:right; padding:0px 20px 10px'><a href='" + PhotoConst.PAGE_PHOTO_DETAILS + "?" + PhotoConst.PARAM_PHOTO + "=" + image.Id + "'>" + PhotoManagerResource.AddCommentLink + "</a></div>");
                sb.Append("</td></tr>");
            }

            sb.Append("</table>");

            _contentHolder.Controls.Add(new Literal {
                Text = sb.ToString()
            });
        }