/// <summary> Constructor for a new instance of the Static_Pages_Builder class </summary> /// <param name="Primary_Web_Server_URL"> URL for the primary web server </param> /// <param name="Static_Data_Location"> Network location for the data directory </param> /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param> /// <param name="HTML_Skin_Collection"> HTML Web skin collection 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="Default_Skin"> Default skin code </param> public Static_Pages_Builder(string Primary_Web_Server_URL, string Static_Data_Location, Language_Support_Info Translator, Aggregation_Code_Manager Code_Manager, Dictionary<string, Wordmark_Icon> Icon_Table, SobekCM_Skin_Collection HTML_Skin_Collection, string Default_Skin) { primaryWebServerUrl = Primary_Web_Server_URL; staticSobekcmDataLocation = Static_Data_Location; staticSobekcmLocation = String.Empty; tracer = new Custom_Tracer(); assistant = new SobekCM_Assistant(); // Save all the objects needed by the SobekCM Library iconList = Icon_Table; translations = Translator; codeManager = Code_Manager; skinsCollection = HTML_Skin_Collection; defaultSkin = Default_Skin; // Create the mode object currentMode = new SobekCM_Navigation_Object { ViewerCode = "citation", Skin = String.Empty, Mode = Display_Mode_Enum.Item_Display, Language = Web_Language_Enum.English, Base_URL = primaryWebServerUrl }; }
/// <summary> Populates/builds the main default HTML skin during application startup </summary> /// <param name="Skin_List"> List of skin to populate with the default, commonly used skin</param> /// <param name="tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <returns> TRUE if successful, otherwise FALSE </returns> /// <remarks> Most HTML skins are built as they are needed and then cached for a period of time. The main default skins are /// permanently stored in this global <see cref="SobekCM_Skin_Collection"/> object.<br /><br /> /// The default skins currently include: UFDC (english), dLOC (english, french, and spanish) </remarks> public static bool Populate_Default_Skins(SobekCM_Skin_Collection Skin_List, Custom_Tracer tracer) { tracer.Add_Trace("SobekCM_Skin_Collection_Builder.Populate_Default_Skins", "Build the standard interfaces"); // Get the data from the database DataTable skinData = SobekCM_Database.Get_All_Web_Skins(tracer); // Just return if the data appears bad.. if ((skinData == null) || (skinData.Rows.Count == 0)) { return(false); } // Clear existing interfaces Skin_List.Clear(); // Set the data table Skin_List.Skin_Table = skinData; return(true); }
/// <summary> Gets the HTML skin indicated in the current navigation mode </summary> /// <param name="Web_Skin_Code"> Web skin code </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Skin_Collection"> Collection of the most common skins and source information for all the skins made on the fly </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <returns> Fully-built object used to "skin" this digital library </returns> public SobekCM_Skin_Object Get_HTML_Skin( string Web_Skin_Code, SobekCM_Navigation_Object Current_Mode, SobekCM_Skin_Collection Skin_Collection, Custom_Tracer Tracer ) { // Get the interface object SobekCM_Skin_Object htmlSkin = null; string webskin_code_language = Web_Skin_Code; if ( Current_Mode.Language_Code.Length > 0 ) webskin_code_language = webskin_code_language + "_" + Current_Mode.Language_Code; if (Skin_Collection[webskin_code_language] != null) { htmlSkin = Skin_Collection[webskin_code_language]; Current_Mode.Base_Skin = htmlSkin.Base_Skin_Code; Tracer.Add_Trace("SobekCM_Assistant.Get_HTML_Skin", "Web Skin '" + Web_Skin_Code + "' found in global values"); return htmlSkin; } // If no interface yet, look in the cache if (Web_Skin_Code != "new") { htmlSkin = Cached_Data_Manager.Retrieve_Skin(Web_Skin_Code, Current_Mode.Language_Code, Tracer); if (htmlSkin != null) { Tracer.Add_Trace("SobekCM_Assistant.Get_HTML_Skin", "Web skin '" + Web_Skin_Code + "' found in cache"); Current_Mode.Base_Skin = htmlSkin.Base_Skin_Code; return htmlSkin; } } // If still not interface, build one DataRow skin_row = Skin_Collection.Skin_Row(Web_Skin_Code); if (skin_row != null) { Tracer.Add_Trace("SobekCM_Assistant.Get_HTML_Skin", "Building web skin '" + Web_Skin_Code + "'"); SobekCM_Skin_Object new_skin = SobekCM_Skin_Collection_Builder.Build_Skin(skin_row, Current_Mode.Language_Code ); // Look in the web skin row and see if it should be kept around, rather than momentarily cached if (new_skin != null) { if ((skin_row.Table.Columns.Contains("Build_On_Launch")) && (Convert.ToBoolean(skin_row["Build_On_Launch"]))) { // Save this semi-permanently in memory Skin_Collection.Add(new_skin); } else { // Momentarily cache this web skin object Cached_Data_Manager.Store_Skin(Web_Skin_Code, Current_Mode.Language_Code, new_skin, Tracer); } htmlSkin = new_skin; } } // If there is still no interface, this is an ERROR if (htmlSkin == null) { Current_Mode.Mode = Display_Mode_Enum.Error; Current_Mode.Error_Message = "Invalid web skin '" + Web_Skin_Code + "' requested."; } else { Current_Mode.Base_Skin = htmlSkin.Base_Skin_Code; } // Return the value return htmlSkin; }
/// <summary> Gets the HTML skin indicated in the current navigation mode </summary> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Skin_Collection"> Collection of the most common skins and source information for all the skins made on the fly </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <returns> Fully-built object used to "skin" this digital library </returns> public SobekCM_Skin_Object Get_HTML_Skin(SobekCM_Navigation_Object Current_Mode, SobekCM_Skin_Collection Skin_Collection, Custom_Tracer Tracer) { return Get_HTML_Skin(Current_Mode.Skin, Current_Mode, Skin_Collection, Tracer); }
/// <summary> Constructor for a new instance of the Edit_Item_Metadata_MySobekViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="All_Items_Lookup"> Allows individual items to be retrieved by various methods as <see cref="Single_Item"/> objects.</param> /// <param name="Current_Item"> Individual digital resource to be edited by the user </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="HTML_Skin_Collection"> HTML Web skin collection which controls the overall appearance of this digital library </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Edit_Item_Metadata_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Item_Lookup_Object All_Items_Lookup, SobekCM_Item Current_Item, 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("Edit_Item_Metadata_MySobekViewer.Constructor", String.Empty); currentMode = Current_Mode; item = Current_Item; itemList = All_Items_Lookup; codeManager = Code_Manager; iconList = Icon_Table; webSkin = HTML_Skin; popUpFormsHtml = String.Empty; delayed_popup = String.Empty; base.Translator = Translator; 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; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // Is this a project isProject = item.Bib_Info.SobekCM_Type == TypeOfResource_SobekCM_Enum.Project; string template_code = user.Edit_Template_Code; if ((isProject) || (item.Contains_Complex_Content) || (item.Using_Complex_Template)) { template_code = user.Edit_Template_MARC_Code; } template = Cached_Data_Manager.Retrieve_Template(template_code, Tracer); if (template != null) { Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Found template in cache"); } else { Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Reading template file"); // Read this template Template_XML_Reader reader = new Template_XML_Reader(); template = new Template(); reader.Read_XML( SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\edit\\" + template_code + ".xml", template, true); // Add the current codes to this template template.Add_Codes(Code_Manager); // Save this into the cache Cached_Data_Manager.Store_Template(template_code, template, Tracer); } // Get the current page number, or default to 1 page = 1; if (currentMode.My_Sobek_SubMode.Length > 0) { if ((currentMode.My_Sobek_SubMode == "preview") || (currentMode.My_Sobek_SubMode == "marc") || (currentMode.My_Sobek_SubMode == "mets")) { page = 0; } else { page = 1; bool isNumber = currentMode.My_Sobek_SubMode.All(Char.IsNumber); if (isNumber) { if (isProject) Double.TryParse(currentMode.My_Sobek_SubMode[0].ToString(), out page); else Double.TryParse(currentMode.My_Sobek_SubMode, out page); } else if ( isProject ) { if ( Char.IsNumber(currentMode.My_Sobek_SubMode[0])) Double.TryParse(currentMode.My_Sobek_SubMode[0].ToString(), out page); } } } // Handle post backs if (Current_Mode.isPostBack) { // See if there was a hidden request string hidden_request = HttpContext.Current.Request.Form["new_element_requested"] ?? String.Empty; // If this was a cancel request do that if (hidden_request == "cancel") { if (isProject) { Cached_Data_Manager.Remove_Project(user.UserID, item.BibID, null); currentMode.Mode = Display_Mode_Enum.Administrative; currentMode.Admin_Type = Admin_Type_Enum.Default_Metadata; currentMode.My_Sobek_SubMode = String.Empty; currentMode.Redirect(); } else { Cached_Data_Manager.Remove_Digital_Resource_Object(user.UserID, item.BibID, item.VID, null); currentMode.Mode = Display_Mode_Enum.Item_Display; currentMode.Redirect(); } return; } // Save these changes to bib template.Save_To_Bib(item, user, ((int) page)); // See if the user asked for a new element of a complex form type delayed_popup = String.Empty; switch (hidden_request.Trim()) { case "name": delayed_popup = "name"; item.Bib_Info.Add_Named_Entity(String.Empty).Name_Type = Name_Info_Type_Enum.personal; break; case "title": delayed_popup = "title"; item.Bib_Info.Add_Other_Title(String.Empty, Title_Type_Enum.alternative); break; case "subject": delayed_popup = "subject"; item.Bib_Info.Add_Subject(); break; case "spatial": delayed_popup = "spatial"; item.Bib_Info.Add_Hierarchical_Geographic_Subject(); break; case "relateditem": delayed_popup = "relateditem"; item.Bib_Info.Add_Related_Item(new Related_Item_Info()); break; case "save": Complete_Item_Save(); break; case "complicate": item.Using_Complex_Template = true; HttpContext.Current.Response.Redirect( "?" + HttpContext.Current.Request.QueryString, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); currentMode.Request_Completed = true; return; case "simplify": item.Using_Complex_Template = false; HttpContext.Current.Response.Redirect( "?" + HttpContext.Current.Request.QueryString, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); currentMode.Request_Completed = true; return; } // Was this for a new page? if (hidden_request.IndexOf("newpage") == 0) { string page_requested = hidden_request.Replace("newpage", ""); if (page_requested != currentMode.My_Sobek_SubMode) { // forward to requested page currentMode.My_Sobek_SubMode = page_requested; if (currentMode.My_Sobek_SubMode == "0") currentMode.My_Sobek_SubMode = "preview"; if (isProject) currentMode.My_Sobek_SubMode = page_requested + item.BibID; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL() + "#template", false); HttpContext.Current.ApplicationInstance.CompleteRequest(); currentMode.Request_Completed = true; } } } }
/// <summary> Constructor for a new instance of the Portals_AdminViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="URL_Portals"> List of all web portals into this system </param> /// <param name="Web_Skin_Collection"> Contains the collection of all the default skins and the data to create any additional skins on request</param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Portals_AdminViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Portal_List URL_Portals, SobekCM_Skin_Collection Web_Skin_Collection, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Portals_AdminViewer.Constructor", String.Empty); portals = URL_Portals; skinCollection = Web_Skin_Collection; // Save the mode currentMode = Current_Mode; // Set action message to nothing to start actionMessage = String.Empty; // If the user cannot edit this, go back if (( user == null ) || ((!user.Is_System_Admin) && ( !user.Is_Portal_Admin ))) { Current_Mode.Mode = Display_Mode_Enum.My_Sobek; Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; currentMode.Redirect(); return; } // Handle any post backs if ((Current_Mode.isPostBack) && ( user.Is_System_Admin )) { try { // Pull the standard values from the form NameValueCollection form = HttpContext.Current.Request.Form; string save_value = form["admin_portal_tosave"]; string action_value = form["admin_portal_action"]; // Switch, depending on the request if (action_value != null) { switch (action_value.Trim().ToLower()) { case "edit": // Get the values from the form for this new portal string edit_name = form["form_portal_name"].Trim(); string edit_abbr = form["form_portal_abbr"].Trim(); string edit_skin = form["form_portal_skin"].Trim(); string edit_aggr = form["form_portal_aggregation"].Trim(); string edit_url = form["form_portal_url"].Trim(); string edit_purl = form["form_portal_purl"].Trim(); int portalid = Convert.ToInt32(save_value); // Look for this to see if this was the pre-existing default bool isDefault = portals.Default_Portal.ID == portalid; // Don't edit if the URL segment is empty and this is NOT default if ((!isDefault) && (edit_url.Trim().Length == 0)) { actionMessage = "ERROR: Non default portals MUST have a url segment associated."; } else { // Now, save this portal information int edit_id = SobekCM_Database.Edit_URL_Portal(portalid, edit_url, true, isDefault, edit_abbr, edit_name, edit_aggr, edit_skin, edit_purl, Tracer); if (edit_id > 0) actionMessage = "Edited existing URL portal '" + edit_name + "'"; else actionMessage = "Error editing URL portal."; } break; case "delete": actionMessage = SobekCM_Database.Delete_URL_Portal(Convert.ToInt32(save_value), Tracer) ? "URL portal deleted" : "Error deleting the URL portal"; break; case "new": // Get the values from the form for this new portal string new_name = form["admin_portal_name"]; string new_abbr = form["admin_portal_abbr"]; string new_skin = form["admin_portal_skin"]; string new_aggr = form["admin_portal_aggregation"]; string new_url = form["admin_portal_url"]; string new_purl = form["admin_portal_purl"]; // Save this to the database int new_id = SobekCM_Database.Edit_URL_Portal(-1, new_url, true, false, new_abbr, new_name, new_aggr, new_skin, new_purl, Tracer); if (new_id > 0) actionMessage = "Saved new URL portal '" + new_name + "'"; else actionMessage = "Error saving URL portal."; break; } } } catch (Exception) { actionMessage = "Exception caught while handling request"; } // Reload all the URL portals SobekCM_Database.Populate_URL_Portals(portals, Tracer); } }
/// <summary> Constructor for a new instance of the Admin_HtmlSubwriter class </summary> /// <param name="Results_Statistics"> Information about the entire set of results for a browse of a user's bookshelf folder </param> /// <param name="Paged_Results"> Single page of results for a browse of a user's bookshelf folder, within the entire set </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="All_Items_Lookup"> Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Item">Current item to edit, if the user is requesting to edit an item</param> /// <param name="Aggregation_Aliases"> List of all existing aliases for existing aggregations </param> /// <param name="Web_Skin_Collection"> Collection of all the web skins </param> /// <param name="Current_User"> Currently logged on user </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="IP_Restrictions"> List of all IP Restriction ranges in use by this digital library </param> /// <param name="URL_Portals"> List of all web portals into this system </param> /// <param name="Stats_Date_Range"> Object contains the start and end dates for the statistical data in the database </param> /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the home page are organized </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public Admin_HtmlSubwriter(Search_Results_Statistics Results_Statistics, List<iSearch_Title_Result> Paged_Results, Aggregation_Code_Manager Code_Manager, Item_Lookup_Object All_Items_Lookup, Item_Aggregation Hierarchy_Object, SobekCM_Skin_Object HTML_Skin, Language_Support_Info Translator, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Dictionary<string,string> Aggregation_Aliases, SobekCM_Skin_Collection Web_Skin_Collection, User_Object Current_User, IP_Restriction_Ranges IP_Restrictions, Dictionary<string, Wordmark_Icon> Icon_Table, Portal_List URL_Portals, Statistics_Dates Stats_Date_Range, List<Thematic_Heading> Thematic_Headings, Custom_Tracer Tracer ) { Tracer.Add_Trace("Admin_HtmlSubwriter.Constructor", "Saving values and geting user object back from the session"); resultsStatistics = Results_Statistics; pagedResults = Paged_Results; codeManager = Code_Manager; itemList = All_Items_Lookup; htmlSkin = HTML_Skin; translator = Translator; currentCollection = Hierarchy_Object; currentItem = Current_Item; user = Current_User; ipRestrictions = IP_Restrictions; iconTable = Icon_Table; statsDates = Stats_Date_Range; if (Current_Mode.My_Sobek_Type == My_Sobek_Type_Enum.Log_Out) { Tracer.Add_Trace("Admin_HtmlSubwriter.Constructor", "Performing logout"); HttpContext.Current.Session["user"] = null; HttpContext.Current.Response.Redirect("?"); } if ((Current_Mode.My_Sobek_Type != My_Sobek_Type_Enum.Logon) && (user != null) && (user.Is_Temporary_Password)) { Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.New_Password; } if (Current_Mode.Logon_Required) Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Logon; // If the user is not an admin, and admin was selected, reroute this if ((!Current_User.Is_System_Admin) && (!Current_User.Is_Portal_Admin)) { Current_Mode.Mode = Display_Mode_Enum.My_Sobek; Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; Current_Mode.My_Sobek_SubMode = String.Empty; HttpContext.Current.Response.Redirect(Current_Mode.Redirect_URL()); } Tracer.Add_Trace("Admin_HtmlSubwriter.Constructor", "Building the my sobek viewer object"); switch (Current_Mode.Admin_Type) { case Admin_Type_Enum.Aggregation_Single: adminViewer = new Aggregation_Single_AdminViewer(user, Current_Mode, codeManager, Thematic_Headings, Web_Skin_Collection, Tracer); break; case Admin_Type_Enum.Home: adminViewer = new Home_AdminViewer(user, Current_Mode, Tracer); break; case Admin_Type_Enum.Builder_Status: adminViewer = new Builder_AdminViewer(user, Current_Mode); break; case Admin_Type_Enum.Interfaces: adminViewer = new Skins_AdminViewer(user, Current_Mode, Web_Skin_Collection, Tracer); break; case Admin_Type_Enum.Forwarding: adminViewer = new Aliases_AdminViewer(user, Current_Mode, Aggregation_Aliases, Tracer); break; case Admin_Type_Enum.Wordmarks: adminViewer = new Wordmarks_AdminViewer(user, Current_Mode, Tracer); break; case Admin_Type_Enum.URL_Portals: adminViewer = new Portals_AdminViewer(user, Current_Mode, URL_Portals, Tracer); break; case Admin_Type_Enum.Users: adminViewer = new Users_AdminViewer(user, Current_Mode, codeManager, Tracer); break; case Admin_Type_Enum.User_Groups: adminViewer = new User_Group_AdminViewer(user, Current_Mode, codeManager, Tracer); break; case Admin_Type_Enum.Aggregations_Mgmt: adminViewer = new Aggregations_Mgmt_AdminViewer(user, Current_Mode, codeManager, Tracer); break; case Admin_Type_Enum.IP_Restrictions: adminViewer = new IP_Restrictions_AdminViewer(user, Current_Mode, ipRestrictions, Tracer); break; case Admin_Type_Enum.Thematic_Headings: adminViewer = new Thematic_Headings_AdminViewer(user, Current_Mode, Thematic_Headings, Tracer); break; case Admin_Type_Enum.Settings: adminViewer = new Settings_AdminViewer(user, Current_Mode, Tracer); break; case Admin_Type_Enum.Projects: if (Current_Mode.My_Sobek_SubMode.Length > 1) { string project_code = Current_Mode.My_Sobek_SubMode.Substring(1); Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Checking cache for valid project file"); if (user != null) { SobekCM_Item projectObject = Cached_Data_Manager.Retrieve_Project(user.UserID, project_code, Tracer); if (projectObject != null) { Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Valid project file found in cache"); adminViewer = new Edit_Item_Metadata_MySobekViewer(user, Current_Mode, itemList, projectObject, codeManager, iconTable, htmlSkin, Tracer); } else { if (SobekCM_Database.Get_All_Projects_Templates(Tracer).Tables[0].Select("ProjectCode='" + project_code + "'").Length > 0) { Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Building project file from (possible) PMETS"); string pmets_file = SobekCM_Library_Settings.Base_MySobek_Directory + "projects\\" + Current_Mode.My_Sobek_SubMode.Substring(1) + ".pmets"; SobekCM_Item pmets_item = File.Exists(pmets_file) ? SobekCM_Item.Read_METS(pmets_file) : new SobekCM_Item(); pmets_item.Bib_Info.Main_Title.Title = "Project level metadata for '" + project_code + "'"; pmets_item.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Project; pmets_item.BibID = project_code.ToUpper(); pmets_item.VID = "00001"; pmets_item.Source_Directory = SobekCM_Library_Settings.Base_MySobek_Directory + "projects\\"; Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Adding project file to cache"); Cached_Data_Manager.Store_Project(user.UserID, project_code, pmets_item, Tracer); adminViewer = new Edit_Item_Metadata_MySobekViewer(user, Current_Mode, itemList, pmets_item, codeManager, iconTable, htmlSkin, Tracer); } } } } if (adminViewer == null) adminViewer = new Projects_AdminViewer(user, Current_Mode, Tracer); break; } // Pass in the navigation and translator information adminViewer.CurrentMode = Current_Mode; adminViewer.Translator = translator; }
/// <summary> Constructor for a new instance of the Aggregation_Single_AdminViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the home page are organized </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> /// <remarks> Postback from handling an edit or new aggregation is handled here in the constructor </remarks> public Aggregation_Single_AdminViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Aggregation_Code_Manager Code_Manager, List<Thematic_Heading> Thematic_Headings, SobekCM_Skin_Collection Web_Skin_Collection, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Aggregation_Single_AdminViewer.Constructor", String.Empty); // Save the parameters thematicHeadings = Thematic_Headings; webSkins = Web_Skin_Collection; codeManager = Code_Manager; base.currentMode = Current_Mode; // Set some defaults actionMessage = String.Empty; // Get the code for the aggregation being edited string code = currentMode.Aggregation; // If the user cannot edit this, go back if (!user.Is_Aggregation_Curator(code)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // Load the item aggregation, either currenlty from the session (if already editing this aggregation ) // or by reading all the appropriate XML and reading data from the database object possibleEditAggregation = HttpContext.Current.Session["Edit_Aggregation_" + code]; Item_Aggregation cachedInstance = null; if (possibleEditAggregation != null) cachedInstance = (Item_Aggregation)possibleEditAggregation; itemAggregation = Item_Aggregation_Builder.Get_Item_Aggregation(code, String.Empty, cachedInstance, false, Tracer); // If unable to retrieve this aggregation, send to home if (itemAggregation == null) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // Determine the page page = 1; if (currentMode.My_Sobek_SubMode == "b" ) page = 2; else if (currentMode.My_Sobek_SubMode == "c") page = 3; else if (currentMode.My_Sobek_SubMode == "d") page = 4; else if (currentMode.My_Sobek_SubMode == "e") page = 5; else if (currentMode.My_Sobek_SubMode == "f") page = 6; else if (currentMode.My_Sobek_SubMode == "g") page = 7; // If this is a postback, handle any events first if (currentMode.isPostBack) { try { // Pull the standard values NameValueCollection form = HttpContext.Current.Request.Form; // Get the curret action string action = form["admin_aggr_save"]; // If this is to cancel, handle that here; no need to handle post-back from the // editing form page first if (action == "z") { // Clear the aggregation from the sessions HttpContext.Current.Session["Edit_Aggregation_" + itemAggregation.Code] = null; // Redirect the user currentMode.Mode = Display_Mode_Enum.Aggregation_Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); return; } // Save the returned values, depending on the page switch (page) { case 1: Save_Page_1_Postback(form); break; case 2: Save_Page_2_Postback(form); break; case 3: Save_Page_3_Postback(form); break; case 4: Save_Page_4_Postback(form); break; case 5: Save_Page_5_Postback(form); break; case 6: Save_Page_6_Postback(form); break; case 7: Save_Page_7_Postback(form); break; default: break; } // Should this be saved to the database? if (action == "save") { // Save this aggregation information bool successful_save = true; // Save the new configuration file itemAggregation.Write_Configuration_File( SobekCM_Library_Settings.Base_Design_Location + itemAggregation.objDirectory ); // Save to the database itemAggregation.Save_To_Database(null); // Clear the aggregation from the cache MemoryMgmt.Cached_Data_Manager.Remove_Item_Aggregation(itemAggregation.Code, null); // Forward back to the aggregation home page, if this was successful if (successful_save) { // Clear the aggregation from the sessions HttpContext.Current.Session["Edit_Aggregation_" + itemAggregation.Code] = null; // Redirect the user currentMode.Mode = Display_Mode_Enum.Aggregation_Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } } else { // Save to the admins session HttpContext.Current.Session["Edit_Aggregation_" + itemAggregation.Code] = itemAggregation; currentMode.My_Sobek_SubMode = action; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL(), false); } } catch { actionMessage = "Unable to correctly parse postback data."; } } }
/// <summary> Constructor for a new instance of the Group_Add_Volume_MySobekViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="All_Items_Lookup"> Allows individual items to be retrieved by various methods as <see cref="Single_Item"/> objects.</param> /// <param name="Current_Item"> Individual digital resource to be edited by the user </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="Items_In_Title"> List of items within this title </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 Group_Add_Volume_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Item_Lookup_Object All_Items_Lookup, SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager, Dictionary<string, Wordmark_Icon> Icon_Table, SobekCM_Skin_Object HTML_Skin, SobekCM_Items_In_Title Items_In_Title, Language_Support_Info Translator, SobekCM_Skin_Collection HTML_Skin_Collection, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", String.Empty); currentMode = Current_Mode; item = Current_Item; itemList = All_Items_Lookup; codeManager = Code_Manager; iconList = Icon_Table; webSkin = HTML_Skin; itemsInTitle = Items_In_Title; base.Translator = Translator; skins = HTML_Skin_Collection; // Set some defaults ipRestrict = -1; title = String.Empty; date = String.Empty; level1 = String.Empty; level2 = String.Empty; level3 = String.Empty; level1Order = -1; level2Order = -1; level3Order = -1; hierarchyCopiedFromDate = false; message = String.Empty; trackingBox = String.Empty; bornDigital = false; materialRecdDate = null; materialRecdNotes = String.Empty; dispositionAdvice = -1; dispositionAdviceNotes = String.Empty; // 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; } // Determine the default template code string template_code = "addvolume"; if (!user.Include_Tracking_In_Standard_Forms) template_code = "addvolume_notracking"; // Load this template template = Cached_Data_Manager.Retrieve_Template(template_code, Tracer); if (template != null) { Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Found template in cache"); } else { Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Reading template file"); // Read this template Template_XML_Reader reader = new Template_XML_Reader(); template = new Template(); reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\defaults\\" + template_code + ".xml", template, true); // Add the current codes to this template template.Add_Codes(Code_Manager); // Save this into the cache Cached_Data_Manager.Store_Template(template_code, template, Tracer); } // See if there was a hidden request string hidden_request = HttpContext.Current.Request.Form["action"] ?? String.Empty; // If this was a cancel request do that if (hidden_request == "cancel") { currentMode.Mode = Display_Mode_Enum.Item_Display; currentMode.Redirect(); } else if (hidden_request.IndexOf("save") == 0 ) { // Get the VID that used as a source for this string vid = HttpContext.Current.Request.Form["base_volume"]; if (string.IsNullOrEmpty(vid)) { message = "<span style=\"color: red\"><strong>No base volume selected!</strong></span>"; } else { try { // Get a new instance of this item SobekCM_Item saveItem = SobekCM_Item_Factory.Get_Item(Current_Mode.BibID, vid, Icon_Table, null, Tracer); // Clear some values for this item saveItem.VID = String.Empty; saveItem.Divisions.Clear(); saveItem.Behaviors.Serial_Info.Clear(); saveItem.Bib_Info.Series_Part_Info.Clear(); saveItem.Behaviors.Clear_Ticklers(); saveItem.Tracking.Internal_Comments = String.Empty; saveItem.Bib_Info.Location.PURL = String.Empty; saveItem.Behaviors.Main_Thumbnail = String.Empty; saveItem.METS_Header.Create_Date = DateTime.Now; saveItem.METS_Header.Modify_Date = saveItem.METS_Header.Create_Date; saveItem.METS_Header.Creator_Software = "SobekCM Web - Online add a volume (derived from VID " + vid + ")"; saveItem.METS_Header.Clear_Creator_Individual_Notes(); saveItem.METS_Header.Creator_Individual = user.Full_Name; saveItem.Bib_Info.Location.Other_URL = String.Empty; saveItem.Bib_Info.Location.Other_URL_Display_Label = String.Empty; saveItem.Bib_Info.Location.Other_URL_Note = String.Empty; // Save the template changes to this item template.Save_To_Bib(saveItem, user, 1); // Save this item and copy over complete_item_submission(saveItem, Tracer); // Clear the volume list Cached_Data_Manager.Remove_Items_In_Title(saveItem.BibID, Tracer); // Forward differently depending on request switch (hidden_request) { case "save_edit": currentMode.Mode = Display_Mode_Enum.My_Sobek; currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Edit_Item_Metadata; currentMode.VID = saveItem.VID; currentMode.Redirect(); break; case "save_again": // No redirect, but save values date = saveItem.Bib_Info.Origin_Info.Date_Issued; ipRestrict = saveItem.Behaviors.IP_Restriction_Membership; trackingBox = saveItem.Tracking.Tracking_Box; bornDigital = saveItem.Tracking.Born_Digital; dispositionAdvice = saveItem.Tracking.Disposition_Advice; dispositionAdviceNotes = saveItem.Tracking.Disposition_Advice_Notes; materialRecdDate = saveItem.Tracking.Material_Received_Date; materialRecdNotes = saveItem.Tracking.Material_Received_Notes; if (!hierarchyCopiedFromDate) { if (saveItem.Behaviors.Serial_Info.Count > 0) { level1 = saveItem.Behaviors.Serial_Info[0].Display; level1Order = saveItem.Behaviors.Serial_Info[0].Order; } if (saveItem.Behaviors.Serial_Info.Count > 1) { level2 = saveItem.Behaviors.Serial_Info[1].Display; level2Order = saveItem.Behaviors.Serial_Info[1].Order; } if (saveItem.Behaviors.Serial_Info.Count > 2) { level3 = saveItem.Behaviors.Serial_Info[2].Display; level3Order = saveItem.Behaviors.Serial_Info[2].Order; } } message = message + "<span style=\"color: blue\"><strong>Saved new volume ( " + saveItem.BibID + " : " + saveItem.VID + ")</strong></span>"; break; case "save_addfiles": currentMode.Mode = Display_Mode_Enum.My_Sobek; currentMode.My_Sobek_Type = My_Sobek_Type_Enum.File_Management; currentMode.VID = saveItem.VID; currentMode.Redirect(); break; default: currentMode.Mode = Display_Mode_Enum.Item_Display; currentMode.VID = saveItem.VID; currentMode.Redirect(); break; } } catch ( Exception ee ) { message = message + "<br /><span style=\"color: red\"><strong>EXCEPTION CAUGHT!<br /><br />" + ee.Message + "<br /><br />" + ee.StackTrace.Replace("\n","<br />") + "</strong></span>"; } } } }
/// <summary> Constructor for a new instance of the Static_Pages_Builder class </summary> /// <param name="Primary_Web_Server_URL"> URL for the primary web server </param> /// <param name="Static_Data_Location"> Network location for the data directory </param> /// <param name="Base_Network_Location"> Location where the web application files site for this </param> /// <remarks> This constructor pulls all the needed information from the database</remarks> public Static_Pages_Builder(string Primary_Web_Server_URL, string Static_Data_Location, string Base_Network_Location ) { primaryWebServerUrl = Primary_Web_Server_URL; staticSobekcmDataLocation = Static_Data_Location; staticSobekcmLocation = Base_Network_Location; tracer = new Custom_Tracer(); assistant = new SobekCM_Assistant(); // Build all the objects needed by the SobekCM Library iconList = new Dictionary<string, Wordmark_Icon>(); SobekCM_Database.Populate_Icon_List(iconList, tracer); translations = new Language_Support_Info(); SobekCM_Database.Populate_Translations(translations, tracer); codeManager = new Aggregation_Code_Manager(); SobekCM_Database.Populate_Code_Manager(codeManager, tracer); Portal_List urlPortals = new Portal_List(); SobekCM_Database.Populate_URL_Portals(urlPortals, tracer); defaultSkin = urlPortals.Default_Portal.Default_Web_Skin; skinsCollection = new SobekCM_Skin_Collection(); SobekCM_Skin_Collection_Builder.Populate_Default_Skins(skinsCollection, null); // Set some constant settings // SobekCM.Library.SobekCM_Library_Settings.Watermarks_URL = primary_web_server_url + "/design/wordmarks/"; SobekCM_Library_Settings.Base_SobekCM_Location_Relative = primaryWebServerUrl; // Create the mode object currentMode = new SobekCM_Navigation_Object { ViewerCode = "FC", Skin = defaultSkin, Mode = Display_Mode_Enum.Item_Display, Language = Web_Language_Enum.English, Base_URL = primaryWebServerUrl }; // Ensure all the folders exist if (!Directory.Exists(staticSobekcmDataLocation)) Directory.CreateDirectory(staticSobekcmDataLocation); if (!Directory.Exists(staticSobekcmDataLocation + "\\rss")) Directory.CreateDirectory(staticSobekcmDataLocation + "\\rss"); // Disable the cached data manager Cached_Data_Manager.Disabled = true; }
/// <summary> Constructor for a new instance of the Aggregation_Single_AdminViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the home page are organized </param> /// <param name="Web_Skin_Collection"> Contains the collection of all the default skins and the data to create any additional skins on request</param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> /// <remarks> Postback from handling an edit or new aggregation is handled here in the constructor </remarks> public Aggregation_Single_AdminViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Aggregation_Code_Manager Code_Manager, List<Thematic_Heading> Thematic_Headings, SobekCM_Skin_Collection Web_Skin_Collection, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Aggregation_Single_AdminViewer.Constructor", String.Empty); // Save the parameters thematicHeadings = Thematic_Headings; webSkins = Web_Skin_Collection; codeManager = Code_Manager; currentMode = Current_Mode; // Set some defaults actionMessage = String.Empty; // Get the code for the aggregation being edited string code = currentMode.Aggregation; // If the user cannot edit this, go back if (!user.Is_Aggregation_Curator(code)) { Current_Mode.Mode = Display_Mode_Enum.My_Sobek; currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; currentMode.Redirect(); return; } // Load the item aggregation, either currenlty from the session (if already editing this aggregation ) // or by reading all the appropriate XML and reading data from the database object possibleEditAggregation = HttpContext.Current.Session["Edit_Aggregation_" + code]; Item_Aggregation cachedInstance = null; if (possibleEditAggregation != null) cachedInstance = (Item_Aggregation)possibleEditAggregation; itemAggregation = Item_Aggregation_Builder.Get_Item_Aggregation(code, String.Empty, cachedInstance, false, false, Tracer); // If unable to retrieve this aggregation, send to home if (itemAggregation == null) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; currentMode.Redirect(); return; } // Get the aggregation directory and ensure it exists aggregationDirectory = HttpContext.Current.Server.MapPath("design/aggregations/" + itemAggregation.Code ); if (!Directory.Exists(aggregationDirectory)) Directory.CreateDirectory(aggregationDirectory); // Determine the page page = 1; if (currentMode.My_Sobek_SubMode == "b") page = 2; else if (currentMode.My_Sobek_SubMode == "c") page = 3; else if (currentMode.My_Sobek_SubMode == "d") page = 4; else if (currentMode.My_Sobek_SubMode == "e") page = 5; else if (currentMode.My_Sobek_SubMode == "f") page = 6; else if (currentMode.My_Sobek_SubMode == "g") page = 7; else if (currentMode.My_Sobek_SubMode == "h") page = 8; else if (currentMode.My_Sobek_SubMode == "y") page = 9; else if (currentMode.My_Sobek_SubMode.IndexOf("g_") == 0) page = 10; // If this is a postback, handle any events first if (currentMode.isPostBack) { try { // Pull the standard values NameValueCollection form = HttpContext.Current.Request.Form; // Get the curret action string action = form["admin_aggr_save"]; // If no action, then we should return to the current tab page if (action.Length == 0) action = currentMode.My_Sobek_SubMode; // If this is to cancel, handle that here; no need to handle post-back from the // editing form page first if (action == "z") { // Clear the aggregation from the sessions HttpContext.Current.Session["Edit_Aggregation_" + itemAggregation.Code] = null; HttpContext.Current.Session["Item_Aggr_Edit_" + itemAggregation.Code + "_NewLanguages"] = null; // Redirect the user currentMode.Mode = Display_Mode_Enum.Aggregation; currentMode.Aggregation_Type = Aggregation_Type_Enum.Home; currentMode.Redirect(); return; } // Save the returned values, depending on the page switch (page) { case 1: Save_Page_1_Postback(form); break; case 2: Save_Page_2_Postback(form); break; case 3: Save_Page_3_Postback(form); break; case 4: Save_Page_4_Postback(form); break; case 5: Save_Page_5_Postback(form); break; case 6: Save_Page_6_Postback(form); break; case 7: Save_Page_7_Postback(form); break; case 8: Save_Page_8_Postback(form); break; case 9: Save_Page_CSS_Postback(form); break; case 10: Save_Child_Page_Postback(form); break; } // Should this be saved to the database? if (action == "save") { // Save the new configuration file bool successful_save = (itemAggregation.Write_Configuration_File(SobekCM_Library_Settings.Base_Design_Location + itemAggregation.ObjDirectory)); // Save to the database if (!itemAggregation.Save_To_Database(user.Full_Name,null)) successful_save = false; // Save the link between this item and the thematic heading codeManager.Set_Aggregation_Thematic_Heading(itemAggregation.Code, itemAggregation.Thematic_Heading_ID); // Clear the aggregation from the cache Cached_Data_Manager.Remove_Item_Aggregation(itemAggregation.Code, null); // Forward back to the aggregation home page, if this was successful if (successful_save) { // Clear the aggregation from the sessions HttpContext.Current.Session["Edit_Aggregation_" + itemAggregation.Code] = null; HttpContext.Current.Session["Item_Aggr_Edit_" + itemAggregation.Code + "_NewLanguages"] = null; // Redirect the user currentMode.Mode = Display_Mode_Enum.Aggregation; currentMode.Aggregation_Type = Aggregation_Type_Enum.Home; currentMode.Redirect(); } else { actionMessage = "Error saving aggregation information!"; } } else { // In some cases, skip this part if (((page == 8) && (action == "h")) || ((page == 7) && (action == "g"))) return; // Save to the admins session HttpContext.Current.Session["Edit_Aggregation_" + itemAggregation.Code] = itemAggregation; currentMode.My_Sobek_SubMode = action; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL(), false); HttpContext.Current.ApplicationInstance.CompleteRequest(); currentMode.Request_Completed = true; } } catch { actionMessage = "Unable to correctly parse postback data."; } } }
/// <summary> Populates/builds the main default HTML skin during application startup </summary> /// <param name="Skin_List"> List of skin to populate with the default, commonly used skin</param> /// <param name="tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <returns> TRUE if successful, otherwise FALSE </returns> /// <remarks> Most HTML skins are built as they are needed and then cached for a period of time. The main default skins are /// permanently stored in this global <see cref="SobekCM_Skin_Collection"/> object.</remarks> public static bool Populate_Default_Skins(SobekCM_Skin_Collection Skin_List, Custom_Tracer tracer) { if (tracer != null) { tracer.Add_Trace("SobekCM_Skin_Collection_Builder.Populate_Default_Skins", "Build the standard interfaces"); } // Get the data from the database DataTable skinData = SobekCM_Database.Get_All_Web_Skins(tracer); // Just return if the data appears bad.. if ((skinData == null) || (skinData.Rows.Count == 0)) return false; // Clear existing interfaces Skin_List.Clear(); // Set the data table Skin_List.Skin_Table = skinData; return true; }
/// <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="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 New_Group_And_Item_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, 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("New_Group_And_Item_MySobekViewer.Constructor", String.Empty); // Save the parameters currentMode = Current_Mode; codeManager = Code_Manager; iconList = Icon_Table; webSkin = HTML_Skin; base.Translator = Translator; skins = HTML_Skin_Collection; // If the user cannot submit items, go back if (!user.Can_Submit) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; currentMode.Redirect(); return; } itemList = Item_List; // Determine the in process directory for this if (user.ShibbID.Trim().Length > 0) userInProcessDirectory = SobekCM_Library_Settings.In_Process_Submission_Location + "\\" + user.ShibbID + "\\newgroup"; else userInProcessDirectory = SobekCM_Library_Settings.In_Process_Submission_Location + "\\" + user.UserName.Replace(".","").Replace("@","") + "\\newgroup"; // Handle postback for changing the template or project templateCode = user.Current_Template; if (currentMode.isPostBack) { string action1 = HttpContext.Current.Request.Form["action"]; if ((action1 != null) && ((action1 == "template") || (action1 == "project"))) { string newvalue = HttpContext.Current.Request.Form["phase"]; if ((action1 == "template") && ( newvalue != templateCode )) { user.Current_Template = newvalue; templateCode = user.Current_Template; if (File.Exists(userInProcessDirectory + "\\agreement.txt")) File.Delete(userInProcessDirectory + "\\agreement.txt"); } if ((action1 == "project") && (newvalue != user.Current_Default_Metadata)) { user.Current_Default_Metadata = newvalue; } HttpContext.Current.Session["item"] = null; } } // Load the template templateCode = user.Current_Template; template = Cached_Data_Manager.Retrieve_Template(templateCode, Tracer); if ( template != null ) { Tracer.Add_Trace("New_Group_And_Item_MySobekViewer.Constructor", "Found template in cache"); } else { Tracer.Add_Trace("New_Group_And_Item_MySobekViewer.Constructor", "Reading template"); // Read this template Template_XML_Reader reader = new Template_XML_Reader(); template = new Template(); reader.Read_XML( SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\" + templateCode + ".xml", template, true); // Add the current codes to this template template.Add_Codes(Code_Manager); // Save this into the cache Cached_Data_Manager.Store_Template(templateCode, template, Tracer); } // Determine the number of total template pages totalTemplatePages = template.InputPages_Count; if (template.Permissions_Agreement.Length > 0) totalTemplatePages++; if (template.Upload_Types != Template.Template_Upload_Types.None) totalTemplatePages++; // Determine the title for this template, or use a default toolTitle = template.Title; if (toolTitle.Length == 0) toolTitle = "Self-Submittal Tool"; // Determine the current phase currentProcessStep = 1; if ((currentMode.My_Sobek_SubMode.Length > 0) && (Char.IsNumber(currentMode.My_Sobek_SubMode[0]))) { Int32.TryParse(currentMode.My_Sobek_SubMode.Substring(0), out currentProcessStep); } // If this is process step 1 and there is no permissions statement in the template, // just go to step 2 if ((currentProcessStep == 1) && (template.Permissions_Agreement.Length == 0)) { // Delete any pre-existing agreement from an earlier aborted submission process if (File.Exists(userInProcessDirectory + "\\agreement.txt")) File.Delete(userInProcessDirectory + "\\agreement.txt"); // Skip the permissions step currentProcessStep = 2; } // If there is a boundary infraction here, go back to step 2 if (currentProcessStep < 0) currentProcessStep = 2; if ((currentProcessStep > template.InputPages.Count + 1 ) && ( currentProcessStep != 8 ) && ( currentProcessStep != 9 )) currentProcessStep = 2; // If this is to enter a file or URL, and the template does not include this, skip over this step if (( currentProcessStep == 8 ) && ( template.Upload_Types == Template.Template_Upload_Types.None )) { // For now, just forward to the next phase currentMode.My_Sobek_SubMode = "9"; currentMode.Redirect(); return; } // Look for the item in the session, then directory, then just create a new one if (HttpContext.Current.Session["Item"] == null) { // Clear any old files (older than 24 hours) that are in the directory if (!Directory.Exists(userInProcessDirectory)) Directory.CreateDirectory(userInProcessDirectory); else { // Anything older than a day should be deleted string[] files = Directory.GetFiles(userInProcessDirectory); foreach (string thisFile in files) { DateTime modifiedDate = ((new FileInfo(thisFile)).LastWriteTime); if (DateTime.Now.Subtract(modifiedDate).TotalHours > (24 * 7)) { try { File.Delete(thisFile); } catch(Exception ) { // Unable to delete existing file in the user's folder. // This is an error, but how to report it? } } } } // First, look for an existing METS file string[] existing_mets = Directory.GetFiles(userInProcessDirectory, "*.mets*"); if (existing_mets.Length > 0) { Tracer.Add_Trace("New_Group_And_Item_MySobekViewer.Constructor", "Reading existing METS file<br />(" + existing_mets[0] + ")"); item = SobekCM_Item.Read_METS(existing_mets[0]); // Set the visibility information from the template item.Behaviors.IP_Restriction_Membership = template.Default_Visibility; } // If there is still no item, just create a new one if (item == null) { // Build a new empty METS file new_item( Tracer ); } // Save this to the session state now HttpContext.Current.Session["Item"] = item; } else { Tracer.Add_Trace("New_Group_And_Item_MySobekViewer.Constructor", "Item found in session cache"); item = (SobekCM_Item)HttpContext.Current.Session["Item"]; } #region Special code to handle any uploaded files // Any post-processing to do? if ((currentProcessStep == 8) && (Directory.Exists(userInProcessDirectory))) { string[] processFiles = Directory.GetFiles(userInProcessDirectory); foreach (string thisFile in processFiles) { FileInfo thisFileInfo = new FileInfo(thisFile); if ((thisFileInfo.Extension.ToUpper() == ".TIF") || (thisFileInfo.Extension.ToUpper() == ".TIFF")) { // Is there a JPEG and/or thumbnail? string jpeg = userInProcessDirectory + "\\" + thisFileInfo.Name.Replace(thisFileInfo.Extension, "") + ".jpg"; string jpeg_thumbnail = userInProcessDirectory + "\\" + thisFileInfo.Name.Replace(thisFileInfo.Extension, "") + "thm.jpg"; // Is one missing? if ((!File.Exists(jpeg)) || (!File.Exists(jpeg_thumbnail))) { using (System.Drawing.Image tiffImg = System.Drawing.Image.FromFile(thisFile)) { try { var mainImg = ScaleImage(tiffImg, SobekCM_Library_Settings.JPEG_Width, SobekCM_Library_Settings.JPEG_Height); mainImg.Save(jpeg, ImageFormat.Jpeg); mainImg.Dispose(); var thumbnailImg = ScaleImage(tiffImg, 150, 400); thumbnailImg.Save(jpeg_thumbnail, ImageFormat.Jpeg); thumbnailImg.Dispose(); } catch { } finally { if ( tiffImg != null ) tiffImg.Dispose(); } } } } } } #endregion #region Handle any other post back requests // If this is post-back, handle it if (currentMode.isPostBack) { // If this is a request from stage 8, save the new labels and url first if (currentProcessStep == 8) { 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_" + 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 == "cancel") { // Clear all files in the user process folder try { string[] all_files = Directory.GetFiles(userInProcessDirectory); foreach (string thisFile in all_files) Directory.Delete(thisFile); Directory.Delete(userInProcessDirectory); } catch (Exception) { // Unable to delete existing file in the user's folder. // This is an error, but how to report it? } // Clear all the information in memory HttpContext.Current.Session["agreement_date"] = null; HttpContext.Current.Session["item"] = null; // Clear any temporarily assigned current project and template user.Current_Default_Metadata = null; user.Current_Template = null; // Forward back to my Sobek home currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; currentMode.Redirect(); } if ( action == "delete" ) { string filename = HttpContext.Current.Request.Form["phase"]; try { if (File.Exists(userInProcessDirectory + "\\" + filename)) File.Delete(userInProcessDirectory + "\\" + filename); // Forward currentMode.Redirect(); return; } catch (Exception) { // Unable to delete existing file in the user's folder. // This is an error, but how to report it? } } if (action == "clear") { // If there is an old METS file, delete it if (File.Exists(userInProcessDirectory + "\\TEMP000001_00001.mets")) File.Delete(userInProcessDirectory + "\\TEMP000001_00001.mets"); // Create the new METS file and add to the session new_item(null); HttpContext.Current.Session["Item"] = item; // Forward back to the same URL currentMode.My_Sobek_SubMode = "2"; currentMode.Redirect(); return; } if (action == "next_phase") { string next_phase = HttpContext.Current.Request.Form["phase"]; // If this goes from step 1 to step 2, write the permissions first if ((currentProcessStep == 1) && (next_phase == "2") && ( template.Permissions_Agreement.Length > 0 )) { // Store this agreement in the session state DateTime agreement_date = DateTime.Now; HttpContext.Current.Session["agreement_date"] = agreement_date; // Also, save this as a text file string agreement_file = userInProcessDirectory + "\\agreement.txt"; StreamWriter writer = new StreamWriter(agreement_file, false); writer.WriteLine("Permissions Agreement"); writer.WriteLine(); writer.WriteLine("User: "******" ( " + user.ShibbID + " )"); writer.WriteLine("Date: " + agreement_date.ToString()); writer.WriteLine(); writer.WriteLine(template.Permissions_Agreement); writer.Flush(); writer.Close(); if (HttpContext.Current.Request.Form["setNewDefaultCheckBox"] != null ) { string prefProject = HttpContext.Current.Request.Form["prefProject"]; string prefTemplate = HttpContext.Current.Request.Form["prefTemplate"]; user.Set_Default_Template(prefTemplate.Trim()); user.Set_Current_Default_Metadata(prefProject.Trim()); Database.SobekCM_Database.Save_User(user, String.Empty, user.Authentication_Type, Tracer); } } // If this is going from a step that includes the metadata entry portion, save this to the item if ((currentProcessStep > 1) && (currentProcessStep < 8)) { // Save to the item template.Save_To_Bib(item, user, currentProcessStep - 1); item.Save_METS(); HttpContext.Current.Session["Item"] = item; // Save the pertinent data to the METS file package item.METS_Header.Create_Date = DateTime.Now; if ((HttpContext.Current.Session["agreement_date"] != null) && (HttpContext.Current.Session["agreement_date"].ToString().Length > 0)) { DateTime asDateTime; if (DateTime.TryParse(HttpContext.Current.Session["agreement_date"].ToString(), out asDateTime)) item.METS_Header.Create_Date = asDateTime; } HttpContext.Current.Session["Item"] = item; // Save this item, just in case it gets lost somehow item.Source_Directory = userInProcessDirectory; string acquisition_append = "Submitted by " + user.Full_Name + "."; if (item.Bib_Info.Notes_Count > 0) { foreach (Note_Info thisNote in item.Bib_Info.Notes.Where(ThisNote => ThisNote.Note_Type == Note_Type_Enum.acquisition)) { if (thisNote.Note.IndexOf(acquisition_append) < 0) thisNote.Note = thisNote.Note.Trim() + " " + acquisition_append; break; } } // Also, check all the authors to add the current users attribution information if (user.Organization.Length > 0) { if ((item.Bib_Info.Main_Entity_Name.Full_Name.IndexOf(user.Family_Name) >= 0) && ((item.Bib_Info.Main_Entity_Name.Full_Name.IndexOf(user.Given_Name) >= 0) || ((user.Nickname.Length > 2) && (item.Bib_Info.Main_Entity_Name.Full_Name.IndexOf(user.Nickname) > 0)))) { item.Bib_Info.Main_Entity_Name.Affiliation = user.Organization; if (user.College.Length > 0) item.Bib_Info.Main_Entity_Name.Affiliation = item.Bib_Info.Main_Entity_Name.Affiliation + " -- " + user.College; if (user.Department.Length > 0) item.Bib_Info.Main_Entity_Name.Affiliation = item.Bib_Info.Main_Entity_Name.Affiliation + " -- " + user.Department; if (user.Unit.Length > 0) item.Bib_Info.Main_Entity_Name.Affiliation = item.Bib_Info.Main_Entity_Name.Affiliation + " -- " + user.Unit; } if (item.Bib_Info.Names_Count > 0) { foreach (Name_Info thisName in item.Bib_Info.Names) { if ((thisName.Full_Name.IndexOf(user.Family_Name) >= 0) && ((thisName.Full_Name.IndexOf(user.Given_Name) >= 0) || ((user.Nickname.Length > 2) && (thisName.Full_Name.IndexOf(user.Nickname) > 0)))) { thisName.Affiliation = user.Organization; if (user.College.Length > 0) thisName.Affiliation = thisName.Affiliation + " -- " + user.College; if (user.Department.Length > 0) thisName.Affiliation = thisName.Affiliation + " -- " + user.Department; if (user.Unit.Length > 0) thisName.Affiliation = thisName.Affiliation + " -- " + user.Unit; } } } } item.Save_METS(); HttpContext.Current.Session["Item"] = item; } // For now, just forward to the next phase currentMode.My_Sobek_SubMode = next_phase; currentMode.Redirect(); return; } } #endregion #region Perform some validation to determine if the user should be at this step // If this is past the agreement phase, check that an agreement exists if (currentProcessStep > 1) { // Validate that an agreement.txt file exists, if the template has permissions if (( template.Permissions_Agreement.Length > 0 ) && (!File.Exists(userInProcessDirectory + "\\agreement.txt"))) { currentMode.My_Sobek_SubMode = "1"; currentMode.Redirect(); return; } // Get the validation errors validationErrors = new List<string>(); SobekCM_Item_Validator.Validate_SobekCM_Item(item, validationErrors); } // If this is to put up items or complete the item, validate the METS if ( currentProcessStep >= 8 ) { // Validate that a METS file exists if (Directory.GetFiles( userInProcessDirectory, "*.mets*").Length == 0 ) { currentMode.My_Sobek_SubMode = "2"; currentMode.Redirect(); return; } // Get the validation errors if ( validationErrors.Count == 0 ) item.Save_METS(); else { item.Web.Show_Validation_Errors = true; currentMode.My_Sobek_SubMode = "2"; currentMode.Redirect(); return; } } // If this is for step 8, ensure that this even takes this information, or go to step 9 if (( currentProcessStep == 8 ) && ( template.Upload_Types == Template.Template_Upload_Types.None )) { currentMode.My_Sobek_SubMode = "9"; currentMode.Redirect(); return; } // If this is going into the last process step, check that any mandatory info (file, url, .. ) // from the last step is present if ( currentProcessStep == 9 ) { // Only check if this is mandatory if (( template.Upload_Mandatory ) && ( template.Upload_Types != Template.Template_Upload_Types.None )) { // Does this require either a FILE or URL? bool required_file_present = false; bool required_url_present = false; // If this accepts files, check for acceptable files if (( template.Upload_Types == Template.Template_Upload_Types.File ) || ( template.Upload_Types == Template.Template_Upload_Types.URL )) { // Get list of files in this package string[] all_files = Directory.GetFiles(userInProcessDirectory); List<string> acceptable_files = all_files.Where(ThisFile => (ThisFile.IndexOf("agreement.txt") < 0) && (ThisFile.IndexOf("TEMP000001_00001.mets") < 0)).ToList(); // Acceptable files found? if ( acceptable_files.Count > 0 ) required_file_present = true; } // If this accepts URLs, check for a URL if (( template.Upload_Types == Template.Template_Upload_Types.URL ) || ( template.Upload_Types == Template.Template_Upload_Types.File_or_URL )) { if ( item.Bib_Info.Location.Other_URL.Length > 0 ) { required_url_present = true; } } // If neither was present, go back to step 8 if (( !required_file_present ) && ( !required_url_present )) { currentMode.My_Sobek_SubMode = "8"; currentMode.Redirect(); return; } } // Complete the item submission complete_item_submission( item, Tracer ); } #endregion }
/// <summary> Verifies that each global object is built and builds them upon request </summary> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <param name="Reload_All"> Flag indicates if everything should be reloaded/repopulated</param> /// <param name="Skins"> [REF] Collection of all the web skins </param> /// <param name="Translator"> [REF] Language support object which handles simple translational duties </param> /// <param name="Code_Manager"> [REF] List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="All_Items_Lookup"> [REF] Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Icon_Dictionary"> [REF] Dictionary of information about every wordmark/icon in this digital library </param> /// <param name="Stats_Date_Range"> [REF] Object contains the start and end dates for the statistical data in the database </param> /// <param name="Thematic_Headings"> [REF] Headings under which all the highlighted collections on the main home page are organized </param> /// <param name="Aggregation_Aliases"> [REF] List of all existing aliases for existing aggregations </param> /// <param name="IP_Restrictions"> [REF] List of all IP Restriction ranges in use by this digital library </param> /// <param name="URL_Portals"> [REF] List of all web portals into this system </param> /// <param name="Mime_Types">[REF] Dictionary of MIME types by extension</param> public static void Build_Application_State(Custom_Tracer Tracer, bool Reload_All, ref SobekCM_Skin_Collection Skins, ref Language_Support_Info Translator, ref Aggregation_Code_Manager Code_Manager, ref Item_Lookup_Object All_Items_Lookup, ref Dictionary<string, Wordmark_Icon> Icon_Dictionary, ref Statistics_Dates Stats_Date_Range, ref List<Thematic_Heading> Thematic_Headings, ref Dictionary<string, string> Aggregation_Aliases, ref IP_Restriction_Ranges IP_Restrictions, ref Portal_List URL_Portals, ref Dictionary<string, Mime_Type_Info> Mime_Types, ref List<string> Item_Viewer_Priority ) { // Should we reload the data from the exteral configuraiton file? if (Reload_All) { SobekCM_Library_Settings.Read_Configuration_File(); if ( SobekCM_Library_Settings.Database_Connections.Count > 0 ) SobekCM_Database.Connection_String = SobekCM_Library_Settings.Database_Connections[0].Connection_String; SobekCM_Library_Settings.Refresh(SobekCM_Database.Get_Settings_Complete(null)); } // If there is no database connection string, there is a problem if ((SobekCM_Library_Settings.Database_Connections.Count == 0) || (String.IsNullOrEmpty(SobekCM_Library_Settings.Database_Connections[0].Connection_String))) { throw new ApplicationException("Missing database connection string!"); } // Set the database connection strings Resource_Object.Database.SobekCM_Database.Connection_String = SobekCM_Library_Settings.Database_Connections[0].Connection_String; SobekCM_Database.Connection_String = SobekCM_Library_Settings.Database_Connections[0].Connection_String; // Set the workflow and disposition types if ((SobekCM_Library_Settings.Need_Workflow_And_Disposition_Types) || ( Reload_All )) { SobekCM_Library_Settings.Set_Workflow_And_Disposition_Types(SobekCM_Database.All_WorkFlow_Types, SobekCM_Database.All_Possible_Disposition_Types); } // Set the metadata types if ((SobekCM_Library_Settings.Need_Metadata_Types) || ( Reload_All )) { SobekCM_Library_Settings.Set_Metadata_Types(SobekCM_Database.Get_Metadata_Fields(null) ); } // Set the search stop words if ((SobekCM_Library_Settings.Need_Search_Stop_Words) || (Reload_All)) { SobekCM_Library_Settings.Search_Stop_Words = SobekCM_Database.Search_Stop_Words(Tracer); } // Check the list of thematic headings if ((Thematic_Headings == null) || (Reload_All)) { if (Thematic_Headings != null) { lock (Thematic_Headings) { if (!SobekCM_Database.Populate_Thematic_Headings(Thematic_Headings, Tracer)) { Thematic_Headings = null; throw SobekCM_Database.Last_Exception; } } } else { Thematic_Headings = new List<Thematic_Heading>(); if (!SobekCM_Database.Populate_Thematic_Headings(Thematic_Headings, Tracer)) { Thematic_Headings = null; throw SobekCM_Database.Last_Exception; } } } // Check the list of forwardings if ((Aggregation_Aliases == null) || (Reload_All)) { if (Aggregation_Aliases != null) { lock (Aggregation_Aliases) { SobekCM_Database.Populate_Aggregation_Aliases(Aggregation_Aliases, Tracer); } } else { Aggregation_Aliases = new Dictionary<string, string>(); SobekCM_Database.Populate_Aggregation_Aliases(Aggregation_Aliases, Tracer); } } // Check the list of constant skins if ((Skins == null) || (Skins.Count == 0) || (Reload_All)) { if (Skins != null) { lock (Skins) { SobekCM_Skin_Collection_Builder.Populate_Default_Skins(Skins, Tracer); } } else { Skins = new SobekCM_Skin_Collection(); SobekCM_Skin_Collection_Builder.Populate_Default_Skins(Skins, Tracer); } } // Check the list of all web portals if ((URL_Portals == null) || (URL_Portals.Count == 0) || (Reload_All)) { if (URL_Portals != null) { lock (URL_Portals) { SobekCM_Database.Populate_URL_Portals(URL_Portals, Tracer); } } else { URL_Portals = new Portal_List(); SobekCM_Database.Populate_URL_Portals(URL_Portals, Tracer); } } // Check the translation table has been loaded if (( Translator == null) || (Reload_All)) { // Get the translation hashes into memory if (Translator != null) { lock (Translator) { SobekCM_Database.Populate_Translations(Translator, Tracer); } } else { Translator = new Language_Support_Info(); SobekCM_Database.Populate_Translations(Translator, Tracer); } } // Check that the conversion from SobekCM Codes to Greenstone Codes has been loaded if ((Code_Manager == null) || (Reload_All)) { if (Code_Manager != null) { lock (Code_Manager) { SobekCM_Database.Populate_Code_Manager(Code_Manager, Tracer); } } else { Code_Manager = new Aggregation_Code_Manager(); SobekCM_Database.Populate_Code_Manager(Code_Manager, Tracer); } } // Check the statistics date range information if ((Stats_Date_Range == null) || (Reload_All)) { if (Stats_Date_Range != null) { // Get the translation hashes into memory lock (Stats_Date_Range) { SobekCM_Database.Populate_Statistics_Dates(Stats_Date_Range, Tracer); } } else { Stats_Date_Range = new Statistics_Dates(); SobekCM_Database.Populate_Statistics_Dates(Stats_Date_Range, Tracer); } } // Get the Icon list if ((Icon_Dictionary == null) || ( Reload_All )) { if (Icon_Dictionary != null) { // Get the translation hashes into memory lock (Icon_Dictionary) { SobekCM_Database.Populate_Icon_List(Icon_Dictionary, Tracer); } } else { Icon_Dictionary = new Dictionary<string, Wordmark_Icon>(); SobekCM_Database.Populate_Icon_List(Icon_Dictionary, Tracer); } } // Check the list of ip range restrictions if ((IP_Restrictions == null) || (Reload_All)) { if (IP_Restrictions != null) { lock (IP_Restrictions) { DataTable ipRestrictionTbl = SobekCM_Database.Get_IP_Restriction_Ranges(Tracer); if (ipRestrictionTbl != null) { IP_Restrictions.Populate_IP_Ranges(ipRestrictionTbl); } } } else { DataTable ipRestrictionTbl = SobekCM_Database.Get_IP_Restriction_Ranges(Tracer); if (ipRestrictionTbl != null) { IP_Restrictions = new IP_Restriction_Ranges(); IP_Restrictions.Populate_IP_Ranges(ipRestrictionTbl); } } } // Get the MIME type list if ((Mime_Types == null) || (Reload_All)) { if (Mime_Types != null) { // Get the translation hashes into memory lock (Mime_Types) { SobekCM_Database.Populate_MIME_List(Mime_Types, Tracer); } } else { Mime_Types = new Dictionary<string, Mime_Type_Info>(); SobekCM_Database.Populate_MIME_List(Mime_Types, Tracer); } } // Check the list of forwardings if ((Item_Viewer_Priority == null) || (Reload_All)) { if (Item_Viewer_Priority != null) { lock (Item_Viewer_Priority) { Item_Viewer_Priority = SobekCM_Database.Get_Viewer_Priority(Tracer); } } else { Item_Viewer_Priority = SobekCM_Database.Get_Viewer_Priority(Tracer); } } // Check the IE hack CSS is loaded if ((HttpContext.Current.Application["NonIE_Hack_CSS"] == null) || (Reload_All)) { string css_file = HttpContext.Current.Server.MapPath("default/SobekCM_NonIE.css"); if (File.Exists(css_file)) { try { StreamReader reader = new StreamReader(css_file); HttpContext.Current.Application["NonIE_Hack_CSS"] = reader.ReadToEnd().Trim(); reader.Close(); } catch (Exception) { HttpContext.Current.Application["NonIE_Hack_CSS"] = "/* ERROR READING FILE: default/SobekCM_NonIE.css */"; throw; } } else { HttpContext.Current.Application["NonIE_Hack_CSS"] = String.Empty; } } }
/// <summary> Constructor for a new instance of the MySobek_HtmlSubwriter class </summary> /// <param name="Results_Statistics"> Information about the entire set of results for a browse of a user's bookshelf folder </param> /// <param name="Paged_Results"> Single page of results for a browse of a user's bookshelf folder, within the entire set </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="All_Items_Lookup"> Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Item">Current item to edit, if the user is requesting to edit an item</param> /// <param name="Current_User"> Currently logged on user </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="Stats_Date_Range"> Object contains the start and end dates for the statistical data in the database </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 MySobek_HtmlSubwriter(Search_Results_Statistics Results_Statistics, List<iSearch_Title_Result> Paged_Results, Aggregation_Code_Manager Code_Manager, Item_Lookup_Object All_Items_Lookup, Item_Aggregation Hierarchy_Object, SobekCM_Skin_Object HTML_Skin, Language_Support_Info Translator, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, User_Object Current_User, Dictionary<string, Wordmark_Icon> Icon_Table, Statistics_Dates Stats_Date_Range, SobekCM_Skin_Collection HTML_Skin_Collection, Custom_Tracer Tracer ) { Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Saving values and geting user object back from the session"); resultsStatistics = Results_Statistics; pagedResults = Paged_Results; codeManager = Code_Manager; itemList = All_Items_Lookup; htmlSkin = HTML_Skin; translator = Translator; currentCollection = Hierarchy_Object; currentItem = Current_Item; user = Current_User; iconTable = Icon_Table; statsDates = Stats_Date_Range; if (Current_Mode.My_Sobek_Type == My_Sobek_Type_Enum.Log_Out) { Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Performing logout"); HttpContext.Current.Session["user"] = null; HttpContext.Current.Response.Redirect("?", false); HttpContext.Current.ApplicationInstance.CompleteRequest(); Current_Mode.Request_Completed = true; return; } if ((Current_Mode.My_Sobek_Type != My_Sobek_Type_Enum.Logon) && (user != null) && (user.Is_Temporary_Password)) { Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.New_Password; } if (Current_Mode.Logon_Required) Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Logon; Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Building the my sobek viewer object"); switch (Current_Mode.My_Sobek_Type) { case My_Sobek_Type_Enum.Home: mySobekViewer = new Home_MySobekViewer(user, Tracer); break; case My_Sobek_Type_Enum.New_Item: mySobekViewer = new New_Group_And_Item_MySobekViewer(user, Current_Mode, itemList, codeManager, iconTable, htmlSkin, translator, HTML_Skin_Collection, Tracer); break; case My_Sobek_Type_Enum.Folder_Management: mySobekViewer = new Folder_Mgmt_MySobekViewer(user, resultsStatistics, pagedResults, codeManager, itemList, currentCollection, htmlSkin, translator, Current_Mode, Tracer); break; case My_Sobek_Type_Enum.Saved_Searches: mySobekViewer = new Saved_Searches_MySobekViewer(user, translator, Current_Mode, Tracer); break; case My_Sobek_Type_Enum.Preferences: mySobekViewer = new Preferences_MySobekViewer(user, Current_Mode, Tracer); break; case My_Sobek_Type_Enum.Logon: mySobekViewer = new Logon_MySobekViewer(Current_Mode, Tracer); break; case My_Sobek_Type_Enum.New_Password: mySobekViewer = new NewPassword_MySobekViewer(user, Tracer); break; case My_Sobek_Type_Enum.Delete_Item: mySobekViewer = new Delete_Item_MySobekViewer(user, Current_Mode, currentItem, All_Items_Lookup, Tracer); break; case My_Sobek_Type_Enum.Edit_Item_Behaviors: mySobekViewer = new Edit_Item_Behaviors_MySobekViewer(user, Current_Mode, currentItem, codeManager, Tracer); break; case My_Sobek_Type_Enum.Edit_Item_Metadata: mySobekViewer = new Edit_Item_Metadata_MySobekViewer(user, Current_Mode, itemList, currentItem, codeManager, iconTable, htmlSkin, translator, HTML_Skin_Collection, Tracer); break; case My_Sobek_Type_Enum.File_Management: mySobekViewer = new File_Management_MySobekViewer(user, Current_Mode, Current_Item, itemList, codeManager, iconTable, htmlSkin, translator, HTML_Skin_Collection, Tracer); break; case My_Sobek_Type_Enum.Edit_Group_Behaviors: mySobekViewer = new Edit_Group_Behaviors_MySobekViewer(user, Current_Mode, currentItem, codeManager, Tracer); break; case My_Sobek_Type_Enum.Edit_Group_Serial_Hierarchy: mySobekViewer = new Edit_Serial_Hierarchy_MySobekViewer(user); break; case My_Sobek_Type_Enum.Item_Tracking: mySobekViewer = new Track_Item_MySobekViewer(user, Current_Mode, Tracer); break; case My_Sobek_Type_Enum.Group_Add_Volume: // Pull the list of items tied to this group SobekCM_Items_In_Title itemsInTitle = Cached_Data_Manager.Retrieve_Items_In_Title(currentItem.BibID, Tracer); if (itemsInTitle == null) { // Get list of information about this item group and save the item list DataSet itemDetails = SobekCM_Database.Get_Item_Group_Details(currentItem.BibID, Tracer); itemsInTitle = new SobekCM_Items_In_Title(itemDetails.Tables[1]); // Store in cache if retrieved Cached_Data_Manager.Store_Items_In_Title(currentItem.BibID, itemsInTitle, Tracer); } mySobekViewer = new Group_Add_Volume_MySobekViewer(user, Current_Mode, itemList, currentItem, codeManager, iconTable, htmlSkin, itemsInTitle, translator, HTML_Skin_Collection, Tracer); break; case My_Sobek_Type_Enum.Group_AutoFill_Volumes: mySobekViewer = new Group_AutoFill_Volume_MySobekViewer(user); break; case My_Sobek_Type_Enum.Group_Mass_Update_Items: mySobekViewer = new Mass_Update_Items_MySobekViewer(user, Current_Mode, currentItem, codeManager, Tracer); break; case My_Sobek_Type_Enum.Page_Images_Management: mySobekViewer = new Page_Image_Upload_MySobekViewer(user, Current_Mode, Current_Item, itemList, codeManager, iconTable, htmlSkin, translator, Tracer ); break; case My_Sobek_Type_Enum.User_Tags: mySobekViewer = new User_Tags_MySobekViewer(user, Tracer); break; case My_Sobek_Type_Enum.User_Usage_Stats: mySobekViewer = new User_Usage_Stats_MySobekViewer(user, Current_Mode, statsDates, Tracer); break; } // Pass in the navigation and translator information mySobekViewer.CurrentMode = Current_Mode; mySobekViewer.Translator = translator; }
/// <summary> Constructor for a new instance of the Skins_AdminViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="currentMode"> Mode / navigation information for the current request</param> /// <param name="Web_Skin_Collection"> Contains the collection of all the default skins and the data to create any additional skins on request</param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> /// <remarks> Postback from handling an edit or new html skin is handled here in the constructor </remarks> public Skins_AdminViewer(User_Object User, SobekCM_Navigation_Object currentMode, SobekCM_Skin_Collection Web_Skin_Collection, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Skins_AdminViewer.Constructor", String.Empty); // Save the mode and settings here base.currentMode = currentMode; skinCollection = Web_Skin_Collection; // Set action message to nothing to start actionMessage = String.Empty; // If the user cannot edit this, go back if ((!user.Is_System_Admin) && ( !user.Is_Portal_Admin )) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // If this is a postback, handle any events first if (currentMode.isPostBack) { try { // Pull the standard values NameValueCollection form = HttpContext.Current.Request.Form; string reset_value = form["admin_interface_reset"].ToLower(); string save_value = form["admin_interface_tosave"].ToUpper().Trim(); string new_interface_code = form["admin_interface_code"].ToUpper().Trim(); // Was this a reset request? if (reset_value.Length > 0) { Tracer.Add_Trace("Skins_AdminViewer.Constructor", "Reset html skin '" + reset_value + "'"); if (Web_Skin_Collection.Remove(reset_value)) { actionMessage = "Removed skin <i>" + reset_value.ToUpper() + "</i> from the semi-permanent skin collection"; } else { int values_cleared = Cached_Data_Manager.Remove_Skin(reset_value, Tracer); if (values_cleared == 0) { actionMessage = "Html skin <i>" + reset_value.ToUpper() + "</i> was not in the application cache"; } else { actionMessage = "Removed " + values_cleared + " values from the cache for <i>" + reset_value.ToUpper() + "</i>"; } } } else { // Or.. was this a save request if (save_value.Length > 0) { Tracer.Add_Trace("Skins_AdminViewer.Constructor", "Save html skin '" + save_value + "'"); bool override_banner = false; bool override_header = false; bool build_on_launch = false; bool suppress_top_nav = false; bool copycurrent = false; object temp_object; // Was this to save a new interface (from the main page) or edit an existing (from the popup form)? if (save_value == new_interface_code) { string new_base_code = form["admin_interface_basecode"].ToUpper().Trim(); string new_banner_link = form["admin_interface_link"].Trim(); string new_notes = form["admin_interface_notes"].Trim(); temp_object = form["admin_interface_banner_override"]; if (temp_object != null) { override_banner = true; } temp_object = form["admin_interface_header_override"]; if (temp_object != null) { override_header = true; } temp_object = form["admin_interface_buildlaunch"]; if (temp_object != null) { build_on_launch = true; } temp_object = form["admin_interface_top_nav"]; if (temp_object != null) { suppress_top_nav = true; } temp_object = form["admin_interface_copycurrent"]; if (temp_object != null) { copycurrent = true; } // Save this new interface if (SobekCM_Database.Save_Web_Skin(save_value, new_base_code, override_banner, override_header, new_banner_link, new_notes, build_on_launch, suppress_top_nav, Tracer)) { // Ensure a folder exists for this, otherwise create one try { string folder = SobekCM_Library_Settings.Base_Design_Location + "skins/" + save_value.ToLower(); if (!Directory.Exists(folder)) { // Create this directory and the necessary subdirectories Directory.CreateDirectory(folder); // Create a default stylesheet StreamWriter writer = new StreamWriter(folder + "\\" + save_value.ToLower() + ".css"); writer.WriteLine("/* Skin-specific stylesheet used to override values from the base stylesheets */"); writer.WriteLine(); writer.WriteLine(); writer.Flush(); writer.Close(); // Create the html subdirectory Directory.CreateDirectory(folder + "/html"); // Do the rest differently depending on whether we should copy the current files if (!copycurrent) { // Write the default header file writer = new StreamWriter(folder + "\\html\\header.html"); writer.WriteLine("<div id=\"container-inner\">"); writer.WriteLine(); writer.WriteLine("<!-- Add the standard header buttons -->"); writer.WriteLine("<div style=\"width: 100%; background-color: #eeeeee; color: Black; height:30px;\">"); writer.WriteLine("<%BREADCRUMBS%>"); writer.WriteLine("<div style=\"float: right\"><%MYSOBEK%></div>"); writer.WriteLine("</div>"); writer.WriteLine(); writer.WriteLine("<%BANNER%>"); writer.WriteLine(); writer.WriteLine("<div id=\"pagecontainer\">"); writer.WriteLine(); writer.WriteLine("<!-- Blankets out the rest of the web form when a pop-up form is envoked -->"); writer.WriteLine("<div id=\"blanket_outer\" style=\"display:none;\"></div>"); writer.Flush(); writer.Close(); // Write the default header_item file writer = new StreamWriter(folder + "/html/header_item.html"); writer.WriteLine("<!-- Blankets out the rest of the web form when a pop-up form is envoked -->"); writer.WriteLine("<div id=\"blanket_outer\" style=\"display:none;\"></div>"); writer.WriteLine(); writer.WriteLine("<!-- Add the standard header buttons -->"); writer.WriteLine("<div style=\"width: 100%; background-color: #eeeeee; color: Black; height:30px;\">"); writer.WriteLine("<%BREADCRUMBS%>"); writer.WriteLine("<div style=\"float: right\"><%MYSOBEK%></div>"); writer.WriteLine("</div>"); writer.WriteLine(); writer.WriteLine("<%BANNER%>"); writer.Flush(); writer.Close(); // Write the default footer file writer = new StreamWriter(folder + "/html/footer.html"); writer.WriteLine("</div> <!-- END PAGE CONTAINER DIV -->"); writer.WriteLine(); writer.WriteLine("<!-- Add most the standard footer buttons -->"); writer.WriteLine("<center>"); writer.WriteLine("<a href=\"<%BASEURL%>contact<%?URLOPTS%>\">Contact Us</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>preferences<%?URLOPTS%>\">Preferences</a> | "); writer.WriteLine("<a href=\"http://ufdc.ufl.edu/sobekcm\">Technical Aspects</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>stats<%?URLOPTS%>\">Statistics</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>internal<%?URLOPTS%>\">Internal</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>admin<%?URLOPTS%>\">Admin</a>"); writer.WriteLine("</center>"); writer.WriteLine("<br />"); writer.WriteLine("<br />"); writer.WriteLine("<span style=\"color: Gray; font-size: 0.8em;\">"); writer.WriteLine("To edit this footer or header, edit header.html or footer.html at: " + folder + "\\html\\ <br />"); writer.WriteLine("</span>"); writer.WriteLine(); writer.WriteLine("</div> <!-- END CONTAINER INNER -->"); writer.Flush(); writer.Close(); // Write the default footer item file writer = new StreamWriter(folder + "/html/footer_item.html"); writer.WriteLine("<!-- Add most the standard footer buttons -->"); writer.WriteLine("<center>"); writer.WriteLine("<a href=\"<%BASEURL%>contact<%?URLOPTS%>\">Contact Us</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>preferences<%?URLOPTS%>\">Preferences</a> | "); writer.WriteLine("<a href=\"http://ufdc.ufl.edu/sobekcm\">Technical Aspects</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>stats<%?URLOPTS%>\">Statistics</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>internal<%?URLOPTS%>\">Internal</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>admin<%?URLOPTS%>\">Admin</a>"); writer.WriteLine("</center>"); writer.WriteLine("<br />"); writer.WriteLine("<br />"); writer.WriteLine("<span style=\"color: Gray; font-size: 0.8em;\">"); writer.WriteLine("To edit this footer or header, edit header.html or footer.html at: " + folder + "\\html\\ <br />"); writer.WriteLine("</span>"); writer.Flush(); writer.Close(); } else { // Copy the web skin information over? string current_web_skin = currentMode.Skin; string current_web_folder = SobekCM_Library_Settings.Base_Design_Location + "skins/" + current_web_skin; copy_entire_folder(current_web_folder, folder); //if (File.Exists(current_web_folder + "\\" + current_web_skin + ".css")) //{ // File.Copy(current_web_folder + "\\" + current_web_skin + ".css", folder + "\\" + new_interface_code + ".css", true ); //} //if (File.Exists(current_web_folder + "\\html\\header.html")) //{ // File.Copy(current_web_folder + "\\html\\header.html", folder + "\\html\\header.html"); //} //if (File.Exists(current_web_folder + "\\html\\header_item.html")) //{ // File.Copy(current_web_folder + "\\html\\header_item.html", folder + "\\html\\header_item.html"); //} //if (File.Exists(current_web_folder + "\\html\\footer.html")) //{ // File.Copy(current_web_folder + "\\html\\footer.html", folder + "\\html\\footer.html"); //} //if (File.Exists(current_web_folder + "\\html\\footer_item.html")) //{ // File.Copy(current_web_folder + "\\html\\footer_item.html", folder + "\\html\\footer_item.html"); //} if (File.Exists(folder + "\\" + current_web_skin + ".css")) { if (File.Exists(folder + "\\" + new_interface_code + ".css")) File.Delete(folder + "\\" + new_interface_code + ".css"); File.Move( folder + "\\" + current_web_skin + ".css", folder + "\\" + new_interface_code + ".css" ); } } // Irregardless of the user's choice on whether to copy the current skin, if there is NO base skin // provided and the folder does not exist, then we'll copy over the base skin type of stuff, such // as buttons, tabs, etc... if (new_base_code.Length == 0) { // What is the current base skin folder then? string base_skin_folder = SobekCM_Library_Settings.Base_Design_Location + "skins/" + currentMode.Base_Skin; copy_entire_folder(base_skin_folder + "/buttons", folder + "/buttons"); copy_entire_folder(base_skin_folder + "/tabs", folder + "/tabs"); copy_entire_folder(base_skin_folder + "/zoom_controls", folder + "/zoom_controls"); } } } catch (Exception ee ) { bool error = false; } // Reload the list of all skins from the database, to include this new skin lock (skinCollection) { SobekCM_Skin_Collection_Builder.Populate_Default_Skins(skinCollection, Tracer); } actionMessage = "Saved new html skin <i>" + save_value + "</i>"; } else { actionMessage = "Unable to save new html skin <i>" + save_value + "</i>"; } // Try to create the directory try { if (!Directory.Exists(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value)) { Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value); } if (!Directory.Exists(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\html")) { Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\html"); } if (new_base_code.Length == 0) { if (!Directory.Exists(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\buttons")) { Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\buttons"); } if (!Directory.Exists(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\tabs")) { Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\tabs"); } if (!Directory.Exists(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\zoom_controls")) { Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\zoom_controls"); } } } catch (Exception) { actionMessage = "Error creating all the necessary folders"; } } else { string edit_base_code = form["form_interface_basecode"].ToUpper().Trim(); string edit_banner_link = form["form_interface_link"].Trim(); string edit_notes = form["form_interface_notes"].Trim(); temp_object = form["form_interface_banner_override"]; if (temp_object != null) { override_banner = true; } temp_object = form["form_interface_header_override"]; if (temp_object != null) { override_header = true; } temp_object = form["form_interface_buildlaunch"]; if (temp_object != null) { build_on_launch = true; } temp_object = form["form_interface_top_nav"]; if (temp_object != null) { suppress_top_nav = true; } // Save this existing interface if (SobekCM_Database.Save_Web_Skin(save_value, edit_base_code, override_banner, override_header, edit_banner_link, edit_notes, build_on_launch, suppress_top_nav, Tracer)) { lock (skinCollection) { SobekCM_Skin_Collection_Builder.Populate_Default_Skins(skinCollection, Tracer); } Cached_Data_Manager.Remove_Skin(save_value, Tracer); actionMessage = "Edited existing html skin <i>" + save_value + "</i>"; } else { actionMessage = "Unable to edit existing html skin <i>" + save_value + "</i>"; } } } } } catch (Exception) { actionMessage = "Unknown error caught while handing your request."; } } }
/// <summary> Constructor for a new instance of the Text_MainWriter class </summary> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </param> /// <param name="Paged_Results"> Single page of results for a search or browse, within the entire set </param> /// <param name="Browse_Object"> Object contains all the basic information about any browse or info display </param> /// <param name="Current_Item"> Current item to display </param> /// <param name="Current_Page"> Current page within the item</param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Current_User"> Currently logged on user </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="Item_List"> Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Stats_Date_Range"> Object contains the start and end dates for the statistical data in the database </param> /// <param name="Search_History"> List of recent searches performed against this digital library </param> /// <param name="Icon_Dictionary"> Dictionary of information about every wordmark/icon in this digital library, used to build the wordmarks subpage </param> /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the main home page are organized </param> /// <param name="Public_Folder"> Object contains the information about the public folder to display </param> /// <param name="Aggregation_Aliases"> List of all existing aliases for existing aggregations </param> /// <param name="Web_Skin_Collection"> Collection of all the web skins </param> /// <param name="Checked_Items"> List of all items which are currently checked out for single fair use and the IP address currently viewing the item</param> /// <param name="IP_Restrictions"> Any possible restriction on item access by IP ranges </param> /// <param name="URL_Portals"> List of all web portals into this system </param> /// <param name="Site_Map"> Optional site map object used to render a navigational tree-view on left side of static web content pages </param> /// <param name="Items_In_Title"> List of items within the current title ( used for the Item Group display )</param> /// <param name="Static_Web_Content"> HTML content-based browse, info, or imple CMS-style web content objects. These are objects which are read from a static HTML file and much of the head information must be maintained </param> public Html_MainWriter(SobekCM_Navigation_Object Current_Mode, Item_Aggregation Hierarchy_Object, Search_Results_Statistics Results_Statistics, List<iSearch_Title_Result> Paged_Results, Item_Aggregation_Browse_Info Browse_Object, SobekCM_Item Current_Item, Page_TreeNode Current_Page, SobekCM_Skin_Object HTML_Skin, User_Object Current_User, Language_Support_Info Translator, Aggregation_Code_Manager Code_Manager, Item_Lookup_Object Item_List, Statistics_Dates Stats_Date_Range, Recent_Searches Search_History, Dictionary<string, Wordmark_Icon> Icon_Dictionary, List<Thematic_Heading> Thematic_Headings, Public_User_Folder Public_Folder, Dictionary<string, string> Aggregation_Aliases, SobekCM_Skin_Collection Web_Skin_Collection, Checked_Out_Items_List Checked_Items, IP_Restriction_Ranges IP_Restrictions, Portal_List URL_Portals, SobekCM_SiteMap Site_Map, SobekCM_Items_In_Title Items_In_Title, HTML_Based_Content Static_Web_Content ) : base(Current_Mode, Hierarchy_Object, Results_Statistics, Paged_Results, Browse_Object, Current_Item, Current_Page, Static_Web_Content) { // Save parameters htmlSkin = HTML_Skin; translator = Translator; codeManager = Code_Manager; itemList = Item_List; statsDateRange = Stats_Date_Range; searchHistory = Search_History; currentUser = Current_User; iconList = Icon_Dictionary; thematicHeadings = Thematic_Headings; publicFolder = Public_Folder; aggregationAliases = Aggregation_Aliases; webSkins = Web_Skin_Collection; checkedItems = Checked_Items; ipRestrictionInfo = IP_Restrictions; urlPortals = URL_Portals; siteMap = Site_Map; itemsInTitle = Items_In_Title; // Set some defaults finishPageInAddFinalHtmlMethod = false; // Handle basic events which may be fired by the internal header if (HttpContext.Current.Request.Form["internal_header_action"] != null) { // Pull the action value string internalHeaderAction = HttpContext.Current.Request.Form["internal_header_action"].Trim(); // Was this to hide or show the header? if ((internalHeaderAction == "hide") || (internalHeaderAction == "show")) { // Pull the current visibility from the session bool shown = true; if ((HttpContext.Current.Session["internal_header"] != null) && (HttpContext.Current.Session["internal_header"].ToString() == "hidden")) { shown = false; } if ((internalHeaderAction == "hide") && (shown)) { HttpContext.Current.Session["internal_header"] = "hidden"; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL(), true); } if ((internalHeaderAction == "show") && (!shown)) { HttpContext.Current.Session["internal_header"] = "shown"; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL(), true); } } } }
/// <summary> Constructor for a new instance of the Text_MainWriter class </summary> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </param> /// <param name="Paged_Results"> Single page of results for a search or browse, within the entire set </param> /// <param name="Browse_Object"> Object contains all the basic information about any browse or info display </param> /// <param name="Current_Item"> Current item to display </param> /// <param name="Current_Page"> Current page within the item</param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Current_User"> Currently logged on user </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="Item_List"> Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Stats_Date_Range"> Object contains the start and end dates for the statistical data in the database </param> /// <param name="Search_History"> List of recent searches performed against this digital library </param> /// <param name="Icon_Dictionary"> Dictionary of information about every wordmark/icon in this digital library, used to build the wordmarks subpage </param> /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the main home page are organized </param> /// <param name="Public_Folder"> Object contains the information about the public folder to display </param> /// <param name="Aggregation_Aliases"> List of all existing aliases for existing aggregations </param> /// <param name="Web_Skin_Collection"> Collection of all the web skins </param> /// <param name="Checked_Items"> List of all items which are currently checked out for single fair use and the IP address currently viewing the item</param> /// <param name="IP_Restrictions"> Any possible restriction on item access by IP ranges </param> /// <param name="URL_Portals"> List of all web portals into this system </param> /// <param name="Site_Map"> Optional site map object used to render a navigational tree-view on left side of static web content pages </param> /// <param name="Items_In_Title"> List of items within the current title ( used for the Item Group display )</param> /// <param name="Static_Web_Content"> HTML content-based browse, info, or imple CMS-style web content objects. These are objects which are read from a static HTML file and much of the head information must be maintained </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public Html_MainWriter(SobekCM_Navigation_Object Current_Mode, Item_Aggregation Hierarchy_Object, Search_Results_Statistics Results_Statistics, List<iSearch_Title_Result> Paged_Results, Item_Aggregation_Child_Page Browse_Object, SobekCM_Item Current_Item, Page_TreeNode Current_Page, SobekCM_Skin_Object HTML_Skin, User_Object Current_User, Language_Support_Info Translator, Aggregation_Code_Manager Code_Manager, Item_Lookup_Object Item_List, Statistics_Dates Stats_Date_Range, Recent_Searches Search_History, Dictionary<string, Wordmark_Icon> Icon_Dictionary, List<Thematic_Heading> Thematic_Headings, Public_User_Folder Public_Folder, Dictionary<string, string> Aggregation_Aliases, SobekCM_Skin_Collection Web_Skin_Collection, Checked_Out_Items_List Checked_Items, IP_Restriction_Ranges IP_Restrictions, Portal_List URL_Portals, SobekCM_SiteMap Site_Map, SobekCM_Items_In_Title Items_In_Title, HTML_Based_Content Static_Web_Content, Custom_Tracer Tracer ) : base(Current_Mode, Hierarchy_Object, Results_Statistics, Paged_Results, Browse_Object, Current_Item, Current_Page, Static_Web_Content) { // Save parameters htmlSkin = HTML_Skin; translator = Translator; codeManager = Code_Manager; itemList = Item_List; statsDateRange = Stats_Date_Range; searchHistory = Search_History; currentUser = Current_User; iconList = Icon_Dictionary; thematicHeadings = Thematic_Headings; publicFolder = Public_Folder; aggregationAliases = Aggregation_Aliases; webSkins = Web_Skin_Collection; checkedItems = Checked_Items; ipRestrictionInfo = IP_Restrictions; urlPortals = URL_Portals; siteMap = Site_Map; itemsInTitle = Items_In_Title; // Set some defaults // Handle basic events which may be fired by the internal header if (HttpContext.Current.Request.Form["internal_header_action"] != null) { // Pull the action value string internalHeaderAction = HttpContext.Current.Request.Form["internal_header_action"].Trim(); // Was this to hide or show the header? if ((internalHeaderAction == "hide") || (internalHeaderAction == "show")) { // Pull the current visibility from the session bool shown = !((HttpContext.Current.Session["internal_header"] != null) && (HttpContext.Current.Session["internal_header"].ToString() == "hidden")); if ((internalHeaderAction == "hide") && (shown)) { HttpContext.Current.Session["internal_header"] = "hidden"; currentMode.Redirect(); return; } if ((internalHeaderAction == "show") && (!shown)) { HttpContext.Current.Session["internal_header"] = "shown"; currentMode.Redirect(); return; } } } try { // Create the html sub writer now switch (Current_Mode.Mode) { case Display_Mode_Enum.Internal: subwriter = new Internal_HtmlSubwriter(iconList, currentUser, codeManager); break; case Display_Mode_Enum.Statistics: subwriter = new Statistics_HtmlSubwriter(searchHistory, codeManager, statsDateRange); break; case Display_Mode_Enum.Preferences: subwriter = new Preferences_HtmlSubwriter(currentMode); break; case Display_Mode_Enum.Error: subwriter = new Error_HtmlSubwriter(false); // Send the email now if (currentMode.Caught_Exception != null) { if (currentMode.Error_Message.Length == 0) currentMode.Error_Message = "Unknown exception caught"; Email_Information(currentMode.Error_Message, currentMode.Caught_Exception, Tracer, false); } break; case Display_Mode_Enum.Legacy_URL: subwriter = new LegacyUrl_HtmlSubwriter(); break; case Display_Mode_Enum.Item_Print: subwriter = new Print_Item_HtmlSubwriter(currentItem, codeManager, translator, currentMode); break; case Display_Mode_Enum.Contact: StringBuilder builder = new StringBuilder(); builder.Append("\n\nSUBMISSION INFORMATION\n"); builder.Append("\tDate:\t\t\t\t" + DateTime.Now.ToString() + "\n"); string lastMode = String.Empty; try { if (HttpContext.Current.Session["Last_Mode"] != null) lastMode = HttpContext.Current.Session["Last_Mode"].ToString(); builder.Append("\tIP Address:\t\t\t" + HttpContext.Current.Request.UserHostAddress + "\n"); builder.Append("\tHost Name:\t\t\t" + HttpContext.Current.Request.UserHostName + "\n"); builder.Append("\tBrowser:\t\t\t" + HttpContext.Current.Request.Browser.Browser + "\n"); builder.Append("\tBrowser Platform:\t\t" + HttpContext.Current.Request.Browser.Platform + "\n"); builder.Append("\tBrowser Version:\t\t" + HttpContext.Current.Request.Browser.Version + "\n"); builder.Append("\tBrowser Language:\t\t"); bool first = true; string[] languages = HttpContext.Current.Request.UserLanguages; if (languages != null) foreach (string thisLanguage in languages) { if (first) { builder.Append(thisLanguage); first = false; } else { builder.Append(", " + thisLanguage); } } builder.Append("\n\nHISTORY\n"); if (HttpContext.Current.Session["LastSearch"] != null) builder.Append("\tLast Search:\t\t" + HttpContext.Current.Session["LastSearch"] + "\n"); if (HttpContext.Current.Session["LastResults"] != null) builder.Append("\tLast Results:\t\t" + HttpContext.Current.Session["LastResults"] + "\n"); if (HttpContext.Current.Session["Last_Mode"] != null) builder.Append("\tLast Mode:\t\t\t" + HttpContext.Current.Session["Last_Mode"] + "\n"); builder.Append("\tURL:\t\t\t\t" + HttpContext.Current.Items["Original_URL"]); } catch { } subwriter = new Contact_HtmlSubwriter(lastMode, builder.ToString(), currentMode, hierarchyObject); break; case Display_Mode_Enum.Contact_Sent: subwriter = new Contact_HtmlSubwriter(String.Empty, String.Empty, currentMode, hierarchyObject); break; case Display_Mode_Enum.Simple_HTML_CMS: subwriter = new Web_Content_HtmlSubwriter(hierarchyObject, currentMode, htmlSkin, htmlBasedContent, siteMap); break; case Display_Mode_Enum.My_Sobek: subwriter = new MySobek_HtmlSubwriter(results_statistics, paged_results, codeManager, itemList, hierarchyObject, htmlSkin, translator, currentMode, currentItem, currentUser, iconList, statsDateRange, webSkins, Tracer); break; case Display_Mode_Enum.Administrative: subwriter = new Admin_HtmlSubwriter(codeManager, itemList, hierarchyObject, htmlSkin, translator, currentMode, aggregationAliases, webSkins, currentUser, ipRestrictionInfo, iconList, urlPortals, thematicHeadings, Tracer); break; case Display_Mode_Enum.Results: subwriter = new Search_Results_HtmlSubwriter(results_statistics, paged_results, codeManager, translator, itemList, currentUser); break; case Display_Mode_Enum.Public_Folder: subwriter = new Public_Folder_HtmlSubwriter(results_statistics, paged_results, codeManager, translator, itemList, currentUser, publicFolder); break; case Display_Mode_Enum.Search: case Display_Mode_Enum.Aggregation: subwriter = new Aggregation_HtmlSubwriter(hierarchyObject, currentMode, htmlSkin, translator, thisBrowseObject, results_statistics, paged_results, codeManager, itemList, thematicHeadings, currentUser, htmlBasedContent, Tracer); break; case Display_Mode_Enum.Item_Display: if ((!currentMode.Invalid_Item) && (currentItem != null)) { bool show_toc = false; if (HttpContext.Current.Session["Show TOC"] != null) { Boolean.TryParse(HttpContext.Current.Session["Show TOC"].ToString(), out show_toc); } // Check that this item is not checked out by another user bool itemCheckedOutByOtherUser = false; if (currentItem.Behaviors.CheckOut_Required) { if (!checkedItems.Check_Out(currentItem.Web.ItemID, HttpContext.Current.Request.UserHostAddress)) { itemCheckedOutByOtherUser = true; } } // Check to see if this is IP restricted string restriction_message = String.Empty; if (currentItem.Behaviors.IP_Restriction_Membership > 0) { if (HttpContext.Current != null) { int user_mask = (int)HttpContext.Current.Session["IP_Range_Membership"]; int comparison = currentItem.Behaviors.IP_Restriction_Membership & user_mask; if (comparison == 0) { int restriction = currentItem.Behaviors.IP_Restriction_Membership; int restriction_counter = 0; while (restriction % 2 != 1) { restriction = restriction >> 1; restriction_counter++; } restriction_message = ipRestrictionInfo[restriction_counter].Item_Restricted_Statement; } } } // Create the item viewer writer subwriter = new Item_HtmlSubwriter(currentItem, currentPage, currentUser, codeManager, translator, show_toc, (SobekCM_Library_Settings.JP2ServerUrl.Length > 0), currentMode, hierarchyObject, restriction_message, itemsInTitle, Tracer); ((Item_HtmlSubwriter)subwriter).Item_Checked_Out_By_Other_User = itemCheckedOutByOtherUser; } else { // Create the invalid item html subwrite and write the HTML subwriter = new Error_HtmlSubwriter(true); } break; } } catch (Exception ee) { // Send to the dashboard if ((HttpContext.Current.Request.UserHostAddress == "127.0.0.1") || (HttpContext.Current.Request.UserHostAddress == HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"]) || (HttpContext.Current.Request.Url.ToString().IndexOf("localhost") >= 0)) { Tracer.Add_Trace("Html_MainWriter.Constructor", "Exception caught!", Custom_Trace_Type_Enum.Error); Tracer.Add_Trace("Html_MainWriter.Constructor", ee.Message, Custom_Trace_Type_Enum.Error); Tracer.Add_Trace("Html_MainWriter.Constructor", ee.StackTrace, Custom_Trace_Type_Enum.Error); // Wrap this into the SobekCM Exception SobekCM_Traced_Exception newException = new SobekCM_Traced_Exception("Exception caught while building the mode-specific HTML Subwriter", ee, Tracer); // Save this to the session state, and then forward to the dashboard HttpContext.Current.Session["Last_Exception"] = newException; HttpContext.Current.Response.Redirect("dashboard.aspx", false); Current_Mode.Request_Completed = true; return; } else { subwriter = new Error_HtmlSubwriter(false); } } if (subwriter != null) { subwriter.Mode = currentMode; subwriter.Skin = htmlSkin; subwriter.Current_Aggregation = hierarchyObject; } }
/// <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; } } } }