Class is a helper class that pulls much of the data needed for the processing of requests. Tries to retrieve from the cache, and if the data is not there, it will then build the object and try to store on the cache
        /// <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="Default_Skin"> Default skin code </param>
        public Static_Pages_Builder(string Primary_Web_Server_URL, string Static_Data_Location, string Default_Skin)
        {
            primaryWebServerUrl = Primary_Web_Server_URL;
            staticSobekcmDataLocation = Static_Data_Location;
            staticSobekcmLocation = UI_ApplicationCache_Gateway.Settings.Servers.Application_Server_Network;

            tracer = new Custom_Tracer();
            assistant = new SobekCM_Assistant();

            // Save all the objects needed by the SobekCM Library
            defaultSkin = Default_Skin;

            // Create the mode object
            currentMode = new Navigation_Object
                              {
                                  ViewerCode = "citation",
                                  Skin = String.Empty,
                                  Mode = Display_Mode_Enum.Item_Display,
                                  Language = Web_Language_Enum.English,
                                  Base_URL = primaryWebServerUrl
                              };

            // Set some constant settings
            // SobekCM.Library.UI_ApplicationCache_Gateway.Settings.Watermarks_URL = primary_web_server_url + "/design/wordmarks/";
            UI_ApplicationCache_Gateway.Settings.Base_SobekCM_Location_Relative = primaryWebServerUrl;

            // Ensure all the folders exist
            if (!Directory.Exists(staticSobekcmDataLocation))
                Directory.CreateDirectory(staticSobekcmDataLocation);
            if (!Directory.Exists(staticSobekcmDataLocation + "\\rss"))
                Directory.CreateDirectory(staticSobekcmDataLocation + "\\rss");
        }
        /// <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> 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="All_Items_Lookup"> Allows individual items to be retrieved by various methods as <see cref="Application_State.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>
        public Static_Pages_Builder(string Primary_Web_Server_URL, string Static_Data_Location,
            Language_Support_Info Translator,
            Aggregation_Code_Manager Code_Manager,
            Item_Lookup_Object All_Items_Lookup,
            Dictionary<string, Wordmark_Icon> Icon_Table,
            SobekCM_Skin_Object HTML_Skin)
        {
            primaryWebServerUrl = Primary_Web_Server_URL;
            staticSobekcmDataLocation = Static_Data_Location;

            tracer = new Custom_Tracer();
            assistant = new SobekCM_Assistant();

               // marcWriter = new MARC_Writer();

            // Save all the objects needed by the UFDC Library
            iconList = Icon_Table;
            translations = Translator;
            codeManager = Code_Manager;
            itemList = All_Items_Lookup;
            ufdcInterface = HTML_Skin;
            dlocInterface = HTML_Skin;

            // Create the mode object
            currentMode = new SobekCM_Navigation_Object
                              {
                                  ViewerCode = "citation",
                                  Skin = "UFDC",
                                  Mode = Display_Mode_Enum.Item_Display,
                                  Language = Web_Language_Enum.English,
                                  Base_URL = primaryWebServerUrl
                              };
        }
        private void MySobekCM_Block()
        {
            if ((currentMode.My_Sobek_Type == My_Sobek_Type_Enum.Folder_Management) && (HttpContext.Current.Session["user"] != null) && (currentMode.My_Sobek_SubMode.Length > 0))
            {
                tracer.Add_Trace("SobekCM_Page_Globals.MySobekCM_Block", "Retrieiving Browse/Info Object");

                User_Object userObj = (User_Object) HttpContext.Current.Session["user"];

                // For EXPORT option, include ALL the items
                int results_per_page = 20;
                int current_page = currentMode.Page;
                if (currentMode.Result_Display_Type == Result_Display_Type_Enum.Export)
                {
                    results_per_page = 10000;
                    current_page = 1;
                }

                // Get the folder
                SobekCM_Assistant assistant = new SobekCM_Assistant();
                if (!assistant.Get_User_Folder(currentMode.My_Sobek_SubMode, userObj.UserID, results_per_page, current_page, tracer, out searchResultStatistics, out pagedSearchResults))
                {
                    currentMode.Mode = Display_Mode_Enum.Error;
                }
            }
        }
        private void Get_Entire_Collection_Hierarchy()
        {
            // If the mode is NULL or the request was already completed, do nothing
            if ((currentMode == null) || (currentMode.Request_Completed))
                return;

            tracer.Add_Trace("SobekCM_Page_Globals.Get_Entire_Collection_Hierarchy", "Retrieving hierarchy information");

            // Check that the current aggregation code is valid
            if (!Global.Codes.isValidCode(currentMode.Aggregation))
            {
                // Is there a "forward value"
                if (Global.Collection_Aliases.ContainsKey(currentMode.Aggregation))
                {
                    currentMode.Aggregation = Global.Collection_Aliases[currentMode.Aggregation];
                }
            }

            SobekCM_Assistant assistant = new SobekCM_Assistant();
            if (!assistant.Get_Entire_Collection_Hierarchy(currentMode, Global.Codes, tracer, out hierarchyObject))
            {
                currentMode.Mode = Display_Mode_Enum.Error;
            }
        }
        private void Display_Item()
        {
            tracer.Add_Trace("SobekCM_Page_Globals.Display_Item", "Retrieving item or group information");

            // Build the SobekCM assistant
            SobekCM_Assistant assistant = new SobekCM_Assistant();

            // If this is a robot, then get the text from the static page
            if (currentMode.Is_Robot)
            {
                string directory = currentMode.BibID.Substring(0, 2) + "/" + currentMode.BibID.Substring(2, 2) + "/" + currentMode.BibID.Substring(4, 2) + "/" + currentMode.BibID.Substring(6, 2) + "/" + currentMode.BibID.Substring(8);
                string redirect_dir = "~/data/" + directory + "/" + currentMode.BibID + "_" + currentMode.VID + ".html";
                HttpContext.Current.RewritePath(redirect_dir, true);
                currentMode.Request_Completed = true;
            }
            else
            {
                if (!assistant.Get_Item(currentMode, Global.Item_List, SobekCM_Library_Settings.Image_URL,
                                        Global.Icon_List, Global.Item_Viewer_Priority, currentUser, tracer, out currentItem, out currentPage, out itemsInTitle))
                {
                    if ((currentMode.Mode == Display_Mode_Enum.Legacy_URL) || (currentMode.Invalid_Item))
                    {
                        if (currentMode.Mode != Display_Mode_Enum.Legacy_URL)
                        {
                            currentMode.Mode = Display_Mode_Enum.Error;
                            currentMode.Error_Message = "Invalid Item Requested";
                        }
                    }
                    else
                    {
                        Email_Information("Unable to find metadata for valid item", null);
                        currentMode.Mode = Display_Mode_Enum.Aggregation;
                        currentMode.Aggregation_Type = Aggregation_Type_Enum.Home;
                        currentMode.Redirect();
                        // return;
                    }
                }
            }
        }
        private void Browse_Info_Block()
        {
            tracer.Add_Trace("SobekCM_Page_Globals.Browse_Info_Block", "Retrieiving Browse/Info Object");

            SobekCM_Assistant assistant = new SobekCM_Assistant();

            // If this is a robot, then get the text from the static page
            if ((currentMode.Is_Robot) && (currentMode.Info_Browse_Mode == "all"))
            {
                browse_info_display_text = assistant.Get_All_Browse_Static_HTML(currentMode, tracer);
                currentMode.Writer_Type = Writer_Type_Enum.HTML_Echo;
            }
            else
            {
                if (!assistant.Get_Browse_Info(currentMode, hierarchyObject, SobekCM_Library_Settings.Base_Directory, tracer, out thisBrowseObject, out searchResultStatistics, out pagedSearchResults, out staticWebContent))
                {
                    currentMode.Mode = Display_Mode_Enum.Error;
                }
            }
        }
        public void Set_Main_Writer()
        {
            // Load the html writer
            string current_skin_code = currentMode.Skin.ToUpper();
            if ((currentMode.Writer_Type == Writer_Type_Enum.HTML) || (currentMode.Writer_Type == Writer_Type_Enum.HTML_LoggedIn))
            {
                // Check if a different skin should be used if this is an item display
                if ((currentMode.Mode == Display_Mode_Enum.Item_Display) || (currentMode.Mode == Display_Mode_Enum.Item_Print))
                {
                    if ((currentItem != null) && (currentItem.Behaviors.Web_Skin_Count > 0))
                    {
                        if (!currentItem.Behaviors.Web_Skins.Contains(current_skin_code))
                        {
                            string new_skin_code = currentItem.Behaviors.Web_Skins[0];
                            current_skin_code = new_skin_code;
                        }
                    }
                }

                // Check if a differente skin should be used if this is a collection display
                if ((hierarchyObject != null) && (hierarchyObject.Web_Skins.Count > 0))
                {
                    if (!hierarchyObject.Web_Skins.Contains(current_skin_code.ToLower()))
                    {
                        current_skin_code = hierarchyObject.Web_Skins[0];
                    }
                }

                SobekCM_Assistant assistant = new SobekCM_Assistant();

                // Try to get the web skin from the cache or skin collection, otherwise build it
                htmlSkin = assistant.Get_HTML_Skin(current_skin_code, currentMode, Global.Skins, true, tracer);

                // If there was no web skin returned, forward user to URL with no web skin.
                // This happens if the web skin code is invalid.  If a robot, just return a bad request
                // value though.
                if (htmlSkin == null)
                {
                    if ((currentMode == null) || (currentMode.Is_Robot))
                    {
                        HttpContext.Current.Response.StatusCode = 404;
                        HttpContext.Current.Response.Output.WriteLine("404 - INVALID URL");
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                        currentMode.Request_Completed = true;
                    }
                    else
                    {
                        currentMode.Skin = String.Empty;
                        currentMode.Redirect();
                        return;
                    }

                    return;
                }

                mainWriter = new Html_MainWriter(currentMode, hierarchyObject, searchResultStatistics, pagedSearchResults, thisBrowseObject,
                                                 currentItem, currentPage, htmlSkin, currentUser, Global.Translation, Global.Codes,
                                                 Global.Item_List, Global.Stats_Date_Range,
                                                 Global.Search_History, Global.Icon_List, Global.Thematic_Headings, publicFolder, Global.Collection_Aliases, Global.Skins, Global.Checked_List,
                                                 Global.IP_Restrictions, Global.URL_Portals, siteMap, itemsInTitle, staticWebContent, tracer);
            }

            // Load the OAI writer
            if (currentMode.Writer_Type == Writer_Type_Enum.OAI)
            {
                mainWriter = new Oai_MainWriter(HttpContext.Current.Request.QueryString, Global.Item_List);
            }

            // Load the DataSet writer
            if (currentMode.Writer_Type == Writer_Type_Enum.DataSet)
            {
                mainWriter = new Dataset_MainWriter(currentMode, hierarchyObject, searchResultStatistics, pagedSearchResults, thisBrowseObject, currentItem, currentPage);
            }

            // Load the DataProvider writer
            if (currentMode.Writer_Type == Writer_Type_Enum.Data_Provider)
            {
                mainWriter = new DataProvider_MainWriter(currentMode, hierarchyObject, searchResultStatistics, pagedSearchResults, thisBrowseObject, currentItem, currentPage);
            }

            // Load the XML writer
            if (currentMode.Writer_Type == Writer_Type_Enum.XML)
            {
                mainWriter = new Xml_MainWriter(currentMode, hierarchyObject, searchResultStatistics, pagedSearchResults, thisBrowseObject, currentItem, currentPage);
            }

            // Load the JSON writer
            if (currentMode.Writer_Type == Writer_Type_Enum.JSON)
            {
                mainWriter = new Json_MainWriter(currentMode, hierarchyObject, searchResultStatistics, pagedSearchResults, thisBrowseObject, currentItem, currentPage, Global.Item_List, SobekCM_Library_Settings.Image_URL);
            }

            // Load the HTML ECHO writer
            if (currentMode.Writer_Type == Writer_Type_Enum.HTML_Echo)
            {
                mainWriter = new Html_Echo_MainWriter(currentMode, browse_info_display_text);
            }

            // Default to HTML
            if (mainWriter == null)
            {
                SobekCM_Assistant assistant = new SobekCM_Assistant();
                htmlSkin = assistant.Get_HTML_Skin(currentMode, Global.Skins, true, tracer);

                mainWriter = new Html_MainWriter(currentMode, hierarchyObject, searchResultStatistics, pagedSearchResults, thisBrowseObject,
                                                 currentItem, currentPage, htmlSkin, currentUser, Global.Translation, Global.Codes,
                                                 Global.Item_List,
                                                 Global.Stats_Date_Range, Global.Search_History, Global.Icon_List, Global.Thematic_Headings, publicFolder,
                                                 Global.Collection_Aliases, Global.Skins, Global.Checked_List, Global.IP_Restrictions, Global.URL_Portals, siteMap, itemsInTitle, staticWebContent, tracer);
            }
        }
        private void Simple_Web_Content_Text_Block()
        {
            tracer.Add_Trace("SobekCM_Page_Globals.Simple_Web_Content_Text_Block", "Retrieiving Simple Web Content Object");

            SobekCM_Assistant assistant = new SobekCM_Assistant();
            if (!assistant.Get_Simple_Web_Content_Text(currentMode, SobekCM_Library_Settings.Base_Directory, tracer,
                                                       out staticWebContent, out siteMap))
            {
                currentMode.Mode = Display_Mode_Enum.Error;
                return;
            }

            // If the web skin is indicated in the browse file, set that
            if (staticWebContent.Web_Skin.Length > 0)
            {
                currentMode.Default_Skin = staticWebContent.Web_Skin;
                currentMode.Skin = staticWebContent.Web_Skin;
            }
        }
        private void Search_Block()
        {
            tracer.Add_Trace("SobekCM_Page_Globals.Search_Block", "Retreiving search results");

            try
            {
                // If there is no search term, forward back to the collection
                if ((currentMode.Search_String.Length == 0) && (currentMode.Coordinates.Length == 0))
                {
                    currentMode.Mode = Display_Mode_Enum.Aggregation;
                    currentMode.Aggregation_Type = Aggregation_Type_Enum.Home;
                    currentMode.Redirect();
                    return;
                }

                SobekCM_Assistant assistant = new SobekCM_Assistant();
                assistant.Get_Search_Results(currentMode, Global.Item_List, hierarchyObject, tracer, out searchResultStatistics, out pagedSearchResults);

                if ((!currentMode.isPostBack) && (Global.Search_History != null))
                {
                    Global.Search_History.Add_New_Search(currentMode, HttpContext.Current.Request.UserHostAddress, currentMode.Search_Type, hierarchyObject.Name, currentMode.Search_String);
                }
            }
            catch (Exception ee)
            {
                currentMode.Mode = Display_Mode_Enum.Error;
                currentMode.Error_Message = "Unable to perform search at this time ";
                if (hierarchyObject == null)
                    currentMode.Error_Message = "Unlable to perform search - hierarchyObject = null";
                currentMode.Caught_Exception = ee;
            }
        }
        private void Public_Folder()
        {
            tracer.Add_Trace("SobekCM_Page_Globals.Public_Folder", "Retrieving public folder information and browse");

            SobekCM_Assistant assistant = new SobekCM_Assistant();
            bool result = assistant.Get_Public_User_Folder(currentMode.FolderID, currentMode.Page, tracer, out publicFolder, out searchResultStatistics, out pagedSearchResults);

            if ((!result) || (!publicFolder.isPublic))
            {
                currentMode.Error_Message = "Invalid or private bookshelf";
                currentMode.Mode = Display_Mode_Enum.Error;
            }
        }
        public void Set_Main_Writer()
        {
            // If this is for HTML or HTML logged in, try to get the web skin object
            string current_skin_code = currentMode.Skin.ToUpper();
            if ((currentMode.Writer_Type == Writer_Type_Enum.HTML) || (currentMode.Writer_Type == Writer_Type_Enum.HTML_LoggedIn))
            {
                // Check if a different skin should be used if this is an item display
                if ((currentMode.Mode == Display_Mode_Enum.Item_Display) || (currentMode.Mode == Display_Mode_Enum.Item_Print))
                {
                    if ((currentItem != null) && (currentItem.Behaviors.Web_Skin_Count > 0))
                    {
                        if (!currentItem.Behaviors.Web_Skins.Contains(current_skin_code))
                        {
                            string new_skin_code = currentItem.Behaviors.Web_Skins[0];
                            current_skin_code = new_skin_code;
                        }
                    }
                }

                // Check if a differente skin should be used if this is a collection display
                if ((hierarchyObject != null) && ( hierarchyObject.Web_Skins != null ) && (hierarchyObject.Web_Skins.Count > 0))
                {
                    // Do NOT do this replacement if the web skin is in the URL and this is admin mode
                    if ((!currentMode.Skin_In_URL) || (currentMode.Mode != Display_Mode_Enum.Administrative))
                    {
                        if (!hierarchyObject.Web_Skins.Contains(current_skin_code.ToLower()))
                        {
                            current_skin_code = hierarchyObject.Web_Skins[0];
                        }
                    }
                }

                SobekCM_Assistant assistant = new SobekCM_Assistant();

                // Try to get the web skin from the cache or skin collection, otherwise build it
                htmlSkin = assistant.Get_HTML_Skin(current_skin_code, currentMode, UI_ApplicationCache_Gateway.Web_Skin_Collection, true, tracer);

                // If the skin was somehow overriden, default back to the default skin
                if (( htmlSkin == null ) && ( !String.IsNullOrEmpty(defaultSkin)))
                {
                    if (String.Compare(current_skin_code, defaultSkin, StringComparison.InvariantCultureIgnoreCase) != 0)
                    {
                        currentMode.Skin = defaultSkin;
                        htmlSkin = assistant.Get_HTML_Skin(defaultSkin, currentMode, UI_ApplicationCache_Gateway.Web_Skin_Collection, true, tracer);
                    }
                }

                // If there was no web skin returned, forward user to URL with no web skin.
                // This happens if the web skin code is invalid.  If a robot, just return a bad request
                // value though.
                if (htmlSkin == null)
                {

                        HttpContext.Current.Response.StatusCode = 404;
                        HttpContext.Current.Response.Output.WriteLine("404 - INVALID URL");
                        HttpContext.Current.Response.Output.WriteLine("Web skin indicated is invalid, default web skin invalid - line 1029");

                    HttpContext.Current.Response.Output.WriteLine(tracer.Text_Trace);
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                        currentMode.Request_Completed = true;

                    return;
                }
            }

            // Build the RequestCache object
            RequestCache RequestSpecificValues = new RequestCache(currentMode, hierarchyObject, searchResultStatistics, pagedSearchResults, thisBrowseObject, currentItem, currentPage, htmlSkin, currentUser, publicFolder, siteMap, itemsInTitle, staticWebContent, tracer);

            if ((currentMode.Writer_Type == Writer_Type_Enum.HTML) || (currentMode.Writer_Type == Writer_Type_Enum.HTML_LoggedIn))
            {
                mainWriter = new Html_MainWriter(RequestSpecificValues);
            }

            // Load the OAI writer
            if (currentMode.Writer_Type == Writer_Type_Enum.OAI)
            {
                mainWriter = new Oai_MainWriter(HttpContext.Current.Request.QueryString, RequestSpecificValues);
            }

            // Load the DataSet writer
            if (currentMode.Writer_Type == Writer_Type_Enum.DataSet)
            {
                mainWriter = new Dataset_MainWriter(RequestSpecificValues);
            }

            // Load the DataProvider writer
            if (currentMode.Writer_Type == Writer_Type_Enum.Data_Provider)
            {
                mainWriter = new DataProvider_MainWriter(RequestSpecificValues);
            }

            // Load the XML writer
            if (currentMode.Writer_Type == Writer_Type_Enum.XML)
            {
                mainWriter = new Xml_MainWriter(RequestSpecificValues);
            }

            // Load the JSON writer
            if (currentMode.Writer_Type == Writer_Type_Enum.JSON)
            {
                mainWriter = new Json_MainWriter(RequestSpecificValues, UI_ApplicationCache_Gateway.Settings.Servers.Image_URL);
            }

            // Load the HTML ECHO writer
            if (currentMode.Writer_Type == Writer_Type_Enum.HTML_Echo)
            {
                mainWriter = new Html_Echo_MainWriter(RequestSpecificValues, browse_info_display_text);
            }

            // Default to HTML
            if (mainWriter == null)
            {
                mainWriter = new Html_MainWriter(RequestSpecificValues);
            }
        }
        private void Simple_Web_Content_Text_Block()
        {
            tracer.Add_Trace("SobekCM_Page_Globals.Simple_Web_Content_Text_Block", "Retrieiving Simple Web Content Object");

            SobekCM_Assistant assistant = new SobekCM_Assistant();
            if (!assistant.Get_Simple_Web_Content_Text(currentMode, UI_ApplicationCache_Gateway.Settings.Servers.Base_Directory, tracer,
                                                       out staticWebContent, out siteMap))
            {
                currentMode.Mode = Display_Mode_Enum.Error;
                return;
            }

            // IF this is display mode and this is a redirect, do the redirect
            if ((currentMode.Mode == Display_Mode_Enum.Simple_HTML_CMS) && (currentMode.WebContent_Type == WebContent_Type_Enum.Display) && (staticWebContent != null) && (!String.IsNullOrEmpty(staticWebContent.Redirect)))
            {
                currentMode.Request_Completed = true;
                HttpContext.Current.Response.Redirect(staticWebContent.Redirect, false);
                HttpContext.Current.ApplicationInstance.CompleteRequest();
                return;
            }

            // If the web skin is indicated in the browse file, set that
            if ( !String.IsNullOrEmpty(staticWebContent.Web_Skin))
            {
                currentMode.Default_Skin = staticWebContent.Web_Skin;
                currentMode.Skin = staticWebContent.Web_Skin;
            }
        }
        private void Search_Block()
        {
            tracer.Add_Trace("SobekCM_Page_Globals.Search_Block", "Retreiving search results");

            try
            {
                // If there is no search term, forward back to the collection
                if (( String.IsNullOrEmpty(currentMode.Search_String)) && ( String.IsNullOrEmpty(currentMode.Coordinates)))
                {
                    currentMode.Mode = Display_Mode_Enum.Aggregation;
                    currentMode.Aggregation_Type = Aggregation_Type_Enum.Home;
                    UrlWriterHelper.Redirect(currentMode);
                    return;
                }

                SobekCM_Assistant assistant = new SobekCM_Assistant();
                assistant.Get_Search_Results(currentMode, UI_ApplicationCache_Gateway.Items, hierarchyObject, UI_ApplicationCache_Gateway.Search_Stop_Words, tracer, out searchResultStatistics, out pagedSearchResults);

                if ((!currentMode.isPostBack) && (UI_ApplicationCache_Gateway.Search_History != null))
                {
                    UI_ApplicationCache_Gateway.Search_History.Add_New_Search(Get_Search_From_Mode(currentMode, HttpContext.Current.Request.UserHostAddress, currentMode.Search_Type, hierarchyObject.Name, currentMode.Search_String ));
                }
            }
            catch (Exception ee)
            {
                currentMode.Mode = Display_Mode_Enum.Error;
                currentMode.Error_Message = "Unable to perform search at this time ";
                if (hierarchyObject == null)
                    currentMode.Error_Message = "Unlable to perform search - hierarchyObject = null";
                currentMode.Caught_Exception = ee;
            }
        }
        /// <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 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>
        /// <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 )
        {
            primaryWebServerUrl = Primary_Web_Server_URL;
            staticSobekcmDataLocation = Static_Data_Location;

            tracer = new Custom_Tracer();
            assistant = new SobekCM_Assistant();

               // marcWriter = new MARC_Writer();

            // Get the list of all items
            SobekCM_Database.Connection_String = SobekCM_Library_Settings.Database_Connection_String; ;

            // Build all the objects needed by the UFDC 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);

            // Get the item list and build the hashtable
               //     DataSet tempSet = SobekCM.Library.Database.SobekCM_Database.Get_Item_List(false, tracer);
            itemList = new Item_Lookup_Object();
            SobekCM_Database.Populate_Item_Lookup_Object(false, itemList, tracer);

            // 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 = "UFDC",
                                  Mode = Display_Mode_Enum.Item_Display,
                                  Language = Web_Language_Enum.English,
                                  Base_URL = primaryWebServerUrl
                              };

            // Create the ufdc interface object
            ufdcInterface = new SobekCM_Skin_Object("ufdc", String.Empty, currentMode.Base_Design_URL + "skins/ufdc/ufdc.css")
                                {
                                    Header_Item_HTML =GetHtmlPage(primaryWebServerUrl + "/design/skins/UFDC/html/header_item.html").Replace("<%BREADCRUMBS%>","<a href=\"" + primaryWebServerUrl + "\">UFDC Home</a>").Replace("<%MYSOBEK%>","<a href=\"" + primaryWebServerUrl + "my\">myUFDC Home</a>"),
                                    Footer_Item_HTML = GetHtmlPage(primaryWebServerUrl + "/design/skins/UFDC/html/footer_item.html").Replace("<%VERSION%>", SobekCM_Library_Settings.CURRENT_WEB_VERSION).Replace("src=\"" + currentMode.Base_URL + "design/", "src=\"" + primaryWebServerUrl + "/design/"),
                                    Header_HTML = GetHtmlPage(primaryWebServerUrl + "/design/skins/UFDC/html/header.html").Replace("<%BREADCRUMBS%>", "<a href=\"" + primaryWebServerUrl + "\">UFDC Home</a>").Replace("<%MYSOBEK%>","<a href=\"" + primaryWebServerUrl + "my\">myUFDC Home</a>"),
                                    Footer_HTML = GetHtmlPage(primaryWebServerUrl + "/design/skins/UFDC/html/footer.html").Replace("<%VERSION%>", SobekCM_Library_Settings.CURRENT_WEB_VERSION).Replace("src=\"" + currentMode.Base_URL + "design/", "src=\"" + primaryWebServerUrl + "/design/"),
                                    Language_Code = "",
                                    Override_Banner = false
                                };

            // Create the dLOC_English interface
            dlocInterface = new SobekCM_Skin_Object("dloc", String.Empty, currentMode.Base_Design_URL + "skins/dloc/dloc.css", "<img id=\"mainBanner\" src=\"" + currentMode.Base_URL + "design/skins/dloc/banner.jpg\" alt=\"MISSING BANNER\" />")
                                {
                                    Header_Item_HTML = GetHtmlPage(primaryWebServerUrl + "/design/skins/dloc/html/header_item.html").Replace("<%BREADCRUMBS%>", "<a href=\"" + primaryWebServerUrl + "\">UFDC Home</a>").Replace("<%MYSOBEK%>", "<a href=\"" + primaryWebServerUrl + "my\">myUFDC Home</a>"),
                                    Footer_Item_HTML = GetHtmlPage(primaryWebServerUrl + "/design/skins/dloc/html/footer_item.html").Replace("<%VERSION%>", SobekCM_Library_Settings.CURRENT_WEB_VERSION).Replace("src=\"" + currentMode.Base_URL + "design/", "src=\"" + primaryWebServerUrl + "/design/"),
                                    Header_HTML = GetHtmlPage(primaryWebServerUrl + "/design/skins/dloc/html/header.html").Replace("<%BREADCRUMBS%>", "<a href=\"" + primaryWebServerUrl + "\">UFDC Home</a>").Replace("<%MYSOBEK%>", "<a href=\"" + primaryWebServerUrl + "my\">myUFDC Home</a>"),
                                    Footer_HTML = GetHtmlPage(primaryWebServerUrl + "/design/skins/dloc/html/footer.html").Replace("<%VERSION%>", SobekCM_Library_Settings.CURRENT_WEB_VERSION).Replace("src=\"" + currentMode.Base_URL + "design/", "src=\"" + primaryWebServerUrl + "/design/"),
                                    Language_Code = "",
                                    Override_Banner = false
                                };

            // Disable the cached data manager
            Cached_Data_Manager.Disabled = true;
        }