public AjaxResponse GetImage(string imageID) { var storage = StorageFactory.GetStorage(); var store = Data.Storage.StorageFactory.GetStorage(TenantProvider.CurrentTenantID.ToString(), "photo"); var currentItem = storage.GetAlbumItem(Convert.ToInt64(imageID)); if (currentItem == null) { return new AjaxResponse { status = "error", message = "have no photo", rs2 = "", rs3 = WebImageSupplier.GetAbsoluteWebPath("blank.gif") } } ; var items = storage.GetAlbumItems(currentItem.Album); var pos = items.IndexOf(currentItem); var htw = new HtmlTextWriter(new StringWriter()); var imageComments = StorageFactory.GetStorage().GetComments(currentItem.Id); var comments = new List <CommentInfo>(); AppendChildsComments(ref comments, imageComments); var CommentsList = new CommentsList(); ConfigureCommentsList(CommentsList, currentItem); CommentsList.Items = comments; CommentsList.RenderControl(htw); if (!SecurityContext.DemoMode) { storage.ReadAlbumItem(currentItem.Id, currentUserID.ToString()); } return(new AjaxResponse { rs1 = currentItem.Id.ToString(), rs2 = (currentItem.Name ?? string.Empty).HtmlEncode(), rs3 = ImageHTMLHelper.GetImageUrl(currentItem.ExpandedStorePreview, store), rs4 = (currentItem.Description ?? string.Empty).HtmlEncode(), rs5 = currentItem.PreviewSize.Width.ToString(), rs6 = currentItem.PreviewSize.Height.ToString(), rs7 = Grammatical.ViewsCount(currentItem.ViewsCount), rs8 = Grammatical.CommentsCount(currentItem.CommentsCount), rs9 = RenderEditPhotoLink(currentItem), rs10 = RenderSlideShowLink(currentItem), rs11 = pos > 0 ? items[pos - 1].Id.ToString() : "", rs12 = pos < items.Count - 1 ? items[pos + 1].Id.ToString() : "", rs13 = htw.InnerWriter.ToString() }); }
protected override void PageLoad() { lbtnEdit.CssClass = "linkAction" + (SetupInfo.WorkMode == WorkMode.Promo ? " promoAction" : ""); confirmContainer.Options.IsPopup = true; var store = Data.Storage.StorageFactory.GetStorage(TenantProvider.CurrentTenantID.ToString(), "photo"); var storage = StorageFactory.GetStorage(); service = storage; InitPageParams(); if (!IsPostBack) { countAlbumItems = 0; if (!String.IsNullOrEmpty(AlbumID)) { mainContainer.BreadCrumbs.Add(new Web.Controls.BreadCrumb { Caption = PhotoManagerResource.PhotoTitle, NavigationUrl = PhotoConst.PAGE_DEFAULT }); pnlCurrentAlbum.Visible = true; pnlUserAlbums.Visible = false; album = storage.GetAlbum(Convert.ToInt64(AlbumID)); if (album != null) { var editRemovePermissions = CommunitySecurity.CheckPermissions(album, PhotoConst.Action_EditRemovePhoto); if (album == null) { Response.Redirect(PhotoConst.PAGE_DEFAULT); } if (editRemovePermissions) { pnlEditPhoto.Visible = true; } ltrLinkAllPhoto.Text = "<a href='" + PhotoConst.PAGE_PHOTO + "?" + PhotoConst.PARAM_USER + "=" + album.UserID + "'>" + PhotoManagerResource.AllAuthorAlbumsTitle + "</a>"; var caption = (string.IsNullOrEmpty(album.Caption) ? DisplayUserSettings.GetFullUserName(new Guid(album.UserID), false) : album.Caption); mainContainer.BreadCrumbs.Add(new Web.Controls.BreadCrumb { Caption = album.Event.Name, NavigationUrl = PhotoConst.PAGE_DEFAULT + "?" + PhotoConst.PARAM_EVENT + "=" + album.Event.Id }); mainContainer.BreadCrumbs.Add(new Web.Controls.BreadCrumb { Caption = caption }); var cssStyle = ImageHTMLHelper.GetImagePreviewSizeLimit(album.FaceItem, 260); if (album.FaceItem != null) { ltrAlbumFace.Text = "<a href='" + PhotoConst.PAGE_PHOTO_DETAILS + "?" + PhotoConst.PARAM_PHOTO + "=" + album.FaceItem.Id + "'><img " + cssStyle + " style='border:0px solid #000;margin:8px 0px;' src=\"" + ImageHTMLHelper.GetImageUrl(album.FaceItem.ExpandedStorePreview, store) + "\" /></a>"; } var countComments = album.CommentsCount; var countViews = album.ViewsCount; LoadAlbumsLinks(album.Event); ltrAlbumInfo.Text = "<div class=\"textMediumDescribe\" style=\"padding: 15px 10px 0px;\"><span class='textBaseSmall'>" + Grammatical.PhotosCount(album.ImagesCount) + "</span><span class='splitter'>|</span>" + Grammatical.ViewsCount(countViews) + "<span class='splitter'>|</span>" + Grammatical.CommentsCount(countComments) + "</div>" + "<div class=\"textMediumDescribe\" style=\"padding: 5px 10px; max-width:255px; overflow:hidden;\">" + PhotoManagerResource.PostedByTitle + ": " + CoreContext.UserManager.GetUsers(new Guid(album.UserID)).RenderProfileLink(Product.CommunityProduct.ID) + "</div><div class=\"textMediumDescribe\" style=\"padding: 0px 10px;\">" + PhotoManagerResource.LastUpdateTitle + ": " + album.LastUpdate.ToShortDateString() + "</div>"; foreach (var albumItem in storage.GetAlbumItems(album)) { ltrPhoto.Text += ImageHTMLHelper.GetSmallHTMLImage(albumItem, countAlbumItems, false, 75, store); countAlbumItems++; } } else { pnlCurrentAlbum.Controls.Clear(); pnlCurrentAlbum.Controls.Add(new Literal { Text = string.Format("<div class=\"noContentBlock\">{0}</div>", PhotoManagerResource.NoFoundMessage) }); albumsContainer.Visible = false; } } else { pnlCurrentAlbum.Visible = false; pnlUserAlbums.Visible = true; albumsContainer.Visible = false; LoadUserAllPhoto(!String.IsNullOrEmpty(UserID) ? UserID : currentUserID.ToString(), store); } } Title = HeaderStringHelper.GetPageTitle(PhotoManagerResource.AddonName, mainContainer.BreadCrumbs); sideRecentActivity.TenantId = TenantProvider.CurrentTenantID; sideRecentActivity.ProductId = Product.CommunityProduct.ID; sideRecentActivity.ModuleId = PhotoConst.ModuleID; }
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 + ": <a class='linkDescribe' href=\"" + PhotoConst.PAGE_DEFAULT + "?" + PhotoConst.PARAM_EVENT + "=" + image.Album.Event.Id + "\">" + HttpUtility.HtmlEncode(image.Album.Event.Name) + "</a><span class='textMediumDescribe'>, </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() }); }