/// <summary> Constructor for a new instance of the abstractMainWriter abstract class </summary>
 /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
 /// <param name="Hierarchy_Object"> Current item aggregation object to display </param>
 /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </param>
 /// <param name="Paged_Results"> Single page of results for a search or browse, within the entire set </param>
 /// <param name="Browse_Object"> Object contains all the basic information about any browse or info display </param>
 /// <param name="Current_Item"> Current item to display </param>
 /// <param name="Current_Page"> Current page within the item</param>
 /// <param name="Static_Web_Content"> HTML content-based browse, info, or imple CMS-style web content objects.  These are objects which are read from a static HTML file and much of the head information must be maintained </param>
 protected abstractMainWriter(SobekCM_Navigation_Object Current_Mode,
                              Item_Aggregation Hierarchy_Object,
                              Search_Results_Statistics Results_Statistics,
                              List <iSearch_Title_Result> Paged_Results,
                              Item_Aggregation_Child_Page Browse_Object,
                              SobekCM_Item Current_Item,
                              Page_TreeNode Current_Page,
                              HTML_Based_Content Static_Web_Content)
 {
     currentMode        = Current_Mode;
     hierarchyObject    = Hierarchy_Object;
     results_statistics = Results_Statistics;
     paged_results      = Paged_Results;
     thisBrowseObject   = Browse_Object;
     currentItem        = Current_Item;
     currentPage        = Current_Page;
     htmlBasedContent   = Static_Web_Content;
 }
        /// <summary> Constructor for a new instance of the Metadata_Browse_AggregationViewer class </summary>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Current_Aggregation"> Current item aggregation object to display </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Metadata_Browse_AggregationViewer(SobekCM_Navigation_Object Current_Mode, Item_Aggregation Current_Aggregation, Custom_Tracer Tracer) : base(Current_Aggregation, Current_Mode)
        {
            string defaultBrowseBy = Current_Aggregation.Default_BrowseBy;

            // If there is not info browse mode listed, use the default
            if (Current_Mode.Info_Browse_Mode.Length == 0)
            {
                Current_Mode.Info_Browse_Mode = defaultBrowseBy;
            }
            if ((Current_Mode.Info_Browse_Mode.Length == 0) && (Current_Aggregation.Has_Browse_By_Pages))
            {
                Current_Mode.Info_Browse_Mode = Current_Aggregation.Browse_By_Pages(Current_Mode.Language)[0].Code;
            }

            // Get this browse
            browseObject = Current_Aggregation.Get_Browse_Info_Object(Current_Mode.Info_Browse_Mode);

            // Was this a metadata browseby, or just a static html?
            if ((browseObject == null) || (browseObject.Source != Item_Aggregation_Child_Page.Source_Type.Static_HTML))
            {
                // Determine the correct metadata code
                string metadata_code = Current_Mode.Info_Browse_Mode.Trim().Replace("_", " ");
                Current_Mode.Info_Browse_Mode = metadata_code;

                // Only get values if there was a metadata code
                if (metadata_code.Length > 0)
                {
                    // Check the cache for this value
                    List <string> cacheInstance = Cached_Data_Manager.Retrieve_Aggregation_Metadata_Browse(Current_Mode.Aggregation, Current_Mode.Info_Browse_Mode, Tracer);

                    if (cacheInstance != null)
                    {
                        results = cacheInstance;
                    }
                    else
                    {
                        results = SobekCM_Database.Get_Item_Aggregation_Metadata_Browse(Current_Mode.Aggregation, Current_Mode.Info_Browse_Mode, Tracer);
                        Cached_Data_Manager.Store_Aggregation_Metadata_Browse(Current_Mode.Aggregation, Current_Mode.Info_Browse_Mode, results, Tracer);
                    }
                }
            }
        }
        /// <summary> Gets the browse or info object and any other needed data for display ( text to display) </summary>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Aggregation_Object"> Item Aggregation object</param>
        /// <param name="Base_Directory"> Base directory location under which the the CMS/info source file will be found</param>
        /// <param name="Current_User"> Currently logged on user, which can determine which items to show </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        /// <param name="Browse_Object"> [OUT] Stores all the information about this browse or info </param>
        /// <param name="Complete_Result_Set_Info"> [OUT] Information about the entire set of results </param>
        /// <param name="Paged_Results"> [OUT] List of search results for the requested page of results </param>
        /// <param name="Browse_Info_Display_Text"> [OUT] Static HTML-based content to be displayed if this is browing a staticly created html source file </param>
        /// <returns> TRUE if successful, otherwise FALSE </returns>
        /// <remarks> This attempts to pull the objects from the cache.  If unsuccessful, it builds the objects from the
        /// database and hands off to the <see cref="CachedDataManager" /> to store in the cache </remarks>
        protected static bool Get_Browse_Info(Navigation_Object Current_Mode,
                                              Item_Aggregation Aggregation_Object,
                                              string Base_Directory,
                                              User_Object Current_User,
                                              Custom_Tracer Tracer,
                                              out Item_Aggregation_Child_Page Browse_Object,
                                              out Search_Results_Statistics Complete_Result_Set_Info,
                                              out List <iSearch_Title_Result> Paged_Results,
                                              out HTML_Based_Content Browse_Info_Display_Text)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("abstractHtmlSubwriter.Get_Browse_Info", String.Empty);
            }

            // Set output initially to null
            Paged_Results            = null;
            Complete_Result_Set_Info = null;
            Browse_Info_Display_Text = null;

            // First, make sure the browse submode is valid
            Browse_Object = Aggregation_Object.Child_Page_By_Code(Current_Mode.Info_Browse_Mode);

            if (Browse_Object == null)
            {
                Current_Mode.Error_Message = "Unable to retrieve browse/info item '" + Current_Mode.Info_Browse_Mode + "'";
                return(false);
            }

            // Is this a table result, or a string?
            switch (Browse_Object.Source_Data_Type)
            {
            case Item_Aggregation_Child_Source_Data_Enum.Database_Table:

                // Set the current sort to ZERO, if currently set to ONE and this is an ALL BROWSE.
                // Those two sorts are the same in this case
                int sort = Current_Mode.Sort.HasValue ? Math.Max(Current_Mode.Sort.Value, ((ushort)1)) : 1;
                if ((sort == 0) && (Browse_Object.Code == "all"))
                {
                    sort = 1;
                }

                // Special code if this is a JSON browse
                string browse_code = Current_Mode.Info_Browse_Mode;
                if (Current_Mode.Writer_Type == Writer_Type_Enum.JSON)
                {
                    browse_code = browse_code + "_JSON";
                    sort        = 12;
                }

                // Get the page count in the results
                int current_page_index = Current_Mode.Page.HasValue ? Math.Max(Current_Mode.Page.Value, ((ushort)1)) : 1;

                // Determine if this is a special search type which returns more rows and is not cached.
                // This is used to return the results as XML and DATASET
                bool special_search_type = false;
                int  results_per_page    = 20;
                if ((Current_Mode.Writer_Type == Writer_Type_Enum.XML) || (Current_Mode.Writer_Type == Writer_Type_Enum.DataSet))
                {
                    results_per_page    = 1000000;
                    special_search_type = true;
                    sort = 2;     // Sort by BibID always for these
                }

                Tracer.Add_Trace("abstractHtmlSubwriter.Get_Browse_Info", "Current_Mode.Writer_Type=[" + Current_Mode.Writer_Type.ToString() + "].");
                Tracer.Add_Trace("abstractHtmlSubwriter.Get_Browse_Info", "Current_Mode.Results_Display_Type=[" + Current_Mode.Result_Display_Type + "].");

                if (String.Equals(Current_Mode.Result_Display_Type, "timeline", StringComparison.OrdinalIgnoreCase))
                {
                    Tracer.Add_Trace("abstractHtmlSubwriter.Get_Browse_Info", "Is timeline, setting browse results_per_page and sort.");

                    results_per_page = 20000;
                    sort             = 12;
                }

                // Set the flags for how much data is needed.  (i.e., do we need to pull ANYTHING?  or
                // perhaps just the next page of results ( as opposed to pulling facets again).
                bool need_browse_statistics = true;
                bool need_paged_results     = true;
                if ((!special_search_type) && (Current_User == null))
                {
                    // Look to see if the browse statistics are available on any cache for this browse
                    Complete_Result_Set_Info = CachedDataManager.Retrieve_Browse_Result_Statistics(Aggregation_Object.Code, browse_code, Tracer);
                    if (Complete_Result_Set_Info != null)
                    {
                        need_browse_statistics = false;
                    }

                    // Look to see if the paged results are available on any cache..
                    Paged_Results = CachedDataManager.Retrieve_Browse_Results(Aggregation_Object.Code, browse_code, current_page_index, sort, (uint)results_per_page, Tracer);
                    if (Paged_Results != null)
                    {
                        need_paged_results = false;
                    }
                }

                // Was a copy found in the cache?
                if ((!need_browse_statistics) && (!need_paged_results))
                {
                    if (Tracer != null)
                    {
                        Tracer.Add_Trace("SobekCM_Assistant.Get_Browse_Info", "Browse statistics and paged results retrieved from cache");
                    }
                }
                else
                {
                    if (Tracer != null)
                    {
                        Tracer.Add_Trace("SobekCM_Assistant.Get_Browse_Info", "Building results information");
                    }

                    // Try to pull more than one page, so we can cache the next page or so
                    List <List <iSearch_Title_Result> > pagesOfResults;

                    // Get from the hierarchy object
                    Multiple_Paged_Results_Args returnArgs = Item_Aggregation_Utilities.Get_Browse_Results(Aggregation_Object, Browse_Object, current_page_index, sort, results_per_page, !special_search_type, need_browse_statistics, Current_User, Tracer);
                    if (need_browse_statistics)
                    {
                        Complete_Result_Set_Info = returnArgs.Statistics;
                    }
                    pagesOfResults = returnArgs.Paged_Results;
                    if ((pagesOfResults != null) && (pagesOfResults.Count > 0))
                    {
                        Paged_Results = pagesOfResults[0];
                    }

                    // Save the overall result set statistics to the cache if something was pulled
                    if ((!special_search_type) && (Current_User == null))
                    {
                        if ((need_browse_statistics) && (Complete_Result_Set_Info != null))
                        {
                            CachedDataManager.Store_Browse_Result_Statistics(Aggregation_Object.Code, browse_code, Complete_Result_Set_Info, Tracer);
                        }

                        // Save the overall result set statistics to the cache if something was pulled
                        if ((need_paged_results) && (Paged_Results != null))
                        {
                            CachedDataManager.Store_Browse_Results(Aggregation_Object.Code, browse_code, current_page_index, sort, (uint)results_per_page, pagesOfResults, Tracer);
                        }
                    }
                }
                break;

            case Item_Aggregation_Child_Source_Data_Enum.Static_HTML:
                Browse_Info_Display_Text = SobekEngineClient.Aggregations.Get_Aggregation_HTML_Child_Page(Aggregation_Object.Code, Aggregation_Object.Language, UI_ApplicationCache_Gateway.Settings.System.Default_UI_Language, Browse_Object.Code, Tracer);
                break;
            }
            return(true);
        }
Esempio n. 4
0
        /// <summary> Constructor for a new instance of the Static_Browse_Info_AggregationViewer class </summary>
        /// <param name="Browse_Object"> Browse or information object to be displayed </param>
        /// <param name="Static_Web_Content"> HTML content-based browse, info, or imple CMS-style web content objects.  These are objects which are read from a static HTML file and much of the head information must be maintained </param>
        /// <param name="Current_Collection"> Current collection being displayed</param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Current_User"> Current user/session information </param>
        public Static_Browse_Info_AggregationViewer(Item_Aggregation_Child_Page Browse_Object, HTML_Based_Content Static_Web_Content, Item_Aggregation Current_Collection, SobekCM_Navigation_Object Current_Mode, User_Object Current_User) : base(Current_Collection, Current_Mode)
        {
            browseObject     = Browse_Object;
            staticWebContent = Static_Web_Content;
            currentUser      = Current_User;

            bool isAdmin = (currentUser != null) && (currentUser.Is_Aggregation_Admin(currentCollection.Code));

            if ((currentMode.Aggregation_Type == Aggregation_Type_Enum.Child_Page_Edit) && (!isAdmin))
            {
                currentMode.Aggregation_Type = Aggregation_Type_Enum.Browse_Info;
            }

            NameValueCollection form = HttpContext.Current.Request.Form;

            if ((currentMode.Aggregation_Type == Aggregation_Type_Enum.Child_Page_Edit) && (form["sbkSbia_ChildTextEdit"] != null) && (currentUser != null))
            {
                string aggregation_folder = SobekCM_Library_Settings.Base_Design_Location + "aggregations\\" + currentCollection.Code + "\\";
                string file = aggregation_folder + browseObject.Get_Static_HTML_Source(currentMode.Language);

                // Get the header information as well
                if (!String.IsNullOrEmpty(form["admin_childpage_title"]))
                {
                    staticWebContent.Title = form["admin_childpage_title"];
                }
                if (form["admin_childpage_author"] != null)
                {
                    staticWebContent.Author = form["admin_childpage_author"];
                }
                if (form["admin_childpage_date"] != null)
                {
                    staticWebContent.Date = form["admin_childpage_date"];
                }
                if (form["admin_childpage_description"] != null)
                {
                    staticWebContent.Description = form["admin_childpage_description"];
                }
                if (form["admin_childpage_keywords"] != null)
                {
                    staticWebContent.Keywords = form["admin_childpage_keywords"];
                }
                if (form["admin_childpage_extrahead"] != null)
                {
                    staticWebContent.Extra_Head_Info = form["admin_childpage_extrahead"];
                }


                // Make a backup from today, if none made yet
                if (File.Exists(file))
                {
                    DateTime lastWrite = (new FileInfo(file)).LastWriteTime;
                    string   new_file  = file.ToLower().Replace(".txt", "").Replace(".html", "").Replace(".htm", "") + lastWrite.Year + lastWrite.Month.ToString().PadLeft(2, '0') + lastWrite.Day.ToString().PadLeft(2, '0') + ".bak";
                    if (File.Exists(new_file))
                    {
                        File.Delete(new_file);
                    }
                    File.Move(file, new_file);
                }


                // Assign the new text
                Static_Web_Content.Static_Text = form["sbkSbia_ChildTextEdit"];
                Static_Web_Content.Date        = DateTime.Now.ToLongDateString();
                Static_Web_Content.Save_To_File(file);

                // Also save this change
                SobekCM_Database.Save_Item_Aggregation_Milestone(currentCollection.Code, "Child page '" + browseObject.Code + "' edited (" + Web_Language_Enum_Converter.Enum_To_Name(currentMode.Language) + ")", currentUser.Full_Name);

                // Forward along
                currentMode.Aggregation_Type = Aggregation_Type_Enum.Browse_Info;
                if (Browse_Object.Browse_Type == Item_Aggregation_Child_Page.Visibility_Type.METADATA_BROWSE_BY)
                {
                    currentMode.Aggregation_Type = Aggregation_Type_Enum.Browse_By;
                }

                string redirect_url = currentMode.Redirect_URL();
                if (redirect_url.IndexOf("?") > 0)
                {
                    redirect_url = redirect_url + "&refresh=always";
                }
                else
                {
                    redirect_url = redirect_url + "?refresh=always";
                }
                currentMode.Request_Completed = true;
                HttpContext.Current.Response.Redirect(redirect_url, false);
                HttpContext.Current.ApplicationInstance.CompleteRequest();
            }
        }
        /// <summary> Get the language specific item aggregation, from the complete item aggregation object </summary>
        /// <param name="CompAggr"> Copmlete item aggregation object </param>
        /// <param name="RequestedLanguage"> Language version requested </param>
        /// <param name="Tracer"></param>
        /// <returns> The language-specific aggregation, built from the complete aggregation object, or NULL if an error occurred </returns>
        public static Item_Aggregation Get_Item_Aggregation(Complete_Item_Aggregation CompAggr, Web_Language_Enum RequestedLanguage, Custom_Tracer Tracer)
        {
            // If the complete aggregation was null, return null
            if (CompAggr == null)
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Complete item aggregation was NULL.. aborting and returning NULL");
                }

                return(null);
            }

            if (Tracer != null)
            {
                Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Building language-specific item aggregation from the complete object");
            }

            // Build the item aggregation
            Item_Aggregation returnValue = new Item_Aggregation(RequestedLanguage, CompAggr.ID, CompAggr.Code)
            {
                Active              = CompAggr.Active,
                BannerImage         = CompAggr.Banner_Image(RequestedLanguage, null),
                Child_Types         = CompAggr.Child_Types,
                Contact_Email       = CompAggr.Contact_Email,
                ContactForm         = CompAggr.ContactForm,
                CSS_File            = CompAggr.CSS_File,
                Default_BrowseBy    = CompAggr.Default_BrowseBy,
                Default_Result_View = CompAggr.Default_Result_View,
                Default_Skin        = CompAggr.Default_Skin,
                Description         = CompAggr.Description,
                Display_Options     = CompAggr.Display_Options,
                FrontBannerObj      = CompAggr.Front_Banner_Image(RequestedLanguage),
                Hidden              = CompAggr.Hidden,
                Last_Item_Added     = CompAggr.Last_Item_Added,
                Name = CompAggr.Name,
                Rotating_Highlights = CompAggr.Rotating_Highlights,
                ShortName           = CompAggr.ShortName,
                Statistics          = CompAggr.Statistics,
                Type = CompAggr.Type
            };

            // Copy the map search and browse information
            if (CompAggr.Map_Search_Display != null)
            {
                returnValue.Map_Search_Display = CompAggr.Map_Search_Display.Copy();
            }
            if (CompAggr.Map_Browse_Display != null)
            {
                returnValue.Map_Browse_Display = CompAggr.Map_Browse_Display.Copy();
            }

            // Copy any children aggregations over
            if (CompAggr.Active_Children_Count > 0)
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "...Copying children objects");
                }

                returnValue.Children = new List <Item_Aggregation_Related_Aggregations>();
                foreach (Item_Aggregation_Related_Aggregations thisAggr in CompAggr.Children)
                {
                    returnValue.Children.Add(thisAggr);
                }
            }

            // Copy any parent aggregations over
            if (CompAggr.Parent_Count > 0)
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "...Copying parent objects");
                }

                returnValue.Parents = new List <Item_Aggregation_Related_Aggregations>();
                foreach (Item_Aggregation_Related_Aggregations thisAggr in CompAggr.Parents)
                {
                    returnValue.Parents.Add(thisAggr);
                }
            }

            // Copy all the facet information over
            if (Tracer != null)
            {
                Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "...Copying facets");
            }
            foreach (short thisFacet in CompAggr.Facets)
            {
                returnValue.Facets.Add(thisFacet);
            }

            // Copy over all the results views
            if (Tracer != null)
            {
                Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "...Copying result views");
            }
            foreach (string display in CompAggr.Result_Views)
            {
                returnValue.Result_Views.Add(display);
            }

            // Copy all the views and searches over
            if (Tracer != null)
            {
                Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "...Copying views and searches");
            }
            if (CompAggr.Views_And_Searches != null)
            {
                foreach (Item_Aggregation_Views_Searches_Enum viewsSearches in CompAggr.Views_And_Searches)
                {
                    returnValue.Views_And_Searches.Add(viewsSearches);
                }
            }

            // Copy all the setting values
            if ((CompAggr.Settings != null) && (CompAggr.Settings.Count > 0))
            {
                foreach (StringKeyValuePair setting in CompAggr.Settings)
                {
                    returnValue.Add_Setting(setting.Key, setting.Value);
                }
            }

            // Copy over any web skin limitations
            if ((CompAggr.Web_Skins != null) && (CompAggr.Web_Skins.Count > 0))
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "...Copying web skins");
                }

                returnValue.Web_Skins = new List <string>();
                foreach (string thisSkin in CompAggr.Web_Skins)
                {
                    returnValue.Web_Skins.Add(thisSkin);
                }
            }

            // Language-specific (and simplified) metadata type info
            if (Tracer != null)
            {
                Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "...Copying search anbd browseable fields");
            }
            foreach (Complete_Item_Aggregation_Metadata_Type thisAdvSearchField in CompAggr.Search_Fields)
            {
                returnValue.Search_Fields.Add(new Item_Aggregation_Metadata_Type(thisAdvSearchField.DisplayTerm, thisAdvSearchField.SobekCode));
            }
            foreach (Complete_Item_Aggregation_Metadata_Type thisAdvSearchField in CompAggr.Browseable_Fields)
            {
                returnValue.Browseable_Fields.Add(new Item_Aggregation_Metadata_Type(thisAdvSearchField.DisplayTerm, thisAdvSearchField.SobekCode));
            }

            // Language-specific (and simplified) child pages information
            if ((CompAggr.Child_Pages != null) && (CompAggr.Child_Pages.Count > 0))
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "...Copying child pages");
                }

                returnValue.Child_Pages = new List <Item_Aggregation_Child_Page>();
                foreach (Complete_Item_Aggregation_Child_Page fullPage in CompAggr.Child_Pages)
                {
                    Item_Aggregation_Child_Page newPage = new Item_Aggregation_Child_Page
                    {
                        Browse_Type      = fullPage.Browse_Type,
                        Code             = fullPage.Code,
                        Parent_Code      = fullPage.Parent_Code,
                        Source_Data_Type = fullPage.Source_Data_Type
                    };

                    string label = fullPage.Get_Label(RequestedLanguage);
                    if (!String.IsNullOrEmpty(label))
                    {
                        newPage.Label = label;
                    }

                    string source = fullPage.Get_Static_HTML_Source(RequestedLanguage);
                    if (!String.IsNullOrEmpty(label))
                    {
                        newPage.Source = source;
                    }

                    returnValue.Child_Pages.Add(newPage);
                }
            }

            // Language-specific (and simplified) highlight information
            if ((CompAggr.Highlights != null) && (CompAggr.Highlights.Count > 0))
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "...Copying relevant highlights");
                }

                returnValue.Highlights = new List <Item_Aggregation_Highlights>();
                int day_integer      = DateTime.Now.DayOfYear + 1;
                int highlight_to_use = day_integer % CompAggr.Highlights.Count;

                // If this is for rotating highlights, show up to eight
                if ((CompAggr.Rotating_Highlights.HasValue) && (CompAggr.Rotating_Highlights.Value))
                {
                    // Copy over just the eight highlights we should use
                    int number = Math.Min(8, CompAggr.Highlights.Count);
                    for (int i = 0; i < number; i++)
                    {
                        Complete_Item_Aggregation_Highlights thisHighlight = CompAggr.Highlights[highlight_to_use];

                        Item_Aggregation_Highlights newHighlight = new Item_Aggregation_Highlights
                        {
                            Image = thisHighlight.Image,
                            Link  = thisHighlight.Link
                        };

                        string text = thisHighlight.Get_Text(RequestedLanguage);
                        if (!String.IsNullOrEmpty(text))
                        {
                            newHighlight.Text = text;
                        }

                        string tooltip = thisHighlight.Get_Tooltip(RequestedLanguage);
                        if (!String.IsNullOrEmpty(tooltip))
                        {
                            newHighlight.Tooltip = tooltip;
                        }

                        returnValue.Highlights.Add(newHighlight);

                        highlight_to_use++;
                        if (highlight_to_use >= CompAggr.Highlights.Count)
                        {
                            highlight_to_use = 0;
                        }
                    }
                }
                else
                {
                    Complete_Item_Aggregation_Highlights thisHighlight = CompAggr.Highlights[highlight_to_use];

                    Item_Aggregation_Highlights newHighlight = new Item_Aggregation_Highlights
                    {
                        Image = thisHighlight.Image,
                        Link  = thisHighlight.Link
                    };

                    string text = thisHighlight.Get_Text(RequestedLanguage);
                    if (!String.IsNullOrEmpty(text))
                    {
                        newHighlight.Text = text;
                    }

                    string tooltip = thisHighlight.Get_Tooltip(RequestedLanguage);
                    if (!String.IsNullOrEmpty(tooltip))
                    {
                        newHighlight.Tooltip = tooltip;
                    }

                    returnValue.Highlights.Add(newHighlight);
                }
            }

            // Language-specific source page
            if (Tracer != null)
            {
                Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Getting the home page source");
            }
            returnValue.HomePageSource = String.Empty;
            HTML_Based_Content homeHtml = Get_Home_HTML(CompAggr, RequestedLanguage, null);

            returnValue.HomePageHtml     = homeHtml;
            returnValue.Custom_Home_Page = (CompAggr.Home_Page_File(RequestedLanguage) != null) && (CompAggr.Home_Page_File(RequestedLanguage).isCustomHome);

            if (Tracer != null)
            {
                Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Returning fully built item aggregation object");
            }
            return(returnValue);
        }
        /// <summary> Method returns the table of results for the browse indicated </summary>
        /// <param name="ItemAggr"> Item Aggregation from which to return the browse </param>
        /// <param name = "ChildPageObject">Object with all the information about the browse</param>
        /// <param name = "Page"> Page of results requested for the indicated browse </param>
        /// <param name = "Sort"> Sort applied to the results before being returned </param>
        /// <param name="Potentially_Include_Facets"> Flag indicates if facets could be included in this browse results </param>
        /// <param name = "Need_Browse_Statistics"> Flag indicates if the browse statistics (facets and total counts) are required for this browse as well </param>
        /// <param name = "Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <param name="Results_Per_Page"> Number of results to retrieve per page</param>
        /// <returns> Resutls for the browse or info in table form </returns>
        public static Multiple_Paged_Results_Args Get_Browse_Results(Item_Aggregation ItemAggr, Item_Aggregation_Child_Page ChildPageObject,
                                                                     int Page, int Sort, int Results_Per_Page, bool Potentially_Include_Facets, bool Need_Browse_Statistics,
                                                                     Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Browse_Results", String.Empty);
            }

            // Get the list of facets first
            List <short> facetsList = ItemAggr.Facets;

            if (!Potentially_Include_Facets)
            {
                facetsList = null;
            }

            // Pull data from the database if necessary
            if ((ChildPageObject.Code == "all") || (ChildPageObject.Code == "new"))
            {
                // Get this browse from the database
                if ((ItemAggr.ID < 0) || (ItemAggr.Code.ToUpper() == "ALL"))
                {
                    if (ChildPageObject.Code == "new")
                    {
                        return(Engine_Database.Get_All_Browse_Paged(true, false, Results_Per_Page, Page, Sort, Need_Browse_Statistics, facetsList, Need_Browse_Statistics, Tracer));
                    }
                    return(Engine_Database.Get_All_Browse_Paged(false, false, Results_Per_Page, Page, Sort, Need_Browse_Statistics, facetsList, Need_Browse_Statistics, Tracer));
                }

                if (ChildPageObject.Code == "new")
                {
                    return(Engine_Database.Get_Item_Aggregation_Browse_Paged(ItemAggr.Code, true, false, Results_Per_Page, Page, Sort, Need_Browse_Statistics, facetsList, Need_Browse_Statistics, Tracer));
                }
                return(Engine_Database.Get_Item_Aggregation_Browse_Paged(ItemAggr.Code, false, false, Results_Per_Page, Page, Sort, Need_Browse_Statistics, facetsList, Need_Browse_Statistics, Tracer));
            }

            // Default return NULL
            return(null);
        }