public AjaxResponse ImageRotate(string imageID, bool isBackRotate) { try { var storage = StorageFactory.GetStorage(); var store = Data.Storage.StorageFactory.GetStorage(TenantProvider.CurrentTenantID.ToString(), "photo"); var albumItem = storage.GetAlbumItem(Convert.ToInt64(imageID)); var pathPreview = PhotoConst.ImagesPath + albumItem.ExpandedStorePreview; var pathThumb = PhotoConst.ImagesPath + albumItem.ExpandedStoreThumb; int j; try { j = Convert.ToInt32(GetFileNameIndex(albumItem.Location)); } catch { j = 1; } while (store.IsFile((PhotoConst.ImagesPath + albumItem.ExpandedStoreThumb))) { albumItem.Location = GetNextFileName(albumItem.Location, j++); } var newPathPreview = PhotoConst.ImagesPath + albumItem.ExpandedStorePreview; var newPathThumb = PhotoConst.ImagesPath + albumItem.ExpandedStoreThumb; Rotate(pathPreview, newPathPreview, isBackRotate, store); Rotate(pathThumb, newPathThumb, isBackRotate, store); albumItem.PreviewSize = new Size(albumItem.PreviewSize.Height, albumItem.PreviewSize.Width); albumItem.ThumbnailSize = new Size(albumItem.ThumbnailSize.Height, albumItem.ThumbnailSize.Width); storage.SaveAlbumItem(albumItem); return(new AjaxResponse { rs1 = albumItem.Id.ToString(), rs2 = albumItem.Name.HtmlEncode(), rs3 = ImageHTMLHelper.GetImageUrl(albumItem.ExpandedStorePreview, store), rs4 = ImageHTMLHelper.GetImageUrl(albumItem.ExpandedStoreThumb, store), rs5 = albumItem.PreviewSize.Width.ToString(), rs6 = albumItem.PreviewSize.Height.ToString() }); } catch { return(new AjaxResponse { rs1 = "0", rs2 = string.Empty, rs3 = WebImageSupplier.GetAbsoluteWebPath("no_photo.png", PhotoConst.ModuleID), rs4 = WebImageSupplier.GetAbsoluteWebPath("photo_icon.png", PhotoConst.ModuleID), rs5 = "100", rs6 = "100" }); } }
public AjaxResponse GetImage(long albumID, int index) { return(new AjaxResponse() { rs1 = LoadImage(albumID, index).ToString(), rs2 = ImageHTMLHelper.GetImageUrl(image.ExpandedStorePreview, ASC.Data.Storage.StorageFactory.GetStorage(TenantProvider.CurrentTenantID.ToString(), "photo")), rs3 = image.Name }); }
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() }); }
public PhotoAlbumItemWrapper(AlbumItem faceItem) { Id = faceItem.Id; Title = faceItem.Name; Updated = Created = (ApiDateTime)faceItem.Timestamp; Description = faceItem.Description; var storage = Data.Storage.StorageFactory.GetStorage( CoreContext.TenantManager.GetCurrentTenant().TenantId.ToString(), "photo"); Thumbnail = ImageHTMLHelper.GetImageUrl(faceItem.ExpandedStorePreview, storage); Location = ImageHTMLHelper.GetImageUrl(faceItem.ExpandedStoreThumb, storage); Comments = faceItem.CommentsCount; }
private void LoadThumbnails(Album AlbumItem) { var storage = StorageFactory.GetStorage(); var store = Data.Storage.StorageFactory.GetStorage(TenantProvider.CurrentTenantID.ToString(), "photo"); var items = storage.GetAlbumItems(AlbumItem); var thumbnails = new List <Dictionary <String, String> >(); for (int i = 0, n = items.Count; i < n; i++) { var thumbnail = new Dictionary <String, String>(); thumbnail.Add("Id", items[i].Id.ToString()); thumbnail.Add("Name", (items[i].Name ?? string.Empty).HtmlEncode()); thumbnail.Add("Src", ImageHTMLHelper.GetImageUrl(items[i].ExpandedStoreThumb, store)); thumbnails.Add(thumbnail); } PhotoThumbnails.DataSource = thumbnails; PhotoThumbnails.DataBind(); }
private string AddAlbumItem(AlbumItem albumItem, bool isFace) { StringBuilder sb = new StringBuilder(); if (countItems != 0 && countItems % 3 == 0) { sb.Append("</div>"); } if (countItems % 3 == 0) { sb.Append("<div class=\"borderLight tintMediumLight clearFix\" style=\"padding:20px; border-left:none;border-right:none;margin-bottom:8px;\">"); } sb.Append("<div style='float:left;margin-bottom:5px;" + (countItems % 3 == 0 ? "" : "margin-left:22px; ") + "'>"); sb.Append("<span>"); sb.Append("<input name=\"" + ASC.PhotoManager.PhotoConst.PARAM_EDIT_ITEMID + countItems + "\" name=\"" + ASC.PhotoManager.PhotoConst.PARAM_EDIT_ITEMID + countItems + "\" type=\"hidden\" value=\"" + albumItem.Id + "\" />"); sb.Append("<div style=\"width: 200px;height:200px;background-color: #EBF0F4;padding:5px;\">" + ImageHTMLHelper.GetHTMLThumb(ImageHTMLHelper.GetImageUrl(albumItem.ExpandedStorePreview, store), 200, albumItem.PreviewSize.Width, albumItem.PreviewSize.Height) + "</div>"); sb.Append("<div class='textBigDescribe clearFix' style=\" padding-left:5px;padding-top:5px;width:200px;\">"); sb.Append("<div style=\"padding-top: 5px; float: left;\">" + PhotoManagerResource.EditPhotoNameTitle + "</div>"); sb.Append("<div style=\"float: right;\">"); sb.Append("<label class='textMediumDescribe' for=\"face_" + countItems + "\">"); sb.Append(PhotoManagerResource.AlbumCoverTitle + "</label><input type=\"radio\" id=\"face_" + countItems + "\" name=\"album_face\" value=\"" + albumItem.Id + "\" " + (isFace ? "checked" : "") + " /></div></div>"); sb.Append("<div><input class=\"textEdit\" style=\"width:200px;margin-top:5px;\" maxlength=\"255\" name=\"" + ASC.PhotoManager.PhotoConst.PARAM_EDIT_NAME + countItems + "\" id=\"" + ASC.PhotoManager.PhotoConst.PARAM_EDIT_NAME + countItems + "\" value='" + HttpUtility.HtmlEncode(albumItem.Name) + "' type=\"text\"/></div>"); sb.Append("</span>"); sb.Append("</div>"); countItems++; return(sb.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() }); }
protected void btnUpload_Click(object sender, EventArgs e) { var photoCount = 0; var simpleUploader = false; var sb = new StringBuilder(); IList <AlbumItem> images = new List <AlbumItem>(); var storage = StorageFactory.GetStorage(); try { var eventID = Convert.ToInt64(Request.Form["events_selector"]); var authorID = SecurityContext.CurrentAccount.ID.ToString(); Album currentAlbum = null; if (selectedAlbum != null) { currentAlbum = selectedAlbum; } else if (string.IsNullOrEmpty(authorID)) { return; } else if (authorID != "0") { var albums = storage.GetAlbums(eventID, authorID); currentAlbum = 0 < albums.Count ? albums[0] : null; } if (currentAlbum == null) { var Event = storage.GetEvent(eventID); currentAlbum = new Album(); currentAlbum.Event = Event; currentAlbum.UserID = SecurityContext.CurrentAccount.ID.ToString(); storage.SaveAlbum(currentAlbum); } var imagesInfo = !simpleUploader?CreateImagesInfo(Request.Form["phtm_imagesInfo"]) : CreateImagesInfoBySimple(); if (imagesInfo != null) { var i = 0; var store = Data.Storage.StorageFactory.GetStorage(TenantProvider.CurrentTenantID.ToString(), "photo"); foreach (var info in imagesInfo) { var item = storage.GetAlbumItem(Convert.ToInt64(info)); images.Add(item); if (photoCount != 0 && photoCount % 3 == 0) { sb.Append("</div>"); } if (photoCount % 3 == 0) { sb.Append("<div class=\"borderLight tintMediumLight clearFix\" style=\"padding:20px; border-left:none;border-right:none;margin-bottom:8px;\">"); } sb.Append("<div style='float:left;margin-bottom:5px;" + (photoCount % 3 == 0 ? "" : "margin-left:22px; ") + "'>"); sb.Append(AddPreviewImage(ImageHTMLHelper.GetImageUrl(item.ExpandedStorePreview, store), item.Name, item.Id, i == 0, i, item.PreviewSize.Width, item.PreviewSize.Height)); sb.Append("</div>"); i++; photoCount++; } } sb.Append("</div>"); ltrUploadedImages.Text = sb.ToString(); pnlImageForm.Visible = false; pnlSave.Visible = true; storage.SaveAlbum(currentAlbum, images); } catch (Exception) { } }
private string GetHTMLSmallThumb(AlbumItem image, int maxSize, string link, Data.Storage.IDataStore store) { var sb = new StringBuilder(); var limit = ImageHTMLHelper.GetImageSizeLimit(image, maxSize); sb.Append("<span style=\"padding: 3px; display: inline-block; position: relative; text-align: center; vertical-align: top;\" >"); sb.Append("<table border=0 cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"text-align:center;vertical-align:middle;border:solid 0px #cfcfcf;height:" + maxSize + "px;width:" + maxSize + "px;table-layout:fixed;\">"); sb.Append("<a href=\"" + link + "\">"); sb.Append("<img " + limit + " title=\"" + (image != null ? HttpUtility.HtmlEncode(image.Name) : "") + "\" src=\"" + (image != null ? ImageHTMLHelper.GetImageUrl(image.ExpandedStoreThumb, store) : "") + "\" class=\"borderBase\">"); sb.Append("</a></td></tr></table></span>"); return(sb.ToString()); }
protected string RenderImagePath() { return(ImageHTMLHelper.GetImageUrl(image.ExpandedStorePreview, ASC.Data.Storage.StorageFactory.GetStorage(TenantProvider.CurrentTenantID.ToString(), "photo"))); }