/// <summary> Saves the data rendered by this element to the provided bibliographic object during postback </summary> /// <param name="Bib"> Object into which to save the user's data, entered into the html rendered by this element </param> public override void Save_To_Bib(SobekCM_Item Bib) { // Try to get any existing metadata module VRACore_Info vraInfo = Bib.Get_Metadata_Module(GlobalVar.VRACORE_METADATA_MODULE_KEY) as VRACore_Info; string[] getKeys = HttpContext.Current.Request.Form.AllKeys; foreach (string thisKey in getKeys.Where(ThisKey => ThisKey.IndexOf(html_element_name.Replace("_", "")) == 0)) { // Get the value from the form element string value = HttpContext.Current.Request.Form[thisKey].Trim(); if (value.Length > 0) { // There is a value, so ensure metadata does exist if (vraInfo == null) { vraInfo = new VRACore_Info(); Bib.Add_Metadata_Module(GlobalVar.VRACORE_METADATA_MODULE_KEY, vraInfo); } // Add the value vraInfo.Add_Cultural_Context(value); } } }
/// <summary> Saves the data rendered by this element to the provided bibliographic object during postback </summary> /// <param name="Bib"> Object into which to save the user's data, entered into the html rendered by this element </param> public override void Save_To_Bib(SobekCM_Item Bib) { string[] getKeys = HttpContext.Current.Request.Form.AllKeys; foreach (string thisKey in getKeys.Where(ThisKey => ThisKey.IndexOf(html_element_name) == 0)) { string video_embedding_html = HttpContext.Current.Request.Form[thisKey]; if (video_embedding_html.IndexOf(".uflib.ufl.edu/vodou") > 0) { video_embedding_html = video_embedding_html.Replace("height='475'", "height='435'").Replace("uflib.ufl.edu/vodou/DesktopModules/UltraVideoGallery", "uflib.ufl.edu/DesktopModules/UltraVideoGallery"); } Bib.Behaviors.Embedded_Video = video_embedding_html; } }
/// <summary> Constructor for a new instance of the File_Management_MySobekViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> public File_Management_MySobekViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", String.Empty); // If no user then that is an error if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn)) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation; RequestSpecificValues.Current_Mode.Aggregation = String.Empty; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // Ensure BibID and VID provided RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "Validate provided bibid / vid"); if ((String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.BibID)) || (String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.VID))) { RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "BibID or VID was not provided!"); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error; RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : BibID/VID missing in item file upload request"; return; } RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "Try to pull this sobek complete item"); currentItem = SobekEngineClient.Items.Get_Sobek_Item(RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Current_Mode.VID, RequestSpecificValues.Current_User.UserID, RequestSpecificValues.Tracer); if (currentItem == null) { RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "Unable to build complete item"); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error; RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : Unable to build complete item"; return; } digitalResourceDirectory = currentItem.Source_Directory; // If the user cannot edit this currentItem, go back if (!RequestSpecificValues.Current_User.Can_Edit_This_Item(currentItem.BibID, currentItem.Bib_Info.SobekCM_Type_String, currentItem.Bib_Info.Source.Code, currentItem.Bib_Info.HoldingCode, currentItem.Behaviors.Aggregation_Code_List)) { RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // If this is post-back, handle it if (RequestSpecificValues.Current_Mode.isPostBack) { string[] getKeys = HttpContext.Current.Request.Form.AllKeys; string file_name_from_keys = String.Empty; string label_from_keys = String.Empty; foreach (string thisKey in getKeys) { if (thisKey.IndexOf("upload_file") == 0) { file_name_from_keys = HttpContext.Current.Request.Form[thisKey]; } if (thisKey.IndexOf("upload_label") == 0) { label_from_keys = HttpContext.Current.Request.Form[thisKey]; } if ((file_name_from_keys.Length > 0) && (label_from_keys.Length > 0)) { HttpContext.Current.Session["file_" + currentItem.Web.ItemID + "_" + file_name_from_keys.Trim()] = label_from_keys.Trim(); file_name_from_keys = String.Empty; label_from_keys = String.Empty; } if (thisKey == "url_input") { currentItem.Bib_Info.Location.Other_URL = HttpContext.Current.Request.Form[thisKey]; } } string action = HttpContext.Current.Request.Form["action"]; if (action == "delete") { string filename = HttpContext.Current.Request.Form["phase"]; try { if (File.Exists(digitalResourceDirectory + "\\" + filename)) { File.Delete(digitalResourceDirectory + "\\" + filename); } // Special code for PDF files and their derivatives if (filename.IndexOf(".pdf", StringComparison.OrdinalIgnoreCase) > 0) { // Delete the PDF text if (File.Exists(digitalResourceDirectory + "\\" + filename.ToLower().Replace(".pdf", "_pdf.txt"))) { File.Delete(digitalResourceDirectory + "\\" + filename.ToLower().Replace(".pdf", "_pdf.txt")); } // Delete the PDF thumbnail if (File.Exists(digitalResourceDirectory + "\\" + filename.ToLower().Replace(".pdf", "thm.jpg"))) { File.Delete(digitalResourceDirectory + "\\" + filename.ToLower().Replace(".pdf", "thm.jpg")); } } // Forward UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } catch { // Error was caught during attempted delete } } if (action == "next_phase") { int phase = Convert.ToInt32(HttpContext.Current.Request.Form["phase"]); switch (phase) { case 2: // Clear all the file keys in the session state List <string> keys = HttpContext.Current.Session.Keys.Cast <string>().Where(ThisKey => ThisKey.IndexOf("file_" + currentItem.Web.ItemID + "_") == 0).ToList(); foreach (string thisKey in keys) { HttpContext.Current.Session.Remove(thisKey); } // Redirect to the currentItem RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); break; case 9: if (!complete_item_submission(currentItem, null)) { // Clear all the file keys in the session state List <string> keys2 = HttpContext.Current.Session.Keys.Cast <string>().Where(ThisKey => ThisKey.IndexOf("file_" + currentItem.Web.ItemID + "_") == 0).ToList(); foreach (string thisKey in keys2) { HttpContext.Current.Session.Remove(thisKey); } // Remoe from the caches (to replace the other) CachedDataManager.Items.Remove_Digital_Resource_Object(currentItem.BibID, currentItem.VID, RequestSpecificValues.Tracer); // Also clear the engine SobekEngineClient.Items.Clear_Item_Cache(currentItem.BibID, currentItem.VID, RequestSpecificValues.Tracer); // Redirect to the currentItem RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } break; } } } }
/// <summary> Constructor for a new instance of the New_Group_And_Item_MySobekViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Item"> Digital resource selected for file management </param> /// <param name="Item_List"> Allows individual items to be retrieved by various methods as <see cref="Single_Item"/> objects.</param> /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="HTML_Skin_Collection"> HTML Web skin collection which controls the overall appearance of this digital library </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public File_Management_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Item_Lookup_Object Item_List, Aggregation_Code_Manager Code_Manager, Dictionary <string, Wordmark_Icon> Icon_Table, SobekCM_Skin_Object HTML_Skin, Language_Support_Info Translator, SobekCM_Skin_Collection HTML_Skin_Collection, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", String.Empty); // Save the parameters codeManager = Code_Manager; itemList = Item_List; iconList = Icon_Table; currentMode = Current_Mode; webSkin = HTML_Skin; base.Translator = Translator; item = Current_Item; digitalResourceDirectory = Current_Item.Source_Directory; skins = HTML_Skin_Collection; // If the user cannot edit this item, go back if (!user.Can_Edit_This_Item(item)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; currentMode.Redirect(); return; } // If this is post-back, handle it if (currentMode.isPostBack) { string[] getKeys = HttpContext.Current.Request.Form.AllKeys; string file_name_from_keys = String.Empty; string label_from_keys = String.Empty; foreach (string thisKey in getKeys) { if (thisKey.IndexOf("upload_file") == 0) { file_name_from_keys = HttpContext.Current.Request.Form[thisKey]; } if (thisKey.IndexOf("upload_label") == 0) { label_from_keys = HttpContext.Current.Request.Form[thisKey]; } if ((file_name_from_keys.Length > 0) && (label_from_keys.Length > 0)) { HttpContext.Current.Session["file_" + item.Web.ItemID + "_" + file_name_from_keys.Trim()] = label_from_keys.Trim(); file_name_from_keys = String.Empty; label_from_keys = String.Empty; } if (thisKey == "url_input") { item.Bib_Info.Location.Other_URL = HttpContext.Current.Request.Form[thisKey]; } } string action = HttpContext.Current.Request.Form["action"]; if (action == "delete") { string filename = HttpContext.Current.Request.Form["phase"]; try { if (File.Exists(digitalResourceDirectory + "\\" + filename)) { File.Delete(digitalResourceDirectory + "\\" + filename); } // Forward currentMode.Redirect(); return; } catch { // Error was caught during attempted delete } } if (action == "next_phase") { int phase = Convert.ToInt32(HttpContext.Current.Request.Form["phase"]); switch (phase) { case 2: // Clear all the file keys in the session state List <string> keys = HttpContext.Current.Session.Keys.Cast <string>().Where(ThisKey => ThisKey.IndexOf("file_" + item.Web.ItemID + "_") == 0).ToList(); foreach (string thisKey in keys) { HttpContext.Current.Session.Remove(thisKey); } // Redirect to the item currentMode.Mode = Display_Mode_Enum.Item_Display; currentMode.Redirect(); break; case 9: if (!complete_item_submission(item, null)) { // Clear all the file keys in the session state List <string> keys2 = HttpContext.Current.Session.Keys.Cast <string>().Where(ThisKey => ThisKey.IndexOf("file_" + item.Web.ItemID + "_") == 0).ToList(); foreach (string thisKey in keys2) { HttpContext.Current.Session.Remove(thisKey); } // Also clear the item from the cache MemoryMgmt.Cached_Data_Manager.Remove_Digital_Resource_Object(item.BibID, item.VID, null); // Redirect to the item currentMode.Mode = Display_Mode_Enum.Item_Display; currentMode.Redirect(); } break; } } } }