Add_Child_Page() public method

Add a new browse or info object to this hierarchical object
public Add_Child_Page ( Item_Aggregation_Child_Visibility_Enum Browse_Type, string Browse_Code, string StaticHtmlSource, string Text ) : Complete_Item_Aggregation_Child_Page
Browse_Type Item_Aggregation_Child_Visibility_Enum Flag indicates if this is a BROWSE or INFO object
Browse_Code string SubMode indicator for this object
StaticHtmlSource string Any static HTML source to be used for display
Text string Text to display for this browse
return Complete_Item_Aggregation_Child_Page
        /// <summary> Checks the appropriate design folders to add any existing browse or info pages to the item aggregation </summary>
        /// <param name="ThisObject"> Item aggregation object to add the browse and info pages to</param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks>This method is only called if the item aggregation does not have an existing XML configuration file.</remarks>
        protected static void Add_Browse_Files(Complete_Item_Aggregation ThisObject, Custom_Tracer Tracer)
        {
            // Collect the list of items in the browse folder
            if (Directory.Exists(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + ThisObject.ObjDirectory + "html/browse"))
            {
                string[] files = Directory.GetFiles(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + ThisObject.ObjDirectory + "html/browse", "*.htm*");
                foreach (string thisFile in files)
                {
                    // Get the new browse info object
                    Complete_Item_Aggregation_Child_Page newBrowse = Get_Item_Aggregation_Browse_Info(thisFile, Item_Aggregation_Child_Visibility_Enum.Main_Menu, Tracer);
                    if (newBrowse != null)
                    {
                        ThisObject.Add_Child_Page(newBrowse);
                    }
                }
            }

            // Collect the list of items in the info folder
            if (Directory.Exists(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + ThisObject.ObjDirectory + "html/info"))
            {
                string[] files = Directory.GetFiles(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + ThisObject.ObjDirectory + "html/info", "*.htm*");
                foreach (string thisFile in files)
                {
                    // Get the title for this file
                    // Get the new browse info object
                    Complete_Item_Aggregation_Child_Page newInfo = Get_Item_Aggregation_Browse_Info(thisFile, Item_Aggregation_Child_Visibility_Enum.None, Tracer);
                    if (newInfo != null)
                    {
                        ThisObject.Add_Child_Page(newInfo);
                    }
                }
            }
        }
        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;
                    }
                }
            }
        }
        /// <summary> Adds the ALL ITEMS and NEW ITEMS browses to the item aggregation, if the display options and last added
        /// item date call for it </summary>
        /// <param name="ThisObject"> Item aggregation to which to add the ALL ITEMS and NEW ITEMS browse</param>
        /// <remarks>This method is always called while building an item aggregation, irregardless of whether there is an
        /// item aggregation configuration XML file or not.</remarks>
        protected static void Add_All_New_Browses(Complete_Item_Aggregation ThisObject)
        {
            // If this is the main home page for this site, do not show ALL since we cannot browse ALL items
            if (!ThisObject.Can_Browse_Items )
                return;

            // If this is in the display options, and the item browses
            if ((ThisObject.Display_Options.Length == 0) || (ThisObject.Display_Options.IndexOf("I") >= 0))
            {
                // Add the ALL browse, if there should be one
                ThisObject.Add_Child_Page(Item_Aggregation_Child_Visibility_Enum.Main_Menu, "all", String.Empty, "All Items");

                // Add the NEW search, if the ALL search exists
                if ((ThisObject.Get_Browse_Info_Object("all") != null) && (ThisObject.Show_New_Item_Browse))
                {
                    ThisObject.Add_Child_Page(Item_Aggregation_Child_Visibility_Enum.Main_Menu, "new", String.Empty, "Recently Added Items");
                }
            }
            else
            {
                // Add the ALL browse as an info
                ThisObject.Add_Child_Page(Item_Aggregation_Child_Visibility_Enum.None, "all", String.Empty, "All Items");
            }
        }