Beispiel #1
0
        /// <summary>Reads the item aggregation browse or info file and returns a built <see cref="Item_Aggregation_Browse_Info"/> object for
        /// inclusion in the item aggregation </summary>
        /// <param name="fileName"> Filename of the browse or info file</param>
        /// <param name="Browse_Type"> Flag indicates if this is a browse or info file</param>
        /// <param name="tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <returns> Built object containing all of the pertinent details about this info or browse </returns>
        private static Item_Aggregation_Browse_Info Get_Item_Aggregation_Browse_Info(string fileName, Item_Aggregation_Browse_Info.Browse_Info_Type Browse_Type, Custom_Tracer tracer)
        {
            HTML_Based_Content           fileContent  = HTML_Based_Content_Reader.Read_HTML_File(fileName, false, tracer);
            Item_Aggregation_Browse_Info returnObject = new Item_Aggregation_Browse_Info(Browse_Type, Item_Aggregation_Browse_Info.Source_Type.Static_HTML, fileContent.Code, fileName, fileContent.Title);

            return(returnObject);
        }
        /// <summary>Reads the item aggregation browse or info file and returns a built <see cref="Item_Aggregation_Child_Page"/> object for
        /// inclusion in the item aggregation </summary>
        /// <param name="FileName"> Filename of the browse or info file</param>
        /// <param name="Browse_Type"> Flag indicates if this is a browse or info file</param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <returns> Built object containing all of the pertinent details about this info or browse </returns>
        private static Item_Aggregation_Child_Page Get_Item_Aggregation_Browse_Info(string FileName, Item_Aggregation_Child_Page.Visibility_Type Browse_Type, Custom_Tracer Tracer)
        {
            HTML_Based_Content          fileContent  = HTML_Based_Content_Reader.Read_HTML_File(FileName, false, Tracer);
            Item_Aggregation_Child_Page returnObject = new Item_Aggregation_Child_Page(Browse_Type, Item_Aggregation_Child_Page.Source_Type.Static_HTML, fileContent.Code, FileName, fileContent.Title);

            return(returnObject);
        }
        /// <summary>Reads the item aggregation browse or info file and returns a built <see cref="Item_Aggregation_Child_Page"/> object for
        /// inclusion in the item aggregation </summary>
        /// <param name="FileName"> Filename of the browse or info file</param>
        /// <param name="Browse_Type"> Flag indicates if this is a browse or info file</param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <returns> Built object containing all of the pertinent details about this info or browse </returns>
        private static Complete_Item_Aggregation_Child_Page Get_Item_Aggregation_Browse_Info(string FileName, Item_Aggregation_Child_Visibility_Enum Browse_Type, Custom_Tracer Tracer)
        {
            HTML_Based_Content fileContent = HTML_Based_Content_Reader.Read_HTML_File(FileName, false, Tracer);
            Complete_Item_Aggregation_Child_Page returnObject = new Complete_Item_Aggregation_Child_Page(Browse_Type, Item_Aggregation_Child_Source_Data_Enum.Static_HTML, fileContent.Code, FileName, fileContent.Title ?? "Missing Title");

            return(returnObject);
        }
        /// <summary> [HELPER] Gets the all information, including the HTML, for an item aggregation child page </summary>
        /// <param name="AggregationCode"> Code for the aggregation </param>
        /// <param name="RequestedLanguage"> Requested language to retrieve </param>
        /// <param name="DefaultLanguage"> Default interface language, in case the requested language does not exist </param>
        /// <param name="ChildPageCode"> Code the requested child page </param>
        /// <param name="Tracer"></param>
        /// <returns> Fully built object, based on the aggregation configuration and reading the source HTML file </returns>
        /// <remarks> This may be public now, but this will be converted into a private helped class with
        /// the release of SobekCM 5.0 </remarks>
        public static HTML_Based_Content get_item_aggregation_html_child_page(string AggregationCode, Web_Language_Enum RequestedLanguage, Web_Language_Enum DefaultLanguage, string ChildPageCode, Custom_Tracer Tracer)
        {
            // Try to pull from the cache
            HTML_Based_Content cacheInst = CachedDataManager.Aggregations.Retrieve_Aggregation_HTML_Based_Content(AggregationCode, RequestedLanguage, ChildPageCode, Tracer);

            if (cacheInst != null)
            {
                Tracer.Add_Trace("AggregationServices.get_item_aggregation_html_child_page", "Found built child page in the cache");
                return(cacheInst);
            }

            // Get the language-specific item aggregation object
            Item_Aggregation itemAggr = get_item_aggregation(AggregationCode, RequestedLanguage, DefaultLanguage, Tracer);

            if (itemAggr == null)
            {
                Tracer.Add_Trace("AggregationServices.get_item_aggregation_html_child_page", "Item aggregation object was NULL.. May not be a valid aggregation code");
                return(null);
            }

            // Get the child page object
            Tracer.Add_Trace("AggregationServices.get_item_aggregation_html_child_page", "Get child page object from the language-specific item aggregation");
            Item_Aggregation_Child_Page childPage = itemAggr.Child_Page_By_Code(ChildPageCode);

            if (childPage == null)
            {
                Tracer.Add_Trace("AggregationServices.get_item_aggregation_html_child_page", "Child page does not exist in language-specific item agggregation");
                return(null);
            }

            if (childPage.Source_Data_Type != Item_Aggregation_Child_Source_Data_Enum.Static_HTML)
            {
                Tracer.Add_Trace("AggregationServices.get_item_aggregation_html_child_page", "Child page exists in language-specific item aggregation, but it is not of type static html");
                return(null);
            }

            string path = Path.Combine("/design/", itemAggr.ObjDirectory, childPage.Source);
            string file = HttpContext.Current.Server.MapPath(path);

            Tracer.Add_Trace("AggregationServices.get_item_aggregation_html_child_page", "Attempting to read source file for child page");
            HTML_Based_Content results = HTML_Based_Content_Reader.Read_HTML_File(file, true, Tracer);

            if (results != null)
            {
                Tracer.Add_Trace("AggregationServices.get_item_aggregation_html_child_page", "Storing build child page in the cache");

                CachedDataManager.Aggregations.Store_Aggregation_HTML_Based_Content(AggregationCode, RequestedLanguage, ChildPageCode, results, Tracer);
            }
            else
            {
                Tracer.Add_Trace("AggregationServices.get_item_aggregation_html_child_page", "Child page object returned from HTML_Based_Content_Reader was null.. returning NULL");
            }

            return(results);
        }
        /// <summary> Method gets the HOME PAGE html for the appropriate UI settings </summary>
        /// <param name="CompAggr"> Complete item aggregation object </param>
        /// <param name = "Language"> Current language of the user interface </param>
        /// <param name = "Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <returns>Home page HTML</returns>
        private static HTML_Based_Content Get_Home_HTML(Complete_Item_Aggregation CompAggr, Web_Language_Enum Language, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Home_HTML", "Reading home text source file");
            }

            string homeFileSource = "";

            // Get the home file source
            if (CompAggr.Home_Page_File(Language) != null)
            {
                homeFileSource = Path.Combine(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location, CompAggr.ObjDirectory, CompAggr.Home_Page_File(Language).Source);
            }

            // If no home file source even found, return a message to that affect
            if (homeFileSource.Length == 0)
            {
                return(new HTML_Based_Content("<div class=\"error_div\">NO HOME PAGE SOURCE FILE FOUND</div>", null, homeFileSource));
            }

            // Do the rest in a try/catch
            try
            {
                // Does the file exist?
                if (!File.Exists(homeFileSource))
                {
                    return(new HTML_Based_Content("<div class=\"error_div\">HOME PAGE SOURCE FILE '" + homeFileSource + "' DOES NOT EXIST.</div>", null, homeFileSource));
                }

                HTML_Based_Content content = HTML_Based_Content_Reader.Read_HTML_File(homeFileSource, true, Tracer);
                content.Source = homeFileSource;

                return(content);
            }
            catch (Exception ee)
            {
                return(new HTML_Based_Content("<div class=\"error_div\">EXCEPTION CAUGHT WHILE TRYING TO READ THE HOME PAGE SOURCE FILE '" + homeFileSource + "'.<br /><br />ERROR: " + ee.Message + "</div>", null, homeFileSource));
            }
        }
        /// <summary> Add the HTML to be displayed below the search box </summary>
        /// <param name="Output"> Textwriter to write the HTML for this viewer</param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> This writes the HTML from the static browse or info page here  </remarks>
        public override void Add_Secondary_HTML(TextWriter Output, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("Metadata_Browse_AggregationViewer.Add_Secondary_HTML", "Adding HTML");
            }

            // Get collection of (public) browse bys linked to this aggregation
            ReadOnlyCollection <Item_Aggregation_Child_Page> public_browses = ViewBag.Hierarchy_Object.Browse_By_Pages;

            // Determine if this is an internal user and create list of internal user browses
            List <string> internal_browses = new List <string>();

            if ((RequestSpecificValues.Current_User != null) && ((RequestSpecificValues.Current_User.Is_Internal_User) || (RequestSpecificValues.Current_User.Is_Aggregation_Curator(RequestSpecificValues.Current_Mode.Aggregation))))
            {
                // Just add every metadata field here
                foreach (Item_Aggregation_Metadata_Type field in ViewBag.Hierarchy_Object.Browseable_Fields)
                {
                    internal_browses.Add(field.DisplayTerm);
                }
            }

            // Retain the original short code (or the first public code)
            string original_browse_mode = RequestSpecificValues.Current_Mode.Info_Browse_Mode.ToLower();

            // Get any paging URL and retain original page
            int current_page = RequestSpecificValues.Current_Mode.Page.HasValue ? RequestSpecificValues.Current_Mode.Page.Value : 1;

            RequestSpecificValues.Current_Mode.Page = 1;
            string page_url    = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode, false);
            string url_options = UrlWriterHelper.URL_Options(RequestSpecificValues.Current_Mode);

            if (url_options.Length > 0)
            {
                url_options = "?" + url_options.Replace("&", "&amp");
            }

            if ((public_browses.Count > 1) || (internal_browses.Count > 0))
            {
                Output.WriteLine("<table>");
                Output.WriteLine("<tr style=\"vertical-align:top;\">");
                Output.WriteLine("<td id=\"sbkMebv_FacetOuterColumn\">");
                Output.WriteLine("<div class=\"sbkMebv_FacetColumn\">");
                Output.WriteLine("<div class=\"sbkMebv_FacetColumnTitle\">BROWSE BY:</div>");
                Output.WriteLine("<br />");

                if (public_browses.Count > 0)
                {
                    // Sort these by title
                    SortedList <string, Item_Aggregation_Child_Page> sortedBrowses = new SortedList <string, Item_Aggregation_Child_Page>();
                    foreach (Item_Aggregation_Child_Page thisBrowse in public_browses)
                    {
                        if (thisBrowse.Source_Data_Type == Item_Aggregation_Child_Source_Data_Enum.Static_HTML)
                        {
                            sortedBrowses[thisBrowse.Code.ToLower()] = thisBrowse;
                        }
                        else
                        {
                            Metadata_Search_Field facetField = UI_ApplicationCache_Gateway.Settings.Metadata_Search_Field_By_Name(thisBrowse.Code);
                            if (facetField != null)
                            {
                                string facetName = facetField.Display_Term;

                                if (internal_browses.Contains(facetName))
                                {
                                    internal_browses.Remove(facetName);
                                }

                                sortedBrowses[facetName.ToLower()] = thisBrowse;
                            }
                        }
                    }

                    Output.WriteLine(internal_browses.Count > 0 ? "<b> &nbsp;Public Browses</b><br />" : "<b> &nbsp;Browses</b><br />");

                    Output.WriteLine("<div class=\"sbkMebv_FacetBox\">");
                    foreach (Item_Aggregation_Child_Page thisBrowse in sortedBrowses.Values)
                    {
                        // Static HTML or metadata browse by?
                        if (thisBrowse.Source_Data_Type == Item_Aggregation_Child_Source_Data_Enum.Static_HTML)
                        {
                            if (original_browse_mode != thisBrowse.Code)
                            {
                                RequestSpecificValues.Current_Mode.Info_Browse_Mode = thisBrowse.Code;
                                Output.WriteLine("<a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode).Replace("&", "&amp") + "\">" + thisBrowse.Label + "</a><br />");
                            }
                            else
                            {
                                Output.WriteLine(thisBrowse.Label + "<br />");
                            }
                        }
                        else
                        {
                            Metadata_Search_Field facetField = UI_ApplicationCache_Gateway.Settings.Metadata_Search_Field_By_Display_Name(thisBrowse.Code);
                            if (thisBrowse.Code.ToLower().Replace("_", " ") != original_browse_mode.Replace("_", " "))
                            {
                                RequestSpecificValues.Current_Mode.Info_Browse_Mode = thisBrowse.Code.ToLower().Replace(" ", "_");
                                Output.WriteLine("<a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode).Replace("&", "&amp") + "\">" + facetField.Display_Term + "</a><br />");
                            }
                            else
                            {
                                Output.WriteLine(facetField.Display_Term + "<br />");
                            }
                        }
                    }

                    Output.WriteLine("</div>");
                    Output.WriteLine("<br />");
                }

                if (internal_browses.Count > 0)
                {
                    Output.WriteLine("<b> &nbsp;Internal Browses</b><br />");
                    Output.WriteLine("<div class=\"sbkMebv_FacetBox\">");

                    foreach (string thisShort in internal_browses)
                    {
                        Metadata_Search_Field facetField = UI_ApplicationCache_Gateway.Settings.Metadata_Search_Field_By_Facet_Name(thisShort);
                        if (facetField != null)
                        {
                            if (thisShort.ToLower() != original_browse_mode)
                            {
                                RequestSpecificValues.Current_Mode.Info_Browse_Mode = thisShort.ToLower().Replace(" ", "_");
                                Output.WriteLine("<a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode).Replace("&", "&amp") + "\">" + facetField.Display_Term + "</a><br />");
                            }
                            else
                            {
                                Output.WriteLine(facetField.Display_Term + "<br />");
                            }
                        }
                    }

                    Output.WriteLine("</div>");
                    Output.WriteLine("<br />");
                }
                Output.WriteLine("<br />");
                Output.WriteLine("<br />");
                Output.WriteLine("<br />");
                Output.WriteLine("<br />");
                Output.WriteLine("<br />");
                Output.WriteLine("</div>");
                Output.WriteLine("</td>");
                Output.WriteLine("<td>");
            }
            Output.WriteLine("<div class=\"sbkMebv_ResultsPanel\" id=\"main-content\" role=\"main\">");

            RequestSpecificValues.Current_Mode.Info_Browse_Mode = original_browse_mode;

            // Was this static or metadata browse by?
            if ((browseObject != null) && (browseObject.Source_Data_Type == Item_Aggregation_Child_Source_Data_Enum.Static_HTML))
            {
                // Read the content file for this browse
                string             source_file         = UI_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + ViewBag.Hierarchy_Object.ObjDirectory.Replace("/", "\\") + browseObject.Source;
                HTML_Based_Content staticBrowseContent = HTML_Based_Content_Reader.Read_HTML_File(source_file, true, Tracer);
                if (staticBrowseContent == null)
                {
                    staticBrowseContent = new HTML_Based_Content("Unable to find source file!\n\n" + ViewBag.Hierarchy_Object.ObjDirectory.Replace("/", "\\") + browseObject.Source, browseObject.Code);
                }

                // Apply current user settings for this
                string browseInfoDisplayText = staticBrowseContent.Apply_Settings_To_Static_Text(staticBrowseContent.Content, ViewBag.Hierarchy_Object, RequestSpecificValues.HTML_Skin.Skin_Code, RequestSpecificValues.HTML_Skin.Base_Skin_Code, RequestSpecificValues.Current_Mode.Base_URL, UrlWriterHelper.URL_Options(RequestSpecificValues.Current_Mode), Tracer);

                // Is this an admin?
                bool isAdmin = (RequestSpecificValues.Current_User != null) && (RequestSpecificValues.Current_User.Is_Aggregation_Admin(ViewBag.Hierarchy_Object.Code));
                Aggregation_Type_Enum aggrType = RequestSpecificValues.Current_Mode.Aggregation_Type;

                // Output the adjusted home html
                if (isAdmin)
                {
                    Output.WriteLine("<div id=\"sbkSbia_MainTextEditable\">");
                    Output.WriteLine(browseInfoDisplayText);
                    RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Child_Page_Edit;
                    Output.WriteLine("  <div id=\"sbkSbia_EditableTextLink\"><a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "\" title=\"Edit this page's text\"><img src=\"" + Static_Resources_Gateway.Edit_Gif + "\" alt=\"\" />edit content</a></div>");
                    RequestSpecificValues.Current_Mode.Aggregation_Type = aggrType;
                    Output.WriteLine("</div>");
                    Output.WriteLine();

                    Output.WriteLine("<script>");
                    Output.WriteLine("  $(\"#sbkSbia_MainTextEditable\").mouseover(function() { $(\"#sbkSbia_EditableTextLink\").css(\"display\",\"inline-block\"); });");
                    Output.WriteLine("  $(\"#sbkSbia_MainTextEditable\").mouseout(function() { $(\"#sbkSbia_EditableTextLink\").css(\"display\",\"none\"); });");
                    Output.WriteLine("</script>");
                    Output.WriteLine();
                }
                else
                {
                    Output.WriteLine("<div id=\"sbkSbia_MainText\">");
                    Output.WriteLine(browseInfoDisplayText);
                    Output.WriteLine("</div>");
                }
            }
            else
            {
                //Output the results
                if ((results != null) && (results.Count > 0))
                {
                    // Determine which letters appear
                    List <char> letters_appearing = new List <char>();
                    char        last_char         = '\n';
                    if (results.Count > 100)
                    {
                        foreach (string thisValue in results)
                        {
                            if (thisValue.Length > 0)
                            {
                                char this_first_char = Char.ToLower(thisValue[0]);
                                int  ascii           = this_first_char;

                                if (ascii < 97)
                                {
                                    this_first_char = 'a';
                                }
                                if (ascii > 122)
                                {
                                    this_first_char = 'z';
                                }

                                if (this_first_char != last_char)
                                {
                                    if (!letters_appearing.Contains(this_first_char))
                                    {
                                        letters_appearing.Add(this_first_char);
                                    }
                                    last_char = this_first_char;
                                }
                            }
                        }
                    }

                    // Get the search URL
                    RequestSpecificValues.Current_Mode.Mode             = Display_Mode_Enum.Results;
                    RequestSpecificValues.Current_Mode.Search_Precision = Search_Precision_Type_Enum.Exact_Match;
                    RequestSpecificValues.Current_Mode.Search_Type      = Search_Type_Enum.Advanced;
                    Metadata_Search_Field facetField = UI_ApplicationCache_Gateway.Settings.Metadata_Search_Field_By_Display_Name(original_browse_mode);
                    RequestSpecificValues.Current_Mode.Search_Fields = facetField.Web_Code;
                    RequestSpecificValues.Current_Mode.Search_String = "\"<%TERM%>\"";
                    string search_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

                    Output.WriteLine("<br />");

                    if (results.Count < 100)
                    {
                        foreach (string thisResult in results)
                        {
                            Output.WriteLine("<a href=\"" + search_url.Replace("%3c%25TERM%25%3e", thisResult.Trim().Replace(",", "%2C").Replace("&", "%26").Replace("\"", "%22").Replace("&", "&amp")) + "\">" + thisResult.Replace("\"", "&quot;").Replace("&", "&amp;") + "</a><br />");
                        }
                    }
                    else if (results.Count < 500)
                    {
                        // Determine the actual page first
                        int first_valid_page = -1;
                        if ((letters_appearing.Contains('a')) || (letters_appearing.Contains('b')))
                        {
                            first_valid_page = 1;
                        }

                        if ((letters_appearing.Contains('c')) || (letters_appearing.Contains('d')) || (letters_appearing.Contains('e')))
                        {
                            if (first_valid_page < 0)
                            {
                                first_valid_page = 2;
                            }
                        }

                        if ((letters_appearing.Contains('f')) || (letters_appearing.Contains('g')) || (letters_appearing.Contains('h')))
                        {
                            if (first_valid_page < 0)
                            {
                                first_valid_page = 3;
                            }
                        }

                        if ((letters_appearing.Contains('i')) || (letters_appearing.Contains('j')) || (letters_appearing.Contains('k')))
                        {
                            if (first_valid_page < 0)
                            {
                                first_valid_page = 4;
                            }
                        }

                        if ((letters_appearing.Contains('l')) || (letters_appearing.Contains('m')) || (letters_appearing.Contains('n')))
                        {
                            if (first_valid_page < 0)
                            {
                                first_valid_page = 5;
                            }
                        }

                        if ((letters_appearing.Contains('o')) || (letters_appearing.Contains('p')) || (letters_appearing.Contains('q')))
                        {
                            if (first_valid_page < 0)
                            {
                                first_valid_page = 6;
                            }
                        }

                        if ((letters_appearing.Contains('r')) || (letters_appearing.Contains('s')) || (letters_appearing.Contains('t')))
                        {
                            if (first_valid_page < 0)
                            {
                                first_valid_page = 7;
                            }
                        }

                        if ((letters_appearing.Contains('u')) || (letters_appearing.Contains('v')) || (letters_appearing.Contains('w')))
                        {
                            if (first_valid_page < 0)
                            {
                                first_valid_page = 8;
                            }
                        }

                        if ((letters_appearing.Contains('x')) || (letters_appearing.Contains('y')) || (letters_appearing.Contains('z')))
                        {
                            if (first_valid_page < 0)
                            {
                                first_valid_page = 9;
                            }
                        }

                        // Define the limits of the page value
                        if ((current_page < first_valid_page) || (current_page > 9))
                        {
                            current_page = first_valid_page;
                        }


                        // Add the links for paging through results
                        Output.WriteLine("<div class=\"sbkMebv_NavRow\">");
                        if ((letters_appearing.Contains('a')) || (letters_appearing.Contains('b')))
                        {
                            if (current_page == 1)
                            {
                                Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">AB</span> &nbsp; ");
                            }
                            else
                            {
                                Output.WriteLine("<a href=\"" + page_url + "/1" + url_options + "\" class=\"mbb1\">AB</a> &nbsp; ");
                            }
                        }
                        else
                        {
                            Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">AB</span> &nbsp; ");
                        }

                        if ((letters_appearing.Contains('c')) || (letters_appearing.Contains('d')) || (letters_appearing.Contains('e')))
                        {
                            if (current_page == 2)
                            {
                                Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">CDE</span> &nbsp; ");
                            }
                            else
                            {
                                Output.WriteLine("<a href=\"" + page_url + "/2" + url_options + "\">CDE</a> &nbsp; ");
                            }
                        }
                        else
                        {
                            Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">CDE</span> &nbsp; ");
                        }

                        if ((letters_appearing.Contains('f')) || (letters_appearing.Contains('g')) || (letters_appearing.Contains('h')))
                        {
                            if (current_page == 3)
                            {
                                Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">FGH</span> &nbsp; ");
                            }
                            else
                            {
                                Output.WriteLine("<a href=\"" + page_url + "/3" + url_options + "\">FGH</a> &nbsp; ");
                            }
                        }
                        else
                        {
                            Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">FGH</span> &nbsp; ");
                        }

                        if ((letters_appearing.Contains('i')) || (letters_appearing.Contains('j')) || (letters_appearing.Contains('k')))
                        {
                            if (current_page == 4)
                            {
                                Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">IJK</span> &nbsp; ");
                            }
                            else
                            {
                                Output.WriteLine("<a href=\"" + page_url + "/4" + url_options + "\">IJK</a> &nbsp; ");
                            }
                        }
                        else
                        {
                            Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">IJK</span> &nbsp; ");
                        }

                        if ((letters_appearing.Contains('l')) || (letters_appearing.Contains('m')) || (letters_appearing.Contains('n')))
                        {
                            if (current_page == 5)
                            {
                                Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">LMN</span> &nbsp; ");
                            }
                            else
                            {
                                Output.WriteLine("<a href=\"" + page_url + "/5" + url_options + "\">LMN</a> &nbsp; ");
                            }
                        }
                        else
                        {
                            Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">LMN</span> &nbsp; ");
                        }

                        if ((letters_appearing.Contains('o')) || (letters_appearing.Contains('p')) || (letters_appearing.Contains('q')))
                        {
                            if (current_page == 6)
                            {
                                Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">OPQ</span> &nbsp; ");
                            }
                            else
                            {
                                Output.WriteLine("<a href=\"" + page_url + "/6" + url_options + "\">OPQ</a> &nbsp; ");
                            }
                        }
                        else
                        {
                            Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">OPQ</span> &nbsp; ");
                        }

                        if ((letters_appearing.Contains('r')) || (letters_appearing.Contains('s')) || (letters_appearing.Contains('t')))
                        {
                            if (current_page == 7)
                            {
                                Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">RST</span> &nbsp; ");
                            }
                            else
                            {
                                Output.WriteLine("<a href=\"" + page_url + "/7" + url_options + "\">RST</a> &nbsp; ");
                            }
                        }
                        else
                        {
                            Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">RST</span> &nbsp; ");
                        }

                        if ((letters_appearing.Contains('u')) || (letters_appearing.Contains('v')) || (letters_appearing.Contains('w')))
                        {
                            if (current_page == 8)
                            {
                                Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">UVW</span> &nbsp; ");
                            }
                            else
                            {
                                Output.WriteLine("<a href=\"" + page_url + "/8" + url_options + "\">UVW</a> &nbsp; ");
                            }
                        }
                        else
                        {
                            Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">UVW</span> &nbsp; ");
                        }

                        if ((letters_appearing.Contains('x')) || (letters_appearing.Contains('y')) || (letters_appearing.Contains('z')))
                        {
                            if (current_page == 9)
                            {
                                Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">XYZ</span> &nbsp; ");
                            }
                            else
                            {
                                Output.WriteLine("<a href=\"" + page_url + "/9" + url_options + "\">XYZ</a> &nbsp; ");
                            }
                        }
                        else
                        {
                            Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\" >XYZ</span> &nbsp; ");
                        }

                        Output.WriteLine("</div>");

                        Output.WriteLine("<br />");
                        Output.WriteLine("<br />");



                        // Find the start character and last character, per the page
                        char first_char = ' ';
                        char stop_char  = 'c';
                        switch (current_page)
                        {
                        case 2:
                            first_char = 'c';
                            stop_char  = 'f';
                            break;

                        case 3:
                            first_char = 'f';
                            stop_char  = 'i';
                            break;

                        case 4:
                            first_char = 'i';
                            stop_char  = 'l';
                            break;

                        case 5:
                            first_char = 'l';
                            stop_char  = 'o';
                            break;

                        case 6:
                            first_char = 'o';
                            stop_char  = 'r';
                            break;

                        case 7:
                            first_char = 'r';
                            stop_char  = 'u';
                            break;

                        case 8:
                            first_char = 'u';
                            stop_char  = 'x';
                            break;

                        case 9:
                            first_char = 'x';
                            stop_char  = '}';
                            break;
                        }

                        // Add the pertinent rows
                        foreach (string thisValue in results)
                        {
                            if (thisValue.Length > 0)
                            {
                                char this_first_char = Char.ToLower(thisValue[0]);
                                if ((this_first_char >= first_char) && (this_first_char < stop_char))
                                {
                                    Output.WriteLine("<a href=\"" + search_url.Replace("%3c%25TERM%25%3e", thisValue.Trim().Replace(",", "%2C").Replace("&", "%26").Replace("\"", "%22")).Replace("&", "&amp;") + "\">" + thisValue.Replace("\"", "&quot;").Replace("&", "&amp;") + "</a><br />");
                                }
                            }
                        }
                    }
                    else
                    {
                        // Determine the first valid page
                        char label_char       = 'a';
                        int  first_valid_page = -1;
                        int  counter          = 1;
                        while (label_char <= 'z')
                        {
                            if (letters_appearing.Contains(label_char))
                            {
                                if (first_valid_page < 0)
                                {
                                    first_valid_page = counter;
                                }
                            }

                            counter++;
                            label_char = (char)((label_char) + 1);
                        }

                        // Define the limits of the page value
                        if ((current_page < first_valid_page) || (current_page > 26))
                        {
                            current_page = first_valid_page;
                        }


                        // Add the links for paging through results
                        label_char = 'a';
                        counter    = 1;
                        Output.WriteLine("<div class=\"sbkMebv_NavRow\">");
                        while (label_char <= 'z')
                        {
                            if (letters_appearing.Contains(label_char))
                            {
                                if (current_page == counter)
                                {
                                    Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">" + Char.ToUpper(label_char) + "</span>&nbsp;");
                                }
                                else
                                {
                                    Output.WriteLine("<a href=\"" + page_url + "/" + counter + url_options + "\" >" + Char.ToUpper(label_char) + "</a>&nbsp;");
                                }
                            }
                            else
                            {
                                Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\" >" + Char.ToUpper(label_char) + "</span>&nbsp;");
                            }

                            counter++;
                            label_char = (char)((label_char) + 1);
                        }
                        Output.WriteLine("</div>");

                        Output.WriteLine("<br />");
                        Output.WriteLine("<br />");

                        // Find the start character and last character, per the page
                        char first_char = ' ';
                        char stop_char  = 'b';
                        if (current_page > 1)
                        {
                            first_char = (char)(96 + current_page);
                            stop_char  = (char)(97 + current_page);
                        }


                        // Add the pertinent rows
                        foreach (string thisValue in results)
                        {
                            if (thisValue.Length > 0)
                            {
                                char this_first_char = Char.ToLower(thisValue[0]);
                                if ((this_first_char >= first_char) && (this_first_char < stop_char))
                                {
                                    Output.WriteLine("<a href=\"" + search_url.Replace("%3c%25TERM%25%3e", thisValue.Trim().Replace(",", "%2C").Replace("&", "%26").Replace("\"", "%22")).Replace("&", "&amp;") + "\">" + thisValue.Replace("\"", "&quot;").Replace("&", "&amp;") + "</a><br />");
                                }
                            }
                        }
                    }
                }
                else
                {
                    Output.WriteLine("<br /><br /><br /><br />");
                    Output.WriteLine(RequestSpecificValues.Current_Mode.Info_Browse_Mode.Length == 0 ? "<center>Select a metadata field to browse by from the list on the left</center>" : "<center>NO MATCHING VALUES</center>");
                    Output.WriteLine("<br /><br />");
                }
            }

            // Set the current mode back
            RequestSpecificValues.Current_Mode.Mode             = Display_Mode_Enum.Aggregation;
            RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Browse_By;

            Output.WriteLine("</div>");
            Output.WriteLine("<br />");

            if ((public_browses.Count > 1) || (internal_browses.Count > 0))
            {
                Output.WriteLine("</td>");
                Output.WriteLine("</tr>");
                Output.WriteLine("</table>");
            }
            Output.WriteLine();
        }
Beispiel #7
0
        /// <summary> Gets the static HTML_based content  associated with this browse/info file (if it is TEXT type )</summary>
        /// <param name="Language"> Language of the static-html request, used to find the appropriate source file </param>
        /// <param name="Base_URL"> Currently used Base URL to reach this system </param>
        /// <param name="Base_Network"> Base network location from which this static content would be located from </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        /// <returns> Static HTML-based content to read from a  html source file </returns>
        /// <remarks> This actually reads the HTML file each time this is requested </remarks>
        public HTML_Based_Content Get_Static_Content(Web_Language_Enum Language, string Base_URL, string Base_Network, Custom_Tracer Tracer)
        {
            if ((Data_Type != Result_Data_Type.Text) || (Source != Source_Type.Static_HTML) || (Source_Dictionary.Count == 0))
            {
                return(null);
            }

            // Get the source file name
            string sourceFile = Get_Static_HTML_Source(Language);

            if (sourceFile.Length == 0)
            {
                return(null);
            }

            if ((sourceFile.IndexOf("http://") < 0) && (sourceFile.IndexOf("<%BASEURL%>") < 0))
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("Item_Aggregation_Child_Page.Get_Static_Text", "Reading browse/info source file from a local directory");
                }

                sourceFile = Base_Network + sourceFile;

                try
                {
                    // Ensure the file exists
                    if (!System.IO.File.Exists(sourceFile))
                    {
                        return(new HTML_Based_Content("<div class=\"error_div\">INVALID OR MISSING BROWSE FILE '" + sourceFile + ".<br /><br />PLEASE CHECK YOUR URL.</div>", "ERROR: Missing File"));
                    }

                    // Read this file from the network
                    return(HTML_Based_Content_Reader.Read_HTML_File(sourceFile, true, Tracer));
                }
                catch (Exception ee)
                {
                    return(new HTML_Based_Content("<div class=\"error_div\">EXCEPTION CAUGHT WHILE TRYING TO READ THE BROWSE/INFO PAGE SOURCE FILE '" + sourceFile + "'.<br /><br />ERROR: " + ee.Message + "</div>", "ERROR: " + ee.Message));
                }
            }

            if (Tracer != null)
            {
                Tracer.Add_Trace("Item_Aggregation_Child_Page.Get_Static_Text", "Reading browse/info source file via http");
            }

            string actualUrl = sourceFile.Replace("<%BASEURL%>", Base_URL);

            try
            {
                // Read this file from the web
                return(HTML_Based_Content_Reader.Read_Web_Document(actualUrl, true, Tracer));
            }
            catch (Exception ee)
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("Item_Aggregation_Child_Page.Get_Static_Text", "Unable to read data from: " + actualUrl, Custom_Trace_Type_Enum.Error);
                }

                return(new HTML_Based_Content("<div class=\"error_div\">EXCEPTION CAUGHT WHILE TRYING TO READ THE BROWSE/INFO PAGE SOURCE FILE '" + actualUrl + "'.<br /><br />ERROR: " + ee.Message + "</div>", "ERROR: " + ee.Message));
            }
        }