private void Highlight_Writer_Helper(TextWriter Output, int HighlightCounter, Complete_Item_Aggregation_Highlights Highlight, int Max_Text, int Max_Tooltips) { // Add the image line Output.WriteLine("<tr><td> <label for=\"admin_aggr_image_" + HighlightCounter + "\">Image:</label></td><td colspan=\"2\"><input class=\"admin_aggr_large_input\" name=\"admin_aggr_image_" + HighlightCounter + "\" id=\"admin_aggr_image_" + HighlightCounter + "\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(Highlight.Image) + "\" onfocus=\"javascript:textbox_enter('admin_aggr_image_" + HighlightCounter + "', 'admin_aggr_large_input_focused')\" onblur=\"javascript:textbox_leave('admin_aggr_image_" + HighlightCounter + "', 'admin_aggr_large_input')\" /></td></tr>"); // Add the link line Output.WriteLine("<tr><td> <label for=\"admin_aggr_link_" + HighlightCounter + "\">Link:</label></td><td colspan=\"2\"><input class=\"admin_aggr_large_input\" name=\"admin_aggr_link_" + HighlightCounter + "\" id=\"admin_aggr_image_" + HighlightCounter + "\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(Highlight.Link) + "\" onfocus=\"javascript:textbox_enter('admin_aggr_image_" + HighlightCounter + "', 'admin_aggr_large_input_focused')\" onblur=\"javascript:textbox_leave('admin_aggr_link_" + HighlightCounter + "', 'admin_aggr_large_input')\" /></td></tr>"); // Add lines for the text Output.Write(Max_Text == 1 ? "<tr><td> Text:</td><td>" : "<tr valign=\"top\"><td><br /> Text:</td><td>"); for (int j = 0; j < Max_Text; j++) { Web_Language_Enum language = UI_ApplicationCache_Gateway.Settings.System.Default_UI_Language; string text = String.Empty; if (j < Highlight.Text_Dictionary.Count) { language = Highlight.Text_Dictionary.Keys.ElementAt(j); text = Highlight.Text_Dictionary[language]; } // Start the select box string id = "admin_aggr_text_lang_" + HighlightCounter + "_" + (j + 1).ToString(); string id2 = "admin_aggr_text_" + HighlightCounter + "_" + (j + 1).ToString(); Output.Write("<select class=\"admin_aggr_select2\" name=\"" + id + "\" id=\"" + id + "\">"); // Add each language in the combo box foreach (string possible_language in Web_Language_Enum_Converter.Language_Name_Array) { if (language == Web_Language_Enum_Converter.Code_To_Enum(possible_language)) { Output.Write("<option value=\"" + possible_language + "\" selected=\"selected\" >" + HttpUtility.HtmlEncode(possible_language) + "</option>"); } else { Output.Write("<option value=\"" + possible_language + "\">" + HttpUtility.HtmlEncode(possible_language) + "</option>"); } } Output.WriteLine("</select> "); // Add the text to the text box Output.Write("<input class=\"admin_aggr_medium_input\" name=\"" + id2 + "\" id=\"" + id2 + "\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(text) + "\" onfocus=\"javascript:textbox_enter('" + id2 + "', 'admin_aggr_medium_input_focused')\" onblur=\"javascript:textbox_leave('" + id2 + "', 'admin_aggr_medium_input')\" /><br />"); } Output.WriteLine("</td></tr>"); // Add lines for the tooltips Output.Write(Max_Tooltips == 1 ? "<tr><td> Tooltip:</td><td>" : "<tr valign=\"top\"><td><br /> Tooltip:</td><td>"); for (int j = 0; j < Max_Tooltips; j++) { Web_Language_Enum language = UI_ApplicationCache_Gateway.Settings.System.Default_UI_Language; string text = String.Empty; if (j < Highlight.Tooltip_Dictionary.Count) { language = Highlight.Tooltip_Dictionary.Keys.ElementAt(j); text = Highlight.Tooltip_Dictionary[language]; } // Start the select box string id = "admin_aggr_tooltip_lang_" + HighlightCounter + "_" + (j + 1).ToString(); string id2 = "admin_aggr_tooltip_" + HighlightCounter + "_" + (j + 1).ToString(); Output.Write("<select class=\"admin_aggr_select2\" name=\"" + id + "\" id=\"" + id + "\">"); // Add each language in the combo box foreach (string possible_language in Web_Language_Enum_Converter.Language_Name_Array) { if (language == Web_Language_Enum_Converter.Code_To_Enum(possible_language)) { Output.Write("<option value=\"" + possible_language + "\" selected=\"selected\" >" + HttpUtility.HtmlEncode(possible_language) + "</option>"); } else { Output.Write("<option value=\"" + possible_language + "\">" + HttpUtility.HtmlEncode(possible_language) + "</option>"); } } Output.WriteLine("</select> "); // Add the text to the text box Output.Write("<input class=\"admin_aggr_medium_input\" name=\"" + id2 + "\" id=\"" + id2 + "\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(text) + "\" onfocus=\"javascript:textbox_enter('" + id2 + "', 'admin_aggr_medium_input_focused')\" onblur=\"javascript:textbox_leave('" + id2 + "', 'admin_aggr_medium_input')\" /><br />"); } Output.WriteLine("</td></tr>"); // Add a delete option Output.WriteLine("<tr><td colspan=\"2\" align=\"right\"><a href=\"\">DELETE THIS HIGHLIGHT</a></td></tr>"); }
private static void read_highlights(XmlNodeReader NodeReader, Complete_Item_Aggregation HierarchyObject) { Complete_Item_Aggregation_Highlights highlight = new Complete_Item_Aggregation_Highlights(); // Determine if this is a rotating type of highlight or not if (NodeReader.HasAttributes) { if (NodeReader.MoveToAttribute("type")) { if (NodeReader.Value == "ROTATING") HierarchyObject.Rotating_Highlights = true; } if (HierarchyObject.Front_Banner_Dictionary != null) { // The following three values are for reading legacy XML files. These // data fields have been moved to be attached to the actual banner if (NodeReader.MoveToAttribute("bannerSide")) { if (NodeReader.Value.Trim().ToUpper() == "RIGHT") { foreach (KeyValuePair<Web_Language_Enum, Item_Aggregation_Front_Banner> banners in HierarchyObject.Front_Banner_Dictionary) banners.Value.Type = Item_Aggregation_Front_Banner_Type_Enum.Right; } else { foreach (KeyValuePair<Web_Language_Enum, Item_Aggregation_Front_Banner> banners in HierarchyObject.Front_Banner_Dictionary) banners.Value.Type = Item_Aggregation_Front_Banner_Type_Enum.Left; } } if (NodeReader.MoveToAttribute("bannerHeight")) { foreach (KeyValuePair<Web_Language_Enum, Item_Aggregation_Front_Banner> banners in HierarchyObject.Front_Banner_Dictionary) banners.Value.Height = Convert.ToUInt16(NodeReader.Value); } if (NodeReader.MoveToAttribute("bannerWidth")) { foreach (KeyValuePair<Web_Language_Enum, Item_Aggregation_Front_Banner> banners in HierarchyObject.Front_Banner_Dictionary) banners.Value.Width = Convert.ToUInt16(NodeReader.Value); } } } while (NodeReader.Read()) { // If this is the beginning tag for an element, assign the next values accordingly if (NodeReader.NodeType == XmlNodeType.Element) { // Get the node name, trimmed and to upper string nodeName = NodeReader.Name.Trim().ToUpper(); // switch the rest based on the tag name string languageText; switch (nodeName) { case "HI:SOURCE": NodeReader.Read(); highlight.Image = NodeReader.Value.ToLower(); break; case "HI:LINK": NodeReader.Read(); highlight.Link = NodeReader.Value.ToLower(); break; case "HI:TOOLTIP": languageText = String.Empty; if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang"))) languageText = NodeReader.Value.ToUpper(); NodeReader.Read(); highlight.Add_Tooltip( Web_Language_Enum_Converter.Code_To_Enum(languageText), NodeReader.Value ); break; case "HI:TEXT": languageText = String.Empty; if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang"))) languageText = NodeReader.Value.ToUpper(); NodeReader.Read(); highlight.Add_Text(Web_Language_Enum_Converter.Code_To_Enum(languageText), NodeReader.Value); break; } } if (NodeReader.NodeType == XmlNodeType.EndElement) { if (NodeReader.Name.Trim().ToUpper() == "HI:HIGHLIGHT" ) { if (HierarchyObject.Highlights == null) HierarchyObject.Highlights = new List<Complete_Item_Aggregation_Highlights>(); HierarchyObject.Highlights.Add(highlight); highlight = new Complete_Item_Aggregation_Highlights(); } if (NodeReader.Name.Trim().ToUpper() == "HI:HIGHLIGHTS") { // Done with all the highlights so return return; } } } }
private void Add_Page_6(TextWriter Output) { Output.WriteLine("<table class=\"popup_table\">"); // Add the highlight type Output.Write("<tr><td width=\"120px\">Highlights Type:</td><td><input type=\"radio\" name=\"admin_aggr_highlight_type\" id=\"rotating\" value=\"rotating\""); if ((itemAggregation.Rotating_Highlights.HasValue ) && ( itemAggregation.Rotating_Highlights.Value )) Output.Write(" checked=\"checked\""); Output.Write("/><label for=\"rotating\">Rotating</label> <input type=\"radio\" name=\"admin_aggr_highlight_type\" id=\"static\" value=\"static\""); if ((!itemAggregation.Rotating_Highlights.HasValue ) || (!itemAggregation.Rotating_Highlights.Value)) Output.Write(" checked=\"checked\""); Output.WriteLine("/><label for=\"static\">Static</label></td></tr>"); // Determine the maximum number of languages used in tooltips and text int max_tooltips = 0; int max_text = 0; if (itemAggregation.Highlights != null) { foreach (Complete_Item_Aggregation_Highlights thisHighlight in itemAggregation.Highlights) { max_tooltips = Math.Max(max_tooltips, thisHighlight.Tooltip_Dictionary.Count); max_text = Math.Max(max_text, thisHighlight.Text_Dictionary.Count); } } max_tooltips += 1; max_text += 1; // Add each highlight if (itemAggregation.Highlights != null) { for (int i = 0; i < itemAggregation.Highlights.Count + 5; i++) { // Add some space and a line Output.WriteLine("<tr><td colspan=\"2\"> </td></tr>"); Output.WriteLine("<tr style=\"background:#333333\"><td colspan=\"2\"></td></tr>"); Output.WriteLine("<tr><td colspan=\"2\"> </td></tr>"); // Either get the highlight, or just make one Complete_Item_Aggregation_Highlights emptyHighlight = new Complete_Item_Aggregation_Highlights(); if (i < itemAggregation.Highlights.Count) emptyHighlight = itemAggregation.Highlights[i]; // Now, add it to the form Highlight_Writer_Helper(Output, i + 1, emptyHighlight, max_text, max_tooltips); } } Output.WriteLine("</table>"); Output.WriteLine("<br />"); }