/// <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> 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(); }
/// <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); }
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 (CurrentMode.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 < 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 == "*") { Builder.AppendLine("\t\t\t\t<tr height=\"10px\"><td> </td><td>" + Translator.Get_Translation(display_field, CurrentMode.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>" + Translator.Get_Translation(display_field, CurrentMode.Language) + ":</td><td>"); value_found = true; } Builder.Append(System.Web.HttpUtility.HtmlEncode(thisValue) + "<br />"); } } if (value_found) { Builder.AppendLine("</td></tr>"); } } else { Builder.AppendLine("\t\t\t\t<tr height=\"10px\"><td> </td><td>" + Translator.Get_Translation(display_field, CurrentMode.Language) + ":</td><td>" + System.Web.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"); } } }