public Get_Banner_Image ( |
||
ThisWebSkin | Web skin object, which may override the banner from this aggregation | |
Résultat | string |
/// <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="Web_Page_Title"> Web page title to add behind the banner image </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, string Web_Page_Title, Navigation_Object CurrentMode, Web_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.HasValue) && (HTML_Skin.Override_Banner.Value)) { if ( !String.IsNullOrEmpty(HTML_Skin.Banner_HTML)) Output.WriteLine(HTML_Skin.Banner_HTML); } else { string url_options = UrlWriterHelper.URL_Options(CurrentMode); if (url_options.Length > 0) url_options = "?" + url_options; if ((Hierarchy_Object != null) && (Hierarchy_Object.Code != "all")) { Output.WriteLine("<section id=\"sbkAhs_BannerDiv\" role=\"banner\" title=\"" + Hierarchy_Object.ShortName + "\">"); Output.WriteLine(" <h1 class=\"hidden-element\">" + Web_Page_Title + "</h1>"); Output.WriteLine(" <a alt=\"" + Hierarchy_Object.ShortName + "\" href=\"" + CurrentMode.Base_URL + Hierarchy_Object.Code + url_options + "\"><img id=\"mainBanner\" src=\"" + CurrentMode.Base_URL + Hierarchy_Object.Get_Banner_Image(HTML_Skin) + "\" alt=\"" + Hierarchy_Object.ShortName + "\" /></a>"); Output.WriteLine("</section>"); } else { if ((Hierarchy_Object != null) && (Hierarchy_Object.Get_Banner_Image(HTML_Skin).Length > 0)) { Output.WriteLine("<section id=\"sbkAhs_BannerDiv\" role=\"banner\" title=\"" + Hierarchy_Object.ShortName + "\">"); Output.WriteLine(" <h1 class=\"hidden-element\">" + Web_Page_Title + "</h1>"); Output.WriteLine(" <a alt=\"" + Hierarchy_Object.ShortName + "\" href=\"" + CurrentMode.Base_URL + url_options + "\"><img id=\"mainBanner\" src=\"" + CurrentMode.Base_URL + Hierarchy_Object.Get_Banner_Image(HTML_Skin) + "\" alt=\"" + Hierarchy_Object.ShortName + "\" /></a>"); Output.WriteLine("</section>"); } else { string skin_url = CurrentMode.Base_Design_URL + "skins/" + CurrentMode.Skin + "/"; Output.WriteLine("<section id=\"sbkAhs_BannerDiv\" role=\"banner\"><h1 class=\"hidden-element\">" + Web_Page_Title + "</h1><a href=\"" + CurrentMode.Base_URL + url_options + "\"><img id=\"mainBanner\" src=\"" + skin_url + "default.jpg\" alt=\"\" /></a></section>"); } } } Output.WriteLine(); }
/// <summary> Add the header to the output </summary> /// <param name="Output"> Stream to which to write the HTML for this header </param> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <param name="Container_CssClass"> Class name for the container around the page </param> /// <param name="Web_Page_Title"> Title for this web page, to include behind the banner possibly </param> /// <param name="Behaviors"> List of behaviors from the html subwriters </param> /// <param name="Current_Aggregation"> Current aggregation object, if there is one </param> /// <param name="Current_Item"> Current item object, if there is one </param> public static void Add_Header(TextWriter Output, RequestCache RequestSpecificValues, string Container_CssClass, string Web_Page_Title, List<HtmlSubwriter_Behaviors_Enum> Behaviors, Item_Aggregation Current_Aggregation, BriefItemInfo Current_Item ) { // Get the url options string url_options = UrlWriterHelper.URL_Options(RequestSpecificValues.Current_Mode); string modified_url_options = String.Empty; if (url_options.Length > 0) modified_url_options = "?" + url_options; // Get the current contact URL Display_Mode_Enum thisMode = RequestSpecificValues.Current_Mode.Mode; RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Contact; string contact = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); // Restore the old mode RequestSpecificValues.Current_Mode.Mode = thisMode; // Determine which header and footer to display bool useItemHeader = (RequestSpecificValues.Current_Mode.Mode == Display_Mode_Enum.Item_Display) || (RequestSpecificValues.Current_Mode.Mode == Display_Mode_Enum.Item_Print) || ((Behaviors != null) && (Behaviors.Contains(HtmlSubwriter_Behaviors_Enum.MySobek_Subwriter_Mimic_Item_Subwriter))); // Create the breadcrumbs text string breadcrumbs = " "; if (useItemHeader) { StringBuilder breadcrumb_builder = new StringBuilder("<a href=\"" + RequestSpecificValues.Current_Mode.Base_URL + modified_url_options + "\">" + RequestSpecificValues.Current_Mode.Instance_Abbreviation + " Home</a>"); int codes_added = 0; if ((RequestSpecificValues.Current_Mode.Aggregation.Length > 0) && (RequestSpecificValues.Current_Mode.Aggregation != "all")) { breadcrumb_builder.Append(" | <a href=\"" + RequestSpecificValues.Current_Mode.Base_URL + RequestSpecificValues.Current_Mode.Aggregation + modified_url_options + "\">" + UI_ApplicationCache_Gateway.Aggregations.Get_Collection_Short_Name(RequestSpecificValues.Current_Mode.Aggregation) + "</a>"); codes_added++; } if (Current_Item != null) { if (( Current_Item.Behaviors.Aggregation_Code_List != null ) && ( Current_Item.Behaviors.Aggregation_Code_List.Count > 0)) { foreach (string aggrCode in Current_Item.Behaviors.Aggregation_Code_List) { if (aggrCode.ToLower() != RequestSpecificValues.Current_Mode.Aggregation) { if (( String.Compare(aggrCode,Current_Item.Behaviors.Source_Institution_Aggregation, StringComparison.OrdinalIgnoreCase ) != 0 ) && ( String.Compare(aggrCode, "i" + Current_Item.Behaviors.Source_Institution_Aggregation, StringComparison.OrdinalIgnoreCase) != 0) && ( String.Compare(aggrCode, Current_Item.Behaviors.Holding_Location_Aggregation, StringComparison.OrdinalIgnoreCase) != 0) && (String.Compare(aggrCode, "i" + Current_Item.Behaviors.Holding_Location_Aggregation, StringComparison.OrdinalIgnoreCase) != 0)) { Item_Aggregation_Related_Aggregations thisAggr = UI_ApplicationCache_Gateway.Aggregations[aggrCode]; if ((thisAggr != null) && (thisAggr.Active)) { breadcrumb_builder.Append(" | <a href=\"" + RequestSpecificValues.Current_Mode.Base_URL + aggrCode.ToLower() + modified_url_options + "\">" + thisAggr.ShortName + "</a>"); codes_added++; } } } if (codes_added == 5) break; } } if (codes_added < 5) { if ( !String.IsNullOrEmpty(Current_Item.Behaviors.Source_Institution_Aggregation)) { // Add source code string source_code = Current_Item.Behaviors.Source_Institution_Aggregation; if ((source_code[0] != 'i') && (source_code[0] != 'I')) source_code = "I" + source_code; Item_Aggregation_Related_Aggregations thisSourceAggr = UI_ApplicationCache_Gateway.Aggregations[source_code]; if ((thisSourceAggr != null) && (!thisSourceAggr.Hidden) && (thisSourceAggr.Active)) { string source_name = thisSourceAggr.ShortName; if (source_name.ToUpper() != "ADDED AUTOMATICALLY") { breadcrumb_builder.Append(" | <a href=\"" + RequestSpecificValues.Current_Mode.Base_URL + source_code.ToLower() + modified_url_options + "\">" + source_name + "</a>"); } } // Add the holding code if (( !String.IsNullOrEmpty(Current_Item.Behaviors.Holding_Location_Aggregation)) && (String.Compare(Current_Item.Behaviors.Source_Institution_Aggregation, Current_Item.Behaviors.Source_Institution_Aggregation, StringComparison.OrdinalIgnoreCase) != 0 )) { // Add holding code string holding_code = Current_Item.Behaviors.Holding_Location_Aggregation; if ((holding_code[0] != 'i') && (holding_code[0] != 'I')) holding_code = "I" + holding_code; Item_Aggregation_Related_Aggregations thisAggr = UI_ApplicationCache_Gateway.Aggregations[holding_code]; if ((thisAggr != null) && (!thisAggr.Hidden) && (thisAggr.Active)) { string holding_name = thisAggr.ShortName; if (holding_name.ToUpper() != "ADDED AUTOMATICALLY") { breadcrumb_builder.Append(" | <a href=\"" + RequestSpecificValues.Current_Mode.Base_URL + holding_code.ToLower() + modified_url_options + "\">" + holding_name + "</a>"); } } } } else { if (!String.IsNullOrEmpty(Current_Item.Behaviors.Holding_Location_Aggregation)) { // Add holding code string holding_code = Current_Item.Behaviors.Holding_Location_Aggregation; if ((holding_code[0] != 'i') && (holding_code[0] != 'I')) holding_code = "I" + holding_code; string holding_name = UI_ApplicationCache_Gateway.Aggregations.Get_Collection_Short_Name(holding_code); if (holding_name.ToUpper() != "ADDED AUTOMATICALLY") { breadcrumb_builder.Append(" | <a href=\"" + RequestSpecificValues.Current_Mode.Base_URL + holding_code.ToLower() + modified_url_options + "\">" + holding_name + "</a>"); } } } } } breadcrumbs = breadcrumb_builder.ToString(); } else { switch (RequestSpecificValues.Current_Mode.Mode) { case Display_Mode_Enum.Error: breadcrumbs = "<a href=\"" + RequestSpecificValues.Current_Mode.Base_URL + modified_url_options + "\">" + RequestSpecificValues.Current_Mode.Instance_Abbreviation + " Home</a>"; break; case Display_Mode_Enum.Aggregation: if ((RequestSpecificValues.Current_Mode.Aggregation_Type == Aggregation_Type_Enum.Home) || (RequestSpecificValues.Current_Mode.Aggregation_Type == Aggregation_Type_Enum.Home_Edit)) { if ((RequestSpecificValues.Current_Mode.Aggregation.Length > 0) && (RequestSpecificValues.Current_Mode.Aggregation != "all")) { breadcrumbs = "<a href=\"" + RequestSpecificValues.Current_Mode.Base_URL + modified_url_options + "\">" + RequestSpecificValues.Current_Mode.Instance_Abbreviation + " Home</a>"; } } else { breadcrumbs = "<a href=\"" + RequestSpecificValues.Current_Mode.Base_URL + modified_url_options + "\">" + RequestSpecificValues.Current_Mode.Instance_Abbreviation + " Home</a>"; if ((RequestSpecificValues.Current_Mode.Aggregation.Length > 0) && (RequestSpecificValues.Current_Mode.Aggregation != "all")) { breadcrumbs = breadcrumbs + " | <a href=\"" + RequestSpecificValues.Current_Mode.Base_URL + RequestSpecificValues.Current_Mode.Aggregation + modified_url_options + "\">" + UI_ApplicationCache_Gateway.Aggregations.Get_Collection_Short_Name(RequestSpecificValues.Current_Mode.Aggregation) + "</a>"; } } break; default: breadcrumbs = "<a href=\"" + RequestSpecificValues.Current_Mode.Base_URL + modified_url_options + "\">" + RequestSpecificValues.Current_Mode.Instance_Abbreviation + " Home</a>"; if ((RequestSpecificValues.Current_Mode.Aggregation.Length > 0) && (RequestSpecificValues.Current_Mode.Aggregation != "all")) { breadcrumbs = breadcrumbs + " | <a href=\"" + RequestSpecificValues.Current_Mode.Base_URL + RequestSpecificValues.Current_Mode.Aggregation + modified_url_options + "\">" + UI_ApplicationCache_Gateway.Aggregations.Get_Collection_Short_Name(RequestSpecificValues.Current_Mode.Aggregation) + "</a>"; } break; } } // Create the mySobek text string mySobekLinks = create_mysobek_link(RequestSpecificValues, url_options, null); // Look for some basic mode data string collection_code = String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.Aggregation) ? String.Empty : RequestSpecificValues.Current_Mode.Aggregation; string bibid = String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.BibID) ? String.Empty : RequestSpecificValues.Current_Mode.BibID; string vid = String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.BibID) ? String.Empty : RequestSpecificValues.Current_Mode.BibID; string mode = String.Empty; switch (RequestSpecificValues.Current_Mode.Mode) { case Display_Mode_Enum.Item_Display: mode = "item"; break; case Display_Mode_Enum.Aggregation: case Display_Mode_Enum.Search: mode = "aggregation"; break; case Display_Mode_Enum.Results: mode = "results"; break; } // Get the language selections Web_Language_Enum language = RequestSpecificValues.Current_Mode.Language; RequestSpecificValues.Current_Mode.Language = Web_Language_Enum.TEMPLATE; string template_language = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); string english = template_language.Replace("l=XXXXX", "l=en"); string french = template_language.Replace("l=XXXXX", "l=fr"); string spanish = template_language.Replace("l=XXXXX", "l=es"); RequestSpecificValues.Current_Mode.Language = language; if (RequestSpecificValues.Current_Mode.Is_Robot) { english = String.Empty; french = String.Empty; spanish = String.Empty; } // Determine which container to use, depending on the current mode string container_inner = Container_CssClass; // Get the skin url string skin_url = RequestSpecificValues.Current_Mode.Base_Design_URL + "skins/" + RequestSpecificValues.Current_Mode.Skin + "/"; // Determine the URL options for replacement string urlOptions1 = String.Empty; string urlOptions2 = String.Empty; if (url_options.Length > 0) { urlOptions1 = "?" + url_options; urlOptions2 = "&" + url_options; } // Determine the possible banner to display string banner = String.Empty; if (( Behaviors != null ) && ( !Behaviors.Contains(HtmlSubwriter_Behaviors_Enum.Suppress_Banner))) { if ((RequestSpecificValues.HTML_Skin != null) && (RequestSpecificValues.HTML_Skin.Override_Banner.HasValue) && (RequestSpecificValues.HTML_Skin.Override_Banner.Value)) { banner = !String.IsNullOrEmpty(RequestSpecificValues.HTML_Skin.Banner_HTML) ? RequestSpecificValues.HTML_Skin.Banner_HTML : String.Empty; } else { if (Current_Aggregation!= null) { string banner_image = Current_Aggregation.Get_Banner_Image( RequestSpecificValues.HTML_Skin); if (Current_Aggregation.Code != "all") { if (banner_image.Length > 0) banner = "<section id=\"sbkHmw_BannerDiv\" role=\"banner\" title=\"" + Current_Aggregation.ShortName + "\"><h1 class=\"hidden-element\">" + Web_Page_Title + "</h1><a alt=\"" + Current_Aggregation.ShortName + "\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + Current_Aggregation.Code + urlOptions1 + "\"><img id=\"mainBanner\" src=\"" + RequestSpecificValues.Current_Mode.Base_URL + banner_image + "\" alt=\"" + Current_Aggregation.ShortName + "\" /></a></section>"; } else { if (banner_image.Length > 0) { banner = "<section id=\"sbkHmw_BannerDiv\" role=\"banner\" title=\"" + Current_Aggregation.ShortName + "\"><h1 class=\"hidden-element\">" + Web_Page_Title + "</h1><a alt=\"" + Current_Aggregation.ShortName + "\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + urlOptions1 + "\"><img id=\"mainBanner\" src=\"" + RequestSpecificValues.Current_Mode.Base_URL + banner_image + "\" alt=\"" + Current_Aggregation.ShortName + "\" /></a></section>"; } else { banner = "<section id=\"sbkHmw_BannerDiv\" role=\"banner\" title=\"" + Current_Aggregation.ShortName + "\"><h1 class=\"hidden-element\">" + Web_Page_Title + "</h1><a alt=\"" + Current_Aggregation.ShortName + "\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + urlOptions1 + "\"><img id=\"mainBanner\" src=\"" + skin_url + "default.jpg\" alt=\"" + Current_Aggregation.ShortName + "\" /></a></section>"; } } } } } // Get the session id and user id string sessionId = HttpContext.Current.Session.SessionID ?? String.Empty; string userid = ((RequestSpecificValues.Current_User != null) && (RequestSpecificValues.Current_User.UserID > 0)) ? RequestSpecificValues.Current_User.UserID.ToString() : String.Empty; // Add the appropriate header StringBuilder headerBuilder = new StringBuilder(); try { if (useItemHeader) { headerBuilder.Append(RequestSpecificValues.HTML_Skin.Header_Item_HTML); } else { headerBuilder.Append(RequestSpecificValues.HTML_Skin.Header_HTML); if ((!String.IsNullOrEmpty(container_inner)) && ((!RequestSpecificValues.HTML_Skin.Header_Has_Container_Directive.HasValue) || (!RequestSpecificValues.HTML_Skin.Header_Has_Container_Directive.Value))) headerBuilder.Insert(0, "<div id=\"" + container_inner + "\">" + Environment.NewLine); } // Do all the replacements headerBuilder.Replace("<%COLLCODE%>", collection_code); headerBuilder.Replace("<%BIBID%>", bibid); headerBuilder.Replace("<%VID%>", vid); headerBuilder.Replace("<%MODE%>", mode); // headerBuilder.Replace("<%COLLNAME%>", collection_name); headerBuilder.Replace("<%CONTACT%>", contact); headerBuilder.Replace("<%URLOPTS%>", url_options); headerBuilder.Replace("<%?URLOPTS%>", urlOptions1); headerBuilder.Replace("<%&URLOPTS%>", urlOptions2); headerBuilder.Replace("<%BREADCRUMBS%>", breadcrumbs); headerBuilder.Replace("<%MYSOBEK%>", mySobekLinks); headerBuilder.Replace("<%ENGLISH%>", english); headerBuilder.Replace("<%FRENCH%>", french); headerBuilder.Replace("<%SPANISH%>", spanish); headerBuilder.Replace("<%BASEURL%>", RequestSpecificValues.Current_Mode.Base_URL); headerBuilder.Replace("\"container-inner\"", "\"" + container_inner + "\""); headerBuilder.Replace("<%BANNER%>", banner); headerBuilder.Replace("<%SKINURL%>", skin_url); if (( !useItemHeader) && ( !String.IsNullOrEmpty(container_inner)) && (RequestSpecificValues.HTML_Skin.Header_Has_Container_Directive.HasValue) && (RequestSpecificValues.HTML_Skin.Header_Has_Container_Directive.Value)) headerBuilder.Replace("<%CONTAINER%>", "<div id=\"" + container_inner + "\">"); else headerBuilder.Replace("<%CONTAINER%>", String.Empty); headerBuilder.Replace("<%INSTANCENAME%>", RequestSpecificValues.Current_Mode.Instance_Name); headerBuilder.Replace("<%SESSIONID%>", sessionId); headerBuilder.Replace("<%USERID%>", userid); } catch (Exception ee) { RequestSpecificValues.Tracer.Add_Trace("HeaderFooter_Helper_HtmlSubWriter.Add_Header", "EXCEPTION CAUGHT while trying to write the header."); if (RequestSpecificValues.HTML_Skin == null) RequestSpecificValues.Tracer.Add_Trace("HeaderFooter_Helper_HtmlSubWriter.Add_Header", "HTML Skin was NULL"); else if (RequestSpecificValues.HTML_Skin.Header_Item_HTML == null) RequestSpecificValues.Tracer.Add_Trace("HeaderFooter_Helper_HtmlSubWriter.Add_Header", "HTML Skin was not NULL, but Header_Item_HTML property was NULL"); } // Write the header Output.WriteLine(headerBuilder.ToString()); }