/// <summary> Parse the query and set the internal variables </summary> /// <param name="QueryString"> QueryString collection passed from the main page </param> /// <param name="Navigator"> Navigation object to hold the mode information </param> /// <param name="Base_URL">Requested base URL (without query string, etc..)</param> /// <param name="User_Languages"> Languages preferred by user, per their browser settings </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections </param> /// <param name="Aggregation_Aliases"> List of all existing aliases for existing aggregationPermissions</param> /// <param name="All_Items_Lookup"> [REF] Lookup object used to pull basic information about any item loaded into this library</param> /// <param name="URL_Portals"> List of all web portals into this system </param> /// <param name="WebHierarchy"> Hierarchy of all non-aggregational web content pages and redirects </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param> public static void Parse_Query(NameValueCollection QueryString, Navigation_Object Navigator, string Base_URL, string[] User_Languages, Aggregation_Code_Manager Code_Manager, Dictionary<string, string> Aggregation_Aliases, Item_Lookup_Object All_Items_Lookup, Portal_List URL_Portals, WebContent_Hierarchy WebHierarchy, Custom_Tracer Tracer ) { if (Tracer != null) Tracer.Add_Trace("QueryString_Analyzer.Parse_Query", "Parse the query into the provided Navigation_Object"); // Set default mode to error Navigator.Mode = Display_Mode_Enum.Error; // If this has 'verb' then this is an OAI-PMH request if ( QueryString["verb"] != null ) { Navigator.Writer_Type = Writer_Type_Enum.OAI; return; } // Is there a TOC state set? if (QueryString["toc"] != null) { if (QueryString["toc"] == "y") { Navigator.TOC_Display = TOC_Display_Type_Enum.Show; } else if ( QueryString["toc"] == "n" ) { Navigator.TOC_Display = TOC_Display_Type_Enum.Hide; } } // Determine the default language, per the browser settings if (User_Languages != null) { foreach (string thisLanguage in User_Languages) { if (thisLanguage.IndexOf("en") == 0) { Navigator.Default_Language = Web_Language_Enum.English; break; } if (thisLanguage.IndexOf("fr") == 0) { Navigator.Default_Language = Web_Language_Enum.French; break; } if (thisLanguage.IndexOf("es") == 0) { Navigator.Default_Language = Web_Language_Enum.Spanish; break; } } } // Is there a language defined? If so, load right into the navigator Navigator.Language = Navigator.Default_Language; if ( !String.IsNullOrEmpty(QueryString["l"])) { Navigator.Language = Web_Language_Enum_Converter.Code_To_Enum(QueryString["l"]); } // If there is flag indicating to show the trace route, save it if (QueryString["trace"] != null) { Navigator.Trace_Flag = QueryString["trace"].ToUpper() == "NO" ? Trace_Flag_Type_Enum.No : Trace_Flag_Type_Enum.Explicit; } else { Navigator.Trace_Flag = Trace_Flag_Type_Enum.Unspecified; } // Did the user request to have it render like it would for a search robot? if (QueryString["robot"] != null) { Navigator.Is_Robot = true; } // Was a fragment specified in the query string? if (QueryString["fragment"] != null) { Navigator.Fragment = QueryString["fragment"]; } // Get the valid URL Portal Navigator.Default_Aggregation = "all"; Portal urlPortal = URL_Portals.Get_Valid_Portal(Base_URL); Navigator.Instance_Abbreviation = urlPortal.Abbreviation; Navigator.Instance_Name = urlPortal.Name; if ( !String.IsNullOrEmpty(urlPortal.Base_PURL )) Navigator.Portal_PURL = urlPortal.Base_PURL; if (String.IsNullOrEmpty(urlPortal.Default_Aggregation)) { Navigator.Aggregation = ""; } else { Navigator.Default_Aggregation = urlPortal.Default_Aggregation; Navigator.Aggregation = urlPortal.Default_Aggregation; } if (!String.IsNullOrEmpty(urlPortal.Default_Web_Skin)) { Navigator.Default_Skin = urlPortal.Default_Web_Skin; Navigator.Skin = urlPortal.Default_Web_Skin; Navigator.Skin_In_URL = false; } // Collect the interface string if (QueryString["n"] != null) { string currSkin = QueryString["n"].ToLower().Replace("'", ""); // Save the interface if (currSkin.Length > 0) { if (currSkin.IndexOf(",") > 0) currSkin = currSkin.Substring(0, currSkin.IndexOf(",")); Navigator.Skin = currSkin.ToLower(); Navigator.Skin_In_URL = true; } } // Parse URL request different now, depending on if this is a legacy URL type or the new URL type Navigator.Mode = Display_Mode_Enum.None; // CHECK FOR LEGACY VALUES // Check for legacy bibid / vid information, since this will be supported indefinitely if (( QueryString["b"] != null ) || ( QueryString["bib"] != null )) { Navigator.BibID = QueryString["b"] ?? QueryString["bib"]; if ( Navigator.BibID.Length > 0 ) { Navigator.Mode = Display_Mode_Enum.Item_Display; if ( QueryString["v"] != null ) Navigator.VID = QueryString["v"]; else if ( QueryString["vid"] != null ) Navigator.VID = QueryString["vid"]; } // No other item information is collected here anymore.. just return return; } // Set the default mode Navigator.Mode = Display_Mode_Enum.Aggregation; Navigator.Aggregation_Type = Aggregation_Type_Enum.Home; Navigator.Home_Type = Home_Type_Enum.List; // Get any url rewrite which occurred if (QueryString["urlrelative"] != null) { string urlrewrite = QueryString["urlrelative"].ToLower(); if (urlrewrite.Length > 0) { // Split the url relative list string[] url_relative_info = urlrewrite.Split("/".ToCharArray()); List<string> url_relative_list = (from thisPart in url_relative_info where thisPart.Length > 0 select thisPart.ToLower()).ToList(); // Determine the main writer (html, json, xml, oai-pmh, etc..) Navigator.Writer_Type = Writer_Type_Enum.HTML; if ( url_relative_list.Count > 0 ) { switch (url_relative_list[0]) { case "l": Navigator.Writer_Type = Writer_Type_Enum.HTML_LoggedIn; url_relative_list.RemoveAt(0); break; case "my": Navigator.Writer_Type = Writer_Type_Enum.HTML_LoggedIn; break; case "json": Navigator.Writer_Type = Writer_Type_Enum.JSON; url_relative_list.RemoveAt(0); break; case "dataset": Navigator.Writer_Type = Writer_Type_Enum.DataSet; url_relative_list.RemoveAt(0); break; case "dataprovider": Navigator.Writer_Type = Writer_Type_Enum.Data_Provider; url_relative_list.RemoveAt(0); break; case "xml": Navigator.Writer_Type = Writer_Type_Enum.XML; url_relative_list.RemoveAt(0); break; case "textonly": Navigator.Writer_Type = Writer_Type_Enum.Text; url_relative_list.RemoveAt(0); break; } } // Is the first part of the list one of these constants? if (( url_relative_list.Count > 0 ) && ( url_relative_list[0].Length > 0 )) { switch ( url_relative_list[0] ) { case "shibboleth": Navigator.Mode = Display_Mode_Enum.My_Sobek; Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Shibboleth_Landing; break; case "internal": Navigator.Mode = Display_Mode_Enum.Internal; Navigator.Internal_Type = Internal_Type_Enum.Aggregations_List; if ( url_relative_list.Count > 1 ) { switch( url_relative_list[1] ) { case "aggregations": Navigator.Internal_Type = Internal_Type_Enum.Aggregations_List; if (url_relative_list.Count > 2) { if (url_relative_list[2] == "tree") { Navigator.Internal_Type = Internal_Type_Enum.Aggregations_Tree; } } break; case "cache": Navigator.Internal_Type = Internal_Type_Enum.Cache; break; case "new": Navigator.Internal_Type = Internal_Type_Enum.New_Items; if (url_relative_list.Count > 2) { Navigator.Info_Browse_Mode = url_relative_list[2]; } break; case "failures": Navigator.Internal_Type = Internal_Type_Enum.Build_Failures; if (url_relative_list.Count > 2) Navigator.Info_Browse_Mode = url_relative_list[2]; break; case "wordmarks": Navigator.Internal_Type = Internal_Type_Enum.Wordmarks; break; } } break; case "contact": Navigator.Mode = Display_Mode_Enum.Contact; if ( url_relative_list.Count > 1 ) { if (url_relative_list[1] == "sent") { Navigator.Mode = Display_Mode_Enum.Contact_Sent; } else { Navigator.Aggregation = url_relative_list[1]; } } if (QueryString["em"] != null) Navigator.Error_Message = QueryString["em"]; break; case "folder": Navigator.Mode = Display_Mode_Enum.Public_Folder; if (url_relative_list.Count >= 2) { try { Navigator.FolderID = Convert.ToInt32(url_relative_list[1]); } catch { Navigator.FolderID = -1; } // Look for result display type if (url_relative_list.Count >=3 ) { switch (url_relative_list[2]) { case "brief": Navigator.Result_Display_Type = Result_Display_Type_Enum.Brief; break; case "export": Navigator.Result_Display_Type = Result_Display_Type_Enum.Export; break; case "citation": Navigator.Result_Display_Type = Result_Display_Type_Enum.Full_Citation; break; case "image": Navigator.Result_Display_Type = Result_Display_Type_Enum.Full_Image; break; case "map": Navigator.Result_Display_Type = Result_Display_Type_Enum.Map; break; case "mapbeta": Navigator.Result_Display_Type = Result_Display_Type_Enum.Map_Beta; break; case "table": Navigator.Result_Display_Type = Result_Display_Type_Enum.Table; break; case "thumbs": Navigator.Result_Display_Type = Result_Display_Type_Enum.Thumbnails; break; default: Navigator.Result_Display_Type = Result_Display_Type_Enum.Brief; break; } } // Look for a page number if (url_relative_list.Count >= 4 ) { string possible_page = url_relative_list[3]; if ((possible_page.Length > 0) && (is_String_Number(possible_page))) { ushort page_result; UInt16.TryParse(possible_page, out page_result); Navigator.Page = page_result; } } } break; case "register": Navigator.Mode = Display_Mode_Enum.My_Sobek; Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Preferences; break; case "my": Navigator.Mode = Display_Mode_Enum.My_Sobek; Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Home; if (QueryString["return"] != null) Navigator.Return_URL = QueryString["return"]; if ( url_relative_list.Count > 1 ) { switch( url_relative_list[1] ) { case "logon": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Logon; if (QueryString["return"] != null) Navigator.Return_URL = QueryString["return"]; break; case "home": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Home; if (QueryString["return"] != null) Navigator.Return_URL = QueryString["return"]; break; case "delete": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Delete_Item; if (url_relative_list.Count > 2) Navigator.BibID = url_relative_list[2].ToUpper(); if (url_relative_list.Count > 3) Navigator.VID = url_relative_list[3]; break; case "submit": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.New_Item; if (url_relative_list.Count > 2) Navigator.My_Sobek_SubMode = url_relative_list[2]; break; case "itempermissions": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Edit_Item_Permissions; if (url_relative_list.Count > 2) Navigator.BibID = url_relative_list[2].ToUpper(); if (url_relative_list.Count > 3) Navigator.VID = url_relative_list[3]; if (url_relative_list.Count > 4) Navigator.My_Sobek_SubMode = url_relative_list[4]; break; case "behaviors": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Edit_Item_Behaviors; if (url_relative_list.Count > 2) Navigator.BibID = url_relative_list[2].ToUpper(); if (url_relative_list.Count > 3) Navigator.VID = url_relative_list[3]; if (url_relative_list.Count > 4) Navigator.My_Sobek_SubMode = url_relative_list[4]; break; case "edit": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Edit_Item_Metadata; if (url_relative_list.Count > 2) Navigator.BibID = url_relative_list[2].ToUpper(); if (url_relative_list.Count > 3) Navigator.VID = url_relative_list[3]; if (url_relative_list.Count > 4) Navigator.My_Sobek_SubMode = url_relative_list[4]; break; case "files": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.File_Management; if (url_relative_list.Count > 2) Navigator.BibID = url_relative_list[2].ToUpper(); if (url_relative_list.Count > 3) Navigator.VID = url_relative_list[3]; if (url_relative_list.Count > 4) Navigator.My_Sobek_SubMode = url_relative_list[4]; break; case "images": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Page_Images_Management; if (url_relative_list.Count > 2) Navigator.BibID = url_relative_list[2].ToUpper(); if (url_relative_list.Count > 3) Navigator.VID = url_relative_list[3]; if (url_relative_list.Count > 4) Navigator.My_Sobek_SubMode = url_relative_list[4]; break; case "addvolume": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Group_Add_Volume; if (url_relative_list.Count > 2) Navigator.BibID = url_relative_list[2].ToUpper(); if (url_relative_list.Count > 3) Navigator.My_Sobek_SubMode = url_relative_list[3]; break; case "autofill": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Group_AutoFill_Volumes; if (url_relative_list.Count > 2) Navigator.BibID = url_relative_list[2].ToUpper(); if (url_relative_list.Count > 3) Navigator.My_Sobek_SubMode = url_relative_list[3]; break; case "massupdate": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Group_Mass_Update_Items; if (url_relative_list.Count > 2) Navigator.BibID = url_relative_list[2].ToUpper(); if (url_relative_list.Count > 3) Navigator.My_Sobek_SubMode = url_relative_list[3]; break; case "groupbehaviors": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Edit_Group_Behaviors; if (url_relative_list.Count > 2) Navigator.BibID = url_relative_list[2].ToUpper(); if (url_relative_list.Count > 3) Navigator.My_Sobek_SubMode = url_relative_list[3]; break; case "serialhierarchy": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Edit_Group_Serial_Hierarchy; if (url_relative_list.Count > 2) Navigator.BibID = url_relative_list[2].ToUpper(); if (url_relative_list.Count > 3) Navigator.My_Sobek_SubMode = url_relative_list[3]; break; case "bookshelf": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Folder_Management; Navigator.Result_Display_Type = Result_Display_Type_Enum.Bookshelf; if (url_relative_list.Count > 2) { Navigator.My_Sobek_SubMode = url_relative_list[2]; if (url_relative_list.Count > 3) { switch (Navigator.My_Sobek_SubMode) { case "brief": Navigator.Result_Display_Type = Result_Display_Type_Enum.Brief; Navigator.My_Sobek_SubMode = url_relative_list[3]; break; case "export": Navigator.Result_Display_Type = Result_Display_Type_Enum.Export; Navigator.My_Sobek_SubMode = url_relative_list[3]; break; case "thumbs": Navigator.Result_Display_Type = Result_Display_Type_Enum.Thumbnails; Navigator.My_Sobek_SubMode = url_relative_list[3]; break; case "table": Navigator.Result_Display_Type = Result_Display_Type_Enum.Table; Navigator.My_Sobek_SubMode = url_relative_list[3]; break; case "citation": Navigator.Result_Display_Type = Result_Display_Type_Enum.Full_Citation; Navigator.My_Sobek_SubMode = url_relative_list[3]; break; case "image": Navigator.Result_Display_Type = Result_Display_Type_Enum.Full_Image; Navigator.My_Sobek_SubMode = url_relative_list[3]; break; default: if (is_String_Number(url_relative_list[3])) { ushort page_result; UInt16.TryParse(url_relative_list[3], out page_result); Navigator.Page = page_result; } break; } } if ((url_relative_list.Count > 4) && ( is_String_Number( url_relative_list[4] ))) { ushort page_result; UInt16.TryParse(url_relative_list[4], out page_result); Navigator.Page = page_result; } } break; case "preferences": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Preferences; break; case "logout": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Log_Out; if (QueryString["return"] != null) Navigator.Return_URL = QueryString["return"]; break; case "shibboleth": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Shibboleth_Landing; if (QueryString["return"] != null) Navigator.Return_URL = QueryString["return"]; break; case "itemtracking": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Item_Tracking; //if(url_relative_list.Count>3 && is_String_Number(url_relative_list[3])) // Navigator.My_Sobek_SubMode = url_relative_list[3]; break; case "searches": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.Saved_Searches; break; case "tags": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.User_Tags; if (url_relative_list.Count > 2) Navigator.My_Sobek_SubMode = url_relative_list[2]; break; case "stats": Navigator.My_Sobek_Type = My_Sobek_Type_Enum.User_Usage_Stats; if (url_relative_list.Count > 2) Navigator.My_Sobek_SubMode = url_relative_list[2]; break; } } break; case "admin": Navigator.Mode = Display_Mode_Enum.Administrative; Navigator.Admin_Type = Admin_Type_Enum.Home; if (QueryString["return"] != null) Navigator.Return_URL = QueryString["return"]; if (url_relative_list.Count > 1) { switch (url_relative_list[1]) { case "builder": Navigator.Admin_Type = Admin_Type_Enum.Builder_Status; if (url_relative_list.Count > 2) Navigator.My_Sobek_SubMode = url_relative_list[2]; break; break; case "addcoll": Navigator.Admin_Type = Admin_Type_Enum.Add_Collection_Wizard; if (url_relative_list.Count > 2) Navigator.My_Sobek_SubMode = url_relative_list[2]; break; case "aggregations": Navigator.Admin_Type = Admin_Type_Enum.Aggregations_Mgmt; if (url_relative_list.Count > 2) Navigator.My_Sobek_SubMode = url_relative_list[2]; break; case "editaggr": Navigator.Admin_Type = Admin_Type_Enum.Aggregation_Single; if (url_relative_list.Count > 2) Navigator.Aggregation = url_relative_list[2]; if (url_relative_list.Count > 3) Navigator.My_Sobek_SubMode = url_relative_list[3]; break; case "aliases": Navigator.Admin_Type = Admin_Type_Enum.Aliases; break; case "webskins": Navigator.Admin_Type = Admin_Type_Enum.Skins_Mgmt; break; case "editskin": Navigator.Admin_Type = Admin_Type_Enum.Skins_Single; if (url_relative_list.Count > 2) Navigator.My_Sobek_SubMode = url_relative_list[2]; if (url_relative_list.Count > 3) Navigator.My_Sobek_SubMode = url_relative_list[2] + "/" + url_relative_list[3]; break; case "defaults": Navigator.Admin_Type = Admin_Type_Enum.Default_Metadata; if (url_relative_list.Count > 2) Navigator.My_Sobek_SubMode = url_relative_list[2]; break; case "restrictions": Navigator.Admin_Type = Admin_Type_Enum.IP_Restrictions; if (url_relative_list.Count > 2) Navigator.My_Sobek_SubMode = url_relative_list[2]; break; case "portals": Navigator.Admin_Type = Admin_Type_Enum.URL_Portals; break; case "users": Navigator.Admin_Type = Admin_Type_Enum.Users; if (url_relative_list.Count > 2) Navigator.My_Sobek_SubMode = url_relative_list[2]; break; case "groups": Navigator.Admin_Type = Admin_Type_Enum.User_Groups; if (url_relative_list.Count > 2) Navigator.My_Sobek_SubMode = url_relative_list[2]; break; case "permissions": Navigator.Admin_Type = Admin_Type_Enum.User_Permissions_Reports; if (url_relative_list.Count > 2) Navigator.My_Sobek_SubMode = url_relative_list[2]; break; case "webadd": Navigator.Admin_Type = Admin_Type_Enum.WebContent_Add_New; if (url_relative_list.Count > 2) Navigator.My_Sobek_SubMode = url_relative_list[2]; break; case "webcontent": Navigator.Admin_Type = Admin_Type_Enum.WebContent_Mgmt; if (url_relative_list.Count > 2) Navigator.My_Sobek_SubMode = url_relative_list[2]; break; case "webhistory": Navigator.Admin_Type = Admin_Type_Enum.WebContent_History; break; case "websingle": Navigator.Admin_Type = Admin_Type_Enum.WebContent_Single; if (url_relative_list.Count > 2) { int possiblewebid; if (Int32.TryParse(url_relative_list[2], out possiblewebid)) { Navigator.WebContentID = possiblewebid; } if (url_relative_list.Count > 3) { Navigator.My_Sobek_SubMode = url_relative_list[3]; } } if ( Navigator.WebContentID < 1 ) Navigator.Admin_Type = Admin_Type_Enum.WebContent_Mgmt; break; case "webusage": Navigator.Admin_Type = Admin_Type_Enum.WebContent_Usage; break; case "wordmarks": Navigator.Admin_Type = Admin_Type_Enum.Wordmarks; break; case "reset": Navigator.Admin_Type = Admin_Type_Enum.Reset; break; case "headings": Navigator.Admin_Type = Admin_Type_Enum.Thematic_Headings; if (url_relative_list.Count > 2) Navigator.My_Sobek_SubMode = url_relative_list[2]; break; case "settings": Navigator.Admin_Type = Admin_Type_Enum.Settings; if (url_relative_list.Count > 2) Navigator.My_Sobek_SubMode = url_relative_list[2]; break; } } break; case "preferences": Navigator.Mode = Display_Mode_Enum.Preferences; break; case "reports": Navigator.Mode = Display_Mode_Enum.Reports; if (url_relative_list.Count > 1) { Navigator.Report_Name = url_relative_list[1]; } break; case "stats": case "statistics": Navigator.Mode = Display_Mode_Enum.Statistics; Navigator.Statistics_Type = Statistics_Type_Enum.Item_Count_Standard_View; if ( url_relative_list.Count > 1 ) { switch( url_relative_list[1] ) { case "itemcount": Navigator.Statistics_Type = Statistics_Type_Enum.Item_Count_Standard_View; if ( url_relative_list.Count > 2 ) { switch( url_relative_list[2]) { case "arbitrary": Navigator.Statistics_Type = Statistics_Type_Enum.Item_Count_Arbitrary_View; if (url_relative_list.Count > 3) { Navigator.Info_Browse_Mode = url_relative_list[3]; } break; case "growth": Navigator.Statistics_Type = Statistics_Type_Enum.Item_Count_Growth_View; break; case "text": Navigator.Statistics_Type = Statistics_Type_Enum.Item_Count_Text; break; case "standard": Navigator.Statistics_Type = Statistics_Type_Enum.Item_Count_Standard_View; break; } } break; case "searches": Navigator.Statistics_Type = Statistics_Type_Enum.Recent_Searches; break; case "usage": Navigator.Statistics_Type = Statistics_Type_Enum.Usage_Overall; if ( url_relative_list.Count > 2 ) { switch( url_relative_list[2]) { case "all": Navigator.Statistics_Type = Statistics_Type_Enum.Usage_Overall; break; case "history": Navigator.Statistics_Type = Statistics_Type_Enum.Usage_Collection_History; if ( url_relative_list.Count > 3 ) { switch( url_relative_list[3] ) { case "text": Navigator.Statistics_Type = Statistics_Type_Enum.Usage_Collection_History_Text; break; default: Navigator.Info_Browse_Mode = url_relative_list[3]; break; } if ((String.IsNullOrEmpty(Navigator.Info_Browse_Mode)) && (url_relative_list.Count > 4)) Navigator.Info_Browse_Mode = url_relative_list[4]; } break; case "collections": Navigator.Statistics_Type = Statistics_Type_Enum.Usage_Collections_By_Date; if (url_relative_list.Count > 3) Navigator.Info_Browse_Mode = url_relative_list[3]; break; case "definitions": Navigator.Statistics_Type = Statistics_Type_Enum.Usage_Definitions; break; case "titles": Navigator.Statistics_Type = Statistics_Type_Enum.Usage_Titles_By_Collection; if (( String.IsNullOrEmpty( Navigator.Info_Browse_Mode )) && ( url_relative_list.Count > 4 )) Navigator.Info_Browse_Mode = url_relative_list[4]; break; case "items": Navigator.Statistics_Type = Statistics_Type_Enum.Usage_Item_Views_By_Date; if ( url_relative_list.Count > 3 ) { switch( url_relative_list[3] ) { case "date": Navigator.Statistics_Type = Statistics_Type_Enum.Usage_Item_Views_By_Date; break; case "top": Navigator.Statistics_Type = Statistics_Type_Enum.Usage_Items_By_Collection; break; case "text": Navigator.Statistics_Type = Statistics_Type_Enum.Usage_By_Date_Text; break; default: Navigator.Info_Browse_Mode = url_relative_list[3]; break; } if (( String.IsNullOrEmpty( Navigator.Info_Browse_Mode )) && ( url_relative_list.Count > 4 )) Navigator.Info_Browse_Mode = url_relative_list[4]; } break; } } break; } } break; case "partners": if (( String.IsNullOrEmpty(Navigator.Default_Aggregation)) || ( Navigator.Default_Aggregation == "all")) { Navigator.Mode = Display_Mode_Enum.Aggregation; Navigator.Aggregation_Type = Aggregation_Type_Enum.Home; Navigator.Aggregation = String.Empty; Navigator.Home_Type = Home_Type_Enum.Partners_List; if ((url_relative_list.Count > 1) && (url_relative_list[1] == "thumbs")) { Navigator.Home_Type = Home_Type_Enum.Partners_Thumbnails; } } else { aggregation_querystring_analyze(Navigator, QueryString, Navigator.Default_Aggregation, url_relative_list); } break; case "tree": Navigator.Mode = Display_Mode_Enum.Aggregation; Navigator.Aggregation_Type = Aggregation_Type_Enum.Home; Navigator.Aggregation = String.Empty; Navigator.Home_Type = Home_Type_Enum.Tree; break; case "brief": Navigator.Mode = Display_Mode_Enum.Aggregation; Navigator.Aggregation_Type = Aggregation_Type_Enum.Home; Navigator.Aggregation = String.Empty; Navigator.Home_Type = Home_Type_Enum.Descriptions; break; case "personalized": Navigator.Mode = Display_Mode_Enum.Aggregation; Navigator.Aggregation_Type = Aggregation_Type_Enum.Home; Navigator.Aggregation = String.Empty; Navigator.Home_Type = Home_Type_Enum.Personalized; break; case "inprocess": Navigator.Aggregation = String.Empty; Navigator.Mode = Display_Mode_Enum.Aggregation; Navigator.Aggregation_Type = Aggregation_Type_Enum.Home; Navigator.Aggregation_Type = Aggregation_Type_Enum.Private_Items; Navigator.Page = 1; if (url_relative_list.Count > 1) { if (is_String_Number(url_relative_list[1])) Navigator.Page = Convert.ToUInt16(url_relative_list[1]); } if ((QueryString["o"] != null) && (is_String_Number(QueryString["o"]))) { Navigator.Sort = Convert.ToInt16(QueryString["o"]); } else { Navigator.Sort = 0; } break; case "all": case "new": case "edit": case "map": case "mapbeta": case "advanced": case "text": case "results": case "contains": case "exact": case "resultslike": case "browseby": case "info": case "aggrmanage": case "aggrhistory": case "aggrpermissions": case "geography": aggregation_querystring_analyze(Navigator, QueryString, Navigator.Default_Aggregation, url_relative_list); break; // This was none of the main constant mode settings, default: // Always check the top-level static web content pages and redirects hierarchy first if ((WebHierarchy != null) && (WebHierarchy.Root_Count > 0)) { WebContent_Hierarchy_Node matchedNode = WebHierarchy.Find(url_relative_list); if (matchedNode != null) { // Maybe this is a web content / info page Navigator.Mode = Display_Mode_Enum.Simple_HTML_CMS; // Get the URL reassembled string possible_info_mode = String.Empty; if (url_relative_list.Count == 1) possible_info_mode = url_relative_list[0]; else if (url_relative_list.Count == 2) possible_info_mode = url_relative_list[0] + "/" + url_relative_list[1]; else if (url_relative_list.Count == 3) possible_info_mode = url_relative_list[0] + "/" + url_relative_list[1] + "/" + url_relative_list[2]; else if (url_relative_list.Count == 4) possible_info_mode = url_relative_list[0] + "/" + url_relative_list[1] + "/" + url_relative_list[2] + "/" + url_relative_list[3]; else if (url_relative_list.Count > 4) { StringBuilder possibleInfoModeBuilder = new StringBuilder(); if (url_relative_list.Count > 0) { possibleInfoModeBuilder.Append(url_relative_list[0]); } for (int i = 1; i < url_relative_list.Count; i++) { possibleInfoModeBuilder.Append("/" + url_relative_list[i]); } possible_info_mode = possibleInfoModeBuilder.ToString().Replace("'", "").Replace("\"", ""); } // Set the source location Navigator.Info_Browse_Mode = possible_info_mode; Navigator.Page_By_FileName = Engine_ApplicationCache_Gateway.Settings.Servers.Base_Directory + "design\\webcontent\\" + possible_info_mode.Replace("/","\\") + "\\default.html"; Navigator.WebContentID = matchedNode.WebContentID; Navigator.Redirect = matchedNode.Redirect; //// If it is missing, mark that //if ((!File.Exists(Navigator.Page_By_FileName)) && ( String.IsNullOrEmpty(Navigator.Redirect))) //{ // Navigator.Missing = true; // Navigator.Info_Browse_Mode = possible_info_mode; // Navigator.Page_By_FileName = Engine_ApplicationCache_Gateway.Settings.Servers.Base_Directory + "design\\webcontent\\missing.html"; //} // If something was found, then check for submodes Navigator.WebContent_Type = WebContent_Type_Enum.Display; if (!String.IsNullOrEmpty(QueryString["mode"])) { switch (QueryString["mode"].ToLower()) { case "edit": Navigator.WebContent_Type = WebContent_Type_Enum.Edit; break; case "menu": Navigator.WebContent_Type = WebContent_Type_Enum.Manage_Menu; break; case "milestones": Navigator.WebContent_Type = WebContent_Type_Enum.Milestones; break; case "permissions": Navigator.WebContent_Type = WebContent_Type_Enum.Permissions; break; case "usage": Navigator.WebContent_Type = WebContent_Type_Enum.Usage; break; case "verify": Navigator.WebContent_Type = WebContent_Type_Enum.Delete_Verify; break; } } return; } } // Check to see if the first term was an item aggregation alias, which // allows for the alias to overwrite an existing aggregation code (limited usability // but can be used to hide an existing aggregation easily) if (Aggregation_Aliases.ContainsKey(url_relative_list[0])) { // Perform all aggregation_style checks next string aggregation_code = Aggregation_Aliases[url_relative_list[0]]; Navigator.Aggregation_Alias = url_relative_list[0]; aggregation_querystring_analyze( Navigator, QueryString, aggregation_code, url_relative_list.GetRange(1, url_relative_list.Count - 1)); } else if ( Code_Manager.isValidCode( url_relative_list[0] )) { // This is an item aggregation call // Perform all aggregation_style checks next aggregation_querystring_analyze( Navigator, QueryString, url_relative_list[0], url_relative_list.GetRange(1, url_relative_list.Count - 1 )); } else if ((Engine_Database.Verify_Item_Lookup_Object(false, true, All_Items_Lookup, Tracer)) && (All_Items_Lookup.Contains_BibID(url_relative_list[0].ToUpper()))) { // This is a BibID for an existing title with at least one public item Navigator.BibID = url_relative_list[0].ToUpper(); Navigator.Mode = Display_Mode_Enum.Item_Display; // Is the next part a VID? int current_list_index = 1; if (url_relative_list.Count > 1) { string possible_vid = url_relative_list[1].Trim().PadLeft(5, '0'); if ((All_Items_Lookup.Contains_BibID_VID(Navigator.BibID, possible_vid)) || ( possible_vid == "00000" )) { Navigator.VID = possible_vid; current_list_index++; } } // Look for the item print mode now if ((url_relative_list.Count > current_list_index) && (url_relative_list[current_list_index] == "print")) { // This is an item print request Navigator.Mode = Display_Mode_Enum.Item_Print; // Since we need special characters for ranges, etc.. the viewer code // is in the options query string variable in this case if (QueryString["options"] != null) { Navigator.ViewerCode = QueryString["options"]; } } else { // Look for the viewercode next if (url_relative_list.Count > current_list_index) { string possible_viewercode = url_relative_list[current_list_index].Trim(); // Get the view code if (possible_viewercode.Length > 0) { // Get the viewer code Navigator.ViewerCode = possible_viewercode; // Now, get the page if ((Navigator.ViewerCode.Length > 0) && (Char.IsNumber(Navigator.ViewerCode[0]))) { // Look for the first number int numberEnd = Navigator.ViewerCode.Length; int count = 0; foreach (char thisChar in Navigator.ViewerCode) { if (!Char.IsNumber(thisChar)) { numberEnd = count; break; } count++; } // Get the page ushort testPage; if (UInt16.TryParse(Navigator.ViewerCode.Substring(0, numberEnd), out testPage)) Navigator.Page = testPage; } } else { // Sequence is set to 1 Navigator.Page = 1; } // Used or discarded the possible viewer code (used unless length of zero ) current_list_index++; // Look for a subpage now, if there since there was a (possible) viewer code if (url_relative_list.Count > current_list_index) { string possible_subpage = url_relative_list[current_list_index].Trim(); if (is_String_Number(possible_subpage)) { ushort testSubPage; if (UInt16.TryParse(possible_subpage, out testSubPage)) Navigator.SubPage = testSubPage; } } } } // Collect number of thumbnails per page if (QueryString["nt"] != null) { short nt_temp; if (short.TryParse(QueryString["nt"], out nt_temp)) Navigator.Thumbnails_Per_Page = nt_temp; } // Collect size of thumbnails per page if (QueryString["ts"] != null) { short ts_temp; if (short.TryParse(QueryString["ts"], out ts_temp)) Navigator.Size_Of_Thumbnails = ts_temp; } // Collect the text search string if (QueryString["search"] != null) Navigator.Text_Search = QueryString["search"].Replace("+"," "); // If coordinates were here, save them if (QueryString["coord"] != null) Navigator.Coordinates = QueryString["coord"]; // If a page is requested by filename (rather than sequenc), collect that if (QueryString["file"] != null) Navigator.Page_By_FileName = QueryString["file"]; } else if ((String.IsNullOrEmpty(Navigator.Page_By_FileName)) && ((String.IsNullOrEmpty(Navigator.Default_Aggregation)) || (Navigator.Default_Aggregation == "all"))) { // This may be a top-level aggregation call // aggregation_querystring_analyze(Navigator, QueryString, Navigator.Default_Aggregation, url_relative_list); // Pass this unmatched query to the simple html cms to show the missing (custom) screen Navigator.Mode = Display_Mode_Enum.Simple_HTML_CMS; string possible_info_mode = String.Empty; if (url_relative_list.Count == 1) possible_info_mode = url_relative_list[0]; else if (url_relative_list.Count == 2) possible_info_mode = url_relative_list[0] + "/" + url_relative_list[1]; else if (url_relative_list.Count == 3) possible_info_mode = url_relative_list[0] + "/" + url_relative_list[1] + "/" + url_relative_list[2]; else if (url_relative_list.Count == 4) possible_info_mode = url_relative_list[0] + "/" + url_relative_list[1] + "/" + url_relative_list[2] + "/" + url_relative_list[3]; else if ( url_relative_list.Count > 4) { StringBuilder possibleInfoModeBuilder = new StringBuilder(); if (url_relative_list.Count > 0) { possibleInfoModeBuilder.Append(url_relative_list[0]); } for (int i = 1; i < url_relative_list.Count; i++) { possibleInfoModeBuilder.Append("/" + url_relative_list[i]); } possible_info_mode = possibleInfoModeBuilder.ToString().Replace("'", "").Replace("\"", ""); } string base_source = Engine_ApplicationCache_Gateway.Settings.Servers.Base_Directory + "design\\webcontent"; // Set the source location Navigator.Missing = true; Navigator.Info_Browse_Mode = possible_info_mode; Navigator.WebContent_Type = WebContent_Type_Enum.Display; Navigator.Page_By_FileName = base_source + "\\missing.html"; Navigator.WebContentID = -1; } break; } } } } }
/// <summary> Refresh the hierarchy of non-aggregational web content pages by pulling the data back from the database </summary> /// <returns> TRUE if successful, otherwise FALSE </returns> public static bool RefreshWebContentHierarchy() { try { lock (webContentHierarchyLock) { // Either create a new hierarchy object , or clear the existing if (webContentHierarchy == null) webContentHierarchy = new WebContent_Hierarchy(); else webContentHierarchy.Clear(); if (!Engine_Database.WebContent_Populate_All_Hierarchy(webContentHierarchy, null)) { webContentHierarchy = null; return false; } } return true; } catch { return false; } }
/// <summary> Gets the hierarchy of all global content pages AND redirects, used for looking for a match from a requested URL </summary> /// <param name="ReturnValue"> Web content hierarchy object to populate - should be pre-cleared </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <returns> Flag indicating if this ran successfully, TRUE if successful, otherwise FALSE </returns> /// <remarks> This calls the 'SobekCM_WebContent_All_Brief' stored procedure </remarks> public static bool WebContent_Populate_All_Hierarchy(WebContent_Hierarchy ReturnValue, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("Engine_Database.WebContent_Populate_All_Hierarchy", "Gets the hierarchy tree of all content pages and redirects"); } try { // Create the database agnostic reader EalDbReaderWrapper readerWrapper = EalDbAccess.ExecuteDataReader(DatabaseType, Connection_String, CommandType.StoredProcedure, "SobekCM_WebContent_All_Brief"); // Get ready to step through all the rows returned from the reader WebContent_Hierarchy_Node[] list = new WebContent_Hierarchy_Node[7]; // Read through each milestone DbDataReader reader = readerWrapper.Reader; while (readerWrapper.Reader.Read()) { // Grab the values out string redirect = (!reader.IsDBNull(9)) ? reader.GetString(9) : null; int id = reader.GetInt32(0); // Handle the first segment string segment1 = reader.GetString(1); if ((list[0] == null) || (String.Compare(list[0].Segment, segment1, StringComparison.OrdinalIgnoreCase) != 0)) { // Build the node and add to the root nodes WebContent_Hierarchy_Node newNode = new WebContent_Hierarchy_Node(segment1, id, redirect); ReturnValue.Add_Child( newNode ); // If there are additional non-null segments, than this node does not represent the // actual node that corresponds to this web content page or redirect if (!reader.IsDBNull(2)) newNode.WebContentID = -1; // Also save in the right spot in the list and clear the next level list[0] = newNode; list[1] = null; } // If there is a second segment here, handle that if (!reader.IsDBNull(2)) { string segment2 = reader.GetString(2); // Is this a new segment 2 value? if ((list[1] == null) || (String.Compare(list[1].Segment, segment2, StringComparison.OrdinalIgnoreCase) != 0)) { // Build the node and add to the current parent node WebContent_Hierarchy_Node newNode = new WebContent_Hierarchy_Node(segment2, id, redirect); list[0].Add_Child(newNode); // If there are additional non-null segments, than this node does not represent the // actual node that corresponds to this web content page or redirect if (!reader.IsDBNull(3)) newNode.WebContentID = -1; // Also save in the right spot in the list and clear the next level list[1] = newNode; list[2] = null; } // Is there a third segment to add as well if (!reader.IsDBNull(3)) { string segment3 = reader.GetString(3); // Is this a new segment 3 value? if ((list[2] == null) || (String.Compare(list[2].Segment, segment3, StringComparison.OrdinalIgnoreCase) != 0)) { // Build the node and add to the current parent node WebContent_Hierarchy_Node newNode = new WebContent_Hierarchy_Node(segment3, id, redirect); list[1].Add_Child(newNode); // If there are additional non-null segments, than this node does not represent the // actual node that corresponds to this web content page or redirect if (!reader.IsDBNull(4)) newNode.WebContentID = -1; // Also save in the right spot in the list and clear the next level list[2] = newNode; list[3] = null; } // Is there a fourth segment to add as well if (!reader.IsDBNull(4)) { string segment4 = reader.GetString(4); // Is this a new segment 4 value? if ((list[3] == null) || (String.Compare(list[3].Segment, segment4, StringComparison.OrdinalIgnoreCase) != 0)) { // Build the node and add to the current parent node WebContent_Hierarchy_Node newNode = new WebContent_Hierarchy_Node(segment4, id, redirect); list[2].Add_Child(newNode); // If there are additional non-null segments, than this node does not represent the // actual node that corresponds to this web content page or redirect if (!reader.IsDBNull(5)) newNode.WebContentID = -1; // Also save in the right spot in the list and clear the next level list[3] = newNode; list[4] = null; } // Is there a fifth segment to add as well if (!reader.IsDBNull(5)) { string segment5 = reader.GetString(5); // Is this a new segment 5 value? if ((list[4] == null) || (String.Compare(list[4].Segment, segment5, StringComparison.OrdinalIgnoreCase) != 0)) { // Build the node and add to the current parent node WebContent_Hierarchy_Node newNode = new WebContent_Hierarchy_Node(segment5, id, redirect); list[3].Add_Child(newNode); // If there are additional non-null segments, than this node does not represent the // actual node that corresponds to this web content page or redirect if (!reader.IsDBNull(6)) newNode.WebContentID = -1; // Also save in the right spot in the list and clear the next level list[4] = newNode; list[5] = null; } // Is there a sixth segment to add as well if (!reader.IsDBNull(6)) { string segment6 = reader.GetString(6); // Is this a new segment 6 value? if ((list[5] == null) || (String.Compare(list[5].Segment, segment6, StringComparison.OrdinalIgnoreCase) != 0)) { // Build the node and add to the current parent node WebContent_Hierarchy_Node newNode = new WebContent_Hierarchy_Node(segment6, id, redirect); list[4].Add_Child(newNode); // If there are additional non-null segments, than this node does not represent the // actual node that corresponds to this web content page or redirect if (!reader.IsDBNull(7)) newNode.WebContentID = -1; // Also save in the right spot in the list and clear the next level list[5] = newNode; list[6] = null; } // Is there a seventh segment to add as well if (!reader.IsDBNull(7)) { string segment7 = reader.GetString(7); // Is this a new segment 7 value? if ((list[6] == null) || (String.Compare(list[6].Segment, segment7, StringComparison.OrdinalIgnoreCase) != 0)) { // Build the node and add to the current parent node WebContent_Hierarchy_Node newNode = new WebContent_Hierarchy_Node(segment7, id, redirect); list[5].Add_Child(newNode); // If there are additional non-null segments, than this node does not represent the // actual node that corresponds to this web content page or redirect if (!reader.IsDBNull(8)) newNode.WebContentID = -1; // Also save in the right spot in the list.. no next level to clear list[6] = newNode; } // Is there an eigth segment? (Will always be a new one since the bottom of the unique hierarchy list) if (!reader.IsDBNull(8)) { string segment8 = reader.GetString(8); // Build the node and add to the current parent node WebContent_Hierarchy_Node newNode = new WebContent_Hierarchy_Node(segment8, id, redirect); list[6].Add_Child(newNode); // Note, this last node always represents the web content page or redirect if // it made it this far. No need to check next level and assign id to -1 if not null } } } } } } } } // Close the reader (which also closes the connection) readerWrapper.Close(); // Return the built list return true; } catch (Exception ee) { Last_Exception = ee; if (Tracer != null) { Tracer.Add_Trace("Engine_Database.WebContent_Populate_All_Hierarchy", "Exception caught during database work", Custom_Trace_Type_Enum.Error); Tracer.Add_Trace("Engine_Database.WebContent_Populate_All_Hierarchy", ee.Message, Custom_Trace_Type_Enum.Error); Tracer.Add_Trace("Engine_Database.WebContent_Populate_All_Hierarchy", ee.StackTrace, Custom_Trace_Type_Enum.Error); } return false; } }
/// <summary> Stores the complete hierarchy of non-aggregational static web content pages and redirects, used for navigation </summary> /// <param name="StoreObject"> List of next level values </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param> public void Store_Hierarchy(WebContent_Hierarchy StoreObject, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("CachedDataManager_WebContentServices.Store_Hierarchy"); } // If the cache is disabled, just return before even tracing if (settings.Disabled) { if (Tracer != null) Tracer.Add_Trace("CachedDataManager_WebContentServices.Store_Hierarchy", "Caching is disabled"); return; } // Determine the key const string KEY = "WEBCONTENT|CLIENT|HIERARCHY"; const int LOCAL_EXPIRATION = 15; // Locally cache if this doesn't exceed the limit if (Tracer != null) { Tracer.Add_Trace("CachedDataManager_WebContentServices.Store_Hierarchy", "Adding object '" + KEY + "' to the local cache with expiration of " + LOCAL_EXPIRATION + " minute(s)"); } HttpContext.Current.Cache.Insert(KEY, StoreObject, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(LOCAL_EXPIRATION)); }
/// <summary> Clear the cached web content hierarchy data </summary> public static void WebContent_Hierarchy_Clear() { webContentHierarchy = null; }