public Add_Label ( string Label, Web_Language_Enum Language ) : void | ||
Label | string | Label for this browse/info object |
Language | Web_Language_Enum | Language code |
return | void |
private static void read_browse(bool Browse, XmlNodeReader NodeReader, Complete_Item_Aggregation HierarchyObject) { // Create a new browse/info object Complete_Item_Aggregation_Child_Page newBrowse = new Complete_Item_Aggregation_Child_Page { Browse_Type = Item_Aggregation_Child_Visibility_Enum.Main_Menu, Source_Data_Type = Item_Aggregation_Child_Source_Data_Enum.Static_HTML }; bool isDefault = false; // Determine which XML node name to look for and set browse v. info string lastName = "HI:BROWSE"; if (!Browse) { lastName = "HI:INFO"; newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.None; } // Check for the attributes if (NodeReader.HasAttributes) { if (NodeReader.MoveToAttribute("location")) { if (NodeReader.Value == "BROWSEBY") newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Metadata_Browse_By; } if (NodeReader.MoveToAttribute("default")) { if (NodeReader.Value == "DEFAULT") isDefault = true; } if (NodeReader.MoveToAttribute("visibility")) { switch (NodeReader.Value) { case "NONE": newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.None; break; case "MAIN_MENU": newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Main_Menu; break; case "BROWSEBY": newBrowse.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Metadata_Browse_By; break; } } if (NodeReader.MoveToAttribute("parent")) { newBrowse.Parent_Code = NodeReader.Value; } } // Step through the XML and build this browse/info object 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 switch (nodeName) { case "HI:METADATA": NodeReader.Read(); newBrowse.Code = NodeReader.Value.ToLower(); newBrowse.Source_Data_Type = Item_Aggregation_Child_Source_Data_Enum.Database_Table; break; case "HI:CODE": NodeReader.Read(); newBrowse.Code = NodeReader.Value.ToLower(); break; case "HI:TITLE": // Look for a language attached to this title string titleLanguage = String.Empty; if ((NodeReader.HasAttributes) && ( NodeReader.MoveToAttribute("lang"))) { titleLanguage = NodeReader.GetAttribute("lang"); } // read and save the title NodeReader.Read(); newBrowse.Add_Label( NodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(titleLanguage)); break; case "HI:BODY": // Look for a language attached to this title string bodyLanguage = String.Empty; if ((NodeReader.HasAttributes) && (NodeReader.MoveToAttribute("lang"))) { bodyLanguage = NodeReader.GetAttribute("lang"); } // read and save the title NodeReader.Read(); string bodySource = NodeReader.Value; newBrowse.Add_Static_HTML_Source(bodySource, Web_Language_Enum_Converter.Code_To_Enum(bodyLanguage)); break; } } if (NodeReader.NodeType == XmlNodeType.EndElement) { if (NodeReader.Name.Trim().ToUpper() == lastName ) { // Don't add ALL or NEW here if ((String.Compare(newBrowse.Code, "all", StringComparison.InvariantCultureIgnoreCase) != 0) && (String.Compare(newBrowse.Code, "new", StringComparison.InvariantCultureIgnoreCase) != 0)) { HierarchyObject.Add_Child_Page(newBrowse); //HierarchyObject.Add // If this set the default browse by save that information if ((newBrowse.Browse_Type == Item_Aggregation_Child_Visibility_Enum.Metadata_Browse_By) && (isDefault)) { HierarchyObject.Default_BrowseBy = newBrowse.Code; } } return; } } } }
private void Save_Page_7_Postback(NameValueCollection Form) { string action = Form["admin_aggr_action"]; if (!String.IsNullOrEmpty(action)) { if ((action.IndexOf("delete_") == 0) && ( action.Length > 7 )) { string code_to_delete = action.Substring(7); itemAggregation.Remove_Child_Page(code_to_delete); // Save to the admins session HttpContext.Current.Session["Edit_Aggregation_" + itemAggregation.Code] = itemAggregation; } if (action == "save_childpage") { childPageCode = Form["admin_aggr_code"]; childPageLabel = Form["admin_aggr_label"]; childPageVisibility = Form["admin_aggr_visibility"]; childPageParent = Form["admin_aggr_parent"]; // Convert to the integer id for the parent and begin to do checking List<string> errors = new List<string>(); // Validate the code if (childPageCode.Length > 20) { errors.Add("New child page code must be twenty characters long or less"); } else if (childPageCode.Length == 0) { errors.Add("You must enter a CODE for this child page"); } else if (UI_ApplicationCache_Gateway.Settings.Static.Reserved_Keywords.Contains(childPageCode.ToLower())) { errors.Add("That code is a system-reserved keyword. Try a different code."); } else if (itemAggregation.Child_Page_By_Code(childPageCode.ToUpper()) != null) { errors.Add("New code must be unique... <i>" + childPageCode + "</i> already exists"); } if (childPageLabel.Trim().Length == 0) errors.Add("You must enter a LABEL for this child page"); if (childPageVisibility.Trim().Length == 0) errors.Add("You must select a VISIBILITY for this child page"); if (errors.Count > 0) { // Create the error message actionMessage = "ERROR: Invalid entry for new item child page<br />"; foreach (string error in errors) actionMessage = actionMessage + "<br />" + error; } else { Complete_Item_Aggregation_Child_Page newPage = new Complete_Item_Aggregation_Child_Page { Code = childPageCode, Parent_Code = childPageParent, Source_Data_Type = Item_Aggregation_Child_Source_Data_Enum.Static_HTML }; newPage.Add_Label(childPageLabel, UI_ApplicationCache_Gateway.Settings.System.Default_UI_Language); switch (childPageVisibility) { case "none": newPage.Browse_Type = Item_Aggregation_Child_Visibility_Enum.None; newPage.Parent_Code = String.Empty; break; case "browse": newPage.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Main_Menu; break; case "browseby": newPage.Browse_Type = Item_Aggregation_Child_Visibility_Enum.Metadata_Browse_By; newPage.Parent_Code = String.Empty; break; } string html_source_dir = aggregationDirectory + "\\html\\browse"; if (!Directory.Exists(html_source_dir)) Directory.CreateDirectory(html_source_dir); string html_source_file = html_source_dir + "\\" + childPageCode + "_" + Web_Language_Enum_Converter.Enum_To_Code(UI_ApplicationCache_Gateway.Settings.System.Default_UI_Language) + ".html"; if (!File.Exists(html_source_file)) { HTML_Based_Content htmlContent = new HTML_Based_Content { Content = "<br /><br />This is a new browse page.<br /><br />" + childPageLabel + "<br /><br />The code for this browse is: " + childPageCode, Author = RequestSpecificValues.Current_User.Full_Name, Date = DateTime.Now.ToLongDateString(), Title = childPageLabel }; htmlContent.Save_To_File(html_source_file); } newPage.Add_Static_HTML_Source("html\\browse\\" + childPageCode + "_" + Web_Language_Enum_Converter.Enum_To_Code(UI_ApplicationCache_Gateway.Settings.System.Default_UI_Language) + ".html", UI_ApplicationCache_Gateway.Settings.System.Default_UI_Language); itemAggregation.Add_Child_Page(newPage); // Save to the admins session HttpContext.Current.Session["Edit_Aggregation_" + itemAggregation.Code] = itemAggregation; } } } }