/// <summary> Gets the simple CMS/info object and text to display </summary> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Base_Directory"> Base directory location under which the the CMS/info source file will be found</param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <param name="Simple_Web_Content"> [OUT] Built browse object which contains information like title, banner, etc.. and the entire text to be displayed </param> /// <param name="Site_Map"> [OUT] Optional navigational site map object related to this page </param> /// <returns>TRUE if successful, otherwise FALSE </returns> /// <remarks> This always pulls the data directly from disk; this text is not cached. </remarks> public bool Get_Simple_Web_Content_Text(SobekCM_Navigation_Object Current_Mode, string Base_Directory, Custom_Tracer Tracer, out HTML_Based_Content Simple_Web_Content, out SobekCM_SiteMap Site_Map ) { if (Tracer != null) { Tracer.Add_Trace("SobekCM_Assistant.Get_Simple_Web_Content_Text", String.Empty); } Site_Map = null; string source = Current_Mode.Page_By_FileName; Simple_Web_Content = HTML_Based_Content_Reader.Read_HTML_File(source, true, Tracer); if (Simple_Web_Content == null) { Current_Mode.Error_Message = "Unable to retrieve simple text item '" + Current_Mode.Info_Browse_Mode.Replace("_","\\") + "'"; return false; } if ( Simple_Web_Content.Static_Text.Length == 0 ) { Current_Mode.Error_Message = "Unable to read the file for display"; return false; } // Now, check for any "server-side include" directorives in the source text int include_index = Simple_Web_Content.Static_Text.IndexOf("<%INCLUDE"); while(( include_index > 0 ) && ( Simple_Web_Content.Static_Text.IndexOf("%>", include_index ) > 0 )) { int include_finish_index = Simple_Web_Content.Static_Text.IndexOf("%>", include_index) + 2; string include_statement = Simple_Web_Content.Static_Text.Substring(include_index, include_finish_index - include_index); string include_statement_upper = include_statement.ToUpper(); int file_index = include_statement_upper.IndexOf("FILE"); string filename_to_include = String.Empty; if (file_index > 0) { // Pull out the possible file name string possible_file_name = include_statement.Substring(file_index + 4); int file_start = -1; int file_end = -1; int char_index = 0; // Find the start of the file information while ((file_start < 0) && (char_index < possible_file_name.Length)) { if ((possible_file_name[char_index] != '"') && (possible_file_name[char_index] != '=') && (possible_file_name[char_index] != ' ')) { file_start = char_index; } else { char_index++; } } // Find the end of the file information if (file_start >= 0) { char_index++; while ((file_end < 0) && (char_index < possible_file_name.Length)) { if ((possible_file_name[char_index] == '"') || (possible_file_name[char_index] == ' ') || (possible_file_name[char_index] == '%')) { file_end = char_index; } else { char_index++; } } } // Get the filename if ((file_start > 0) && (file_end > 0)) { filename_to_include = possible_file_name.Substring(file_start, file_end - file_start); } } // Remove the include and either place in the text from the indicated file, // or just remove if ((filename_to_include.Length > 0 ) && (File.Exists(SobekCM_Library_Settings.Base_Directory + "design\\webcontent\\" + filename_to_include))) { // Define the value for the include text string include_text; // Look in the cache for this object returnValue = HttpContext.Current.Cache.Get("INCLUDE_" + filename_to_include ); if (returnValue != null) { include_text = returnValue.ToString(); } else { try { // Pull from the file StreamReader reader = new StreamReader(SobekCM_Library_Settings.Base_Directory + "design\\webcontent\\" + filename_to_include); include_text = reader.ReadToEnd(); reader.Close(); // Store on the cache for two minutes, if no indication not to if ( include_statement_upper.IndexOf("NOCACHE") < 0 ) HttpContext.Current.Cache.Insert("INCLUDE_" + filename_to_include, include_text, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(2)); } catch(Exception) { include_text = "Unable to read the soruce file ( " + filename_to_include + " )"; } } // Replace the text with the include file Simple_Web_Content.Static_Text = Simple_Web_Content.Static_Text.Replace(include_statement, include_text); include_index = Simple_Web_Content.Static_Text.IndexOf("<%INCLUDE", include_index + include_text.Length - 1 ); } else { // No suitable name was found, or it doesn't exist so just remove the INCLUDE completely Simple_Web_Content.Static_Text = Simple_Web_Content.Static_Text.Replace(include_statement, ""); include_index = Simple_Web_Content.Static_Text.IndexOf("<%INCLUDE", include_index ); } } // Look for a site map if (Simple_Web_Content.SiteMap.Length > 0) { // Look in the cache first Site_Map = Cached_Data_Manager.Retrieve_Site_Map(Simple_Web_Content.SiteMap, Tracer); // If this was NULL, pull it if (Site_Map == null) { // Only continue if the file exists if (File.Exists(SobekCM_Library_Settings.Base_Directory + "design\\webcontent\\" + Simple_Web_Content.SiteMap)) { if (Tracer != null) { Tracer.Add_Trace("SobekCM_Assistant.Get_Simple_Web_Content_Text", "Reading site map file"); } // Try to read this sitemap file Site_Map = SobekCM_SiteMap_Reader.Read_SiteMap_File(SobekCM_Library_Settings.Base_Directory + "design\\webcontent\\" + Simple_Web_Content.SiteMap); // If the sitemap file was succesfully read, cache it if (Site_Map != null) { Cached_Data_Manager.Store_Site_Map(Site_Map, Simple_Web_Content.SiteMap, Tracer); } } } } // Since this is not cached, we can apply the individual user settings to the static text which was read right here Simple_Web_Content.Static_Text = Simple_Web_Content.Apply_Settings_To_Static_Text(Simple_Web_Content.Static_Text, null, Current_Mode.Skin, Current_Mode.Base_Skin, Current_Mode.Base_URL, Current_Mode.URL_Options(), Tracer); return true; }
/// <summary> Adds the banner to the response stream from either the html web skin /// or from the current item aggreagtion object, depending on flags in the web skin object </summary> /// <param name="Output"> Stream to which to write the HTML for the banner </param> /// <param name="Banner_Division_Name"> Name for the wrapper division around the banner </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="CurrentMode"> Mode / navigation information for the current request</param> /// <remarks> This is called by several html subwriters that otherwise tell this class to suppress writing the banner </remarks> public static void Add_Banner(TextWriter Output, string Banner_Division_Name, SobekCM_Navigation_Object CurrentMode, SobekCM_Skin_Object HTML_Skin, Item_Aggregation Hierarchy_Object) { Output.WriteLine("<!-- Write the main collection, interface, or institution banner -->"); if ((HTML_Skin != null) && (HTML_Skin.Override_Banner)) { Output.WriteLine(HTML_Skin.Banner_HTML); } else { string url_options = CurrentMode.URL_Options(); if (url_options.Length > 0) url_options = "?" + url_options; if ((Hierarchy_Object != null) && (Hierarchy_Object.Code != "all")) { Output.WriteLine("<div id=\"sbkAhs_BannerDiv\"><a alt=\"" + Hierarchy_Object.ShortName + "\" href=\"" + CurrentMode.Base_URL + Hierarchy_Object.Code + url_options + "\"><img id=\"mainBanner\" src=\"" + CurrentMode.Base_URL + Hierarchy_Object.Banner_Image(CurrentMode.Language, HTML_Skin) + "\" alt=\"\" /></a></div>"); } else { if ((Hierarchy_Object != null) && (Hierarchy_Object.Banner_Image(CurrentMode.Language, HTML_Skin).Length > 0)) { Output.WriteLine("<div id=\"sbkAhs_BannerDiv\"><a href=\"" + CurrentMode.Base_URL + url_options + "\"><img id=\"mainBanner\" src=\"" + CurrentMode.Base_URL + Hierarchy_Object.Banner_Image(CurrentMode.Language, HTML_Skin) + "\" alt=\"\" /></a></div>"); } else { string skin_url = CurrentMode.Base_Design_URL + "skins/" + CurrentMode.Skin + "/"; Output.WriteLine("<div id=\"sbkAhs_BannerDiv\"><a href=\"" + CurrentMode.Base_URL + url_options + "\"><img id=\"mainBanner\" src=\"" + skin_url + "default.jpg\" alt=\"\" /></a></div>"); } } } Output.WriteLine(); }