/// <summary> Saves all the metadata types from the database, to be treated as constant settings /// for the period of time the web application functios </summary> /// <param name="SettingsObject"> Settings instance to be populated with the metadata types </param> /// <param name="MetadataTypesTable"> DataTable with all the possible metadata types, from the database </param> public static void Set_Metadata_Types(InstanceWide_Settings SettingsObject, DataTable MetadataTypesTable) { SettingsObject.Metadata_Search_Fields.Clear(); // Add ANYWHERE SettingsObject.Metadata_Search_Fields.Add(new Metadata_Search_Field(-1, String.Empty, "Anywhere", "ZZ", "all", "Anywhere")); // Add OCLC SettingsObject.Metadata_Search_Fields.Add(new Metadata_Search_Field(-2, String.Empty, "OCLC", "OC", "oclc", "OCLC")); // Add ALEPH SettingsObject.Metadata_Search_Fields.Add(new Metadata_Search_Field(-3, String.Empty, "ALEPH", "AL", "aleph", "ALEPH")); // Add Full Text SettingsObject.Metadata_Search_Fields.Add(new Metadata_Search_Field(-4, String.Empty, "Full Text", "TX", "fulltext", "Full Text")); // Get the data columns DataColumn idColumn = MetadataTypesTable.Columns["MetadataTypeID"]; DataColumn codeColumn = MetadataTypesTable.Columns["SobekCode"]; DataColumn displayColumn = MetadataTypesTable.Columns["DisplayTerm"]; DataColumn facetColumn = MetadataTypesTable.Columns["FacetTerm"]; DataColumn solrColumn = MetadataTypesTable.Columns["SolrCode"]; DataColumn nameColumn = MetadataTypesTable.Columns["MetadataName"]; // Now add the rest of the fields foreach (DataRow thisRow in MetadataTypesTable.Rows) { // Only add here if there is a sobek code if (thisRow[codeColumn] == DBNull.Value) { continue; } // Retrieve each individual value short id = Convert.ToInt16(thisRow[idColumn]); string code = thisRow[codeColumn].ToString().Trim(); string display = thisRow[displayColumn].ToString(); string facet = thisRow[facetColumn].ToString(); string solr = thisRow[solrColumn].ToString(); string name = thisRow[nameColumn].ToString(); // Also, only continue if the name is NOT user defined if (name.IndexOf("UserDefined", StringComparison.OrdinalIgnoreCase) == 0) { continue; } // Create the new field object Metadata_Search_Field newField = new Metadata_Search_Field(id, facet, display, code, solr, name); // Add this to the collections SettingsObject.Metadata_Search_Fields.Add(newField); } }
/// <summary> Saves all the metadata types from the database, to be treated as constant settings /// for the period of time the web application functios </summary> /// <param name="MetadataTypesTable"> DataTable with all the possible metadata types, from the database </param> public static void Set_Metadata_Types(DataTable MetadataTypesTable) { lock (thisLock) { // Add ANYWHERE Metadata_Search_Field anywhere = new Metadata_Search_Field(-1, "INVALID", "Anywhere", "ZZ", "all"); metadataFields.Add(anywhere); metadataFieldsByCode["ZZ"] = anywhere; metadataFieldsByID[-1] = anywhere; // Add OCLC Metadata_Search_Field oclc = new Metadata_Search_Field(-1, "INVALID", "OCLC", "OC", "oclc"); metadataFieldsByCode["OC"] = oclc; // Add ALEPH Metadata_Search_Field aleph = new Metadata_Search_Field(-1, "INVALID", "ALEPH", "AL", "aleph"); metadataFieldsByCode["AL"] = aleph; // Add Full Text Metadata_Search_Field fulltext = new Metadata_Search_Field(-1, "INVALID", "Full Text", "TX", "fulltext"); metadataFieldsByCode["TX"] = fulltext; // Get the data columns DataColumn idColumn = MetadataTypesTable.Columns["MetadataTypeID"]; DataColumn nameColumn = MetadataTypesTable.Columns["MetadataName"]; DataColumn codeColumn = MetadataTypesTable.Columns["SobekCode"]; DataColumn displayColumn = MetadataTypesTable.Columns["DisplayTerm"]; DataColumn facetColumn = MetadataTypesTable.Columns["FacetTerm"]; DataColumn solrColumn = MetadataTypesTable.Columns["SolrCode"]; // Now add the rest of the fields foreach (DataRow thisRow in MetadataTypesTable.Rows) { // Only add here if there is a sobek code if (thisRow[codeColumn] != DBNull.Value) { // Retrieve each individual value short id = Convert.ToInt16(thisRow[idColumn]); string name = thisRow[nameColumn].ToString(); string code = thisRow[codeColumn].ToString(); string display = thisRow[displayColumn].ToString(); string facet = thisRow[facetColumn].ToString(); string solr = thisRow[solrColumn].ToString(); // Create the new field object Metadata_Search_Field newField = new Metadata_Search_Field(id, facet, display, code, solr); // Add this to the collections metadataFields.Add(newField); metadataFieldsByCode[code] = newField; metadataFieldsByID[id] = newField; } } } }
/// <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("&", "&"); } 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> Public Browses</b><br />" : "<b> 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("&", "&") + "\">" + 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("&", "&") + "\">" + 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> 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("&", "&") + "\">" + 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("&", "&")) + "\">" + thisResult.Replace("\"", """).Replace("&", "&") + "</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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/1" + url_options + "\" class=\"mbb1\">AB</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">AB</span> "); } 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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/2" + url_options + "\">CDE</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">CDE</span> "); } 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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/3" + url_options + "\">FGH</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">FGH</span> "); } 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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/4" + url_options + "\">IJK</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">IJK</span> "); } 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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/5" + url_options + "\">LMN</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">LMN</span> "); } 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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/6" + url_options + "\">OPQ</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">OPQ</span> "); } 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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/7" + url_options + "\">RST</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">RST</span> "); } 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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/8" + url_options + "\">UVW</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">UVW</span> "); } 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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/9" + url_options + "\">XYZ</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\" >XYZ</span> "); } 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("&", "&") + "\">" + thisValue.Replace("\"", """).Replace("&", "&") + "</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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/" + counter + url_options + "\" >" + Char.ToUpper(label_char) + "</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\" >" + Char.ToUpper(label_char) + "</span> "); } 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("&", "&") + "\">" + thisValue.Replace("\"", """).Replace("&", "&") + "</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(); }
/// <summary> Adds the controls for this result viewer to the place holder on the main form </summary> /// <param name="MainPlaceHolder"> Main place holder ( "mainPlaceHolder" ) in the itemNavForm form into which the the bulk of the result viewer's output is displayed</param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <returns> Sorted tree with the results in hierarchical structure with volumes and issues under the titles and sorted by serial hierarchy </returns> public override void Add_HTML(PlaceHolder MainPlaceHolder, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("Thumbnail_ResultsWriter.Add_HTML", "Rendering results in thumbnail view"); } // If results are null, or no results, return empty string if ((Paged_Results == null) || (Results_Statistics == null) || (Results_Statistics.Total_Items <= 0)) { return; } // Get the text search redirect stem and (writer-adjusted) base url string textRedirectStem = Text_Redirect_Stem; string base_url = CurrentMode.Base_URL; if (CurrentMode.Writer_Type == Writer_Type_Enum.HTML_LoggedIn) { base_url = CurrentMode.Base_URL + "l/"; } // Should the publication date be shown? bool showDate = false; if (CurrentMode.Sort >= 10) { showDate = true; } // Start this table StringBuilder resultsBldr = new StringBuilder(5000); //Add the necessary JavaScript, CSS files //resultsBldr.AppendLine("<script type=\"text/javascript\" src=\"" + CurrentMode.Base_URL + "default/scripts/jquery/jquery-1.10.2.min.js\"></script>"); //resultsBldr.AppendLine("<script type=\"text/javascript\" src=\"" + CurrentMode.Base_URL + "default/scripts/jquery/jquery.qtip.min.js\"></script>"); //resultsBldr.AppendLine(" <link rel=\"stylesheet\" type=\"text/css\" href=\"" + CurrentMode.Base_URL + "default/scripts/jquery/jquery.qtip.min.css\" /> "); // resultsBldr.AppendLine("<script type=\"text/javascript\" src=\"" + CurrentMode.Base_URL + "default/scripts/jquery/jquery-ui-1.10.1.js\"></script>"); resultsBldr.AppendLine(" <script type=\"text/javascript\" src=\"" + CurrentMode.Base_URL + "default/scripts/sobekcm_thumb_results.js\"></script>"); // Start this table resultsBldr.AppendLine("<table align=\"center\" width=\"100%\" cellspacing=\"15px\">"); resultsBldr.AppendLine("\t<tr>"); resultsBldr.AppendLine("\t\t<td width=\"25%\"> </td>"); resultsBldr.AppendLine("\t\t<td width=\"25%\"> </td>"); resultsBldr.AppendLine("\t\t<td width=\"25%\"> </td>"); resultsBldr.AppendLine("\t\t<td width=\"25%\"> </td>"); resultsBldr.AppendLine("\t</tr>"); resultsBldr.AppendLine("\t<tr valign=\"top\">"); // Step through all the results int col = 0; int title_count = 0; foreach (iSearch_Title_Result titleResult in Paged_Results) { title_count++; // Should a new row be started if (col == 4) { col = 0; resultsBldr.AppendLine("\t</tr>"); // Horizontal Line resultsBldr.AppendLine("\t<tr><td bgcolor=\"#e7e7e7\" colspan=\"4\"></td></tr>"); resultsBldr.AppendLine("\t<tr valign=\"top\">"); } bool multiple_title = titleResult.Item_Count > 1; // Always get the first item for things like the main link and thumbnail iSearch_Item_Result firstItemResult = titleResult.Get_Item(0); // Determine the internal link to the first (possibly only) item string internal_link = base_url + titleResult.BibID + "/" + firstItemResult.VID + textRedirectStem; // For browses, just point to the title if ((CurrentMode.Mode == Display_Mode_Enum.Aggregation) && (CurrentMode.Aggregation_Type == Aggregation_Type_Enum.Browse_Info)) { internal_link = base_url + titleResult.BibID + textRedirectStem; } resultsBldr.AppendLine("\t\t<td align=\"center\" onmouseover=\"this.className='tableRowHighlight'\" onmouseout=\"this.className='tableRowNormal'\" onclick=\"window.location.href='" + internal_link + "';\" >"); string title; if (multiple_title) { // Determine term to use string multi_term = "volume"; if (titleResult.MaterialType.ToUpper() == "NEWSPAPER") { multi_term = titleResult.Item_Count > 1 ? "issues" : "issue"; } else { if (titleResult.Item_Count > 1) { multi_term = "volumes"; } } if ((showDate)) { if (firstItemResult.PubDate.Length > 0) { title = "[" + firstItemResult.PubDate + "] " + titleResult.GroupTitle; } else { title = titleResult.GroupTitle; } } else { title = titleResult.GroupTitle + "<br />( " + titleResult.Item_Count + " " + multi_term + " )"; } } else { if (showDate) { if (firstItemResult.PubDate.Length > 0) { title = "[" + firstItemResult.PubDate + "] " + firstItemResult.Title; } else { title = firstItemResult.Title; } } else { title = firstItemResult.Title; } } // Start the HTML for this item resultsBldr.AppendLine("<table width=\"150px\">"); //// Is this restricted? bool restricted_by_ip = false; if ((titleResult.Item_Count == 1) && (firstItemResult.IP_Restriction_Mask > 0)) { int comparison = firstItemResult.IP_Restriction_Mask & current_user_mask; if (comparison == 0) { restricted_by_ip = true; } } // Calculate the thumbnail // Add the thumbnail if ((firstItemResult.MainThumbnail.ToUpper().IndexOf(".JPG") < 0) && (firstItemResult.MainThumbnail.ToUpper().IndexOf(".GIF") < 0)) { resultsBldr.AppendLine("<tr><td><span id=\"sbkThumbnailSpan" + title_count + "\"><a href=\"" + internal_link + "\"><img id=\"sbkThumbnailImg" + title_count + "\" src=\"" + CurrentMode.Default_Images_URL + "NoThumb.jpg\" /></a></span></td></tr>"); } else { string thumb = SobekCM_Library_Settings.Image_URL + titleResult.BibID.Substring(0, 2) + "/" + titleResult.BibID.Substring(2, 2) + "/" + titleResult.BibID.Substring(4, 2) + "/" + titleResult.BibID.Substring(6, 2) + "/" + titleResult.BibID.Substring(8) + "/" + firstItemResult.VID + "/" + (firstItemResult.MainThumbnail).Replace("\\", "/").Replace("//", "/"); resultsBldr.AppendLine("<tr><td><span id=\"sbkThumbnailSpan" + title_count + "\"><a href=\"" + internal_link + "\"><img id=\"sbkThumbnailImg" + title_count + "\"src=\"" + thumb + "\" alt=\"MISSING THUMBNAIL\" /></a></span></td></tr>"); } #region Add the div displayed as a tooltip for this thumbnail on hover const string VARIES_STRING = "<span style=\"color:Gray\">( varies )</span>"; //Add the hidden item values for display in the tooltip resultsBldr.AppendLine("<tr style=\"display:none;\"><td colspan=\"100%\"><div id=\"descThumbnail" + title_count + "\" >"); // Add each element to this table resultsBldr.AppendLine("\t\t\t<table cellspacing=\"0px\">"); if (multiple_title) { //<a href=\"" + internal_link + "\"> resultsBldr.AppendLine("\t\t\t\t<tr style=\"height:40px;\" valign=\"middle\"><td colspan=\"3\"><span class=\"qtip_BriefTitle\" style=\"color: #a5a5a5;font-weight: bold;font-size:13px;\">" + titleResult.GroupTitle.Replace("<", "<").Replace(">", ">") + "</span> </td></tr>"); resultsBldr.AppendLine("<tr><td colspan=\"100%\"><br/></td></tr>"); } else { resultsBldr.AppendLine( "\t\t\t\t<tr style=\"height:40px;\" valign=\"middle\"><td colspan=\"3\"><span class=\"qtip_BriefTitle\" style=\"color: #a5a5a5;font-weight: bold;font-size:13px;\">" + firstItemResult.Title.Replace("<", "<").Replace(">", ">") + "</span> </td></tr><br/>"); resultsBldr.AppendLine("<tr><td colspan=\"100%\"><br/></td></tr>"); } if ((titleResult.Primary_Identifier_Type.Length > 0) && (titleResult.Primary_Identifier.Length > 0)) { resultsBldr.AppendLine("\t\t\t\t<tr><td>" + Translator.Get_Translation(titleResult.Primary_Identifier_Type, CurrentMode.Language) + ":</td><td> </td><td>" + System.Web.HttpUtility.HtmlDecode(titleResult.Primary_Identifier) + "</td></tr>"); } if (CurrentMode.Internal_User) { resultsBldr.AppendLine("\t\t\t\t<tr><td>BibID:</td><td> </td><td>" + titleResult.BibID + "</td></tr>"); if (titleResult.OPAC_Number > 1) { resultsBldr.AppendLine("\t\t\t\t<tr><td>OPAC:</td><td> </td><td>" + titleResult.OPAC_Number + "</td></tr>"); } if (titleResult.OCLC_Number > 1) { resultsBldr.AppendLine("\t\t\t\t<tr><td>OCLC:</td><td> </td><td>" + titleResult.OCLC_Number + "</td></tr>"); } } for (int i = 0; i < Results_Statistics.Metadata_Labels.Count; i++) { string field = Results_Statistics.Metadata_Labels[i]; string value = titleResult.Metadata_Display_Values[i]; Metadata_Search_Field thisField = SobekCM_Library_Settings.Metadata_Search_Field_By_Name(field); string display_field = string.Empty; if (thisField != null) { display_field = thisField.Display_Term; } if (display_field.Length == 0) { display_field = field.Replace("_", " "); } if (value == "*") { resultsBldr.AppendLine("\t\t\t\t<tr><td>" + Translator.Get_Translation(display_field, CurrentMode.Language) + ":</td><td> </td><td>" + System.Web.HttpUtility.HtmlDecode(VARIES_STRING) + "</td></tr>"); } else if (value.Trim().Length > 0) { if (value.IndexOf("|") > 0) { bool value_found = false; string[] value_split = value.Split("|".ToCharArray()); foreach (string thisValue in value_split) { if (thisValue.Trim().Trim().Length > 0) { if (!value_found) { resultsBldr.AppendLine("\t\t\t\t<tr valign=\"top\"><td>" + Translator.Get_Translation(display_field, CurrentMode.Language) + ":</td><td> </td><td>"); value_found = true; } resultsBldr.Append(System.Web.HttpUtility.HtmlDecode(thisValue) + "<br />"); } } if (value_found) { resultsBldr.AppendLine("</td></tr>"); } } else { resultsBldr.AppendLine("\t\t\t\t<tr><td>" + Translator.Get_Translation(display_field, CurrentMode.Language) + ":</td><td> </td><td>" + System.Web.HttpUtility.HtmlDecode(value) + "</td></tr>"); } } } if (titleResult.Snippet.Length > 0) { resultsBldr.AppendLine("\t\t\t\t<tr><td colspan=\"3\"><br />“..." + titleResult.Snippet.Replace("<em>", "<span class=\"texthighlight\">").Replace("</em>", "</span>") + "...”</td></tr>"); } resultsBldr.AppendLine("\t\t\t</table>"); // End this row // resultsBldr.AppendLine("\t\t<br />"); //// Add children, if there are some //if (multiple_title) //{ // // Add this to the place holder // Literal thisLiteral = new Literal // { Text = resultsBldr.ToString().Replace("<role>", "<i>").Replace( "</role>", "</i>") }; // MainPlaceHolder.Controls.Add(thisLiteral); // resultsBldr.Remove(0, resultsBldr.Length); // Add_Issue_Tree(MainPlaceHolder, titleResult, current_row, textRedirectStem, base_url); //} //resultsBldr.AppendLine("\t\t</td>"); //resultsBldr.AppendLine("\t</tr>"); // Add a horizontal line // resultsBldr.AppendLine("\t<tr><td bgcolor=\"#e7e7e7\" colspan=\"3\"></td></tr>"); // End this table // resultsBldr.AppendLine("</table>"); resultsBldr.AppendLine("</div></td></tr>"); #endregion // Add the title resultsBldr.AppendLine("<tr><td align=\"center\"><span class=\"SobekThumbnailText\">" + title + "</span></td></tr>"); // If this was access restricted, add that if (restricted_by_ip) { resultsBldr.AppendLine("<tr><td align=\"center\"><span class=\"RestrictedItemText\">Access Restricted</span></td></tr>"); } // Finish this one thumbnail resultsBldr.AppendLine("</table></td>"); col++; } // Finish this row out while (col < 4) { resultsBldr.AppendLine("\t\t<td> </td>"); col++; } // End this table resultsBldr.AppendLine("\t</tr>"); resultsBldr.AppendLine("</table>"); // Add this to the html table Literal mainLiteral = new Literal { Text = resultsBldr.ToString() }; MainPlaceHolder.Controls.Add(mainLiteral); }
/// <summary> Adds the controls for this result viewer to the place holder on the main form </summary> /// <param name="MainPlaceHolder"> Main place holder ( "mainPlaceHolder" ) in the itemNavForm form into which the the bulk of the result viewer's output is displayed</param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <returns> Sorted tree with the results in hierarchical structure with volumes and issues under the titles and sorted by serial hierarchy </returns> public override void Add_HTML(PlaceHolder MainPlaceHolder, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("Brief_ResultsWriter.Add_HTML", "Rendering results in brief view"); } // If results are null, or no results, return empty string if ((PagedResults == null) || (ResultsStats == null) || (ResultsStats.Total_Items <= 0)) { return; } const string VARIES_STRING = "<span style=\"color:Gray\">( varies )</span>"; // Get the text search redirect stem and (writer-adjusted) base url string textRedirectStem = Text_Redirect_Stem; string base_url = RequestSpecificValues.Current_Mode.Base_URL; if (RequestSpecificValues.Current_Mode.Writer_Type == Writer_Type_Enum.HTML_LoggedIn) { base_url = RequestSpecificValues.Current_Mode.Base_URL + "l/"; } // Start the results StringBuilder resultsBldr = new StringBuilder(2000); resultsBldr.AppendLine("<section class=\"sbkBrv_Results\">"); // Set the counter for these results from the page int current_page = RequestSpecificValues.Current_Mode.Page.HasValue ? RequestSpecificValues.Current_Mode.Page.Value : 1; int result_counter = ((current_page - 1) * Results_Per_Page) + 1; Tracer.Add_Trace("Brief_ResultsViewer.Add_HTML", "There are [" + PagedResults.Count + "] results @ [" + Results_Per_Page + "] per page."); // Step through all the results int current_row = 0; foreach (iSearch_Title_Result titleResult in PagedResults) { bool multiple_title = titleResult.Item_Count > 1; // Always get the first item for things like the main link and thumbnail iSearch_Item_Result firstItemResult = titleResult.Get_Item(0); // Determine the internal link to the first (possibly only) item string internal_link = base_url + titleResult.BibID + "/" + firstItemResult.VID + textRedirectStem; // For browses, just point to the title if (RequestSpecificValues.Current_Mode.Mode == Display_Mode_Enum.Aggregation) // browse info only { internal_link = base_url + titleResult.BibID + "/" + firstItemResult.VID + textRedirectStem; } // Start this row string title = firstItemResult.Title.Replace("<", "<").Replace(">", ">"); if (multiple_title) { title = titleResult.GroupTitle.Replace("<", "<").Replace(">", ">"); resultsBldr.AppendLine("\t<section class=\"sbkBrv_SingleResult\">"); } else { resultsBldr.AppendLine("\t<section class=\"sbkBrv_SingleResult\" onclick=\"window.location.href='" + internal_link.Replace("'", "\\'") + "';\" >"); } // Add the counter as the first column resultsBldr.AppendLine("\t\t<div class=\"sbkBrv_SingleResultNum\">" + result_counter + "</div>"); resultsBldr.Append("\t\t<div class=\"sbkBrv_SingleResultThumb\">"); //// Is this restricted? bool restricted_by_ip = false; if ((titleResult.Item_Count == 1) && (firstItemResult.IP_Restriction_Mask > 0)) { int comparison = firstItemResult.IP_Restriction_Mask & CurrentUserMask; if (comparison == 0) { restricted_by_ip = true; } } // Calculate the thumbnail string thumb = titleResult.BibID.Substring(0, 2) + "/" + titleResult.BibID.Substring(2, 2) + "/" + titleResult.BibID.Substring(4, 2) + "/" + titleResult.BibID.Substring(6, 2) + "/" + titleResult.BibID.Substring(8) + "/" + firstItemResult.VID + "/" + (firstItemResult.MainThumbnail).Replace("\\", "/").Replace("//", "/"); // Draw the thumbnail if ((thumb.ToUpper().IndexOf(".JPG") < 0) && (thumb.ToUpper().IndexOf(".GIF") < 0)) { resultsBldr.AppendLine("<a href=\"" + internal_link + "\"><img src=\"" + Static_Resources_Gateway.Nothumb_Jpg + "\" border=\"0px\" class=\"resultsThumbnail\" alt=\"MISSING THUMBNAIL\" /></a></div>"); } else { resultsBldr.AppendLine("<a href=\"" + internal_link + "\"><img src=\"" + UI_ApplicationCache_Gateway.Settings.Servers.Image_URL + thumb + "\" class=\"resultsThumbnail\" alt=\"" + title.Replace("\"", "") + "\" /></a></div>"); } resultsBldr.AppendLine("\t\t<div class=\"sbkBrv_SingleResultDesc\">"); // If this was access restricted, add that if (restricted_by_ip) { resultsBldr.AppendLine("\t\t\t<span class=\"RestrictedItemText\">" + UI_ApplicationCache_Gateway.Translation.Get_Translation("Access Restricted", RequestSpecificValues.Current_Mode.Language) + "</span>"); } if (multiple_title) { resultsBldr.AppendLine("\t\t\t<span class=\"briefResultsTitle\"><a href=\"" + internal_link + "\">" + titleResult.GroupTitle.Replace("<", "<").Replace(">", ">") + "</a></span>"); } else { resultsBldr.AppendLine( "\t\t\t<span class=\"briefResultsTitle\"><a href=\"" + internal_link + "\" onclick=\"cancelPropagation(event);\">" + firstItemResult.Title.Replace("<", "<").Replace(">", ">") + "</a></span>"); } // Add each element to this table resultsBldr.AppendLine("\t\t\t<dl class=\"sbkBrv_SingleResultDescList\">"); if ((!String.IsNullOrEmpty(titleResult.Primary_Identifier_Type)) && (!String.IsNullOrEmpty(titleResult.Primary_Identifier))) { resultsBldr.AppendLine("\t\t\t\t<dt>" + UI_ApplicationCache_Gateway.Translation.Get_Translation(titleResult.Primary_Identifier_Type, RequestSpecificValues.Current_Mode.Language) + ":</dt><dd>" + titleResult.Primary_Identifier + "</dd>"); } if ((RequestSpecificValues.Current_User != null) && (RequestSpecificValues.Current_User.LoggedOn) && (RequestSpecificValues.Current_User.Is_Internal_User)) { resultsBldr.AppendLine("\t\t\t\t<dt>BibID:</dt><dd>" + titleResult.BibID + "</dd>"); if (titleResult.OPAC_Number > 1) { resultsBldr.AppendLine("\t\t\t\t<dt>OPAC:</dt><dd>" + titleResult.OPAC_Number + "</dd>"); } if (titleResult.OCLC_Number > 1) { resultsBldr.AppendLine("\t\t\t\t<dt>OCLC:</dt><dd>" + titleResult.OCLC_Number + "</dd>"); } } for (int i = 0; i < ResultsStats.Metadata_Labels.Count; i++) { string field = ResultsStats.Metadata_Labels[i]; // Somehow the metadata for this item did not fully save in the database. Break out, rather than // throw the exception if ((titleResult.Metadata_Display_Values == null) || (titleResult.Metadata_Display_Values.Length <= i)) { break; } string value = titleResult.Metadata_Display_Values[i]; Metadata_Search_Field thisField = UI_ApplicationCache_Gateway.Settings.Metadata_Search_Field_By_Name(field); string display_field = string.Empty; if (thisField != null) { display_field = thisField.Display_Term; } if (display_field.Length == 0) { display_field = field.Replace("_", " "); } if (value == "*") { resultsBldr.AppendLine("\t\t\t\t<dt>" + UI_ApplicationCache_Gateway.Translation.Get_Translation(display_field, RequestSpecificValues.Current_Mode.Language) + ":</dt><dd>" + HttpUtility.HtmlDecode(VARIES_STRING) + "</dd>"); } else if (value.Trim().Length > 0) { if (value.IndexOf("|") > 0) { bool value_found = false; string[] value_split = value.Split("|".ToCharArray()); foreach (string thisValue in value_split) { if (thisValue.Trim().Trim().Length > 0) { if (!value_found) { resultsBldr.Append("\t\t\t\t<dt>" + UI_ApplicationCache_Gateway.Translation.Get_Translation(display_field, RequestSpecificValues.Current_Mode.Language) + ":</dt>"); value_found = true; } resultsBldr.Append("<dd>" + HttpUtility.HtmlDecode(thisValue) + "</dd>"); } } if (value_found) { resultsBldr.AppendLine(); } } else { resultsBldr.AppendLine("\t\t\t\t<dt>" + UI_ApplicationCache_Gateway.Translation.Get_Translation(display_field, RequestSpecificValues.Current_Mode.Language) + ":</dt><dd>" + HttpUtility.HtmlDecode(value) + "</dd>"); } } } resultsBldr.AppendLine("\t\t\t</dl>"); if (!String.IsNullOrEmpty(titleResult.Snippet)) { resultsBldr.AppendLine("\t\t\t<div class=\"sbkBrv_SearchResultSnippet\">“..." + titleResult.Snippet.Replace("<em>", "<span class=\"texthighlight\">").Replace("</em>", "</span>") + "...”</div>"); } // Add children, if there are some if (multiple_title) { // Add this to the place holder Literal thisLiteral = new Literal { Text = resultsBldr.ToString().Replace("<role>", "<i>").Replace("</role>", "</i>") }; MainPlaceHolder.Controls.Add(thisLiteral); resultsBldr.Remove(0, resultsBldr.Length); Add_Issue_Tree(MainPlaceHolder, titleResult, current_row, textRedirectStem, base_url); } resultsBldr.AppendLine("\t\t</div>"); resultsBldr.AppendLine("\t</section>"); resultsBldr.AppendLine(); // Increment the result counters result_counter++; current_row++; } // End this table resultsBldr.AppendLine("</section>"); // Add this to the HTML page Literal mainLiteral = new Literal { Text = resultsBldr.ToString().Replace("<role>", "<i>").Replace("</role>", "</i>") }; MainPlaceHolder.Controls.Add(mainLiteral); }
/// <summary> Adds the controls for this result viewer to the place holder on the main form </summary> /// <param name="MainPlaceHolder"> Main place holder ( "mainPlaceHolder" ) in the itemNavForm form into which the the bulk of the result viewer's output is displayed</param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <returns> Sorted tree with the results in hierarchical structure with volumes and issues under the titles and sorted by serial hierarchy </returns> public override void Add_HTML(PlaceHolder MainPlaceHolder, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("Brief_ResultsWriter.Add_HTML", "Rendering results in brief view"); } // If results are null, or no results, return empty string if ((Paged_Results == null) || (Results_Statistics == null) || (Results_Statistics.Total_Items <= 0)) { return; } const string VARIES_STRING = "<span style=\"color:Gray\">( varies )</span>"; // Get the text search redirect stem and (writer-adjusted) base url string textRedirectStem = Text_Redirect_Stem; string base_url = CurrentMode.Base_URL; if (CurrentMode.Writer_Type == Writer_Type_Enum.HTML_LoggedIn) { base_url = CurrentMode.Base_URL + "l/"; } // Start the results StringBuilder resultsBldr = new StringBuilder(2000); resultsBldr.AppendLine("<br />"); resultsBldr.AppendLine("<table>"); // Set the counter for these results from the page int result_counter = ((CurrentMode.Page - 1) * Results_Per_Page) + 1; // Step through all the results int current_row = 0; foreach (iSearch_Title_Result titleResult in Paged_Results) { bool multiple_title = titleResult.Item_Count > 1; // Always get the first item for things like the main link and thumbnail iSearch_Item_Result firstItemResult = titleResult.Get_Item(0); // Determine the internal link to the first (possibly only) item string internal_link = base_url + titleResult.BibID + "/" + firstItemResult.VID + textRedirectStem; // For browses, just point to the title if (CurrentMode.Mode == Display_Mode_Enum.Aggregation) // browse info only { internal_link = base_url + titleResult.BibID + textRedirectStem; } // Start this row if (multiple_title) { resultsBldr.AppendLine("\t<tr valign=\"top\" onmouseover=\"this.className='tableRowHighlight'\" onmouseout=\"this.className='tableRowNormal'\" >"); } else { resultsBldr.AppendLine("\t<tr valign=\"top\" onmouseover=\"this.className='tableRowHighlight'\" onmouseout=\"this.className='tableRowNormal'\" onclick=\"window.location.href='" + internal_link + "';\" >"); } // Add the counter as the first column resultsBldr.AppendLine("\t\t<td><br /><b>" + result_counter + "</b></td>\t\t<td valign=\"top\" width=\"150\">"); //// Is this restricted? bool restricted_by_ip = false; if ((titleResult.Item_Count == 1) && (firstItemResult.IP_Restriction_Mask > 0)) { int comparison = firstItemResult.IP_Restriction_Mask & current_user_mask; if (comparison == 0) { restricted_by_ip = true; } } // Calculate the thumbnail string thumb = titleResult.BibID.Substring(0, 2) + "/" + titleResult.BibID.Substring(2, 2) + "/" + titleResult.BibID.Substring(4, 2) + "/" + titleResult.BibID.Substring(6, 2) + "/" + titleResult.BibID.Substring(8) + "/" + firstItemResult.VID + "/" + (firstItemResult.MainThumbnail).Replace("\\", "/").Replace("//", "/"); // Draw the thumbnail if ((thumb.ToUpper().IndexOf(".JPG") < 0) && (thumb.ToUpper().IndexOf(".GIF") < 0)) { resultsBldr.AppendLine("<a href=\"" + internal_link + "\"><img src=\"" + CurrentMode.Default_Images_URL + "NoThumb.jpg\" border=\"0px\" class=\"resultsThumbnail\" alt=\"MISSING THUMBNAIL\" /></a></td>"); } else { resultsBldr.AppendLine("<a href=\"" + internal_link + "\"><img src=\"" + SobekCM_Library_Settings.Image_URL + thumb + "\" class=\"resultsThumbnail\" alt=\"MISSING THUMBNAIL\" /></a></td>"); } resultsBldr.AppendLine("\t\t<td>"); // If this was access restricted, add that if (restricted_by_ip) { resultsBldr.AppendLine("<span class=\"RestrictedItemText\">" + Translator.Get_Translation("Access Restricted", CurrentMode.Language) + "</span>"); } // Add each element to this table resultsBldr.AppendLine("\t\t\t<table cellspacing=\"0px\">"); if (multiple_title) { resultsBldr.AppendLine("\t\t\t\t<tr style=\"height:40px;\" valign=\"middle\"><td colspan=\"3\"><span class=\"briefResultsTitle\"><a href=\"" + internal_link + "\">" + titleResult.GroupTitle.Replace("<", "<").Replace(">", ">") + "</a></span> </td></tr>"); } else { resultsBldr.AppendLine( "\t\t\t\t<tr style=\"height:40px;\" valign=\"middle\"><td colspan=\"3\"><span class=\"briefResultsTitle\"><a href=\"" + internal_link + "\">" + firstItemResult.Title.Replace("<", "<").Replace(">", ">") + "</a></span> </td></tr>"); } if ((titleResult.Primary_Identifier_Type.Length > 0) && (titleResult.Primary_Identifier.Length > 0)) { resultsBldr.AppendLine("\t\t\t\t<tr><td>" + Translator.Get_Translation(titleResult.Primary_Identifier_Type, CurrentMode.Language) + ":</td><td> </td><td>" + titleResult.Primary_Identifier + "</td></tr>"); } if (CurrentMode.Internal_User) { resultsBldr.AppendLine("\t\t\t\t<tr><td>BibID:</td><td> </td><td>" + titleResult.BibID + "</td></tr>"); if (titleResult.OPAC_Number > 1) { resultsBldr.AppendLine("\t\t\t\t<tr><td>OPAC:</td><td> </td><td>" + titleResult.OPAC_Number + "</td></tr>"); } if (titleResult.OCLC_Number > 1) { resultsBldr.AppendLine("\t\t\t\t<tr><td>OCLC:</td><td> </td><td>" + titleResult.OCLC_Number + "</td></tr>"); } } for (int i = 0; i < Results_Statistics.Metadata_Labels.Count; i++) { string field = Results_Statistics.Metadata_Labels[i]; string value = titleResult.Metadata_Display_Values[i]; Metadata_Search_Field thisField = SobekCM_Library_Settings.Metadata_Search_Field_By_Name(field); string display_field = string.Empty; if (thisField != null) { display_field = thisField.Display_Term; } if (display_field.Length == 0) { display_field = field.Replace("_", " "); } if (value == "*") { resultsBldr.AppendLine("\t\t\t\t<tr><td>" + Translator.Get_Translation(display_field, CurrentMode.Language) + ":</td><td> </td><td>" + System.Web.HttpUtility.HtmlDecode(VARIES_STRING) + "</td></tr>"); } else if (value.Trim().Length > 0) { if (value.IndexOf("|") > 0) { bool value_found = false; string[] value_split = value.Split("|".ToCharArray()); foreach (string thisValue in value_split) { if (thisValue.Trim().Trim().Length > 0) { if (!value_found) { resultsBldr.AppendLine("\t\t\t\t<tr valign=\"top\"><td>" + Translator.Get_Translation(display_field, CurrentMode.Language) + ":</td><td> </td><td>"); value_found = true; } resultsBldr.Append(System.Web.HttpUtility.HtmlDecode(thisValue) + "<br />"); } } if (value_found) { resultsBldr.AppendLine("</td></tr>"); } } else { resultsBldr.AppendLine("\t\t\t\t<tr><td>" + Translator.Get_Translation(display_field, CurrentMode.Language) + ":</td><td> </td><td>" + System.Web.HttpUtility.HtmlDecode(value) + "</td></tr>"); } } } //if (titleResult.Author.Length > 0) //{ // string creatorString = "Author"; // if (titleResult.MaterialType.ToUpper().IndexOf("ARTIFACT") == 0) // { // creatorString = "Creator"; // } // if (titleResult.Author == "*") // { // resultsBldr.AppendLine("\t\t\t\t<tr><td>" + Translator.Get_Translation(creatorString, CurrentMode.Language) + ":</td><td> </td><td>" + VARIES_STRING + "</td></tr>"); // } // else // { // bool author_found = false; // string[] author_split = titleResult.Author.Split("|".ToCharArray()); // foreach (string thisAuthor in author_split) // { // if (thisAuthor.ToUpper().IndexOf("PUBLISHER") < 0) // { // if (!author_found) // { // resultsBldr.AppendLine("\t\t\t\t<tr valign=\"top\"><td>" +Translator.Get_Translation(creatorString, CurrentMode.Language) + ":</td><td> </td><td>"); // author_found = true; // } // resultsBldr.Append(thisAuthor + "<br />"); // } // } // if (author_found) // { // resultsBldr.AppendLine("</td></tr>"); // } // } //} if (titleResult.Snippet.Length > 0) { resultsBldr.AppendLine("\t\t\t\t<tr><td colspan=\"3\"><br />“..." + titleResult.Snippet.Replace("<em>", "<span class=\"texthighlight\">").Replace("</em>", "</span>") + "...”</td></tr>"); } resultsBldr.AppendLine("\t\t\t</table>"); // End this row resultsBldr.AppendLine("\t\t<br />"); // Add children, if there are some if (multiple_title) { // Add this to the place holder Literal thisLiteral = new Literal { Text = resultsBldr.ToString().Replace("<role>", "<i>").Replace("</role>", "</i>") }; MainPlaceHolder.Controls.Add(thisLiteral); resultsBldr.Remove(0, resultsBldr.Length); Add_Issue_Tree(MainPlaceHolder, titleResult, current_row, textRedirectStem, base_url); } resultsBldr.AppendLine("\t\t</td>"); resultsBldr.AppendLine("\t</tr>"); // Add a horizontal line resultsBldr.AppendLine("\t<tr><td bgcolor=\"#e7e7e7\" colspan=\"3\"></td></tr>"); // Increment the result counters result_counter++; current_row++; } // End this table resultsBldr.AppendLine("</table>"); // Add this to the HTML page Literal mainLiteral = new Literal { Text = resultsBldr.ToString().Replace("<role>", "<i>").Replace("</role>", "</i>") }; MainPlaceHolder.Controls.Add(mainLiteral); }
/// <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 adds the search tips by calling the base method <see cref="abstractAggregationViewer.Add_Simple_Search_Tips"/> </remarks> public override void Add_Secondary_HTML(TextWriter Output, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("Tiles_Home_AggregationViewer.Add_Secondary_HTML", "Add the entire tiled home page"); } const string VARIES_STRING = "<span style=\"color:Gray\">( varies )</span>"; Output.WriteLine("<div id=\"sbkThav_TileContainer\">"); //Add the necessary JavaScript, CSS files Output.WriteLine(" <script type=\"text/javascript\" src=\"" + Static_Resources_Gateway.Sobekcm_Thumb_Results_Js + "\"></script>"); int title_count = 1; foreach (Tiles_Home_Single_Tile thisTile in selectedTiles) { // Do we have metadat for this? Database_Item_Result itemResult = null; Database_Title_Result titleResult = null; if (tileMetadata != null) { // Find the matching tile, by BibID foreach (Database_Title_Result metadataTitle in tileMetadata.Results) { // Matching BibID? if (String.Compare(metadataTitle.BibID, thisTile.BibID, StringComparison.OrdinalIgnoreCase) == 0) { // Only continue, if we have items if (metadataTitle.Items != null) { // Title matched titleResult = metadataTitle; // Look for matching VID foreach (Database_Item_Result metadataItem in metadataTitle.Items) { // Matching VID? if (String.Compare(metadataItem.VID, thisTile.VID, StringComparison.OrdinalIgnoreCase) == 0) { itemResult = metadataItem; break; } } // If no match by VID, use whatever is in there if (itemResult == null) { itemResult = titleResult.Items[0]; } } } } } // Write the tile Output.WriteLine(" <div class=\"sbkThav_Tile\">"); Output.WriteLine(" <a href=\"" + thisTile.LinkUri + "\">"); Output.WriteLine(" <img id=\"sbkThumbnailImg" + title_count + "\" src=\"" + thisTile.JpegUri + "\" />"); Output.WriteLine(" </a>"); // Was metadta found? if ((titleResult != null) && (itemResult != null)) { //Add the hidden item values for display in the tooltip // Output.WriteLine("<tr style=\"display:none;\"><td colspan=\"100%\"><div id=\"descThumbnail" + title_count + "\" >"); Output.WriteLine("<div id=\"descThumbnail" + title_count + "\" style=\"display:none;\" >"); // Add each element to this table Output.WriteLine("\t\t\t<table cellspacing=\"0px\">"); Output.WriteLine( "\t\t\t\t<tr style=\"height:40px;\" valign=\"middle\"><td colspan=\"3\"><span class=\"qtip_BriefTitle\" style=\"color: #a5a5a5;font-weight: bold;font-size:13px;\">" + itemResult.Title.Replace("<", "<").Replace(">", ">") + "</span> </td></tr><br/>"); Output.WriteLine("<tr><td colspan=\"100%\"><br/></td></tr>"); if ((!String.IsNullOrEmpty(titleResult.Primary_Identifier_Type)) && (!String.IsNullOrEmpty(titleResult.Primary_Identifier))) { Output.WriteLine("\t\t\t\t<tr><td>" + UI_ApplicationCache_Gateway.Translation.Get_Translation(titleResult.Primary_Identifier_Type, RequestSpecificValues.Current_Mode.Language) + ":</td><td> </td><td>" + HttpUtility.HtmlDecode(titleResult.Primary_Identifier) + "</td></tr>"); } if ((RequestSpecificValues.Current_User != null) && (RequestSpecificValues.Current_User.LoggedOn) && (RequestSpecificValues.Current_User.Is_Internal_User)) { Output.WriteLine("\t\t\t\t<tr><td>BibID:</td><td> </td><td>" + titleResult.BibID + "</td></tr>"); if (titleResult.OPAC_Number > 1) { Output.WriteLine("\t\t\t\t<tr><td>OPAC:</td><td> </td><td>" + titleResult.OPAC_Number + "</td></tr>"); } if (titleResult.OCLC_Number > 1) { Output.WriteLine("\t\t\t\t<tr><td>OCLC:</td><td> </td><td>" + titleResult.OCLC_Number + "</td></tr>"); } } for (int i = 0; i < tileMetadata.Metadata_Labels.Count; i++) { string field = tileMetadata.Metadata_Labels[i]; // Somehow the metadata for this item did not fully save in the database. Break out, rather than // throw the exception if ((titleResult.Metadata_Display_Values == null) || (titleResult.Metadata_Display_Values.Length <= i)) { break; } string value = titleResult.Metadata_Display_Values[i]; Metadata_Search_Field thisField = UI_ApplicationCache_Gateway.Settings.Metadata_Search_Field_By_Name(field); string display_field = string.Empty; if (thisField != null) { display_field = thisField.Display_Term; } if (display_field.Length == 0) { display_field = field.Replace("_", " "); } if (value == "*") { Output.WriteLine("\t\t\t\t<tr><td>" + UI_ApplicationCache_Gateway.Translation.Get_Translation(display_field, RequestSpecificValues.Current_Mode.Language) + ":</td><td> </td><td>" + HttpUtility.HtmlDecode(VARIES_STRING) + "</td></tr>"); } else if (value.Trim().Length > 0) { if (value.IndexOf("|") > 0) { bool value_found = false; string[] value_split = value.Split("|".ToCharArray()); foreach (string thisValue in value_split) { if (thisValue.Trim().Trim().Length > 0) { if (!value_found) { Output.WriteLine("\t\t\t\t<tr valign=\"top\"><td>" + UI_ApplicationCache_Gateway.Translation.Get_Translation(display_field, RequestSpecificValues.Current_Mode.Language) + ":</td><td> </td><td>"); value_found = true; } Output.Write(HttpUtility.HtmlDecode(thisValue) + "<br />"); } } if (value_found) { Output.WriteLine("</td></tr>"); } } else { Output.WriteLine("\t\t\t\t<tr><td>" + UI_ApplicationCache_Gateway.Translation.Get_Translation(display_field, RequestSpecificValues.Current_Mode.Language) + ":</td><td> </td><td>" + HttpUtility.HtmlDecode(value) + "</td></tr>"); } } } Output.WriteLine("\t\t\t</table>"); Output.WriteLine(" </div>"); } Output.WriteLine(" </div>"); title_count++; } Output.WriteLine("</div>"); // If there are sub aggregations here, show them if (ViewBag.Hierarchy_Object.Children_Count > 0) { Output.WriteLine("<div class=\"SobekText\">"); Aggregation_HtmlSubwriter.Add_SubCollection_Buttons(Output, RequestSpecificValues, ViewBag.Hierarchy_Object); Output.WriteLine("</div>"); } RequestSpecificValues.Current_Mode.Aggregation = ViewBag.Hierarchy_Object.Code; }
private void Add_Item_Info_And_Map(string TextRedirectStem, string BaseURL, int MapNumber, List <iSearch_Title_Result> TitlesForCurrentMap, PlaceHolder MainPlaceHolder, StringBuilder Builder) { // Set some values before iterating through the item rows const string VARIES_STRING = "<span style=\"color:Gray\">( varies )</span>"; // Step through each collection of items by bib id for this coordinate and see if this is a collection of points bool point_collection_map = false; bool polygon_map = false; if (TitlesForCurrentMap[0].Spatial_Coordinates.Length > 0) { if (TitlesForCurrentMap[0].Spatial_Coordinates[0] == 'P') { point_collection_map = true; } else { polygon_map = true; } } // Add the map division here Builder.AppendLine(" <tr><td bgcolor=\"" + LINE_COLOR + "\" colspan=\"3\"></td></tr>"); Builder.AppendLine(" <tr valign=\"top\">"); if (point_collection_map) { Builder.AppendLine(" <td colspan=\"2\"><div id=\"map" + MapNumber + "\" style=\"width: 450px; height: 450px\"></div></td>"); Builder.AppendLine(" <td>"); Builder.AppendLine(" <table width=\"380px\">"); } if (polygon_map) { Builder.AppendLine(" <td align=\"center\"><div id=\"map" + MapNumber + "\" style=\"width: 250px; height: 250px\"></div></td>"); Builder.AppendLine(" <td colspan=\"2\">"); Builder.AppendLine(" <table width=\"580px\">"); // Put a note here about the number of matches if (TitlesForCurrentMap.Count > 1) { int total_items = TitlesForCurrentMap.Sum(TitleInMap => TitleInMap.Item_Count); if (total_items != TitlesForCurrentMap.Count) { Builder.AppendLine(" <tr><td colspan=\"3\"><span style=\"color: gray;\"><center><em>The following " + total_items + " matches in " + TitlesForCurrentMap.Count + " sets share the same coordinate information</em></center></span></td></tr>"); } else { Builder.AppendLine(" <tr><td colspan=\"3\"><span style=\"color: gray;\"><center><em>The following " + total_items + " matches share the same coordinate information</em></center></span></td></tr>"); } } } if ((!point_collection_map) && (!polygon_map)) { Builder.AppendLine(" <td colspan=\"3\">"); Builder.AppendLine(" <table width=\"100%\">"); // Put a note here about the number of matches if (TitlesForCurrentMap.Count > 1) { int total_items = TitlesForCurrentMap.Sum(TitleInMap => TitleInMap.Item_Count); if (total_items != TitlesForCurrentMap.Count) { Builder.AppendLine(" <tr><td colspan=\"3\"><span style=\"color: gray;\"><center><em>The following " + total_items + " matches in " + TitlesForCurrentMap.Count + " sets have no coordinate information</em></center></span></td></tr>"); } else { Builder.AppendLine(" <tr><td colspan=\"3\"><span style=\"color: gray;\"><center><em>The following " + total_items + " matches have no coordinate information</em></center></span></td></tr>"); } } } // Now, add all the individual item information for each bib id in this map int titles_per_this_map = 0; int items_per_this_map = 0; string last_link = String.Empty; int polygons_added_to_this_map = 0; int coordinates_per_this_map = 1; string coords = String.Empty; foreach (iSearch_Title_Result titleResult in TitlesForCurrentMap) { // Always get the first item for things like the main link and thumbnail iSearch_Item_Result firstItemResult = titleResult.Get_Item(0); // Increment the number of items/titles per this coordiante titles_per_this_map++; // If this is not the first, add a line if (titles_per_this_map > 1) { if ((polygon_map) || (titleResult.Spatial_Coordinates != coords)) { Builder.AppendLine(" <tr><td bgcolor=\"" + LINE_COLOR + "\" colspan=\"3\"></td></tr>"); } else { Builder.AppendLine(" <tr><td></td><td bgcolor=\"" + LINE_COLOR + "\" colspan=\"3\"></td></tr>"); } } // Increment by the number of items in this collection of items items_per_this_map += 1; // Are there multiple volumes to be displayed here? bool multiple = false; string pubdate = firstItemResult.PubDate; if (titleResult.Item_Count > 1) { multiple = true; // This will not include the item details, just the tree Builder.AppendLine(" <tr>"); // If this is a point (and the first point of this coordinate) add the point information here if (point_collection_map) { if (titleResult.Spatial_Coordinates != coords) { // Add the icon for the google marker Builder.AppendLine(" <tr><td width=\"30\"><img src=\"" + icon_by_number(coordinates_per_this_map) + "\" /></td>"); // Look ahead to see if multiple items have the same coordinate int index = TitlesForCurrentMap.IndexOf(titleResult); int matching_titles_for_this_point = 1; while ((index >= 0) && ((index + 1) < TitlesForCurrentMap.Count)) { if (TitlesForCurrentMap[index + 1].Spatial_Coordinates == titleResult.Spatial_Coordinates) { matching_titles_for_this_point++; } else { break; } index++; } if (matching_titles_for_this_point > 1) { Builder.AppendLine(" <td colspan=\"2\"><span style=\"color: gray;\"><center><em>The following " + matching_titles_for_this_point + " titles have the same coordinate point</em></center></span></td>"); Builder.AppendLine(" </tr>"); Builder.AppendLine(" <tr>"); Builder.AppendLine(" <td> </td>"); } coords = titleResult.Spatial_Coordinates; coordinates_per_this_map++; } else { Builder.AppendLine(" <td> </td>"); } } else { Builder.AppendLine(" <td> </td>"); } Builder.AppendLine(" <td colspan=\"2\">"); // Write all the collected HTML to a literal, since we will be adding a // tree view control to the web page next Literal literal = new Literal { Text = Builder.ToString() }; MainPlaceHolder.Controls.Add(literal); Builder.Remove(0, Builder.Length); // Draw the tree of all matching issues Add_Issue_Tree(MainPlaceHolder, titleResult, currentResultCount, TextRedirectStem, BaseURL); // Finish this table in the item results view Builder.AppendLine(" </td>"); Builder.AppendLine(" </tr>"); // Check if the pub date is the same for all items if ((pubdate.Length > 0) && (pubdate != "-1")) { for (int i = 0; i < titleResult.Item_Count; i++) { if (titleResult.Get_Item(i).PubDate != pubdate) { pubdate = String.Empty; break; } } } } else { // If this is a point (and the first point of this coordinate) add the point information here if (point_collection_map) { if (titleResult.Spatial_Coordinates != coords) { // Add the icon for the google marker Builder.AppendLine(" <tr><td width=\"30\"><img src=\"" + icon_by_number(coordinates_per_this_map) + "\" /></td>"); // Look ahead to see if multiple items have the same coordinate int index = TitlesForCurrentMap.IndexOf(titleResult); int matching_titles_for_this_point = 1; while ((index >= 0) && ((index + 1) < TitlesForCurrentMap.Count)) { if (TitlesForCurrentMap[index + 1].Spatial_Coordinates == titleResult.Spatial_Coordinates) { matching_titles_for_this_point++; } else { break; } index++; } if (matching_titles_for_this_point > 1) { Builder.AppendLine(" <td colspan=\"2\"><span style=\"color: gray;\"><center><em>The following " + matching_titles_for_this_point + " titles have the same coordinate point</em></center></span></td>"); Builder.AppendLine(" </tr>"); Builder.AppendLine(" <tr>"); Builder.AppendLine(" <td> </td>"); } coords = titleResult.Spatial_Coordinates; coordinates_per_this_map++; } else { Builder.AppendLine(" <td> </td>"); } Builder.AppendLine("<td colspan=\"2\"><a href=\"" + BaseURL + titleResult.BibID.ToUpper() + "/" + firstItemResult.VID + TextRedirectStem + "\">" + firstItemResult.Title + "</a>"); } else { Builder.AppendLine(" <tr><td></td><td colspan=\"2\"><a href=\"" + BaseURL + titleResult.BibID.ToUpper() + "/" + firstItemResult.VID + TextRedirectStem + "\">" + firstItemResult.Title + "</a>"); // Save this link, just in case it is the only area in this map last_link = BaseURL + titleResult.BibID.ToUpper() + "/" + firstItemResult.VID + TextRedirectStem; } } // Add the bib id and vid if ((RequestSpecificValues.Current_User != null) && (RequestSpecificValues.Current_User.LoggedOn) && (RequestSpecificValues.Current_User.Is_Internal_User)) { Builder.AppendLine(" <tr height=\"10px\"><td> </td><td>BibID:</td><td>" + titleResult.BibID.ToUpper() + "</td></tr>"); if (!multiple) { Builder.AppendLine(" <tr height=\"10px\"><td> </td><td>VID:</td><td>" + firstItemResult.VID + "</td></tr>"); } } for (int i = 0; i < ResultsStats.Metadata_Labels.Count; i++) { string field = ResultsStats.Metadata_Labels[i]; string value = titleResult.Metadata_Display_Values[i]; Metadata_Search_Field thisField = UI_ApplicationCache_Gateway.Settings.Metadata_Search_Field_By_Name(field); string display_field = string.Empty; if (thisField != null) { display_field = thisField.Display_Term; } if (display_field.Length == 0) { display_field = field.Replace("_", " "); } if (value == "*") { Builder.AppendLine("\t\t\t\t<tr height=\"10px\"><td> </td><td>" + UI_ApplicationCache_Gateway.Translation.Get_Translation(display_field, RequestSpecificValues.Current_Mode.Language) + ":</td><td>" + VARIES_STRING + "</td></tr>"); } else if (value.Trim().Length > 0) { if (value.IndexOf("|") > 0) { bool value_found = false; string[] value_split = value.Split("|".ToCharArray()); foreach (string thisValue in value_split) { if (thisValue.Trim().Trim().Length > 0) { if (!value_found) { Builder.AppendLine("\t\t\t\t<tr valign=\"top\"><td> </td><td>" + UI_ApplicationCache_Gateway.Translation.Get_Translation(display_field, RequestSpecificValues.Current_Mode.Language) + ":</td><td>"); value_found = true; } Builder.Append(HttpUtility.HtmlEncode(thisValue) + "<br />"); } } if (value_found) { Builder.AppendLine("</td></tr>"); } } else { Builder.AppendLine("\t\t\t\t<tr height=\"10px\"><td> </td><td>" + UI_ApplicationCache_Gateway.Translation.Get_Translation(display_field, RequestSpecificValues.Current_Mode.Language) + ":</td><td>" + HttpUtility.HtmlEncode(value) + "</td></tr>"); } } } // Increment the row counter currentResultCount++; } // End this map row Builder.AppendLine(" </table>"); Builder.AppendLine(" </td>"); Builder.AppendLine(" </tr>"); if ((point_collection_map) || (polygon_map)) { // Clear the last latitude and longitude information double max_lat = -90; double max_long = -180; double min_lat = 90; double min_long = 180; // Now, start to add the map javascript information to the building javascript mapScriptHtml.AppendLine(); mapScriptHtml.AppendLine(" var map" + MapNumber + "_center = new google.maps.LatLng(<%CENTERINFO" + MapNumber + "%>);"); mapScriptHtml.AppendLine(" var map" + MapNumber + "_options = { zoom: <%ZOOMINFO" + MapNumber + "%>, center: map" + MapNumber + "_center, mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControl: false, streetViewControl: false };"); mapScriptHtml.AppendLine(" var map" + MapNumber + " = new google.maps.Map(document.getElementById(\"map" + MapNumber + "\"), map" + MapNumber + "_options);"); // Step through each coordinate/title collection for this map int point_index = 1; coords = "A"; foreach (iSearch_Title_Result items_per_bib in TitlesForCurrentMap) { // Add this coordinate information to the if (items_per_bib.Spatial_Coordinates.Length > 0) { string[] coords_splitter = items_per_bib.Spatial_Coordinates.Split("|,".ToCharArray()); // If this was a point, add this point if (items_per_bib.Spatial_Coordinates[0] == 'P') { if (items_per_bib.Spatial_Coordinates != coords) { coords = items_per_bib.Spatial_Coordinates; // Add the marker to the map script mapScriptHtml.AppendLine(" var marker" + MapNumber + "_" + point_index + " = new google.maps.Marker({ position: new google.maps.LatLng(" + coords_splitter[1] + ", " + coords_splitter[2] + "), map: map" + MapNumber + ", icon: \"" + icon_by_number(point_index) + "\" });"); point_index++; // Check the new boundaries check_boundaries(coords_splitter[1], coords_splitter[2], ref max_lat, ref max_long, ref min_lat, ref min_long); } } else { if (items_per_bib.Spatial_Coordinates != coords) { coords = items_per_bib.Spatial_Coordinates; if (coords_splitter.Length == 5) { mapScriptHtml.AppendLine(" var polygon" + polyCount + "_outline = [ new google.maps.LatLng(" + coords_splitter[1] + "," + coords_splitter[2] + "), new google.maps.LatLng(" + coords_splitter[1] + "," + coords_splitter[4] + "), new google.maps.LatLng(" + coords_splitter[3] + "," + coords_splitter[4] + "), new google.maps.LatLng(" + coords_splitter[3] + "," + coords_splitter[2] + "), new google.maps.LatLng(" + coords_splitter[1] + "," + coords_splitter[2] + ")];"); mapScriptHtml.AppendLine(" var polygon" + polyCount + " = new google.maps.Polygon({ paths: polygon" + polyCount + "_outline, strokeColor: \"#f33f00\", strokeOpacity: 1, strokeWeight: 5, fillColor: \"#ff0000\", fillOpacity: 0.2 });"); mapScriptHtml.AppendLine(" polygon" + polyCount + ".setMap(map" + MapNumber + ");"); check_boundaries(coords_splitter[1], coords_splitter[2], ref max_lat, ref max_long, ref min_lat, ref min_long); check_boundaries(coords_splitter[3], coords_splitter[4], ref max_lat, ref max_long, ref min_lat, ref min_long); } else { bool first = true; mapScriptHtml.Append(" var polygon" + polyCount + "_outline = [ "); int point = 1; while ((point + 2) <= coords_splitter.Length) { if (!first) { mapScriptHtml.Append(","); } else { first = false; } mapScriptHtml.Append("new google.maps.LatLng(" + coords_splitter[point] + ", " + coords_splitter[point + 1] + ")"); check_boundaries(coords_splitter[point], coords_splitter[point + 1], ref max_lat, ref max_long, ref min_lat, ref min_long); point += 2; } mapScriptHtml.AppendLine("];"); mapScriptHtml.AppendLine(" var polygon" + polyCount + " = new google.maps.Polygon({ paths: polygon" + polyCount + "_outline, strokeColor: \"#f33f00\", strokeOpacity: 1, strokeWeight: 5, fillColor: \"#ff0000\", fillOpacity: 0.2 });"); mapScriptHtml.AppendLine(" polygon" + polyCount + ".setMap(map" + MapNumber + ");"); } // Finish the last polygon by adding the link, if there should be one if ((items_per_this_map == 1) && (last_link.Length > 0)) { mapScriptHtml.AppendLine(" google.maps.event.addListener(polygon" + polyCount + ", 'click', function redirect" + polyCount + "() { window.location.href = \"" + last_link + "\"; }); "); } polyCount++; polygons_added_to_this_map++; } } } } try { // Compute the center and zoom of the last map double mid_lat = (max_lat + min_lat) / 2; double mid_long = (max_long + min_long) / 2; int zoom = compute_zoom(max_lat, max_long, min_lat, min_long); if (coords[0] == 'A') { zoom--; } if ((polygons_added_to_this_map == 0) && (point_index <= 1)) { zoom = 6; } mapScriptHtml.Replace("<%CENTERINFO" + MapNumber + "%>", mid_lat + ", " + mid_long); mapScriptHtml.Replace("<%ZOOMINFO" + MapNumber + "%>", zoom.ToString()); } catch { mapScriptHtml.Replace("<%CENTERINFO" + MapNumber + "%>", "0, 0"); mapScriptHtml.Replace("<%ZOOMINFO" + MapNumber + "%>", "8"); } } }
/// <summary> Perform an search for documents with matching parameters </summary> /// <param name="AggregationCode"> Aggregation code within which to search </param> /// <param name="Terms"> List of the search terms </param> /// <param name="Web_Fields"> List of the web fields associate with the search terms </param> /// <param name="ResultsPerPage"> Number of results to display per a "page" of results </param> /// <param name="Page_Number"> Which page of results to return ( one-based, so the first page is page number of one )</param> /// <param name="Sort"> Sort to apply before returning the results of the search </param> /// <param name="Need_Search_Statistics"> Flag indicates if the search statistics are needed </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </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> /// <returns> Page search result object with all relevant result information </returns> public static bool Search(string AggregationCode, List <string> Terms, List <string> Web_Fields, int ResultsPerPage, int Page_Number, ushort Sort, bool Need_Search_Statistics, Custom_Tracer Tracer, out Search_Results_Statistics Complete_Result_Set_Info, out List <iSearch_Title_Result> Paged_Results) { if (Tracer != null) { Tracer.Add_Trace("Legacy_Solr_Documents_Searcher.Search", "Build the Solr query"); } // Step through all the terms and fields StringBuilder queryStringBuilder = new StringBuilder(); for (int i = 0; i < Math.Min(Terms.Count, Web_Fields.Count); i++) { string web_field = Web_Fields[i]; string searchTerm = Terms[i]; string solr_field; if (i == 0) { // Skip any joiner for the very first field indicated if ((web_field[0] == '+') || (web_field[0] == '=') || (web_field[0] == '-')) { web_field = web_field.Substring(1); } // Try to get the solr field if (web_field == "TX") { solr_field = "fulltext:"; } else { Metadata_Search_Field field = Engine_ApplicationCache_Gateway.Settings.Metadata_Search_Field_By_Code(web_field.ToUpper()); if (field != null) { solr_field = field.Legacy_Solr_Code + ":"; } else { solr_field = String.Empty; } } // Add the solr search string if (searchTerm.IndexOf(" ") > 0) { queryStringBuilder.Append("(" + solr_field + "\"" + searchTerm.Replace(":", "") + "\")"); } else { queryStringBuilder.Append("(" + solr_field + searchTerm.Replace(":", "") + ")"); } } else { // Add the joiner for this subsequent terms if ((web_field[0] == '+') || (web_field[0] == '=') || (web_field[0] == '-')) { switch (web_field[0]) { case '=': queryStringBuilder.Append(" OR "); break; case '+': queryStringBuilder.Append(" AND "); break; case '-': queryStringBuilder.Append(" NOT "); break; default: queryStringBuilder.Append(" AND "); break; } web_field = web_field.Substring(1); } else { queryStringBuilder.Append(" AND "); } // Try to get the solr field if (web_field == "TX") { solr_field = "fulltext:"; } else { Metadata_Search_Field field = Engine_ApplicationCache_Gateway.Settings.Metadata_Search_Field_By_Code(web_field.ToUpper()); if (field != null) { solr_field = field.Legacy_Solr_Code + ":"; } else { solr_field = String.Empty; } } // Add the solr search string if (searchTerm.IndexOf(" ") > 0) { queryStringBuilder.Append("(" + solr_field + "\"" + searchTerm.Replace(":", "") + "\")"); } else { queryStringBuilder.Append("(" + solr_field + searchTerm.Replace(":", "") + ")"); } } } if (Tracer != null) { Tracer.Add_Trace("Legacy_Solr_Documents_Searcher.Search", "Perform the search"); } // Get the query string value string queryString = queryStringBuilder.ToString(); // Set output initially to null Paged_Results = new List <iSearch_Title_Result>(); Complete_Result_Set_Info = null; try { // Ensure page is not erroneously set to zero or negative if (Page_Number <= 0) { Page_Number = 1; } // Create the solr worker to query the document index var solrWorker = Solr_Operations_Cache <Legacy_Solr_Document_Result> .GetSolrOperations(Engine_ApplicationCache_Gateway.Settings.Servers.Document_Solr_Legacy_URL); // Create the query options QueryOptions options = new QueryOptions { Rows = ResultsPerPage, Start = (Page_Number - 1) * ResultsPerPage, Fields = new[] { "did", "score", "url", "aleph", "donor", "edition", "format", "holdinglocation", "sourceinstitution", "maintitle", "materialtype", "oclc", "pubdate_display", "author_display", "publisher_display", "mainthumbnail" }, Highlight = new HighlightingParameters { Fields = new[] { "fulltext" }, }, ExtraParams = new Dictionary <string, string> { { "hl.useFastVectorHighlighter", "true" } } }; // Set the sort value if (Sort != 0) { options.OrderBy.Clear(); switch (Sort) { case 1: options.OrderBy.Add(new SortOrder("maintitle_sort")); break; case 2: options.OrderBy.Add(new SortOrder("bibid", Order.ASC)); break; case 3: options.OrderBy.Add(new SortOrder("bibid", Order.DESC)); break; case 10: options.OrderBy.Add(new SortOrder("pubdate", Order.ASC)); break; case 11: options.OrderBy.Add(new SortOrder("pubdate", Order.DESC)); break; } } // If there was an aggregation code included, put that at the beginning of the search if ((AggregationCode.Length > 0) && (AggregationCode.ToUpper() != "ALL")) { queryString = "(aggregation_code:" + AggregationCode.ToUpper() + ")AND(" + queryString + ")"; } // Perform this search SolrQueryResults <Legacy_Solr_Document_Result> results = solrWorker.Query(queryString, options); // Create the search statistcs List <string> metadataLabels = new List <string> { "Author", "Publisher", "Format", "Edition", "Institution", "Donor" }; Complete_Result_Set_Info = new Search_Results_Statistics(metadataLabels) { Total_Titles = results.NumFound, Total_Items = results.NumFound, QueryTime = results.Header.QTime }; // Pass all the results into the List and add the highlighted text to each result as well foreach (Legacy_Solr_Document_Result thisResult in results) { // Add the highlight snipper if ((results.Highlights.ContainsKey(thisResult.DID)) && (results.Highlights[thisResult.DID].Count > 0) && (results.Highlights[thisResult.DID].ElementAt(0).Value.Count > 0)) { thisResult.Snippet = results.Highlights[thisResult.DID].ElementAt(0).Value.ElementAt(0); } // Add this results Paged_Results.Add(thisResult); } return(true); } catch { return(false); } }
/// <summary> Creates the solr/lucene query string for the search terms and dates</summary> /// <param name="Terms"> List of the search terms </param> /// <param name="Web_Fields"> List of the web fields associate with the search terms </param> /// <param name="StartDate"> Starting date, if this search includes a limitation by time </param> /// <param name="EndDate"> Ending date, if this search includes a limitation by time </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <returns> Fully built query string ( excluding user membership and aggreagtion membership checks ) </returns> public static string Create_Query_String(List <string> Terms, List <string> Web_Fields, Nullable <DateTime> StartDate, Nullable <DateTime> EndDate, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("v5_Solr_Documents_Searcher.Create_Query_String", "Build the Solr query"); } // Start to build the query StringBuilder queryStringBuilder = new StringBuilder(); // If no query, this is an ALL browse if (((Web_Fields == null) || (Web_Fields.Count == 0)) || ((Terms == null) || (Terms.Count == 0))) { queryStringBuilder.Append("(*:*)"); } else { // Step through all the terms and fields for (int i = 0; i < Math.Min(Terms.Count, Web_Fields.Count); i++) { string web_field = Web_Fields[i]; string searchTerm = Terms[i]; string solr_field; if (i == 0) { // Skip any joiner for the very first field indicated if ((web_field[0] == '+') || (web_field[0] == '=') || (web_field[0] == '-')) { web_field = web_field.Substring(1); } // Try to get the solr field if (web_field == "TX") { solr_field = "fulltext:"; } else { Metadata_Search_Field field = Engine_ApplicationCache_Gateway.Settings.Metadata_Search_Field_By_Code(web_field.ToUpper()); if (field != null) { solr_field = field.Solr_Field + ":"; } else { solr_field = String.Empty; } } // Add the solr search string if (searchTerm.IndexOf(" ") > 0) { queryStringBuilder.Append("(" + solr_field + "\"" + searchTerm.Replace(":", "").Replace("[", "").Replace("]", "") + "\")"); } else { queryStringBuilder.Append("(" + solr_field + searchTerm.Replace(":", "").Replace("[", "").Replace("]", "") + ")"); } } else { // Add the joiner for this subsequent terms if ((web_field[0] == '+') || (web_field[0] == '=') || (web_field[0] == '-')) { switch (web_field[0]) { case '=': queryStringBuilder.Append(" OR "); break; case '+': queryStringBuilder.Append(" AND "); break; case '-': queryStringBuilder.Append(" NOT "); break; default: queryStringBuilder.Append(" AND "); break; } web_field = web_field.Substring(1); } else { queryStringBuilder.Append(" AND "); } // Try to get the solr field if (web_field == "TX") { solr_field = "fulltext:"; } else { Metadata_Search_Field field = Engine_ApplicationCache_Gateway.Settings.Metadata_Search_Field_By_Code(web_field.ToUpper()); if (field != null) { solr_field = field.Solr_Field + ":"; } else { solr_field = String.Empty; } } // Add the solr search string if (searchTerm.IndexOf(" ") > 0) { queryStringBuilder.Append("(" + solr_field + "\"" + searchTerm.Replace(":", "") + "\")"); } else { queryStringBuilder.Append("(" + solr_field + searchTerm.Replace(":", "") + ")"); } } } } // Get the query string value string queryString = queryStringBuilder.ToString(); // If there is a date range add that if ((StartDate.HasValue) || (EndDate.HasValue)) { if ((StartDate.HasValue) && (EndDate.HasValue)) { queryString = "(" + queryString + ") AND ( date.gregorian:[" + to_standard_date_string(StartDate.Value) + " TO " + to_standard_date_string(EndDate.Value) + "])"; } else if (StartDate.HasValue) // So EndDate must not have value { queryString = "(" + queryString + ") AND ( date.gregorian:[" + to_standard_date_string(StartDate.Value) + " TO *])"; } else // End date must have value, but not start date { queryString = "(" + queryString + ") AND ( date.gregorian:[* TO " + to_standard_date_string(EndDate.Value) + "])"; } } return(queryString); }
/// <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 = currentCollection.Browse_By_Pages(currentMode.Language); // Determine if this is an internal user and create list of internal user browses List <string> internal_browses = new List <string>(); if ((currentUser != null) && ((currentUser.Is_Internal_User) || (currentUser.Is_Aggregation_Curator(currentMode.Aggregation)))) { // Just add every metadata field here foreach (Metadata_Search_Field field in SobekCM_Library_Settings.All_Metadata_Fields) { if ((field.Web_Code.Length > 0) && (currentCollection.Browseable_Fields.Contains(field.ID))) { internal_browses.Add(field.Display_Term); } } } // Retain the original short code (or the first public code) string original_browse_mode = currentMode.Info_Browse_Mode.ToLower(); // Get any paging URL and retain original page int current_page = currentMode.Page; currentMode.Page = 1; string page_url = currentMode.Redirect_URL(false); string url_options = currentMode.URL_Options(); if (url_options.Length > 0) { url_options = "?" + url_options.Replace("&", "&"); } 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 == Item_Aggregation_Child_Page.Source_Type.Static_HTML) { sortedBrowses[thisBrowse.Code.ToLower()] = thisBrowse; } else { Metadata_Search_Field facetField = SobekCM_Library_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> Public Browses</b><br />" : "<b> 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 == Item_Aggregation_Child_Page.Source_Type.Static_HTML) { if (original_browse_mode != thisBrowse.Code) { currentMode.Info_Browse_Mode = thisBrowse.Code; Output.WriteLine("<a href=\"" + currentMode.Redirect_URL().Replace("&", "&") + "\">" + thisBrowse.Get_Label(currentMode.Language) + "</a><br />"); } else { Output.WriteLine(thisBrowse.Get_Label(currentMode.Language) + "<br />"); } } else { Metadata_Search_Field facetField = SobekCM_Library_Settings.Metadata_Search_Field_By_Display_Name(thisBrowse.Code); if (thisBrowse.Code.ToLower().Replace("_", " ") != original_browse_mode.Replace("_", " ")) { currentMode.Info_Browse_Mode = thisBrowse.Code.ToLower().Replace(" ", "_"); Output.WriteLine("<a href=\"" + currentMode.Redirect_URL().Replace("&", "&") + "\">" + 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> Internal Browses</b><br />"); Output.WriteLine("<div class=\"sbkMebv_FacetBox\">"); foreach (string thisShort in internal_browses) { Metadata_Search_Field facetField = SobekCM_Library_Settings.Metadata_Search_Field_By_Facet_Name(thisShort); if (facetField != null) { if (thisShort.ToLower() != original_browse_mode) { currentMode.Info_Browse_Mode = thisShort.ToLower().Replace(" ", "_"); Output.WriteLine("<a href=\"" + currentMode.Redirect_URL().Replace("&", "&") + "\">" + 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\">"); currentMode.Info_Browse_Mode = original_browse_mode; // Was this static or metadata browse by? if ((browseObject != null) && (browseObject.Source == Item_Aggregation_Child_Page.Source_Type.Static_HTML)) { // Read the content file for this browse HTML_Based_Content staticBrowseContent = browseObject.Get_Static_Content(currentMode.Language, currentMode.Base_URL, SobekCM_Library_Settings.Base_Design_Location + currentCollection.ObjDirectory, Tracer); // Apply current user settings for this string browseInfoDisplayText = staticBrowseContent.Apply_Settings_To_Static_Text(staticBrowseContent.Static_Text, currentCollection, htmlSkin.Skin_Code, htmlSkin.Base_Skin_Code, currentMode.Base_URL, currentMode.URL_Options(), Tracer); // Add this to the output stream Output.WriteLine(browseInfoDisplayText); } 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 currentMode.Mode = Display_Mode_Enum.Results; currentMode.Search_Precision = Search_Precision_Type_Enum.Exact_Match; currentMode.Search_Type = Search_Type_Enum.Advanced; Metadata_Search_Field facetField = SobekCM_Library_Settings.Metadata_Search_Field_By_Display_Name(original_browse_mode); currentMode.Search_Fields = facetField.Web_Code; currentMode.Search_String = "\"<%TERM%>\""; string search_url = currentMode.Redirect_URL(); 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("&", "&")) + "\">" + thisResult.Replace("\"", """).Replace("&", "&") + "</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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/1" + url_options + "\" class=\"mbb1\">AB</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">AB</span> "); } 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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/2" + url_options + "\">CDE</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">CDE</span> "); } 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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/3" + url_options + "\">FGH</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">FGH</span> "); } 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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/4" + url_options + "\">IJK</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">IJK</span> "); } 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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/5" + url_options + "\">LMN</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">LMN</span> "); } 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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/6" + url_options + "\">OPQ</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">OPQ</span> "); } 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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/7" + url_options + "\">RST</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">RST</span> "); } 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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/8" + url_options + "\">UVW</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">UVW</span> "); } 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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/9" + url_options + "\">XYZ</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\" >XYZ</span> "); } 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("&", "&") + "\">" + thisValue.Replace("\"", """).Replace("&", "&") + "</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> "); } else { Output.WriteLine("<a href=\"" + page_url + "/" + counter + url_options + "\" >" + Char.ToUpper(label_char) + "</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\" >" + Char.ToUpper(label_char) + "</span> "); } 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("&", "&") + "\">" + thisValue.Replace("\"", """).Replace("&", "&") + "</a><br />"); } } } } } else { Output.WriteLine("<br /><br /><br /><br />"); Output.WriteLine(currentMode.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 currentMode.Mode = Display_Mode_Enum.Aggregation; currentMode.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(); }