private void ConfigureControlsFirstTime() { this.OkButtonIsVisible = false; // Instead, we'll use our own buttons inside the tab control. this.CancelButtonIsVisible = false; this.TaskHeaderText = Resources.GalleryServerPro.Task_Add_Objects_Header_Text; this.TaskBodyText = Resources.GalleryServerPro.Task_Add_Objects_Body_Text; this.PageTitle = Resources.GalleryServerPro.Task_Add_Objects_Page_Title; cpe.ExpandedImage = Util.GetUrl("/images/collapse.jpg"); cpe.CollapsedImage = Util.GetUrl("/images/expand.jpg"); imgExpCol.ImageUrl = Util.GetUrl("/images/expand.jpg"); ConfigureTabStrip(); if (!HelperFunctions.IsFileAuthorizedForAddingToGallery("dummy.zip", GalleryId)) { chkDoNotExtractZipFile.Enabled = false; chkDoNotExtractZipFile.CssClass = "gsp_disabledtext"; } if (GallerySettings.DiscardOriginalImageDuringImport) { chkDiscardOriginalImage.Checked = true; chkDiscardOriginalImage.Enabled = false; chkDiscardOriginalImage.CssClass = "gsp_disabledtext"; } // Sueetie Modified - Clear Gallery Cache in case gallery just created and this the first object addition SueetieMedia.ClearSueetieMediaGalleryListCache(); }
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 List <SueetieMediaObject> sueetieMediaObjects = new List <SueetieMediaObject>(); IGalleryObjectCollection albumChildren = this.GetAlbum().GetChildGalleryObjects(GalleryObjectType.MediaObject, true); foreach (IGalleryObject _galleryObject in albumChildren) { SueetieMediaObject _sueetieMediaObject = SueetieMedia.GetSueetieMediaObject(this.CurrentSueetieGalleryID, _galleryObject.Id); MediaHelper.PopulateMediaObject(_sueetieMediaObject, _galleryObject); sueetieMediaObjects.Add(_sueetieMediaObject); } 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 Page_Load(object sender, EventArgs e) { string path = this.ViewName.ControlPath(); ContentQuery contentQuery = new ContentQuery { NumRecords = this.NumRecords, UserID = this.UserID, ContentTypeID = (int)SueetieContentType.MediaImage, GroupID = this.GroupID, ApplicationID = this.ApplicationID, IsRestricted = this.IsRestricted, TruncateText = false, SueetieContentViewTypeID = (int)SueetieContentViewType.RecentPhotos, CacheMinutes = this.CacheMinutes }; List <SueetieMediaObject> recentPhotos = SueetieMedia.GetSueetieMediaObjectList(contentQuery); foreach (SueetieMediaObject photo in recentPhotos) { Sueetie.Controls.RecentPhotoView control = (Sueetie.Controls.RecentPhotoView)LoadControl(path); control.RecentPhoto = photo; phRecentPhotos.Controls.Add(control); } }
// Sueetie Modified - Bind Checkbox Checked Status protected void rptr_OnItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { GalleryObject galleryObject = ((GalleryObject)e.Item.DataItem); if (galleryObject.GetType().Name.ToLower() != "album") { int mediaObjectID = galleryObject.Id; CheckBox chkMO = (CheckBox)e.Item.FindControl("chkMO"); chkMO.Checked = SueetieMedia.IsIncludedInDownload(mediaObjectID); } } }
private static IGallery CreateGallery(string description) { IGallery gallery = Factory.CreateGalleryInstance(); gallery.Description = description; gallery.Save(); // Sueetie Modified - Create Sueetie Media Gallery record stub SueetieMedia.CreateMediaGallery(gallery.GalleryId); return(gallery); }
private void SaveSettings() { List <SueetieMediaAlbum> sueetieMediaAlbums = SueetieMedia.GetSueetieAlbumUpdateList(this.GalleryId); int j = 0; foreach (SueetieMediaAlbum _sueetieMediaAlbum in sueetieMediaAlbums) { IAlbum album = Factory.LoadAlbumInstance(_sueetieMediaAlbum.AlbumID, false, true); SueetieContent sueetieAlbumContent = new SueetieContent { SourceID = _sueetieMediaAlbum.AlbumID, ContentTypeID = (int)SueetieContentType.OtherAlbum, ApplicationID = (int)SueetieApplications.Current.ApplicationID, UserID = _sueetieMediaAlbum.SueetieUserID, IsRestricted = _sueetieMediaAlbum.IsRestricted, Permalink = "/" + SueetieApplications.Current.ApplicationKey + "/" + CurrentSueetieGallery.GalleryKey + ".aspx?aid=" + _sueetieMediaAlbum.AlbumID, }; SueetieCommon.AddSueetieContent(sueetieAlbumContent); string sueetieAlbumPath = SueetieMedia.CreateSueetieAlbumPath(album.FullPhysicalPath); SueetieMedia.CreateSueetieAlbum(_sueetieMediaAlbum.AlbumID, sueetieAlbumPath, (int)SueetieContentType.OtherAlbum); j++; } List <SueetieMediaObject> sueetieMediaObjects = SueetieMedia.GetSueetieMediaUpdateList(); int i = 0; foreach (SueetieMediaObject _sueetieMediaObject in sueetieMediaObjects) { int _moid = _sueetieMediaObject.MediaObjectID; IGalleryObject mo = Factory.LoadMediaObjectInstance(_moid); SueetieContent sueetieMediaContent = 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) }; SueetieCommon.AddSueetieContent(sueetieMediaContent); SueetieMedia.CreateSueetieMediaObject(_sueetieMediaObject); i++; } SueetieMedia.ClearMediaPhotoListCache(0); // Clear Recent Photos for top level Gallery SueetieMedia.ClearSueetieMediaAlbumListCache(this.GalleryId); SueetieMedia.ClearSueetieMediaObjectListCache(this.GalleryId); this.wwMessage.CssClass = "wwErrorSuccess gsp_msgfriendly gsp_bold"; this.wwMessage.ShowMessage(i.ToString() + " media objects, " + j.ToString() + " albums added to Sueetie Content Core."); }
private void ConfigureControls() { // Sueetie Modified - Add Album Content Types List <ContentTypeDescription> albumContentTypes = SueetieMedia.GetAlbumContentTypeDescriptionList(); foreach (ContentTypeDescription _albumContentType in albumContentTypes) { ddSueetieAlbumType.Items.Add(new ListItem(_albumContentType.Description, _albumContentType.ContentTypeID.ToString())); } this.TaskHeaderText = Resources.GalleryServerPro.Task_Create_Album_Header_Text; this.TaskBodyText = Resources.GalleryServerPro.Task_Create_Album_Body_Text; this.OkButtonText = Resources.GalleryServerPro.Task_Create_Album_Ok_Button_Text; this.OkButtonToolTip = Resources.GalleryServerPro.Task_Create_Album_Ok_Button_Tooltip; this.PageTitle = Resources.GalleryServerPro.Task_Create_Album_Page_Title; txtTitle.MaxLength = DataConstants.AlbumTitleLength; lblMaxTitleLengthInfo.Text = String.Format(CultureInfo.CurrentCulture, Resources.GalleryServerPro.Task_Create_Album_Title_Max_Length_Text, DataConstants.AlbumTitleLength.ToString(CultureInfo.InvariantCulture)); tvUC.RequiredSecurityPermissions = SecurityActions.AddChildAlbum; if (this.GetAlbum().IsPrivate) { chkIsPrivate.Checked = true; chkIsPrivate.Enabled = false; lblPrivateAlbumIsInherited.Text = Resources.GalleryServerPro.Task_Create_Album_Is_Private_Disabled_Text; } IAlbum albumToSelect = this.GetAlbum(); if (!IsUserAuthorized(SecurityActions.AddChildAlbum, albumToSelect)) { albumToSelect = AlbumController.GetHighestLevelAlbumWithCreatePermission(GalleryId); } if (albumToSelect == null) { tvUC.BindTreeView(); } else { tvUC.BindTreeView(albumToSelect); } this.Page.Form.DefaultFocus = txtTitle.ClientID; }
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 bool btnOkClicked() { CheckBox chkbx; HiddenField gc; foreach (RepeaterItem rptrItem in rptr.Items) { chkbx = rptrItem.FindControl("chkMO") as CheckBox; gc = (HiddenField)rptrItem.FindControl("hdn"); int id = Convert.ToInt32(gc.Value.Substring(1), CultureInfo.InvariantCulture); SueetieMedia.SetIncludedInDownload(id, chkbx.Checked); } return(true); }
public void Synchronize(int albumId, string synchId, bool isRecursive, bool overwriteThumb, bool overwriteOpt, bool regenerateMetadata) { IAlbum album = null; try { #region Check user authorization bool isUserAuthenticated = Util.IsAuthenticated; if (!isUserAuthenticated) { return; } album = Factory.LoadAlbumInstance(albumId, true, true, false); if (!Util.IsUserAuthorized(SecurityActions.Synchronize, RoleController.GetGalleryServerRolesForUser(), albumId, album.GalleryId, false)) { return; } #endregion SynchronizationManager synchMgr = new SynchronizationManager(album.GalleryId); synchMgr.IsRecursive = isRecursive; synchMgr.OverwriteThumbnail = overwriteThumb; synchMgr.OverwriteOptimized = overwriteOpt; synchMgr.RegenerateMetadata = regenerateMetadata; synchMgr.Synchronize(synchId, album, Util.UserName); // Sueetie Modified - Fix missing media object titles from GSP sync process SueetieMedia.PopulateMediaObjectTitles(); } catch (Exception ex) { if (album != null) { AppErrorController.LogError(ex, album.GalleryId); } else { AppErrorController.LogError(ex); } throw; } }
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)); } }
private List <SueetieDownload> SueetieDownloadList() { ContentQuery _contentQuery = new ContentQuery { ApplicationID = this.ApplicationID, SueetieContentViewTypeID = -1, NumRecords = 1000, UserID = this.DownloadUserID, GroupID = this.GroupID, SourceID = this.MediaObjectID, SortBy = (int)SueetieSortBy.MostRecentDateTimeDesc }; List <SueetieDownload> _sueetieDownloads = SueetieMedia.GetSueetieDownloadList(_contentQuery); return(_sueetieDownloads); }
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); } }
private List <SueetieDownload> SueetieDownloadList() { ContentQuery _contentQuery = new ContentQuery { ApplicationID = this.ApplicationID, SueetieContentViewTypeID = (int)SueetieContentViewType.DownloadSummaryReport, NumRecords = 1000, UserID = -1, GroupID = this.GroupID, SourceID = -1, SortBy = this.SortByID }; List <SueetieDownload> _sueetieDownloads = SueetieMedia.GetSueetieDownloadList(_contentQuery); return(_sueetieDownloads); }
protected void ActivitiesGridView_OnRowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow && ((e.Row.RowState & DataControlRowState.Edit) > 0)) { SueetieMediaAlbum _sueetieMediaAlbum = ((SueetieMediaAlbum)e.Row.DataItem); List <ContentTypeDescription> _contentTypeDescriptions = SueetieMedia.GetAlbumContentTypeDescriptionList(); DropDownList ddContentTypes = (DropDownList)e.Row.FindControl("ddContentTypes") as DropDownList; foreach (ContentTypeDescription _contentTypeDescription in _contentTypeDescriptions) { ddContentTypes.Items.Add(new ListItem(_contentTypeDescription.Description, _contentTypeDescription.ContentTypeID.ToString())); } ddContentTypes.Items.FindByValue(_sueetieMediaAlbum.ContentTypeID.ToString()).Selected = true; ddContentTypes.DataBind(); this.ContentID = _sueetieMediaAlbum.ContentID; } }
private void SaveSettings() { List <SueetieMediaAlbum> sueetieMediaAlbums = SueetieMedia.GetSueetieMediaAlbumList(this.GalleryId); int j = 0; foreach (SueetieMediaAlbum _sueetieMediaAlbum in sueetieMediaAlbums) { IAlbum album = Factory.LoadAlbumInstance(_sueetieMediaAlbum.AlbumID, false, true); _sueetieMediaAlbum.SueetieAlbumPath = SueetieMedia.CreateSueetieAlbumPath(album.FullPhysicalPath); SueetieMedia.UpdateSueetieAlbumPath(_sueetieMediaAlbum); j++; } SueetieMedia.ClearMediaPhotoListCache(0); // Clear Recent Photos for top level Gallery SueetieMedia.ClearSueetieMediaAlbumListCache(this.GalleryId); SueetieMedia.ClearSueetieMediaObjectListCache(this.GalleryId); this.wwMessage.CssClass = "wwErrorSuccess gsp_msgfriendly gsp_bold"; this.wwMessage.ShowMessage(j.ToString() + " album paths updated."); }
public string ProcessTags(int _itemID, int _contentID, int _contentTypeID, string _tags) { if (string.IsNullOrEmpty(_tags)) { return(SueetieLocalizer.GetString("no_tags_entered")); } string pipedTags = SueetieTags.PipedTags(_tags); SueetieTagEntry sueetieTagEntry = new SueetieTagEntry { ItemID = _itemID, ContentID = _contentID, ContentTypeID = _contentTypeID, UserID = SueetieContext.Current.User.UserID, Tags = pipedTags }; if (_contentTypeID == (int)SueetieContentType.CMSPage) { SueetieContentParts.EnterContentPageTags(sueetieTagEntry); } else if (SueetieCommon.IsMediaObject(_contentTypeID)) { SueetieMedia.EnterMediaObjectTags(sueetieTagEntry); } else if (SueetieCommon.IsMediaAlbum(_contentTypeID)) { SueetieMedia.EnterMediaAlbumTags(sueetieTagEntry); } else if (_contentTypeID == (int)SueetieContentType.WikiPage) { SueetieWikis.EnterWikiPageTags(sueetieTagEntry); } else if (_contentTypeID == (int)SueetieContentType.ForumTopic) { SueetieForums.EnterForumTopicTags(sueetieTagEntry); } SueetieTags.ClearSueetieTagCache(); return(SueetieTags.TagUrls(pipedTags)); }
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); } }
private void BindData() { //Get the data associated with the album and display if (this.GalleryObjectsDataSource == null) { // Sueetie Modified - Retrieve Recent Photos if (DataHelper.GetIntFromQueryString("aid", 1) == -1) { List <SueetieMediaObject> sueetieMediaObjects = SueetieMedia.GetSueetieMediaObjectList(this.GalleryPage.CurrentSueetieGalleryID, true); sueetieMediaObjects.Sort(delegate(SueetieMediaObject x, SueetieMediaObject y) { return(DateTime.Compare(y.DateAdded, x.DateAdded)); }); int _photoCount = SueetieConfiguration.Get().Media.RecentPhotoCount; if (_photoCount > sueetieMediaObjects.Count) { _photoCount = sueetieMediaObjects.Count; } IGalleryObjectCollection _galleryObjects = new GalleryObjectCollection(); for (int i = 0; i < _photoCount; i++) { IGalleryObject _galleryObject = Factory.LoadMediaObjectInstance(sueetieMediaObjects[i].MediaObjectID); _galleryObjects.Add(_galleryObject); } _galleryObjects.Sort(); DisplayThumbnails(_galleryObjects, true); } else { DisplayThumbnails(this.GalleryPage.GetAlbum().GetChildGalleryObjects(true, this.GalleryPage.IsAnonymousUser), true); } } else { DisplayThumbnails(this.GalleryObjectsDataSource, false); } }
/// <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> /// 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(); } }
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; IGalleryObject mo; string newTitle, previousTitle, previousTags, previousDescription; Message msg = Message.None; if (!IsUserAuthorized(SecurityActions.EditMediaObject)) { return(msg); } try { HelperFunctions.BeginTransaction(); // Loop through each item in the repeater control. If an item is checked, extract the ID. 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 // Retrieve new title. Since the Value property of <TEXTAREA> HTML ENCODEs the text, // and we want to store the actual text, we must decode to get back to the original. newTitle = Util.HtmlDecode(ta.Value); mo = Factory.LoadMediaObjectInstance(Convert.ToInt32(gc.Value, CultureInfo.InvariantCulture), true); previousTitle = mo.Title; mo.Title = Util.RemoveHtmlTags(newTitle); if (mo.Title != previousTitle) { GalleryObjectController.SaveGalleryObject(mo); } SueetieMediaObject _sueetieMediaObject = SueetieMedia.GetSueetieMediaObject(CurrentSueetieGalleryID, mo.Id); previousDescription = _sueetieMediaObject.MediaObjectDescription; _sueetieMediaObject.MediaObjectDescription = tdesc.Value; if (_sueetieMediaObject.MediaObjectTitle != newTitle || _sueetieMediaObject.MediaObjectDescription != previousDescription) { SueetieMedia.UpdateSueetieMediaObject(_sueetieMediaObject); } } HelperFunctions.CommitTransaction(); } catch { HelperFunctions.RollbackTransaction(); throw; } HelperFunctions.PurgeCache(); SueetieMedia.ClearSueetieMediaObjectListCache(CurrentSueetieGalleryID); return(msg); }
/// <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(); } }
private int btnOkClicked() { //User clicked 'Create album'. Create the new album and return the new album ID. TreeViewNode selectedNode = tvUC.SelectedNode; int parentAlbumID = Int32.Parse(selectedNode.Value, CultureInfo.InvariantCulture); IAlbum parentAlbum = Factory.LoadAlbumInstance(parentAlbumID, false); this.CheckUserSecurity(SecurityActions.AddChildAlbum, parentAlbum); int newAlbumID; if (parentAlbumID > 0) { IAlbum newAlbum = Factory.CreateEmptyAlbumInstance(parentAlbum.GalleryId); newAlbum.Title = GetAlbumTitle(); //newAlbum.ThumbnailMediaObjectId = 0; // not needed newAlbum.Parent = parentAlbum; newAlbum.IsPrivate = (parentAlbum.IsPrivate ? true : chkIsPrivate.Checked); GalleryObjectController.SaveGalleryObject(newAlbum); newAlbumID = newAlbum.Id; // Sueetie Modified - Save New Album to Sueetie_Content, Sueetie_gs_Album and log it in User Activity Log string grpString = string.Empty; if (SueetieApplications.Current.IsGroup) { grpString = "/" + SueetieApplications.Current.GroupKey; } string albumUrl = grpString + "/" + SueetieApplications.Current.ApplicationKey + "/" + CurrentSueetieGallery.GalleryKey + ".aspx?aid=" + newAlbumID.ToString(); SueetieContent sueetieContent = new SueetieContent { SourceID = newAlbumID, ContentTypeID = int.Parse(ddSueetieAlbumType.SelectedValue), ApplicationID = (int)SueetieApplications.Current.ApplicationID, UserID = CurrentSueetieUserID, IsRestricted = newAlbum.IsPrivate, Permalink = albumUrl, }; int contentID = SueetieCommon.AddSueetieContent(sueetieContent); var albumLogCategory = SueetieMedia.GetAlbumContentTypeDescriptionList().Single(contentDescription => contentDescription.ContentTypeID.Equals(sueetieContent.ContentTypeID)); UserLogEntry entry = new UserLogEntry { UserLogCategoryID = albumLogCategory.UserLogCategoryID, ItemID = contentID, UserID = CurrentSueetieUserID, }; if (CurrentSueetieGallery.IsLogged) { SueetieLogs.LogUserEntry(entry); } string albumPath = SueetieMedia.CreateSueetieAlbumPath(newAlbum.FullPhysicalPath); SueetieMedia.CreateSueetieAlbum(newAlbumID, albumPath, sueetieContent.ContentTypeID); SueetieMedia.ClearSueetieMediaAlbumListCache(CurrentSueetieGalleryID); SueetieMedia.ClearSueetieMediaGalleryListCache(); HelperFunctions.PurgeCache(); } else { throw new GalleryServerPro.ErrorHandler.CustomExceptions.InvalidAlbumException(parentAlbumID); } return(newAlbumID); }
protected string GenerateUrl(IGalleryObject _galleryObject) { SueetieMediaObject sueetieMediaObject = SueetieMedia.GetSueetieMediaObject(CurrentSueetieGalleryID, _galleryObject.Id); return(GenerateUrl(sueetieMediaObject)); }
/// <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(); }