private Message saveCaptions() { // Iterate through all the textboxes, saving any captions that have changed. // The media object IDs are stored in a hidden input tag. HtmlInputText ta; HtmlTextArea tdesc; HtmlInputHidden gc; string previousTitle, previousDescription; Message msg = Message.None; if (!IsUserAuthorized(SecurityActions.EditMediaObject)) { return(msg); } try { HelperFunctions.BeginTransaction(); foreach (RepeaterItem rptrItem in rptr.Items) { ta = (HtmlInputText)rptrItem.Controls[1]; // The <input TEXT> tag tdesc = (HtmlTextArea)rptrItem.Controls[3]; // The <TEXTAREA> tag gc = (HtmlInputHidden)rptrItem.Controls[5]; // The hidden <input> tag SueetieMediaAlbum _sueetieMediaAlbum = SueetieMedia.GetSueetieMediaAlbum(CurrentSueetieGalleryID, Convert.ToInt32(gc.Value)); previousDescription = _sueetieMediaAlbum.AlbumDescription; previousTitle = _sueetieMediaAlbum.AlbumTitle; _sueetieMediaAlbum.AlbumTitle = Util.HtmlDecode(ta.Value); _sueetieMediaAlbum.AlbumDescription = tdesc.Value; if (_sueetieMediaAlbum.AlbumTitle != previousTitle || _sueetieMediaAlbum.AlbumDescription != previousDescription) { SueetieMedia.UpdateSueetieMediaAlbum(_sueetieMediaAlbum); } } HelperFunctions.CommitTransaction(); } catch { HelperFunctions.RollbackTransaction(); throw; } HelperFunctions.PurgeCache(); SueetieMedia.ClearSueetieMediaAlbumListCache(CurrentSueetieGalleryID); return(msg); }
private void ConfigureControls() { this.TaskHeaderText = Resources.GalleryServerPro.Task_Edit_Captions_Header_Text; this.TaskBodyText = Resources.GalleryServerPro.Task_Edit_Captions_Body_Text; this.OkButtonText = SueetieLocalizer.GetString("process_updates", "MediaGallery.xml"); this.OkButtonToolTip = Resources.GalleryServerPro.Task_Edit_Captions_Ok_Button_Tooltip; this.PageTitle = Resources.GalleryServerPro.Task_Edit_Captions_Page_Title; // Sueetie Modified - Converting GSP galleryObjects into SueetieGalleryObjects SueetieConfiguration config = SueetieConfiguration.Get(); List <SueetieMediaObject> sueetieMediaObjects = new List <SueetieMediaObject>(); IGalleryObjectCollection albumChildren = this.GetAlbum().GetChildGalleryObjects(GalleryObjectType.Album, true); foreach (IGalleryObject _galleryObject in albumChildren) { SueetieMediaAlbum _album = SueetieMedia.GetSueetieMediaAlbum(CurrentSueetieGalleryID, _galleryObject.Id); sueetieMediaObjects.Insert(0, new SueetieMediaObject { MediaObjectID = _galleryObject.Id, MediaObjectTitle = _galleryObject.Title, AlbumID = _galleryObject.Id, IsAlbum = true, MediaObjectUrl = String.Concat(Util.GetUrl(PageId.album, "aid={0}", _galleryObject.Id)), MediaObjectDescription = _album.AlbumDescription, DisplayName = _album.DisplayName, ThumbnailHeight = config.Media.ThumbnailHeight, ThumbnailWidth = config.Media.ThumbnailWidth }); } if (albumChildren.Count > 0) { const int textareaWidthBuffer = 30; // Extra width padding to allow room for the caption. const int textareaHeightBuffer = 72; // Extra height padding to allow room for the caption. SetThumbnailCssStyle(albumChildren, textareaWidthBuffer, textareaHeightBuffer); rptr.DataSource = sueetieMediaObjects; rptr.DataBind(); } else { this.RedirectToAlbumViewPage("msg={0}", ((int)Message.CannotEditCaptionsNoEditableObjectsExistInAlbum).ToString(CultureInfo.InvariantCulture)); } }
protected void rptr_OnItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { SueetieMediaObject sueetieMediaObject = ((SueetieMediaObject)e.Item.DataItem); SueetieMediaAlbum _album = SueetieMedia.GetSueetieMediaAlbum(CurrentSueetieGalleryID, sueetieMediaObject.MediaObjectID); PlaceHolder phTagsControl = (PlaceHolder)e.Item.FindControl("phTagsControl"); tagControl = new TagControl(); tagControl.TagSueetieMediaAlbum = _album; phTagsControl.Controls.Add(tagControl); PlaceHolder phCalendarControl = (PlaceHolder)e.Item.FindControl("phCalendarControl"); calendarControl = new CalendarControl(); calendarControl.CalendarSueetieMediaAlbum = _album; phCalendarControl.Controls.Add(calendarControl); } }
protected void rptr_OnItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { SueetieMediaObject _sueetieMediaObject = ((SueetieMediaObject)e.Item.DataItem); SueetieMediaAlbum _album = SueetieMedia.GetSueetieMediaAlbum(CurrentSueetieGalleryID, _sueetieMediaObject.MediaObjectID); PlaceHolder phTagsControl = (PlaceHolder)e.Item.FindControl("phTagsControl"); tagControl = new TagControl(); tagControl.DisplayTagsPanel = false; if (_sueetieMediaObject.IsAlbum) { tagControl.TagSueetieMediaAlbum = _album; } else { tagControl.TagSueetieMediaObject = _sueetieMediaObject; } phTagsControl.Controls.Add(tagControl); } }
/// <summary> /// Adds the <paramref name="zipContentFile"/> as a media object to the <paramref name="album"/>. /// </summary> /// <param name="zipContentFile">A reference to a file in a ZIP archive.</param> /// <param name="album">The album to which the file should be added as a media object.</param> /// // Sueetie Modified - passing i for single logging of action private void AddMediaObjectToGallery(ZipEntry zipContentFile, IAlbum album, int i) { string zipFileName = Path.GetFileName(zipContentFile.Name).Trim(); if (zipFileName.Length == 0) { return; } string uniqueFilename = HelperFunctions.ValidateFileName(album.FullPhysicalPathOnDisk, zipFileName); string uniqueFilepath = Path.Combine(album.FullPhysicalPathOnDisk, uniqueFilename); // Extract the file from the zip stream and save as the specified filename. ExtractFileFromZipStream(uniqueFilepath); // Get the file we just saved to disk. FileInfo mediaObjectFile = new FileInfo(uniqueFilepath); try { IGalleryObject mediaObject = Factory.CreateMediaObjectInstance(mediaObjectFile, album); HelperFunctions.UpdateAuditFields(mediaObject, this._userName); // Sueetie Modified - Fixes a weird bug where zipped Image file titles are empty when zipped from my machine if (mediaObject.Title.Trim().Length == 0) { mediaObject.Title = mediaObjectFile.Name; } mediaObject.Save(); if ((_discardOriginalImage) && (mediaObject is Business.Image)) { ((Business.Image)mediaObject).DeleteHiResImage(); mediaObject.Save(); } // Sueetie Modified - Add mediaobject to Sueetie_Content - Single File SueetieContent sueetieContent = new SueetieContent { SourceID = mediaObject.Id, ContentTypeID = SueetieMedia.ConvertContentType((int)mediaObject.MimeType.TypeCategory), ApplicationID = (int)SueetieApplications.Current.ApplicationID, UserID = SueetieContext.Current.User.UserID, IsRestricted = ((Album)mediaObject.Parent).IsPrivate, Permalink = SueetieMedia.SueetieMediaObjectUrl(mediaObject.Id, mediaObject.GalleryId) }; SueetieCommon.AddSueetieContent(sueetieContent); // Add Sueetie-specific data to Sueetie_gs_MediaObject SueetieMediaObject _sueetieMediaObject = new SueetieMediaObject(); _sueetieMediaObject.MediaObjectID = mediaObject.Id; _sueetieMediaObject.ContentTypeID = SueetieMedia.ConvertContentType((int)mediaObject.MimeType.TypeCategory); _sueetieMediaObject.AlbumID = mediaObject.Parent.Id; _sueetieMediaObject.InDownloadReport = false; SueetieMedia.CreateSueetieMediaObject(_sueetieMediaObject); SueetieMediaAlbum sueetieAlbum = SueetieMedia.GetSueetieMediaAlbum(mediaObject.Parent.Id); SueetieMediaGallery sueetieGallery = SueetieMedia.GetSueetieMediaGallery(((Album)mediaObject.Parent).GalleryId); if (i == 0 && sueetieGallery.IsLogged) { SueetieLogs.LogUserEntry((UserLogCategoryType)sueetieAlbum.AlbumMediaCategoryID, sueetieAlbum.ContentID, SueetieContext.Current.User.UserID); } SueetieMedia.ClearMediaPhotoListCache(0); SueetieMedia.ClearSueetieMediaObjectListCache(mediaObject.GalleryId); } catch (ErrorHandler.CustomExceptions.UnsupportedMediaObjectTypeException ex) { this._skippedFiles.Add(new KeyValuePair <string, string>(mediaObjectFile.Name, ex.Message)); File.Delete(mediaObjectFile.FullName); } }
/// <summary> /// Displays thumbnail versions of the specified <paramref name="galleryObjects"/>. /// </summary> /// <param name="galleryObjects">The gallery objects to display.</param> /// <param name="showAddObjectsLink">If set to <c>true</c> show a message and a link allowing the user to add objects to the /// current album as specified in the query string. Set to false when displaying objects that may belong to more than one /// album.</param> private void DisplayThumbnails(IGalleryObjectCollection galleryObjects, bool showAddObjectsLink) { string msg; if (galleryObjects.Count > 0) { // At least one album or media object in album. //msg = String.Format(CultureInfo.CurrentCulture, "<p class='gsp_addtopmargin2'>{0}</p>", Resources.GalleryServerPro.UC_ThumbnailView_Intro_Text_With_Objects); //phMsg.Controls.Add(new LiteralControl(msg)); } else if ((showAddObjectsLink) && (this.GalleryPage.UserCanAddMediaObject) && (!this.GalleryPage.GallerySettings.MediaObjectPathIsReadOnly)) { // We have no objects to display. The user is authorized to add objects to this album and the gallery is writeable, so show // message and link to add objects page. string innerMsg = String.Format(CultureInfo.CurrentCulture, Resources.GalleryServerPro.UC_ThumbnailView_Intro_Text_No_Objects_User_Has_Add_MediaObject_Permission, Util.GetUrl(PageId.task_addobjects, "aid={0}", this.GalleryPage.GetAlbumId())); msg = String.Format(CultureInfo.CurrentCulture, "<p class='gsp_addtopmargin2 gsp_msgfriendly'>{0}</p>", innerMsg); phMsg.Controls.Add(new LiteralControl(msg)); } else { // No objects and/or user doesn't have permission to add media objects. msg = String.Format(CultureInfo.CurrentCulture, "<p class='gsp_addtopmargin2 gsp_msgfriendly'>{0}</p>", Resources.GalleryServerPro.UC_ThumbnailView_Intro_Text_No_Objects); phMsg.Controls.Add(new LiteralControl(msg)); } this.GalleryPage.SetThumbnailCssStyle(galleryObjects); // Sueetie Modified - Converting GSP galleryObjects into SueetieGalleryObjects SueetieConfiguration config = SueetieConfiguration.Get(); List <SueetieMediaObject> sueetieMediaObjects = new List <SueetieMediaObject>(); foreach (IGalleryObject _galleryObject in galleryObjects) { if (_galleryObject is Album) { SueetieMediaAlbum _album = SueetieMedia.GetSueetieMediaAlbum(CurrentSueetieGalleryID, _galleryObject.Id); sueetieMediaObjects.Insert(0, new SueetieMediaObject { MediaObjectID = _galleryObject.Id, MediaObjectTitle = _galleryObject.Title, AlbumID = _galleryObject.Id, IsAlbum = true, MediaObjectUrl = String.Concat(Util.GetUrl(PageId.album, "aid={0}", _galleryObject.Id)), MediaObjectDescription = _album.AlbumDescription, DisplayName = _album.DisplayName, ThumbnailHeight = config.Media.ThumbnailHeight, ThumbnailWidth = config.Media.ThumbnailWidth, DateTimeCreated = _album.DateTimeCreated, SueetieUserID = _album.SueetieUserID }); } else { SueetieMediaObject _sueetieMediaObject = SueetieMedia.GetSueetieMediaObject(this.CurrentSueetieGalleryID, _galleryObject.Id); MediaHelper.PopulateMediaObject(_sueetieMediaObject, _galleryObject); _sueetieMediaObject.MediaObjectUrl = GenerateUrl(_galleryObject); sueetieMediaObjects.Add(_sueetieMediaObject); } } if (PagingEnabled) { rptr.DataSource = CreatePaging(sueetieMediaObjects); RegisterPagingScript(); } else { rptr.DataSource = sueetieMediaObjects; } rptr.DataBind(); }
/// <summary> /// Adds the uploaded files to the gallery. This method is called when the application is operating under full trust. In this case, /// the ComponentArt Upload control is used. The logic is nearly identical to that in AddUploadedFilesLessThanFullTrust - the only /// differences are syntax differences arising from the different file upload control. /// </summary> /// <param name="files">The files to add to the gallery.</param> private void AddUploadedFilesForFullTrust(UploadedFileInfoCollection files) { // Clear the list of hash keys so we're starting with a fresh load from the data store. try { MediaObjectHashKeys.Clear(); string albumPhysicalPath = this.GetAlbum().FullPhysicalPathOnDisk; HelperFunctions.BeginTransaction(); UploadedFileInfo[] fileInfos = new UploadedFileInfo[files.Count]; files.CopyTo(fileInfos, 0); Array.Reverse(fileInfos); foreach (UploadedFileInfo file in fileInfos) { if (String.IsNullOrEmpty(file.FileName)) { continue; } if ((System.IO.Path.GetExtension(file.FileName).Equals(".zip", StringComparison.OrdinalIgnoreCase)) && (!chkDoNotExtractZipFile.Checked)) { #region Extract the files from the zipped file. lock (file) { if (File.Exists(file.TempFileName)) { using (ZipUtility zip = new ZipUtility(Util.UserName, GetGalleryServerRolesForUser())) { this._skippedFiles.AddRange(zip.ExtractZipFile(file.GetStream(), this.GetAlbum(), chkDiscardOriginalImage.Checked)); } } else { // When one of the files causes an OutOfMemoryException, this can cause the other files to disappear from the // temp upload directory. This seems to be an issue with the ComponentArt Upload control, since this does not // seem to happen with the ASP.NET FileUpload control. If the file doesn't exist, make a note of it and move on // to the next one. this._skippedFiles.Add(new KeyValuePair <string, string>(file.FileName, Resources.GalleryServerPro.Task_Add_Objects_Uploaded_File_Does_Not_Exist_Msg)); continue; // Skip to the next file. } } // Sueetie Modified - Add contents of ZIP file - All List <SueetieMediaObject> sueetieMediaObjects = SueetieMedia.GetSueetieMediaUpdateList(this.GetAlbumId()); int i = 0; foreach (SueetieMediaObject _sueetieMediaObject in sueetieMediaObjects) { int _moid = _sueetieMediaObject.MediaObjectID; IGalleryObject mo = Factory.LoadMediaObjectInstance(_moid); SueetieContent sueetieContent = new SueetieContent { SourceID = _sueetieMediaObject.MediaObjectID, ContentTypeID = MediaHelper.ConvertContentType(mo.MimeType.TypeCategory), ApplicationID = (int)SueetieApplications.Current.ApplicationID, UserID = _sueetieMediaObject.SueetieUserID, DateTimeCreated = mo.DateAdded, IsRestricted = mo.IsPrivate, Permalink = MediaHelper.SueetieMediaObjectUrl(_moid, this.GalleryId) }; // Add Sueetie-specific data to Sueetie_gs_MediaObject _sueetieMediaObject.ContentTypeID = MediaHelper.ConvertContentType(mo.MimeType.TypeCategory); _sueetieMediaObject.AlbumID = this.GetAlbum().Id; _sueetieMediaObject.InDownloadReport = false; SueetieMedia.CreateSueetieMediaObject(_sueetieMediaObject); SueetieCommon.AddSueetieContent(sueetieContent); i++; } #endregion } else { #region Add the file string filename = HelperFunctions.ValidateFileName(albumPhysicalPath, file.FileName); string filepath = Path.Combine(albumPhysicalPath, filename); lock (file) { if (File.Exists(file.TempFileName)) { file.SaveAs(filepath); } else { // When one of the files causes an OutOfMemoryException, this can cause the other files to disappear from the // temp upload directory. This seems to be an issue with the ComponentArt Upload control, since this does not // seem to happen with the ASP.NET FileUpload control. If the file doesn't exist, make a note of it and move on // to the next one. this._skippedFiles.Add(new KeyValuePair <string, string>(file.FileName, Resources.GalleryServerPro.Task_Add_Objects_Uploaded_File_Does_Not_Exist_Msg)); continue; // Skip to the next file. } } try { IGalleryObject go = Factory.CreateMediaObjectInstance(filepath, this.GetAlbum()); GalleryObjectController.SaveGalleryObject(go); if ((chkDiscardOriginalImage.Checked) && (go is Business.Image)) { ((Business.Image)go).DeleteHiResImage(); GalleryObjectController.SaveGalleryObject(go); } // Sueetie Modified - Add mediaobject to Sueetie_Content - Single File SueetieContent sueetieContent = new SueetieContent { SourceID = go.Id, ContentTypeID = MediaHelper.ConvertContentType(go.MimeType.TypeCategory), ApplicationID = (int)SueetieApplications.Current.ApplicationID, UserID = CurrentSueetieUserID, IsRestricted = this.GetAlbum().IsPrivate, Permalink = MediaHelper.SueetieMediaObjectUrl(go.Id, this.GalleryId) }; SueetieCommon.AddSueetieContent(sueetieContent); // Add Sueetie-specific data to Sueetie_gs_MediaObject SueetieMediaObject _sueetieMediaObject = new SueetieMediaObject(); _sueetieMediaObject.MediaObjectID = go.Id; _sueetieMediaObject.ContentTypeID = MediaHelper.ConvertContentType(go.MimeType.TypeCategory); _sueetieMediaObject.AlbumID = this.GetAlbum().Id; _sueetieMediaObject.InDownloadReport = false; SueetieMedia.CreateSueetieMediaObject(_sueetieMediaObject); SueetieMediaAlbum sueetieAlbum = SueetieMedia.GetSueetieMediaAlbum(this.GetAlbum().Id); if (CurrentSueetieGallery.IsLogged) { SueetieLogs.LogUserEntry((UserLogCategoryType)sueetieAlbum.AlbumMediaCategoryID, sueetieAlbum.ContentID, CurrentSueetieUserID); } } catch (UnsupportedMediaObjectTypeException ex) { try { File.Delete(filepath); } catch (UnauthorizedAccessException) { } // Ignore an error; the file will end up getting deleted during cleanup maintenance this._skippedFiles.Add(new KeyValuePair <string, string>(filename, ex.Message)); } #endregion } } SueetieMedia.ClearMediaPhotoListCache(0); SueetieMedia.ClearSueetieMediaObjectListCache(this.CurrentSueetieGalleryID); HelperFunctions.CommitTransaction(); } catch { HelperFunctions.RollbackTransaction(); throw; } finally { // Delete the uploaded temporary files, as by this time they have been saved to the destination directory. foreach (UploadedFileInfo file in files) { try { System.IO.File.Delete(file.TempFileName); } catch (UnauthorizedAccessException) { } // Ignore an error; the file will end up getting deleted during cleanup maintenance } // Clear the list of hash keys to free up memory. MediaObjectHashKeys.Clear(); HelperFunctions.PurgeCache(); } }
/// <summary> /// Adds the uploaded files to the gallery. This method is called when the application is operating at lesss than full trust. In this case, /// the ASP.NET FileUpload control is used. The logic is nearly identical to that in AddUploadedFilesForFullTrust - the only /// differences are syntax differences arising from the different file upload control. /// </summary> private void AddUploadedFilesLessThanFullTrust() { // Clear the list of hash keys so we're starting with a fresh load from the data store. try { MediaObjectHashKeys.Clear(); string albumPhysicalPath = this.GetAlbum().FullPhysicalPathOnDisk; HelperFunctions.BeginTransaction(); for (int i = 0; i < 5; i++) { FileUpload file = (FileUpload)phUpload.FindControl("fuUpload" + i); if (!file.HasFile) { continue; } if ((System.IO.Path.GetExtension(file.FileName).Equals(".zip", StringComparison.OrdinalIgnoreCase)) && (!chkDoNotExtractZipFile.Checked)) { #region Extract the files from the zipped file. // Extract the files from the zipped file. using (ZipUtility zip = new ZipUtility(Util.UserName, GetGalleryServerRolesForUser())) { this._skippedFiles.AddRange(zip.ExtractZipFile(file.FileContent, this.GetAlbum(), chkDiscardOriginalImage.Checked)); } #endregion } else { #region Add the file string filename = HelperFunctions.ValidateFileName(albumPhysicalPath, file.FileName); string filepath = Path.Combine(albumPhysicalPath, filename); file.SaveAs(filepath); try { IGalleryObject go = Factory.CreateMediaObjectInstance(filepath, this.GetAlbum()); // Sueetie Modified - Fix Blank Title on individual uploads if (go.Title.Trim().Length == 0) { go.Title = go.Original.FileName; } GalleryObjectController.SaveGalleryObject(go); if ((chkDiscardOriginalImage.Checked) && (go is Business.Image)) { ((Business.Image)go).DeleteHiResImage(); GalleryObjectController.SaveGalleryObject(go); } // Sueetie Modified - Add mediaobject to Sueetie_Content - Single File SueetieContent sueetieContent = new SueetieContent { SourceID = go.Id, ContentTypeID = MediaHelper.ConvertContentType(go.MimeType.TypeCategory), ApplicationID = (int)SueetieApplications.Current.ApplicationID, UserID = CurrentSueetieUserID, IsRestricted = this.GetAlbum().IsPrivate, Permalink = MediaHelper.SueetieMediaObjectUrl(go.Id, this.GalleryId) }; SueetieCommon.AddSueetieContent(sueetieContent); // Add Sueetie-specific data to Sueetie_gs_MediaObject SueetieMediaObject _sueetieMediaObject = new SueetieMediaObject(); _sueetieMediaObject.MediaObjectID = go.Id; _sueetieMediaObject.ContentTypeID = MediaHelper.ConvertContentType(go.MimeType.TypeCategory); _sueetieMediaObject.AlbumID = this.GetAlbum().Id; _sueetieMediaObject.InDownloadReport = false; SueetieMedia.CreateSueetieMediaObject(_sueetieMediaObject); SueetieMediaAlbum sueetieAlbum = SueetieMedia.GetSueetieMediaAlbum(this.GetAlbum().Id); if (CurrentSueetieGallery.IsLogged) { SueetieLogs.LogUserEntry((UserLogCategoryType)sueetieAlbum.AlbumMediaCategoryID, sueetieAlbum.ContentID, CurrentSueetieUserID); } SueetieMedia.ClearMediaPhotoListCache(0); SueetieMedia.ClearSueetieMediaObjectListCache(this.CurrentSueetieGalleryID); } catch (UnsupportedMediaObjectTypeException ex) { try { File.Delete(filepath); } catch (UnauthorizedAccessException) { } // Ignore an error; the file will end up getting deleted during cleanup maintenance this._skippedFiles.Add(new KeyValuePair <string, string>(filename, ex.Message)); } #endregion } } HelperFunctions.CommitTransaction(); } catch { HelperFunctions.RollbackTransaction(); throw; } finally { // Clear the list of hash keys to free up memory. MediaObjectHashKeys.Clear(); HelperFunctions.PurgeCache(); } }