/// <summary> Gets the menu items related to this viewer that should be included on the main item (digital resource) menu </summary> /// <param name="CurrentItem"> Digital resource object, which can be used to ensure if and how this viewer should appear /// in the main item (digital resource) menu </param> /// <param name="CurrentUser"> Current user, who may or may not be logged on </param> /// <param name="CurrentRequest"> Information about the current request </param> /// <param name="MenuItems"> List of menu items, to which this method may add one or more menu items </param> /// <param name="IpRestricted"> Flag indicates if this item is IP restricted AND if the current user is outside the ranges </param> public void Add_Menu_items(BriefItemInfo CurrentItem, User_Object CurrentUser, Navigation_Object CurrentRequest, List <Item_MenuItem> MenuItems, bool IpRestricted) { // Try to get the TEI file name string tei_file = CurrentItem.Behaviors.Get_Setting("TEI.Source_File"); if (tei_file == null) { // Ensure the TEI file really exists return; } // Ensure the TEI file really exists if (!SobekFileSystem.FileExists(CurrentItem, tei_file)) { return; } // Look for the label in the METS structure map string first_label = "TEI"; if (CurrentItem.Downloads != null) { foreach (BriefItem_FileGrouping thisPage in CurrentItem.Downloads) { // Look for a flash file on each page foreach (BriefItem_File thisFile in thisPage.Files) { if (String.Compare(thisFile.Name, tei_file, StringComparison.OrdinalIgnoreCase) == 0) { first_label = thisPage.Label.Replace(".xml", "").Replace(".XML", ""); break; } } } } // Allow the label to be implemented for this viewer from the database as well BriefItem_BehaviorViewer thisViewerInfo = CurrentItem.Behaviors.Get_Viewer(ViewerCode); // If this is found, and has a custom label, use that if ((thisViewerInfo != null) && (!String.IsNullOrWhiteSpace(thisViewerInfo.Label))) { first_label = thisViewerInfo.Label; } // Get the URL for this string previous_code = CurrentRequest.ViewerCode; CurrentRequest.ViewerCode = ViewerCode; string url = UrlWriterHelper.Redirect_URL(CurrentRequest); CurrentRequest.ViewerCode = previous_code; // Add the item menu information Item_MenuItem menuItem = new Item_MenuItem(first_label, null, null, url, ViewerCode); MenuItems.Add(menuItem); }
/// <summary> Write the item viewer main section as HTML directly to the HTTP output stream </summary> /// <param name="Output"> Response stream for the item viewer to write directly to </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public override void Write_Main_Viewer_Section(TextWriter Output, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("Video_ItemViewer.Add_Main_Viewer_Section", ""); } // Add the HTML for the image Output.WriteLine(" <!-- VIDEO VIEWER OUTPUT -->"); Output.WriteLine(" <td><div id=\"sbkFiv_ViewerTitle\">" + videoLabels[video - 1] + "</div></td>"); Output.WriteLine(" </tr>"); if (videoFileNames.Count > 1) { Output.WriteLine(" <tr>"); Output.WriteLine(" <td style=\"text-align:center;\">"); string url = UrlWriterHelper.Redirect_URL(CurrentRequest); Output.WriteLine(" <select id=\"sbkViv_VideoSelect\" name=\"sbkViv_VideoSelect\" onchange=\"item_jump_video('" + url + "');\">"); for (int i = 0; i < videoFileNames.Count; i++) { if (video == i + 1) { Output.WriteLine(" <option value=\"" + (i + 1) + "\" selected=\"selected\">" + videoFileNames[i] + "</option>"); } else { Output.WriteLine(" <option value=\"" + (i + 1) + "\">" + videoFileNames[i] + "</option>"); } } Output.WriteLine(" </select>"); Output.WriteLine(" </td>"); Output.WriteLine(" </tr>"); } string video_url = SobekFileSystem.Resource_Web_Uri(BriefItem, videoFileNames[video - 1]); // MAKE THIS USE THE FILES.ASPX WEB PAGE if this is restricted (or dark) if ((BriefItem.Behaviors.Dark_Flag) || (BriefItem.Behaviors.IP_Restriction_Membership > 0)) { video_url = CurrentRequest.Base_URL + "files/" + BriefItem.BibID + "/" + BriefItem.VID + "/" + videoFileNames[video - 1]; } Output.WriteLine(" <tr>"); Output.WriteLine(" <td id=\"sbkFiv_MainArea\">"); Output.WriteLine(" <video id=\"sbkViv_Movie\" src=\"" + video_url + "\" controls autoplay></video>"); Output.WriteLine(" </td>"); Output.WriteLine(" <!-- END VIDEO VIEWER OUTPUT -->"); }
protected override void OnInit(EventArgs E) { // Ensure there is a base URL if (String.IsNullOrEmpty(UI_ApplicationCache_Gateway.Settings.Servers.System_Base_URL)) { string base_url = Request.Url.AbsoluteUri.ToLower().Replace("sobekcm.aspx", ""); if (base_url.IndexOf("?") > 0) { base_url = base_url.Substring(0, base_url.IndexOf("?")); } if (base_url[base_url.Length - 1] != '/') { base_url = base_url + "/"; } UI_ApplicationCache_Gateway.Settings.Servers.System_Base_URL = base_url; UI_ApplicationCache_Gateway.Settings.Servers.Base_URL = base_url; } // Initializee the Sobek file system abstraction SobekFileSystem.Initialize(UI_ApplicationCache_Gateway.Settings.Servers.Image_Server_Network, UI_ApplicationCache_Gateway.Settings.Servers.Image_URL); // Ensure the microservices client has read the configuration file if (!SobekEngineClient.Config_Read_Attempted) { #if DEBUG string base_url = Request.Url.AbsoluteUri.ToLower().Replace("sobekcm.aspx", ""); if (base_url.IndexOf("localhost:") > 0) { if (base_url.IndexOf("?") > 0) { base_url = base_url.Substring(0, base_url.IndexOf("?")); } UI_ApplicationCache_Gateway.Settings.Servers.System_Base_URL = base_url; UI_ApplicationCache_Gateway.Settings.Servers.Base_URL = base_url; } #endif // Get the base URL string path = Server.MapPath("config/default/sobekcm_microservices.config"); SobekEngineClient.Read_Config_File(path, UI_ApplicationCache_Gateway.Settings.Servers.System_Base_URL); } pageGlobals = new SobekCM_Page_Globals(IsPostBack, "SOBEKCM"); base.OnInit(E); }
/// <summary> Indicates if the specified item matches the basic requirements for this viewer, or /// if this viewer should be ignored for this item </summary> /// <param name="CurrentItem"> Digital resource to examine to see if this viewer really should be included </param> /// <returns> TRUE if this viewer should generally be included with this item, otherwise FALSE </returns> public bool Include_Viewer(BriefItemInfo CurrentItem) { // Look for the source TEI in the item settings if ((CurrentItem.Behaviors.Settings == null) || (CurrentItem.Behaviors.Settings.Count == 0)) { return(false); } // Try to get the TEI file settings string tei_file = CurrentItem.Behaviors.Get_Setting("TEI.Source_File"); string xslt_file = CurrentItem.Behaviors.Get_Setting("TEI.XSLT"); if ((tei_file != null) && (xslt_file != null)) { // Ensure the TEI file really exists if (!SobekFileSystem.FileExists(CurrentItem, tei_file)) { return(false); } // Ensure the XSLT file really exists if (!File.Exists(xslt_file)) { // This may just not have the path on it if ((xslt_file.IndexOf("/") < 0) && (xslt_file.IndexOf("\\") < 0)) { xslt_file = Path.Combine(UI_ApplicationCache_Gateway.Settings.Servers.Application_Server_Network, "plugins\\tei\\xslt", xslt_file); if (!File.Exists(xslt_file)) { return(false); } } else { return(false); } } // Everything exists return(true); } // Since no TEI source file was found, skip this return(false); }
/// <summary> This provides an opportunity for the viewer to perform any pre-display work /// which is necessary before entering any of the rendering portions </summary> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <remarks> This ensures the dataset has been read into memory/cache for rendering </remarks> public override void Perform_PreDisplay_Work(Custom_Tracer Tracer) { string key = BriefItem.BibID + "_" + BriefItem.VID + "_Dataset"; itemDataset = HttpContext.Current.Cache[key] as DataSet; if (itemDataset == null) { // Find the dataset from the METS strucutre map. Currently this looks // only for XML with attached XSD string xml_file = null; foreach (BriefItem_FileGrouping briefGroup in BriefItem.Downloads) { foreach (BriefItem_File thisFile in briefGroup.Files) { if (thisFile.Name.IndexOf(".xml", StringComparison.OrdinalIgnoreCase) > 0) { xml_file = thisFile.Name; break; } } } // If one was found, read it in! if (!String.IsNullOrEmpty(xml_file)) { itemDataset = new DataSet(); try { // Read the XML file itemDataset.ReadXml(new StringReader(SobekFileSystem.ReadToEnd(BriefItem, xml_file))); } catch (Exception) { itemDataset = null; error_message = "Error while reading XML file " + xml_file; } // Add this to the cache HttpContext.Current.Cache.Insert(key, itemDataset, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(5)); } } }
/// <summary> Constructor for a new instance of the Sanborn_ItemViewer class, used to display a HTML file from a digital resource </summary> /// <param name="BriefItem"> Digital resource object </param> /// <param name="CurrentUser"> Current user, who may or may not be logged on </param> /// <param name="CurrentRequest"> Information about the current request </param> public Sanborn_ItemViewer(BriefItemInfo BriefItem, User_Object CurrentUser, Navigation_Object CurrentRequest) { // Save the arguments for use later this.BriefItem = BriefItem; this.CurrentUser = CurrentUser; this.CurrentRequest = CurrentRequest; // Set the behavior properties to the empy behaviors ( in the base class ) Behaviors = EmptyBehaviors; // The prototyper checks for existence of the .gif file, so that should exist // and we won't both checking again here. gifFile = BriefItem.BibID + "_" + BriefItem.VID + ".gif"; // Check for existence of the HTMl file though if (SobekFileSystem.FileExists(BriefItem, BriefItem.BibID + "_" + BriefItem.VID + ".htm")) { htmlFile = SobekFileSystem.Resource_Network_Uri(BriefItem, BriefItem.BibID + "_" + BriefItem.VID + ".htm"); } }
/// <summary> Constructor for a new instance of the TEI_ItemViewer class, used to display a /// TEI file for a given digital resource </summary> /// <param name="BriefItem"> Digital resource object </param> /// <param name="CurrentUser"> Current user, who may or may not be logged on </param> /// <param name="CurrentRequest"> Information about the current request </param> public TEI_ItemViewer(BriefItemInfo BriefItem, User_Object CurrentUser, Navigation_Object CurrentRequest) { // Save the arguments for use later this.BriefItem = BriefItem; this.CurrentUser = CurrentUser; this.CurrentRequest = CurrentRequest; // Set the behavior properties to the empy behaviors ( in the base class ) Behaviors = EmptyBehaviors; // Get the TEI files to use tei_file = BriefItem.Behaviors.Get_Setting("TEI.Source_File"); xslt_file = BriefItem.Behaviors.Get_Setting("TEI.XSLT"); css_file = BriefItem.Behaviors.Get_Setting("TEI.CSS"); // Ensure the XSLT file really exists if (!File.Exists(xslt_file)) { // This may just not have the path on it if ((xslt_file.IndexOf("/") < 0) && (xslt_file.IndexOf("\\") < 0)) { xslt_file = Path.Combine(UI_ApplicationCache_Gateway.Settings.Servers.Application_Server_Network, "plugins\\tei\\xslt", xslt_file); } } string tei_file_network = SobekFileSystem.Resource_Network_Uri(BriefItem, tei_file); XSLT_Transformer_ReturnArgs returnArgs = XSLT_Transformer.Transform(tei_file_network, xslt_file); tei_string_to_display = String.Empty; if (returnArgs.Successful) { tei_string_to_display = returnArgs.TransformedString; // FInd the head information int head_start = tei_string_to_display.IndexOf("<head", StringComparison.OrdinalIgnoreCase); int head_end = tei_string_to_display.IndexOf("</head>", StringComparison.OrdinalIgnoreCase); if ((head_start > 0) && (head_end > 0)) { head_info = tei_string_to_display.Substring(head_start, head_end - head_start); int end_bracket = head_info.IndexOf(">"); head_info = head_info.Substring(end_bracket + 1); } // Trim down to the body int body_start = tei_string_to_display.IndexOf("<body", StringComparison.OrdinalIgnoreCase); int body_end = tei_string_to_display.IndexOf("</body>", StringComparison.OrdinalIgnoreCase); if ((body_start > 0) && (body_end > 0)) { tei_string_to_display = tei_string_to_display.Substring(body_start, body_end - body_start); int end_bracket = tei_string_to_display.IndexOf(">"); tei_string_to_display = tei_string_to_display.Substring(end_bracket + 1); } } else { tei_string_to_display = "Error during XSLT transform of TEI<br /><br />" + returnArgs.ErrorMessage; } }
/// <summary> Write the item viewer main section as HTML directly to the HTTP output stream </summary> /// <param name="Output"> Response stream for the item viewer to write directly to </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public override void Write_Main_Viewer_Section(TextWriter Output, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("SearchEngineIndexing_ItemViewer.Write_Main_Viewer_Section", "Write the citation information directly to the output stream"); } // Add the HTML for the citation Output.WriteLine(" <!-- SEARCH ENGINE INDEXING ITEM VIEWER OUTPUT -->"); Output.WriteLine(" "); // If this is DARK and the user cannot edit and the flag is not set to show citation, show nothing here if ((BriefItem.Behaviors.Dark_Flag) || (BriefItem.Behaviors.IP_Restriction_Membership != 0)) { Output.WriteLine(" <td><div id=\"darkItemSuppressCitationMsg\">This item is DARK and cannot be viewed at this time</div>" + Environment.NewLine + "</td>" + Environment.NewLine + " <!-- END SEARCH ENGINE VIEWER OUTPUT -->"); return; } string viewer_code = CurrentRequest.ViewerCode; // Add the CITATION Output.WriteLine(" <td align=\"left\"><span class=\"SobekViewerTitle\">Citation</span></td>"); Output.WriteLine(" </tr>"); Output.WriteLine(" <tr>"); Output.WriteLine(" <td>"); // Add the main wrapper division // Determine the material type string microdata_type = "CreativeWork"; switch (BriefItem.Type) { case "BOOK": case "SERIAL": case "NEWSPAPER": microdata_type = "Book"; break; case "MAP": microdata_type = "Map"; break; case "PHOTOGRAPH": case "AERIAL": microdata_type = "Photograph"; break; } // Set the width int width = 180; if ((CurrentRequest.Language == Web_Language_Enum.French) || (CurrentRequest.Language == Web_Language_Enum.Spanish)) { width = 230; } // Add the main wrapper division, with microdata information Output.WriteLine(" <div id=\"sbkCiv_Citation\" itemprop=\"about\" itemscope itemtype=\"http://schema.org/" + microdata_type + "\">"); Output.WriteLine(); Output.WriteLine(Citation_Standard_ItemViewer.Standard_Citation_String(BriefItem, CurrentRequest, null, width, false, Tracer)); CurrentRequest.ViewerCode = viewer_code; Output.WriteLine(" </td>"); Output.WriteLine(" </tr>"); Output.WriteLine(" <tr>"); // Add the downloads if ((BriefItem.Downloads != null) && (BriefItem.Downloads.Count > 0)) { Output.WriteLine(" <td align=\"left\"><span class=\"SobekViewerTitle\">Downloads</span></td>"); Output.WriteLine(" </tr>"); Output.WriteLine(" <tr>"); Output.WriteLine(" <td id=\"sbkDiv_MainArea\">"); Downloads_ItemViewer.Add_Download_Links(Output, BriefItem, CurrentRequest, null, Tracer); Output.WriteLine(" </td>"); } Output.WriteLine(" </tr>"); string textLocation = SobekFileSystem.Resource_Network_Uri(BriefItem); Add_Full_Text(Output, textLocation); }
public void Simple_Results_XML(HttpResponse Response, List <string> UrlSegments, NameValueCollection QueryString, Microservice_Endpoint_Protocol_Enum Protocol, bool IsDebug) { // Local trace Custom_Tracer tracer = new Custom_Tracer(); tracer.Add_Trace("SimpleResultsEndpoints.Simple_Results_XML"); // Get all the searh field necessary from the query string Results_Arguments args = new Results_Arguments(QueryString); // Additional results arguments // limit number of results int artificial_result_limitation = -1; Boolean isNumeric = false; if (!String.IsNullOrEmpty(QueryString["limit_results"])) { isNumeric = Int32.TryParse(QueryString["limit_results"], out artificial_result_limitation); if (!isNumeric) { artificial_result_limitation = -1; } else if (artificial_result_limitation < 1) { artificial_result_limitation = -1; } } int pagenum = 1; if (!String.IsNullOrEmpty(QueryString["page"])) { isNumeric = Int32.TryParse(QueryString["page"], out pagenum); if (!isNumeric) { pagenum = 1; } else if (pagenum < 1) { pagenum = 1; } else if (pagenum > 1) { artificial_result_limitation = -1; } } // Was a collection indicated? if (UrlSegments.Count > 0) { args.Aggregation = UrlSegments[0]; } // Get the aggregation object (we need to know which facets to use, etc.. ) tracer.Add_Trace("SimpleResultsEndpoints.Get_Search_Results_Set", "Get the '" + args.Aggregation + "' item aggregation (for facets, etc..)"); Complete_Item_Aggregation aggr = AggregationServices.get_complete_aggregation(args.Aggregation, true, tracer); // If no aggregation was returned, that is an error if (aggr == null) { tracer.Add_Trace("SimpleResultsEndpoints.Simple_Results_XML", "Returned aggregation was NULL... aggregation code may not be valid"); if (IsDebug) { Response.ContentType = "text/plain"; Response.Output.WriteLine("DEBUG MODE DETECTED"); Response.Output.WriteLine(); Response.Output.WriteLine(tracer.Text_Trace); return; } Response.ContentType = "text/plain"; Response.Output.WriteLine("Error occurred or aggregation '" + args.Aggregation + "' not valid"); Response.StatusCode = 500; return; } // Perform the search tracer.Add_Trace("SimpleResultsEndpoints.Simple_Results_XML", "Perform the search"); Search_Results_Statistics resultsStats; List <iSearch_Title_Result> resultsPage; ResultsEndpointErrorEnum error = Get_Search_Results(args, aggr, false, tracer, out resultsStats, out resultsPage); // Was this in debug mode? // If this was debug mode, then just write the tracer if (IsDebug) { tracer.Add_Trace("SimpleResultsEndpoints.Simple_Results_XML", "Debug mode detected"); Response.ContentType = "text/plain"; Response.Output.WriteLine("DEBUG MODE DETECTED"); Response.Output.WriteLine(); Response.Output.WriteLine(tracer.Text_Trace); return; } try { tracer.Add_Trace("SimpleResultsEndpoints.Simple_Results_XML", "Begin writing the XML result to the response"); Response.Output.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>"); int count_pages = (int)Math.Floor((double)resultsStats.Total_Items / 20); if (count_pages == 0) { count_pages = 1; } if (pagenum > count_pages) { pagenum = count_pages; } Response.Output.WriteLine("<results total_items=\"" + resultsStats.Total_Items + "\" total_titles=\"" + resultsStats.Total_Titles + "\" page_count=\"" + count_pages + "\" max_results_per_page=\"20\""); if (artificial_result_limitation != -1) { Response.Output.WriteLine("limit_results=\"" + artificial_result_limitation + "\""); } Response.Output.WriteLine(">"); // Map to the results object title / item tracer.Add_Trace("SimpleResultsEndpoints.Get_Search_Results_Set", "Map to the results object title / item"); // resultnum int resultnum = 0; if (pagenum > 1) { resultnum = ((pagenum - 1) * 20); } if (resultsPage != null) { foreach (iSearch_Title_Result thisResult in resultsPage) { // Every results should have an item if (thisResult.Item_Count == 0) { continue; } else { resultnum++; } if (artificial_result_limitation != -1 && resultnum > artificial_result_limitation) { tracer.Add_Trace("SimpleResultsEndpoints.Simple_Results_XML", "Reached limit [" + artificial_result_limitation + "]."); break; } // add each descriptive field over iSearch_Item_Result itemResult = thisResult.Get_Item(0); string bibid = thisResult.BibID; string title = thisResult.GroupTitle; string vid = itemResult.VID; string thumbnail = itemResult.MainThumbnail; Response.Output.WriteLine(" <result resultnum=\"" + resultnum + "\" bibid=\"" + bibid + "\" vid=\"" + vid + "\">"); Response.Output.WriteLine(" <title>" + HttpUtility.HtmlEncode(title) + "</title>"); Response.Output.WriteLine(" <url_item>" + Engine_ApplicationCache_Gateway.Settings.Servers.Application_Server_URL + bibid + "/" + vid + "/</url_item>"); if (!String.IsNullOrEmpty(thumbnail)) { try { Response.Output.WriteLine(" <url_thumbnail>" + Engine_ApplicationCache_Gateway.Settings.Servers.Image_URL + SobekFileSystem.AssociFilePath(bibid, vid).Replace("\\", "/") + thumbnail.Trim() + "</url_thumbnail>"); } catch (Exception ee) { Response.Output.WriteLine("ERROR WRITING THUMBNAIL"); Response.Output.WriteLine(ee.Message); Response.Output.WriteLine(ee.StackTrace); } } int field_index = 0; if (resultsStats.Metadata_Labels.Count > 0) { Response.Output.WriteLine("<metadata>"); foreach (string metadataTerm in resultsStats.Metadata_Labels) { if (!String.IsNullOrWhiteSpace(thisResult.Metadata_Display_Values[field_index])) { // how to display this metadata field? string metadataTermDisplay = metadataTerm; string termString = thisResult.Metadata_Display_Values[field_index]; if (termString.IndexOf("|") > 0) { string[] splitter = termString.Split("|".ToCharArray()); foreach (string thisSplit in splitter) { if (!String.IsNullOrWhiteSpace(thisSplit)) { Response.Output.WriteLine(" <" + metadataTermDisplay + ">" + HttpUtility.HtmlEncode(thisSplit.Trim()) + "</" + metadataTermDisplay + ">"); } } } else { Response.Output.WriteLine(" <" + metadataTermDisplay + ">" + HttpUtility.HtmlEncode(termString.Trim()) + "</" + metadataTermDisplay + ">"); } } field_index++; } Response.Output.WriteLine("</metadata>"); } Response.Output.WriteLine(" </result>"); } } Response.Output.WriteLine("</results>"); tracer.Add_Trace("SimpleResultsEndpoints.Simple_Results_XML", "Done writing the XML result to the response"); } catch (Exception ee) { Response.Output.Write(ee.Message); Response.Output.Write(ee.StackTrace); } // If an error occurred, return the error switch (error) { case ResultsEndpointErrorEnum.Database_Exception: Response.ContentType = "text/plain"; Response.Output.WriteLine("Database exception"); Response.StatusCode = 500; return; case ResultsEndpointErrorEnum.Database_Timeout_Exception: Response.ContentType = "text/plain"; Response.Output.WriteLine("Database timeout"); Response.StatusCode = 500; return; case ResultsEndpointErrorEnum.Solr_Exception: Response.ContentType = "text/plain"; Response.Output.WriteLine("Solr exception"); Response.StatusCode = 500; return; case ResultsEndpointErrorEnum.Unknown: Response.ContentType = "text/plain"; Response.Output.WriteLine("Unknown error"); Response.StatusCode = 500; return; } // If debug, show the trace if (IsDebug) { Response.ContentType = "text/plain"; Response.Output.WriteLine("DEBUG MODE DETECTED"); Response.Output.WriteLine(); Response.Output.WriteLine(tracer.Text_Trace); return; } }
/// <summary> Write the item viewer main section as HTML directly to the HTTP output stream </summary> /// <param name="Output"> Response stream for the item viewer to write directly to </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public override void Write_Main_Viewer_Section(TextWriter Output, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("JPEG_ItemViewer.Write_Main_Viewer_Section", ""); } string displayFileName = SobekFileSystem.Resource_Web_Uri(BriefItem, filename); // MAKE THIS USE THE FILES.ASPX WEB PAGE if this is restricted (or dark) if ((BriefItem.Behaviors.Dark_Flag) || (BriefItem.Behaviors.IP_Restriction_Membership > 0)) { displayFileName = CurrentRequest.Base_URL + "files/" + BriefItem.BibID + "/" + BriefItem.VID + "/" + filename; } string name_for_image = HttpUtility.HtmlEncode(BriefItem.Title); if ((BriefItem.Images != null) && (BriefItem.Images.Count > 1) && (Current_Page - 1 < BriefItem.Images.Count)) { string name_of_page = BriefItem.Images[Current_Page - 1].Label; name_for_image = name_for_image + " - " + HttpUtility.HtmlEncode(name_of_page); } // Add the HTML for the image if (includeLinkToZoomable) { string currViewer = CurrentRequest.ViewerCode; CurrentRequest.ViewerCode = zoomableViewerCode.Replace("#", page.ToString()); string toZoomable = UrlWriterHelper.Redirect_URL(CurrentRequest); CurrentRequest.ViewerCode = currViewer; Output.WriteLine("\t\t<td id=\"sbkJiv_ImageZoomable\">"); Output.WriteLine("Click on image below to switch to zoomable version<br />"); Output.WriteLine("<a href=\"" + toZoomable + "\" title=\"Click on image to switch to zoomable version\">"); Output.Write("\t\t\t<img itemprop=\"primaryImageOfPage\" "); if ((height > 0) && (width > 0)) { Output.Write("style=\"height:" + height + "px;width:" + width + "px;\" "); } Output.WriteLine("src=\"" + displayFileName + "\" alt=\"" + name_for_image + "\" />"); Output.WriteLine("</a>"); } else { Output.WriteLine("\t\t<td align=\"center\" id=\"sbkJiv_Image\">"); Output.Write("\t\t\t<img itemprop=\"primaryImageOfPage\" "); if ((height > 0) && (width > 0)) { Output.Write("style=\"height:" + height + "px;width:" + width + "px;\" "); } Output.WriteLine("src=\"" + displayFileName + "\" alt=\"" + name_for_image + "\" />"); } Output.WriteLine("\t\t</td>"); }
/// <summary> Indicates if the specified item matches the basic requirements for this viewer, or /// if this viewer should be ignored for this item </summary> /// <param name="CurrentItem"> Digital resource to examine to see if this viewer really should be included </param> /// <returns> TRUE if this viewer should generally be included with this item, otherwise FALSE </returns> public override bool Include_Viewer(BriefItemInfo CurrentItem) { // Have to actually look in the digital resource folder return(SobekFileSystem.FileExists(CurrentItem, CurrentItem.BibID + "_" + CurrentItem.VID + ".gif")); }
/// <summary> Write the item viewer main section as HTML directly to the HTTP output stream </summary> /// <param name="Output"> Response stream for the item viewer to write directly to </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public override void Write_Main_Viewer_Section(TextWriter Output, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("Sanborn_ItemViewer.Write_Main_Viewer_Section", ""); } // Save the current viewer code string current_view_code = CurrentRequest.ViewerCode; // Start the citation table Output.WriteLine("\t\t<!-- SANBORN VIEWER OUTPUT -->"); Output.WriteLine("\t\t<td style=\"align:left;\">"); Output.WriteLine("\t\t\t<p>Click on a rectangle in the visual index below to view details.</p>"); // Determine some replacement strings here string itemURL = SobekFileSystem.Resource_Web_Uri(BriefItem); string itemLink = CurrentRequest.Base_URL + "/" + BriefItem.BibID + "/" + BriefItem.VID; // Determine the source string string gif_url = SobekFileSystem.Resource_Web_Uri(BriefItem, gifFile); // Was there a HTML map for this as well? // Look for the HTML map if (String.IsNullOrWhiteSpace(htmlFile)) { // Add just the GIF image then Output.WriteLine("<img alt=\"Sanborn Index\" src=\"" + gif_url + "\" />"); } else { try { string map = SobekFileSystem.ReadToEnd(BriefItem, htmlFile); map = map.Replace("<%ITEM_LINK%>&m=hd", itemLink + "/").Replace("\">", "j\">").Replace("Mapj", "Map"); Output.WriteLine(map); } catch (Exception ee) { } // Add the image, with a reference to the map Output.WriteLine("<img alt=\"Sanborn Index\" src=\"" + gif_url + "\" usemap=\"#Map\" />"); } //// Try to get the HTML for this //if (Tracer != null) //{ // Tracer.Add_Trace("Sanborn_ItemViewer.Write_Main_Viewer_Section", "Reading html for this view from static page"); //} //string map; //try //{ // map = SobekFileSystem.ReadToEnd(BriefItem, sourceString); //} //catch //{ // StringBuilder builder = new StringBuilder(); // builder.AppendLine("<div style=\"background-color: White; color: black;text-align:center; width:630px;\">"); // builder.AppendLine(" <br /><br />"); // builder.AppendLine(" <span style=\"font-weight:bold;font-size:1.4em\">Unable to pull html view for item ( <a href=\"" + sourceString + "\">source</a> )</span><br /><br />"); // builder.AppendLine(" <span style=\"font-size:1.2em\">We apologize for the inconvenience.</span><br /><br />"); // string returnurl = CurrentRequest.Base_URL + "/contact"; // builder.AppendLine(" <span style=\"font-size:1.2em\">Click <a href=\"" + returnurl + "\">here</a> to report the problem.</span>"); // builder.AppendLine(" <br /><br />"); // builder.AppendLine("</div>"); // map = builder.ToString(); //} //// Write the HTML //string url_options = UrlWriterHelper.URL_Options(CurrentRequest); //string urlOptions1 = String.Empty; //string urlOptions2 = String.Empty; //if (url_options.Length > 0) //{ // urlOptions1 = "?" + url_options; // urlOptions2 = "&" + url_options; //} //Output.WriteLine(map.Replace("<%URLOPTS%>", url_options).Replace("<%?URLOPTS%>", urlOptions1).Replace("<%&URLOPTS%>", urlOptions2).Replace("<%ITEMURL%>", itemURL).Replace("<%ITEM_LINK%>", itemLink)); // Finish the table Output.WriteLine("\t\t</td>"); Output.WriteLine("\t\t<!-- END SANBORN VIEWER OUTPUT -->"); // Restore the mode CurrentRequest.ViewerCode = current_view_code; }
/// <summary> Write the item viewer main section as HTML directly to the HTTP output stream </summary> /// <param name="Output"> Response stream for the item viewer to write directly to </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public override void Write_Main_Viewer_Section(TextWriter Output, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("PDF_ItemViewer.Write_Main_Viewer_Section", ""); } // Save the current viewer code string current_view_code = CurrentRequest.ViewerCode; string pdf_url = SobekFileSystem.Resource_Web_Uri(BriefItem, pdfFileNames[pdf - 1]); // Find the PDF download string displayFileName = null; foreach (BriefItem_FileGrouping downloadGroup in BriefItem.Downloads) { foreach (BriefItem_File thisFile in downloadGroup.Files) { if (String.Compare(thisFile.File_Extension, ".pdf", StringComparison.OrdinalIgnoreCase) == 0) { displayFileName = thisFile.Name; break; } } } // If the PDF was not there.. that is strange, so show a message if (String.IsNullOrEmpty(displayFileName)) { Output.WriteLine("\t\t<!-- PDF ITEM VIEWER OUTPUT -->"); Output.WriteLine("\t\t<td id=\"sbkPdf_MainArea\">ERROR: UNABLE TO FIND A PDF FILE IN THIS ITEM TO DISPLAY!</td>"); Output.WriteLine("\t\t<!-- END PDF VIEWER OUTPUT -->"); return; } // If the display name is NOT a web, than add the source URL onto it now if (displayFileName.IndexOf("http") < 0) { // MAKE THIS USE THE FILES.ASPX WEB PAGE if this is restricted (or dark) if ((BriefItem.Behaviors.Dark_Flag) || (BriefItem.Behaviors.IP_Restriction_Membership > 0)) { displayFileName = CurrentRequest.Base_URL + "files/" + BriefItem.BibID + "/" + BriefItem.VID + "/" + displayFileName; } else { displayFileName = SobekFileSystem.Resource_Web_Uri(BriefItem) + displayFileName; } } // Ensure all the slashes are going the right way (had issues with this in the past) displayFileName = displayFileName.Replace("\\", "/").Replace("//", "/").Replace("http:/", "http://"); //replace single & double quote with ascII characters if (displayFileName.Contains("'") || displayFileName.Contains("\"")) { displayFileName = displayFileName.Replace("'", "'"); displayFileName = displayFileName.Replace("\"", """); } // Start the PDF display table Output.WriteLine("\t\t<!-- PDF ITEM VIEWER OUTPUT -->"); Output.WriteLine("\t\t<td id=\"sbkPdf_MainArea\">"); Output.WriteLine("<table style=\"width:95%;\"><tr>"); Output.WriteLine("<td style=\"text-align:left\"><a id=\"sbkPdf_DownloadFileLink\" href=\"" + displayFileName + "\">Download this PDF</a></td>"); Output.WriteLine("<td style=\"text-align:right\"><a id=\"sbkPdf_DownloadAdobeReaderLink\" href=\"http://get.adobe.com/reader/\"><img src=\"" + Static_Resources_Gateway.Get_Adobe_Reader_Png + "\" alt=\"Download Adobe Reader\" /></a></td>"); Output.WriteLine("</tr></table><br />"); // Write as an iFrame, or as embed if (writeAsIframe) { Output.WriteLine(" <iframe id=\"sbkPdf_Container\" src='" + displayFileName + "' href='" + displayFileName + "' style=\"width:100%;\"></iframe>"); } else { if (!String.IsNullOrWhiteSpace(CurrentRequest.Text_Search)) { displayFileName = displayFileName + "#search=\"" + CurrentRequest.Text_Search.Replace("\"", "").Replace("+", " ").Replace("-", " ") + "\""; } Output.WriteLine(" <embed id=\"sbkPdf_Container\" src='" + displayFileName + "' href='" + displayFileName + "' style=\"width:100%;\"></embed>"); } // Finish the table Output.WriteLine("\t\t</td>"); Output.WriteLine("\t\t<!-- END PDF VIEWER OUTPUT -->"); // Restore the mode CurrentRequest.ViewerCode = current_view_code; }
public void Simple_Item_XML(HttpResponse Response, List <string> UrlSegments, NameValueCollection QueryString, Microservice_Endpoint_Protocol_Enum Protocol, bool IsDebug) { // Must at least have one URL segment for the BibID if (UrlSegments.Count > 0) { Custom_Tracer tracer = new Custom_Tracer(); try { // Get the BibID and VID string bibid = UrlSegments[0]; string vid = (UrlSegments.Count > 1) ? UrlSegments[1] : "00001"; tracer.Add_Trace("SimpleItemEndpoints.Simple_Item_XML", "Requested citation for " + bibid + ":" + vid); // Get the brief item tracer.Add_Trace("SimpleItemEndpoints.Simple_Item_XML", "Build full brief item"); Tuple <BriefItemInfo, Items.SobekCM_Item_Error> returnTuple = GetBriefItem(bibid, vid, null, tracer); // Was the item null? if ((returnTuple == null) || (returnTuple.Item1 == null)) { // If this was debug mode, then just write the tracer if (IsDebug) { tracer.Add_Trace("SimpleItemEndpoints.Simple_Item_XML", "NULL value returned from getBriefItem method"); Response.ContentType = "text/plain"; Response.Output.WriteLine("DEBUG MODE DETECTED"); Response.Output.WriteLine(); // Was an error received though? if ((returnTuple != null) && (returnTuple.Item2 != null)) { Items.SobekCM_Item_Error itemError = returnTuple.Item2; switch (itemError.Type) { case Items.SobekCM_Item_Error_Type_Enum.Invalid_BibID: Response.Output.WriteLine("ERROR: Invalid BibID requested"); break; case Items.SobekCM_Item_Error_Type_Enum.Invalid_VID: Response.Output.WriteLine("ERROR: Invalid VID requested"); Response.Output.WriteLine("First valid VID is " + itemError.FirstValidVid); break; case Items.SobekCM_Item_Error_Type_Enum.System_Error: Response.Output.WriteLine("System ERROR detected while attempting to create the item"); Response.Output.WriteLine(itemError.Message); break; } Response.Output.WriteLine(); } Response.Output.WriteLine(tracer.Text_Trace); } return; } // Get the brief item info BriefItemInfo returnValue = returnTuple.Item1; // If this was debug mode, then just write the tracer if (IsDebug) { Response.ContentType = "text/plain"; Response.Output.WriteLine("DEBUG MODE DETECTED"); Response.Output.WriteLine(); Response.Output.WriteLine(tracer.Text_Trace); return; } // If this is dark, do nothing if (returnValue.Behaviors.Dark_Flag) { Response.ContentType = "text/plain"; Response.Output.WriteLine("Item is restricted"); Response.StatusCode = 403; return; } // Create and write the basic item info Response.Output.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>"); Response.Output.WriteLine("<item bibid=\"" + returnValue.BibID + "\" vid=\"" + returnValue.VID + "\">"); Response.Output.WriteLine(" <title>" + HttpUtility.HtmlEncode(returnValue.Title) + "</title>"); Response.Output.WriteLine(" <url_item>" + Engine_ApplicationCache_Gateway.Settings.Servers.Application_Server_URL + returnValue.BibID + "/" + returnValue.VID + "/</url_item>"); // Add the thumbnail URL if (!String.IsNullOrEmpty(returnValue.Behaviors.Main_Thumbnail)) { try { Response.Output.WriteLine(" <url_thumbnail>" + Engine_ApplicationCache_Gateway.Settings.Servers.Image_URL + SobekFileSystem.AssociFilePath(returnValue.BibID, returnValue.VID).Replace("\\", "/") + returnValue.Behaviors.Main_Thumbnail.Trim() + "</url_thumbnail>"); } catch (Exception ee) { Response.Output.WriteLine("ERROR WRITING THUMBNAIL"); Response.Output.WriteLine(ee.Message); Response.Output.WriteLine(ee.StackTrace); } } Response.Output.WriteLine(" <metadata>"); // Step through the citation configuration here CitationSet citationSet = Engine_ApplicationCache_Gateway.Configuration.UI.CitationViewer.Get_CitationSet(); foreach (CitationFieldSet fieldsSet in citationSet.FieldSets) { // Step through all the fields in this field set and write them foreach (CitationElement thisField in fieldsSet.Elements) { // Look for a match in the item description BriefItem_DescriptiveTerm briefTerm = returnValue.Get_Description(thisField.MetadataTerm); // If no match, just continue if ((briefTerm == null) || (briefTerm.Values.Count == 0)) { continue; } // Get the clean XML tag for this term string cleaned_metadata_term = HttpUtility.HtmlEncode(thisField.DisplayTerm.Replace(" ", "_").Replace("/", "_").Replace("__", "_").Replace("__", "_")); foreach (BriefItem_DescTermValue term in briefTerm.Values) { Response.Output.WriteLine(" <" + cleaned_metadata_term + ">" + HttpUtility.HtmlEncode(term.Value) + "</" + cleaned_metadata_term + ">"); } } } Response.Output.WriteLine(" </metadata>"); Response.Output.WriteLine("</item>"); } catch (Exception ee) { if (IsDebug) { Response.ContentType = "text/plain"; Response.Output.WriteLine("EXCEPTION CAUGHT!"); Response.Output.WriteLine(); Response.Output.WriteLine(ee.Message); Response.Output.WriteLine(); Response.Output.WriteLine(ee.StackTrace); Response.Output.WriteLine(); Response.Output.WriteLine(tracer.Text_Trace); return; } Response.ContentType = "text/plain"; Response.Output.WriteLine("Error completing request"); Response.StatusCode = 500; } } }
public void Simple_Results_JSON(HttpResponse Response, List <string> UrlSegments, NameValueCollection QueryString, Microservice_Endpoint_Protocol_Enum Protocol, bool IsDebug) { Custom_Tracer tracer = new Custom_Tracer(); tracer.Add_Trace("SimpleResultsEndpoints.Simple_Results_JSON", "Parse request to determine search requested"); // Get all the searh field necessary from the query string Results_Arguments args = new Results_Arguments(QueryString); // Additional results arguments // limit number of results int artificial_result_limitation = -1; Boolean isNumeric = false; if (!String.IsNullOrEmpty(QueryString["limit_results"])) { isNumeric = Int32.TryParse(QueryString["limit_results"], out artificial_result_limitation); if (!isNumeric) { artificial_result_limitation = -1; } else if (artificial_result_limitation < 1) { artificial_result_limitation = -1; } } int pagenum = 1; if (!String.IsNullOrEmpty(QueryString["page"])) { isNumeric = Int32.TryParse(QueryString["page"], out pagenum); if (!isNumeric) { pagenum = 1; } else if (pagenum < 1) { pagenum = 1; } else if (pagenum > 1) { artificial_result_limitation = -1; } } // Was a collection indicated? if (UrlSegments.Count > 0) { args.Aggregation = UrlSegments[0]; } // Get the aggregation object (we need to know which facets to use, etc.. ) tracer.Add_Trace("SimpleResultsEndpoints.Simple_Results_JSON", "Get the '" + args.Aggregation + "' item aggregation (for facets, etc..)"); Complete_Item_Aggregation aggr = AggregationServices.get_complete_aggregation(args.Aggregation, true, tracer); // If no aggregation was returned, that is an error if (aggr == null) { tracer.Add_Trace("SimpleResultsEndpoints.Simple_Results_JSON", "Returned aggregation was NULL... aggregation code may not be valid"); if (IsDebug) { Response.ContentType = "text/plain"; Response.Output.WriteLine("DEBUG MODE DETECTED"); Response.Output.WriteLine(); Response.Output.WriteLine(tracer.Text_Trace); return; } Response.ContentType = "text/plain"; Response.Output.WriteLine("Error occurred or aggregation '" + args.Aggregation + "' not valid"); Response.StatusCode = 500; return; } // Perform the search tracer.Add_Trace("SimpleResultsEndpoints.Simple_Results_JSON", "Perform the search"); Search_Results_Statistics resultsStats; List <iSearch_Title_Result> resultsPage; ResultsEndpointErrorEnum error = Get_Search_Results(args, aggr, false, tracer, out resultsStats, out resultsPage); // Was this in debug mode? // If this was debug mode, then just write the tracer if (IsDebug) { Response.ContentType = "text/plain"; Response.Output.WriteLine("DEBUG MODE DETECTED"); Response.Output.WriteLine(); Response.Output.WriteLine(tracer.Text_Trace); return; } Response.Output.WriteLine("{\"stats\":{\"total_items\":\"" + resultsStats.Total_Items + "\",\"total_titles\":\"" + resultsStats.Total_Titles + "\"},"); Response.Output.WriteLine(" \"results\":["); // Map to the results object title / item tracer.Add_Trace("SimpleResultsEndpoints.Simple_Results_JSON", "Map to the results object title / item"); int items_counter = 0; int resultnum = 0; if (resultsPage != null) { foreach (iSearch_Title_Result thisResult in resultsPage) { // Every results should have an item if (thisResult.Item_Count == 0) { continue; } else { resultnum++; } if (artificial_result_limitation != -1 && resultnum > artificial_result_limitation) { tracer.Add_Trace("SimpleResultsEndpoints.Simple_Results_XML", "Reached limit [" + artificial_result_limitation + "]."); break; } // Was this NOT the first item? if (items_counter > 0) { Response.Output.WriteLine(","); } Response.Output.Write(" "); items_counter++; // add each descriptive field over iSearch_Item_Result itemResult = thisResult.Get_Item(0); string bibid = thisResult.BibID; string title = thisResult.GroupTitle; string vid = itemResult.VID; string thumbnail = itemResult.MainThumbnail; // {"bibid":"1212", "vid":"00001", "title":"sdsd", "subjects":["subj1", "subj2", "subj3"] }, Response.Output.Write("{ \"bibid\":\"" + bibid + "\", \"vid\":\"" + vid + "\", "); Response.Output.Write("\"title\":\"" + HttpUtility.HtmlEncode(title) + "\","); Response.Output.Write("\"url_item\":\"" + Engine_ApplicationCache_Gateway.Settings.Servers.Application_Server_URL + bibid + "/" + vid + "/\","); Response.Output.Write("\"url_thumbnail\":\"" + Engine_ApplicationCache_Gateway.Settings.Servers.Image_URL + SobekFileSystem.AssociFilePath(bibid, vid).Replace("\\", "/") + thumbnail + "\""); int field_index = 0; if (resultsStats.Metadata_Labels.Count > 0) { foreach (string metadataTerm in resultsStats.Metadata_Labels) { if (!String.IsNullOrWhiteSpace(thisResult.Metadata_Display_Values[field_index])) { // how to display this metadata field? string metadataTermDisplay = metadataTerm; string termString = thisResult.Metadata_Display_Values[field_index]; Response.Output.Write(",\"" + metadataTermDisplay + "\":["); int individual_term_counter = 0; if (termString.IndexOf("|") > 0) { string[] splitter = termString.Split("|".ToCharArray()); foreach (string thisSplit in splitter) { if (!String.IsNullOrWhiteSpace(thisSplit)) { if (individual_term_counter > 0) { Response.Output.Write(", \"" + HttpUtility.HtmlEncode(thisSplit.Trim()) + "\""); } else { Response.Output.Write("\"" + HttpUtility.HtmlEncode(thisSplit.Trim()) + "\""); } individual_term_counter++; } } } else { Response.Output.Write("\"" + HttpUtility.HtmlEncode(termString.Trim()) + "\""); } Response.Output.Write("]"); } field_index++; } } Response.Output.Write("}"); } } Response.Output.WriteLine(); Response.Output.WriteLine(" ]"); Response.Output.WriteLine("} "); // If an error occurred, return the error switch (error) { case ResultsEndpointErrorEnum.Database_Exception: Response.ContentType = "text/plain"; Response.Output.WriteLine("Database exception"); Response.StatusCode = 500; return; case ResultsEndpointErrorEnum.Database_Timeout_Exception: Response.ContentType = "text/plain"; Response.Output.WriteLine("Database timeout"); Response.StatusCode = 500; return; case ResultsEndpointErrorEnum.Solr_Exception: Response.ContentType = "text/plain"; Response.Output.WriteLine("Solr exception"); Response.StatusCode = 500; return; case ResultsEndpointErrorEnum.Unknown: Response.ContentType = "text/plain"; Response.Output.WriteLine("Unknown error"); Response.StatusCode = 500; return; } }
/// <summary> This provides an opportunity for the viewer to perform any pre-display work /// which is necessary before entering any of the rendering portions </summary> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <remarks> This ensures the dataset has been read into memory/cache for rendering </remarks> public override void Perform_PreDisplay_Work(Custom_Tracer Tracer) { string key = CurrentItem.BibID + "_" + CurrentItem.VID + "_Dataset"; itemDataset = HttpContext.Current.Cache[key] as DataSet; if (itemDataset == null) { // Find the dataset from the METS strucutre map. Currently this looks // only for XML with attached XSD string xml_file = null; foreach (BriefItem_FileGrouping briefGroup in BriefItem.Downloads) { foreach (BriefItem_File thisFile in briefGroup.Files) { if (thisFile.Name.IndexOf(".xml", StringComparison.OrdinalIgnoreCase) > 0) { xml_file = thisFile.Name; break; } } } // If one was found, read it in! if (!String.IsNullOrEmpty(xml_file)) { itemDataset = new DataSet(); try { // Read the XML file itemDataset.ReadXml(new StringReader(SobekFileSystem.ReadToEnd(BriefItem, xml_file))); } catch (Exception) { itemDataset = null; error_message = "Error while reading XML file " + xml_file; } // Add this to the cache HttpContext.Current.Cache.Insert(key, itemDataset, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(5)); } } // Check the row data if ((itemDataset != null) && (itemDataset.Tables.Count > 0)) { int subpage_index = CurrentMode.SubPage.HasValue ? CurrentMode.SubPage.Value : 0; DataTable tbl = itemDataset.Tables[0]; if ((subpage_index < itemDataset.Tables.Count + 2) && (subpage_index >= 2)) { tbl = itemDataset.Tables[subpage_index - 2]; } row = -1; if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["row"])) { if (Int32.TryParse(HttpContext.Current.Request.QueryString["row"], out row)) { if ((row < 1) || (row > tbl.Rows.Count)) { row = -1; } } } } }
/// <summary> Write the item viewer main section as HTML directly to the HTTP output stream </summary> /// <param name="Output"> Response stream for the item viewer to write directly to </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public override void Write_Main_Viewer_Section(TextWriter Output, Custom_Tracer Tracer) { Tracer.Add_Trace("Directory_ItemViewer.Write_Main_Viewer_Section", ""); // Add the HTML for the image Output.WriteLine("<!-- DIRECTORY ITEM VIEWER OUTPUT -->"); // Start the citation table Output.WriteLine(" <td align=\"left\"><span class=\"sbkTrk_ViewerTitle\">Tracking Information</span></td>"); Output.WriteLine("</tr>"); Output.WriteLine("<tr>"); Output.WriteLine(" <td class=\"sbkTrk_MainArea\">"); // Add the tabs for related admin viewers (if they exist) Tracking_ItemViewer.Write_Tracking_Tabs(Output, CurrentRequest, BriefItem); Tracer.Add_Trace("Directory_ItemViewer.Directory_String", "Pulling and displaying files in the image directory"); try { string directory = SobekFileSystem.Resource_Network_Uri(BriefItem); string url = SobekFileSystem.Resource_Web_Uri(BriefItem); List <SobekFileSystem_FileInfo> files = SobekFileSystem.GetFiles(BriefItem); // Get all the file info objects and order by name SortedList <string, SobekFileSystem_FileInfo> sortedFiles = new SortedList <string, SobekFileSystem_FileInfo>(); foreach (SobekFileSystem_FileInfo thisFile in files) { sortedFiles.Add(thisFile.Name.ToUpper(), thisFile); } // Remove the THUMBS.DB file, if it exists if (sortedFiles.ContainsKey("THUMBS.DB")) { sortedFiles.Remove("THUMBS.DB"); } // Start the file table Output.WriteLine("<br />"); Output.WriteLine("<br />"); Output.WriteLine("<blockquote>"); Output.WriteLine(" <a href=\"" + directory + "\">" + directory + "</a>"); Output.WriteLine("</blockquote>"); Output.WriteLine("<blockquote>"); // Add all the page images first List <BriefItem_FileGrouping> nodes = BriefItem.Images; if ((nodes != null) && (nodes.Count > 0)) { Output.WriteLine("<span style=\"font-size:1.4em; color:#888888;\"><b>PAGE FILES</b></span><br />"); Output.WriteLine("<table border=\"0px\" cellspacing=\"0px\" class=\"statsTable\">"); Output.WriteLine("<tr align=\"left\" bgcolor=\"#0022a7\" height=\"20px\" >"); Output.WriteLine("<th align=\"left\"><span style=\"color: White\">NAME</span></th>"); Output.WriteLine("<th width=\"10px\"> </th>"); Output.WriteLine("<th align=\"left\" width=\"170px\"><span style=\"color: White\">DATE MODIFIED</span></th>"); Output.WriteLine("<th align=\"left\" width=\"180px\"><span style=\"color: White\">TYPE</span></th>"); Output.WriteLine("<th width=\"10px\"> </th>"); Output.WriteLine("<th align=\"right\"><span style=\"color: White\">SIZE</span></th>"); Output.WriteLine("</tr>"); List <string> file_names_added = new List <string>(); foreach (BriefItem_FileGrouping thisNode in nodes) { // Only show pages with files if (thisNode.Files.Count > 0) { // Ensure that if a page is repeated, it only is written once string[] filename_splitter = thisNode.Files[0].Name.Split(".".ToCharArray()); string fileName = filename_splitter[0].ToUpper(); if (filename_splitter.Length > 1) { fileName = filename_splitter[filename_splitter.Length - 2].ToUpper(); } if (!file_names_added.Contains(fileName)) { file_names_added.Add(fileName); Output.WriteLine("<tr align=\"left\" bgcolor=\"#7d90d5\">"); string pageName = thisNode.Label; if (pageName.Length == 0) { pageName = "PAGE"; } Output.WriteLine("<td colspan=\"6\" ><span style=\"color: White\"><b>" + pageName.ToUpper() + "</b></span></td>"); Output.WriteLine("</tr>"); // Now, check for each file foreach (BriefItem_File thisFile in thisNode.Files) { string thisFileUpper = thisFile.Name.ToUpper(); if (sortedFiles.ContainsKey(thisFileUpper)) { // string file = UI_ApplicationCache_Gateway.Settings.Servers.Image_Server_Network + currentItem.Web.AssocFilePath + thisFile.System_Name; Add_File_HTML(sortedFiles[thisFileUpper], Output, url, true); sortedFiles.Remove(thisFileUpper); } } // Ensure that there still aren't some page files that exist that were not linked string[] other_page_file_endings = { ".JPG", ".JP2", "THM.JPG", ".TXT", ".PRO", ".QC.JPG" }; foreach (string thisFileEnder in other_page_file_endings) { if (sortedFiles.ContainsKey(fileName.ToUpper() + thisFileEnder)) { //string file = UI_ApplicationCache_Gateway.Settings.Servers.Image_Server_Network + currentItem.Web.AssocFilePath + fileName + thisFileEnder.ToLower(); Add_File_HTML(sortedFiles[fileName.ToUpper() + thisFileEnder], Output, url, true); sortedFiles.Remove(fileName.ToUpper() + thisFileEnder); } } } } } // FInish the table Output.WriteLine("</table>"); Output.WriteLine("<br /><br />"); } // Add all the metadata files Output.WriteLine("<span style=\"font-size:1.4em; color:#888888;\"><b>METADATA FILES</b></span><br />"); Output.WriteLine("<table border=\"0px\" cellspacing=\"0px\" class=\"statsTable\">"); Output.WriteLine("<tr align=\"left\" bgcolor=\"#0022a7\" height=\"20px\" >"); Output.WriteLine("<th align=\"left\"><span style=\"color: White\">NAME</span></th>"); Output.WriteLine("<th width=\"10px\"> </th>"); Output.WriteLine("<th align=\"left\" width=\"170px\"><span style=\"color: White\">DATE MODIFIED</span></th>"); Output.WriteLine("<th align=\"left\" width=\"180px\"><span style=\"color: White\">TYPE</span></th>"); Output.WriteLine("<th width=\"10px\"> </th>"); Output.WriteLine("<th align=\"right\"><span style=\"color: White\">SIZE</span></th>"); Output.WriteLine("</tr>"); // Add each metadata file List <string> files_handled = new List <string>(); foreach (string thisFile in sortedFiles.Keys.Where(ThisFile => (ThisFile.IndexOf(".METS.BAK") > 0) || (ThisFile.IndexOf(".METS.XML") > 0) || (ThisFile == "DOC.XML") || (ThisFile == "MARC.XML") || (ThisFile == "CITATION_METS.XML") || (ThisFile == BriefItem.BibID.ToUpper() + "_" + BriefItem.VID + ".HTML"))) { files_handled.Add(thisFile); Add_File_HTML(sortedFiles[thisFile], Output, url, true); } // REmove all handled files foreach (string thisKey in files_handled) { sortedFiles.Remove(thisKey); } // FInish the table Output.WriteLine("</table>"); Output.WriteLine("<br /><br />"); // Finally, add all the remaining files if (sortedFiles.Count > 0) { Output.WriteLine("<span style=\"font-size:1.4em; color:#888888;\"><b>OTHER FILES</b></span><br />"); Output.WriteLine("<table border=\"0px\" cellspacing=\"0px\" class=\"statsTable\">"); Output.WriteLine("<tr align=\"left\" bgcolor=\"#0022a7\" height=\"20px\" >"); Output.WriteLine("<th align=\"left\"><span style=\"color: White\">NAME</span></th>"); Output.WriteLine("<th width=\"10px\"> </th>"); Output.WriteLine("<th align=\"left\" width=\"170px\"><span style=\"color: White\">DATE MODIFIED</span></th>"); Output.WriteLine("<th align=\"left\" width=\"180px\"><span style=\"color: White\">TYPE</span></th>"); Output.WriteLine("<th width=\"10px\"> </th>"); Output.WriteLine("<th align=\"right\"><span style=\"color: White\">SIZE</span></th>"); Output.WriteLine("</tr>"); // Now add all the information foreach (SobekFileSystem_FileInfo thisFile in sortedFiles.Values) { Add_File_HTML(thisFile, Output, url, true); } // FInish the table Output.WriteLine("</table>"); } Output.WriteLine("</blockquote>"); Output.WriteLine("<br />"); } catch { Output.WriteLine("<br /><center><strong>UNABLE TO PULL DIRECTORY INFORMATION</strong></center><br />"); } Output.WriteLine(" </td>"); Output.WriteLine(" <!-- END DIRECTORY VIEWER OUTPUT -->"); }
/// <summary> Write the item viewer main section as HTML directly to the HTTP output stream </summary> /// <param name="Output"> Response stream for the item viewer to write directly to </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public override void Write_Main_Viewer_Section(TextWriter Output, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("HTML_ItemViewer.Write_Main_Viewer_Section", ""); } // Save the current viewer code string current_view_code = CurrentRequest.ViewerCode; // Start the citation table Output.WriteLine("\t\t<!-- HTML VIEWER OUTPUT -->"); Output.WriteLine("\t\t<td style=\"align:left;\">"); // Determine some replacement strings here string itemURL = SobekFileSystem.Resource_Web_Uri(BriefItem); string itemLink = CurrentRequest.Base_URL + "/" + BriefItem.BibID + "/" + BriefItem.VID; // Determine the source string string sourceString = SobekFileSystem.Resource_Web_Uri(BriefItem) + htmlFile; if ((htmlFile.IndexOf("http://") == 0) || (htmlFile.IndexOf("https://") == 0) || (htmlFile.IndexOf("[%BASEURL%]") == 0) || (htmlFile.IndexOf("<%BASEURL%>") == 0)) { sourceString = htmlFile.Replace("[%BASEURL%]", CurrentRequest.Base_URL).Replace("<%BASEURL%>", CurrentRequest.Base_URL); } // Try to get the HTML for this if (Tracer != null) { Tracer.Add_Trace("HTML_ItemViewer.Write_Main_Viewer_Section", "Reading html for this view from static page"); } string map; try { map = SobekFileSystem.ReadToEnd(BriefItem, sourceString); } catch { StringBuilder builder = new StringBuilder(); builder.AppendLine("<div style=\"background-color: White; color: black;text-align:center; width:630px;\">"); builder.AppendLine(" <br /><br />"); builder.AppendLine(" <span style=\"font-weight:bold;font-size:1.4em\">Unable to pull html view for item ( <a href=\"" + sourceString + "\">source</a> )</span><br /><br />"); builder.AppendLine(" <span style=\"font-size:1.2em\">We apologize for the inconvenience.</span><br /><br />"); string returnurl = CurrentRequest.Base_URL + "/contact"; builder.AppendLine(" <span style=\"font-size:1.2em\">Click <a href=\"" + returnurl + "\">here</a> to report the problem.</span>"); builder.AppendLine(" <br /><br />"); builder.AppendLine("</div>"); map = builder.ToString(); } // Write the HTML string url_options = UrlWriterHelper.URL_Options(CurrentRequest); string urlOptions1 = String.Empty; string urlOptions2 = String.Empty; if (url_options.Length > 0) { urlOptions1 = "?" + url_options; urlOptions2 = "&" + url_options; } Output.WriteLine(map.Replace("<%URLOPTS%>", url_options).Replace("<%?URLOPTS%>", urlOptions1).Replace("<%&URLOPTS%>", urlOptions2).Replace("<%ITEMURL%>", itemURL).Replace("<%ITEM_LINK%>", itemLink)); // Finish the table Output.WriteLine("\t\t</td>"); Output.WriteLine("\t\t<!-- END HTML VIEWER OUTPUT -->"); // Restore the mode CurrentRequest.ViewerCode = current_view_code; }
/// <summary> Write the item viewer main section as HTML directly to the HTTP output stream </summary> /// <param name="Output"> Response stream for the item viewer to write directly to </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public override void Write_Main_Viewer_Section(TextWriter Output, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("JPEG2000_ItemViewer.Write_Main_Viewer_Section", "Adds the container for the zoomable image"); } Output.WriteLine("<td>"); Output.WriteLine("<div id=\"sbkJp2_Container\" ></div>"); Output.WriteLine(); Output.WriteLine("<script type=\"text/javascript\">"); Output.WriteLine(" viewer = OpenSeadragon({"); Output.WriteLine(" id: \"sbkJp2_Container\","); Output.WriteLine(" prefixUrl : \"" + Static_Resources_Gateway.OpenSeaDragon_Image_Prefix + "\","); if (suppressNavigator) { Output.WriteLine(" showNavigator: false"); } else { Output.WriteLine(" showNavigator: true,"); Output.WriteLine(" navigatorId: \"sbkJp2_Navigator\","); // Doesn't actually set the navigator size (the CSS does), but setting this means // OpenSeaDragon won't try to set the width/height as a ratio of the main image. Output.WriteLine(" navigatorWidth: \"195px\","); Output.WriteLine(" navigatorHeight: \"195px\""); } Output.WriteLine(" });"); Output.WriteLine(); //add by Keven for FIU dPanther's separate image server if (UI_ApplicationCache_Gateway.Settings.Servers.Image_Server_Root != null) { Output.WriteLine(" viewer.open(\"" + CurrentRequest.Base_URL + "iipimage/iipsrv.fcgi?DeepZoom=" + UI_ApplicationCache_Gateway.Settings.Servers.Image_Server_Root.Replace("\\", "/") + SobekFileSystem.AssociFilePath(BriefItem).Replace("\\", "/") + filename + ".dzi\");"); } else { Output.WriteLine(" viewer.open(\"" + CurrentRequest.Base_URL + "iipimage/iipsrv.fcgi?DeepZoom=" + UI_ApplicationCache_Gateway.Settings.Servers.Image_Server_Network.Replace("\\", "/") + SobekFileSystem.AssociFilePath(BriefItem).Replace("\\", "/") + filename + ".dzi\");"); } Output.WriteLine("</script>"); Output.WriteLine("</td>"); }
/// <summary> Constructor for a new instance of the Text_ItemViewer class, used to display the text /// associated with the pages for a digital resource </summary> /// <param name="BriefItem"> Digital resource object </param> /// <param name="CurrentUser"> Current user, who may or may not be logged on </param> /// <param name="CurrentRequest"> Information about the current request </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <param name="Text_ViewerCode"> Text viewer code, as determined by configuration files </param> /// <param name="FileExtensions"> File extensions that this viewer allows, as determined by configuration files </param> public Text_ItemViewer(BriefItemInfo BriefItem, User_Object CurrentUser, Navigation_Object CurrentRequest, Custom_Tracer Tracer, string Text_ViewerCode, string[] FileExtensions) { // Add the trace if (Tracer != null) { Tracer.Add_Trace("Text_ItemViewer.Constructor"); } // Save the arguments for use later this.BriefItem = BriefItem; this.CurrentUser = CurrentUser; this.CurrentRequest = CurrentRequest; // Set the behavior properties Behaviors = EmptyBehaviors; // Determine the page page = 1; if (!String.IsNullOrEmpty(CurrentRequest.ViewerCode)) { int tempPageParse; if (Int32.TryParse(CurrentRequest.ViewerCode.Replace(Text_ViewerCode.Replace("#", ""), ""), out tempPageParse)) { page = tempPageParse; } } // Just a quick range check if (page > BriefItem.Images.Count) { page = 1; } // Try to set the file information here if ((!set_file_information(FileExtensions)) && (page != 1)) { // If there was an error, just set to the first page page = 1; set_file_information(FileExtensions); } // Since this is a paging viewer, set the viewer code if (String.IsNullOrEmpty(CurrentRequest.ViewerCode)) { CurrentRequest.ViewerCode = Text_ViewerCode.Replace("#", page.ToString()); } try { // Set some defaults text_from_file = String.Empty; file_does_not_exist = false; error_occurred = false; width = -1; if (filename.Length > 0) { text_from_file = SobekFileSystem.ReadToEnd(BriefItem, filename); // Did this work? if (text_from_file.Length > 0) { string[] splitter = text_from_file.Split("\n".ToCharArray()); foreach (string thisString in splitter) { width = Math.Max(width, thisString.Length * 9); } // width = Math.Min(width, 800); } } else { file_does_not_exist = true; } } catch (Exception ee) { text_from_file = "EXCEPTION CAUGHT: " + ee.Message; } }
private void Delete_Item() { errorCode = 0; // Get the current item details string vid_location = SobekFileSystem.Resource_Network_Uri(itemToDelete); DirectoryInfo directoryInfo = (new DirectoryInfo(vid_location)).Parent; if (directoryInfo != null) { string bib_location = directoryInfo.FullName; //if (errorCode == -1) //{ // // Get item details // DataSet itemDetails = SobekCM_Database.Get_Item_Details(currentMode.BibID, currentMode.VID, Tracer); // // If the itemdetails was null, this item is somehow invalid item then // if (itemDetails == null) // { // Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Item indicated is not valid", Custom_Trace_Type_Enum.Error); // errorCode = 2; // } // else // { // // Get the location for this METS file from the returned value // DataRow mainItemRow = itemDetails.Tables[2].Rows[0]; // bib_location = UI_ApplicationCache_Gateway.Settings.Servers.Image_Server_Network + mainItemRow["File_Location"].ToString().Replace("/", "\\"); // vid_location = bib_location + "\\" + currentMode.VID; // } //} // Perform the database delete RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Perform database update"); bool database_result2 = Engine_Database.Delete_SobekCM_Item(RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Current_Mode.VID, RequestSpecificValues.Current_User.Is_System_Admin, String.Empty); // Perform the SOLR delete RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Perform solr delete"); Solr_Controller.Delete_Resource_From_Index(UI_ApplicationCache_Gateway.Settings.Servers.Document_Solr_Index_URL, UI_ApplicationCache_Gateway.Settings.Servers.Page_Solr_Index_URL, RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Current_Mode.VID); if (!database_result2) { RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Error performing delete in the database", Custom_Trace_Type_Enum.Error); errorCode = 3; } else { // Move the folder to deletes try { RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Move resource files to RECYCLE BIN folder"); // Make sure upper RECYCLE BIN folder exists, or create it string delete_folder = UI_ApplicationCache_Gateway.Settings.Servers.Image_Server_Network + "RECYCLE BIN"; if (!Directory.Exists(delete_folder)) { Directory.CreateDirectory(delete_folder); } // Create the bib level folder next string bib_folder = UI_ApplicationCache_Gateway.Settings.Servers.Image_Server_Network + "RECYCLE BIN\\" + RequestSpecificValues.Current_Mode.BibID; if (!Directory.Exists(bib_folder)) { Directory.CreateDirectory(bib_folder); } // Ensure the VID folder does not exist string vid_folder = UI_ApplicationCache_Gateway.Settings.Servers.Image_Server_Network + "RECYCLE BIN\\" + RequestSpecificValues.Current_Mode.BibID + "\\" + RequestSpecificValues.Current_Mode.VID; if (Directory.Exists(vid_folder)) { Directory.Move(vid_folder, vid_folder + "_OLD"); } // Move the VID folder over now Directory.Move(vid_location, vid_folder); // Check if this was the last VID under this BIB if (Directory.GetDirectories(bib_location).Length == 0) { // Move all files over to the bib folder then string[] bib_files = Directory.GetFiles(bib_location); foreach (string thisFile in bib_files) { string fileName = (new FileInfo(thisFile)).Name; string new_file = bib_folder + "\\" + fileName; File.Move(thisFile, new_file); } } } catch (Exception ee) { RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Error moving the folder and files to the RECYCLE BIN folder", Custom_Trace_Type_Enum.Error); RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", ee.Message, Custom_Trace_Type_Enum.Error); RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", ee.StackTrace, Custom_Trace_Type_Enum.Error); errorCode = 4; } // Also remove from the cache CachedDataManager.Items.Remove_Digital_Resource_Object(RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Current_Mode.VID, RequestSpecificValues.Tracer); } } }
/// <summary> Write any additional values within the HTML Head of the final served page </summary> /// <param name="Output"> Output stream currently within the HTML body tags </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public override void Write_Main_Viewer_Section(TextWriter Output, Custom_Tracer Tracer) { //String baseurl = CurrentRequest.Base_URL + "plugins/MODEL3DTHREEJS/models/"; String baseurl = "/plugins/MODEL3DTHREEJS/models/"; Output.WriteLine("<script type=\"text/javascript\">"); Output.WriteLine(" $('#itemNavForm').prop('action','').submit(function(event){ event.preventDefault(); });"); Output.WriteLine("</script>"); // Is there a .obj file in the content folder? Otherwise, use the models/?.obj sample string source_url = "female-croupier-2013-03-26.obj"; string mtl_url = "female-croupier-2013-03-26.mtl"; string network_location; Output.WriteLine("<!-- bibid=[" + BriefItem.BibID + ":" + BriefItem.VID + "] -->"); try { network_location = SobekFileSystem.Resource_Network_Uri(BriefItem); Output.WriteLine("<!-- network_location=[" + network_location + "]. -->"); } catch (Exception e) { Output.WriteLine("<!-- exception trying to get network_location... -->"); network_location = "C:/inetpub/wwwroot/temp/"; } // Does an *.obj file exist? String[] files_obj = Directory.GetFiles(network_location, "*.obj", SearchOption.TopDirectoryOnly); String[] files_mtl = Directory.GetFiles(network_location, "*.mtl", SearchOption.TopDirectoryOnly); if (!(files_obj.Length > 0 && files_mtl.Length > 0)) { Output.WriteLine("<!-- doesn't have both a obj and mtl file -->"); } else { baseurl = SobekFileSystem.AssociFilePath(BriefItem).Replace("\\", "/"); if (files_obj.Length > 0) { Output.WriteLine("<!-- has an obj file. -->"); //baseurl = UI_ApplicationCache_Gateway.Settings.Servers.Image_URL + SobekFileSystem.AssociFilePath(BriefItem).Replace("\\", "/"); baseurl = "/content/" + SobekFileSystem.AssociFilePath(BriefItem).Replace("\\", "/"); source_url = Path.GetFileName(files_obj[0]); Output.WriteLine("<!-- source_url=[" + source_url + "]. -->"); } else { Output.WriteLine("<!-- no obj files found, using default -->"); } if (files_mtl.Length > 0) { Output.WriteLine("<!-- has an mtl file. -->"); //baseurl = UI_ApplicationCache_Gateway.Settings.Servers.Image_URL + SobekFileSystem.AssociFilePath(BriefItem).Replace("\\", "/"); baseurl = "/content/" + SobekFileSystem.AssociFilePath(BriefItem).Replace("\\", "/"); mtl_url = Path.GetFileName(files_mtl[0]); Output.WriteLine("<!-- mtl_url=[" + mtl_url + "]. -->"); } else { Output.WriteLine("<!-- no mtl files found, using default -->"); } } Output.WriteLine("<!-- baseurl=[" + baseurl + "]. -->"); // Fit into SobekCM item page Output.WriteLine(" <td style=\"width:100%; height:100%;\">"); // write tool container Output.WriteLine(" <div id=\"threejsdiv\"></div>"); // Fit into SobekCM item page Output.WriteLine(" </td>"); //jquery document ready Output.WriteLine("<script type=\"text/javascript\">"); Output.WriteLine("$(document).ready(function()"); Output.WriteLine("{"); Output.WriteLine("\tconsole.log(\"additional jquery doc ready.\");"); Output.WriteLine("\tconsole.log(\"baseurl=[" + baseurl + "], source_url=[" + source_url + "], mtl_url=[" + mtl_url + "].\");"); Output.WriteLine("\tsetupTHREEJS('" + baseurl + "','" + source_url + "','" + mtl_url + "');"); Output.WriteLine("\t$(\".sbkIsw_DocumentDisplay2\").css(\"width\",\"100%\").css(\"height\",\"100%\");"); Output.WriteLine("});"); Output.WriteLine("</script>"); }
/// <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) { Tracer.Add_Trace("SimileTimeline_ResultsViewer", "timeline version = " + timeline_version); logme("Add_HTML is called..."); SimileDate sd; string dir_resource = null, mydate, mymonth, myday, myyear, path; string msg = null, packageid = null, myAbstract = "", mySubjects = "", bibid, vid; string SortDateString = ""; List <int> yearsRepresented = new List <int>(); List <int> yearsRepresentedDistinct = new List <int>(); List <int> decades = new List <int>(); List <int> decadesDistinct = new List <int>(); int count_missing_date = 0, pagedresults_itemcount = 0, titleresult_itemcount = 0; int count_total = 0; Dictionary <int, DateTime> earliest_time_by_decade = new Dictionary <int, DateTime>(); Dictionary <int, int> decades_calculated = new Dictionary <int, int>(); List <SimileDate> dateList = new List <SimileDate>(); Literal mainLiteral = null; Random rand = new Random(); Boolean hasMissingDates = false; int tlsn = rand.Next(1, 999999); Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; DateTime convertedDate, dateFromZero; int i = 0, yearnum, monthnum, daynum; if (Tracer != null) { Tracer.Add_Trace("SimileTimeline_ResultsViewer.Add_HTML", "Rendering results in timeline view"); } // Start this table StringBuilder resultsBldr = new StringBuilder(5000); // If results are null, or no results, return empty string if ((PagedResults == null) || (ResultsStats == null) || (ResultsStats.Total_Items <= 0)) { return; } StringBuilder datajs = new StringBuilder(); if (debug) { logme("PagedResults count=[" + PagedResults.Count + "]."); } datajs.Append("var timeline_data = {"); datajs.Append("'dateTimeFormat': 'iso8601',"); datajs.Append("'wikiURL': \"http://simile.mit.edu/shelf/\","); datajs.Append("'wikiSection': \"Simile Timeline\","); datajs.Append("\r\n"); datajs.Append("'events' : ["); // 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/"; } // Should the publication date be shown? bool showDate = RequestSpecificValues.Current_Mode.Sort >= 10; if (debug) { logme("RequestSpecificValues.Current_Mode.Sort=[" + RequestSpecificValues.Current_Mode.Sort + "]."); } resultsBldr.AppendLine("<!-- RequestSpecificValues.Current_Mode.Sort=[" + RequestSpecificValues.Current_Mode.Sort + "]. -->"); resultsBldr.AppendLine("<script type=\"text/javascript\">"); resultsBldr.AppendLine(" jQuery('#itemNavForm').prop('action','').submit(function(event){ event.preventDefault(); });"); resultsBldr.AppendLine("</script>"); //Add the necessary JavaScript, CSS files resultsBldr.AppendLine(" <script type=\"text/javascript\" src=\"" + Static_Resources_Gateway.Sobekcm_Thumb_Results_Js + "\"></script>"); iSearch_Item_Result itemResult; pagedresults_itemcount = PagedResults.Count; Tracer.Add_Trace("SimileTimeline_ResultsViewer", "PagedResults.Count=[" + PagedResults.Count + "]."); foreach (iSearch_Title_Result titleResult in PagedResults) { titleresult_itemcount = titleResult.Item_Count; bool multiple_title = titleResult.Item_Count > 1; if (debug) { resultsBldr.AppendLine("<!-- titleResult.Item_Count=[" + titleResult.Item_Count + "].-->"); } // Get the first item itemResult = titleResult.Get_Item(0); bibid = titleResult.BibID; vid = itemResult.VID; // Determine the internal link to the first (possibly only) item string internal_link = base_url + bibid + "/" + vid + textRedirectStem; packageid = bibid + "/" + vid; //resultsBldr.AppendLine("<!-- internal_link=[" + internal_link + "].-->"); // For browses, just point to the title if ((RequestSpecificValues.Current_Mode.Mode == Display_Mode_Enum.Aggregation) && (RequestSpecificValues.Current_Mode.Aggregation_Type == Aggregation_Type_Enum.Browse_Info)) { internal_link = base_url + titleResult.BibID + textRedirectStem; } if (debug) { resultsBldr.AppendLine("<!-- internal_link=[" + internal_link + "].-->"); } //resultsBldr.AppendLine("<!-- snippet=[" + titleResult.Snippet + "].-->"); dir_resource = SobekFileSystem.Resource_Network_Uri(bibid, vid); if (debug) { logme("dir_resource (SobekFileSystem.Resource_Network_Uri)=[" + dir_resource + "]."); } source_url = UI_ApplicationCache_Gateway.Settings.Servers.Image_URL + SobekFileSystem.AssociFilePath(bibid, vid).Replace("\\", "/"); if (debug) { logme("source_url (UI_ApplicationCache_Gateway.Settings.Server.Image_URL=[" + source_url + "]."); } string title; // metadata Title title = itemResult.Title;; title = Regex.Replace(title, @"<[^>]+>| ", "").Trim(); // Add the title // path = source_url + "/" + firstItemResult.MainThumbnail; // that doesn't work when granting access through a router / local lan if (debug) { logme("source_url=[" + source_url + "]."); } // if (debug) logme("titleResult.GroupThumbnail=[" + titleResult.GroupThumbnail + "]."); if (debug) { logme("thumbnail from item[" + itemResult.MainThumbnail + "]."); } // Check if the thumbnail exists, if the flag is set for that if ((Verify_Thumbnail_Files) && (!File.Exists(dir_resource + @"\" + itemResult.MainThumbnail))) { if (debug) { logme("Thumbnail DOESN'T exist=[" + dir_resource + @"\" + itemResult.MainThumbnail + "]."); } path = "http://" + getMyIP() + "/default/images/misc/nothumb.jpg"; } else { if (debug) { logme("Thumbnail EXISTS=[" + dir_resource + @"\" + itemResult.MainThumbnail + "]."); } // thumbnail filename was titleResult.GroupThumbnail // path = "http://" + getMyIP() + "/" + source_url.Substring(source_url.IndexOf("content")) + itemResult.MainThumbnail; 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) + "/" + itemResult.VID + "/" + (itemResult.MainThumbnail).Replace("\\", "/").Replace("//", "/"); path = UI_ApplicationCache_Gateway.Settings.Servers.Image_URL + thumb; } if (debug) { logme("URL (path) to thumbnail=[" + path + "]."); } SortDateString = getMetadata(titleResult, ResultsStats, "Timeline Date").Trim(); if (debug) { logme(msg); } if (SortDateString.Length > 0 && !SortDateString.Contains("N/A")) { convertedDate = DateTime.Parse(SortDateString); if (debug) { logme(packageid + ": convertedDate=[" + convertedDate.ToString("yyyy-MM-dd") + "]."); } yearnum = convertedDate.Year; monthnum = convertedDate.Month; daynum = convertedDate.Day; yearsRepresented.Add(yearnum); // Get the decade here int decade = RoundDown(yearnum, Tracer); // Does this decade already exist? if (decades_calculated.ContainsKey(decade)) { // Then need to see if this is earlier than the last first date if (earliest_time_by_decade[decade] > convertedDate) { earliest_time_by_decade[decade] = convertedDate; } // Also, increment the number of dates in this decade decades_calculated[decade] = decades_calculated[decade] + 1; } else { // New decade found decades_calculated[decade] = 1; earliest_time_by_decade[decade] = convertedDate; } // Create this simile date object sd = new SimileDate(); sd.yearnum = yearnum; sd.monthnum = monthnum; sd.daynum = daynum; dateList.Add(sd); //msg = packageid + ": Good date: SortDateString=[" + SortDateString + "]."; //Tracer.Add_Trace("SimileTimeline_ResultsViewer", msg); } else { msg = packageid + ": Bad/no date: SortDateString=[" + SortDateString + "]."; Tracer.Add_Trace("SimileTimeline_ResultsViewer", msg); yearnum = -1; monthnum = -1; daynum = -1; hasMissingDates = true; } if (debug) { logme(packageid + ": yearnum=[" + yearnum + "], monthnum=[" + monthnum + "], daynum=[" + daynum + "]."); } // metadata ********************************************************************************************************************** // metadata Abstract // Get the description for this item const string VARIES_STRING = "<span style=\"color:Gray\">( varies )</span>"; StringBuilder singleResultBldr = new StringBuilder(); singleResultBldr.Append("<div style=\"text-align:left\"><dl class=\"sbkBrv_SingleResultDescList\">"); if ((RequestSpecificValues.Current_User != null) && (RequestSpecificValues.Current_User.LoggedOn) && (RequestSpecificValues.Current_User.Is_Internal_User)) { singleResultBldr.Append("<dt>BibID:</dt><dd>" + titleResult.BibID + "</dd>"); if (titleResult.OPAC_Number > 1) { singleResultBldr.Append("<dt>OPAC:</dt><dd>" + titleResult.OPAC_Number + "</dd>"); } if (titleResult.OCLC_Number > 1) { singleResultBldr.Append("<dt>OCLC:</dt><dd>" + titleResult.OCLC_Number + "</dd>"); } } for (int j = 0; j < ResultsStats.Metadata_Labels.Count; j++) { string field = ResultsStats.Metadata_Labels[j]; // 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 <= j)) { break; } string metadata_value = titleResult.Metadata_Display_Values[j]; SobekCM.Core.Search.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 (metadata_value == "*") { singleResultBldr.Append("<dt>" + UI_ApplicationCache_Gateway.Translation.Get_Translation(display_field, RequestSpecificValues.Current_Mode.Language) + ":</dt><dd>" + HttpUtility.HtmlDecode(VARIES_STRING) + "</dd>"); } else if (metadata_value.Trim().Length > 0) { if (metadata_value.IndexOf("|") > 0) { bool value_found = false; string[] value_split = metadata_value.Split("|".ToCharArray()); foreach (string thisValue in value_split) { if (thisValue.Trim().Trim().Length > 0) { if (!value_found) { singleResultBldr.Append("<dt>" + UI_ApplicationCache_Gateway.Translation.Get_Translation(display_field, RequestSpecificValues.Current_Mode.Language) + ":</dt>"); value_found = true; } singleResultBldr.Append("<dd>" + HttpUtility.HtmlDecode(thisValue) + "</dd>"); } } } else { singleResultBldr.Append("<dt>" + UI_ApplicationCache_Gateway.Translation.Get_Translation(display_field, RequestSpecificValues.Current_Mode.Language) + ":</dt><dd>" + HttpUtility.HtmlDecode(metadata_value) + "</dd>"); } } } singleResultBldr.Append("</dl></div>"); myAbstract = singleResultBldr.ToString(); // ******************************************************************************************************************************* if (yearnum == -1 && monthnum == -1 && daynum == -1) { count_missing_date++; if (debug) { logme(packageid + " was missing a date, skipping. count_missing_date=" + count_missing_date + "."); } } else { if (debug) { logme(packageid + " being added as an event."); } count_total++; addToDataJS(datajs, yearnum, monthnum, daynum, title, myAbstract, bibid, vid, path); if (debug) { logme("Added event, count_total=" + count_total); } } // end of item loop if (debug) { logme("There are [" + titleResult.Item_Count + "] items for [" + bibid + "]."); } if (debug) { logme("Done processing bibid=[" + bibid + "], vid=[" + vid + "].\r\n\r\n"); } if (debug) { logme("Total count added=" + count_total + ", missing count date=" + count_missing_date); } // Tracer.Add_Trace("SimileTimeline_ResultsViewer.Add_HTML", "Done processing bibid=[" + bibid + "], vid=[" + vid + "]"); } if (debug) { logme("main processing loop completed."); } if (debug) { logme("datajs length = " + datajs.Length + "."); } // end of titleResults loop datajs.Remove(datajs.Length - 3, 3); // datajs = datajs.Substring(0, datajs.Length - 3); datajs.Append("]}"); msg = "webroot=[" + HttpContext.Current.Server.MapPath("~") + "]."; if (debug) { logme(msg); } Tracer.Add_Trace("SimileTimeline_ResultsViewer", msg); File.WriteAllText(HttpContext.Current.Server.MapPath("~") + @"\temp\" + tlsn + "-" + unixTimestamp + ".js", datajs.ToString()); resultsBldr.AppendLine("<script src=\"" + @"/temp/" + tlsn + "-" + unixTimestamp + ".js" + "\" type=\"text/javascript\"></script>"); if (debug) { logme("count of yearsRepresented=[" + yearsRepresented.Count + "]."); } if (count_total == 0) { resultsBldr.AppendLine("<br/><p id=\"warningzero\">Note: For the timeline, out of " + pagedresults_itemcount.ToString("#,##0") + " results in this page all were missing dates and were skipped. Proceed to the next page (if any).</p>"); msg = "All results in this page were missing dates and were skipped, returning."; Tracer.Add_Trace("SimileTimeline_ResultsViewer", msg); if (debug) { logme(msg); } mainLiteral = new Literal { Text = resultsBldr.ToString() }; MainPlaceHolder.Controls.Add(mainLiteral); return; } Tracer.Add_Trace("timeline", "sorting yearsRepresented"); yearsRepresented.Sort(); int mymin = yearsRepresented[i]; int mymax = yearsRepresented[yearsRepresented.Count - 1]; int sum = 0; var g = yearsRepresented.GroupBy(ig => ig); Tracer.Add_Trace("timeline", "count in yearsRepresented=" + g.Count()); // Get the middle point foreach (int myvalue in yearsRepresented) { sum += myvalue; } int myavg = sum / yearsRepresented.Count; Tracer.Add_Trace("timeline", "min of yearsRepresented=" + mymin); Tracer.Add_Trace("timeline", "max of yearsRepresented=" + mymax); Tracer.Add_Trace("timeline", "average of yearsRepresented=" + myavg); if (debug) { logme("Adding controls."); } resultsBldr.AppendLine("<button id=\"buttonControls\" class=\"btn\" onclick=\"javascript:toggleControls(event);\">Hide Controls</button>"); resultsBldr.AppendLine("<div id=\"tlloadingmsg\">Loading...</div>"); resultsBldr.AppendLine("\t\t\t <div class=\"controls\" id=\"controls\">"); try { decadesDistinct = decades_calculated.Keys.ToList(); decadesDistinct.Sort(); foreach (int mydecade in decadesDistinct) { Tracer.Add_Trace("timeline", "decadesDistinct=" + mydecade); } } catch (Exception e) { if (debug) { logme("exception trying to get decadesDistinct [" + e.Message + "]."); } } // sort dateList by year, month, date var dateListSorted = from mydates in dateList orderby mydates.yearnum, mydates.monthnum, mydates.daynum select mydates; foreach (SimileDate mydate2 in dateList) { Tracer.Add_Trace("timeline", "dateList: " + mydate2.yearnum + "-" + mydate2.monthnum + "-" + mydate2.daynum); } // jump resultsBldr.Append("<p id=\"gotolinks\">Go to: "); int theDecade, idx = 0; foreach (int decade in decadesDistinct) { idx++; if (decade > mymax) { theDecade = mymax; } else { theDecade = decade; } DateTime decades_earliest_date = earliest_time_by_decade[decade]; SimileDate firstDate = new SimileDate(decades_earliest_date); resultsBldr.AppendLine("<a href=\"javascript:centerSimileAjax('" + firstDate.monthnum + "," + firstDate.daynum + "," + firstDate.yearnum + "')\">" + theDecade + "</a> "); } resultsBldr.AppendLine("</p>\r\n\r\n"); // end jump resultsBldr.AppendLine("</div> <!-- end controls div -->\r\n"); resultsBldr.AppendLine("<div id = \"doc3\" class=\"yui-t7\">"); resultsBldr.AppendLine("\t<div id = \"bd\" role= \"main\">"); resultsBldr.AppendLine("\t\t<div class=\"yui-g\">"); resultsBldr.AppendLine("\t\t\t<div id = 'tl'>"); resultsBldr.AppendLine("\t\t\t</div> <!-- end of tl -->"); resultsBldr.AppendLine("\t\t</div> <!-- end of yui-g -->"); resultsBldr.AppendLine("\t\t\t<p style=\"display:none;\">Thanks to the <a href=''>Simile Timeline project</a>. Timeline version <span id='tl_ver'>"); resultsBldr.AppendLine("\t\t\t<script>Timeline.writeVersion('tl_ver');</script></span></p>"); resultsBldr.AppendLine("\t</div> <!-- end of bd -->"); if (debug) { logme("Adding onLoad function..."); } resultsBldr.AppendLine("<script type=\"text/javascript\">"); resultsBldr.AppendLine("var tl;"); resultsBldr.AppendLine("function onLoad() {"); resultsBldr.AppendLine("console.log(\"onload function...\");"); resultsBldr.AppendLine("var tl_el = document.getElementById(\"tl\");"); resultsBldr.AppendLine("var eventSource1 = new Timeline.DefaultEventSource();"); // theme resultsBldr.AppendLine("console.log(\"create theme...\");"); resultsBldr.AppendLine("var theme1 = Timeline.ClassicTheme.create();"); resultsBldr.AppendLine("theme1.autoWidth = true; // Set the Timeline's \"width\" automatically."); resultsBldr.AppendLine("// Set autoWidth on the Timeline's first band's theme,"); resultsBldr.AppendLine("// will affect all bands."); resultsBldr.AppendLine("theme1.timeline_start = new Date(Date.UTC(" + (Math.Abs(mymin) - 100) + ",0,0));"); resultsBldr.AppendLine("theme1.timeline_stop = new Date(Date.UTC(" + (Math.Abs(mymax) + 100) + ", 0, 1));"); resultsBldr.AppendLine("theme1.mouseWheel='scroll';"); resultsBldr.AppendLine("theme1.event.bubble.width = 450;"); resultsBldr.AppendLine("console.log(\"theme1 object\");"); resultsBldr.AppendLine("console.log(theme1);"); resultsBldr.AppendLine("var d = Timeline.DateTime.parseGregorianDateTime(\"" + myavg + "\")"); // bands resultsBldr.AppendLine("console.log(\"createBandInfo...\");"); // need it global, removing var resultsBldr.AppendLine("bandInfos = ["); // Decade resultsBldr.AppendLine("Timeline.createBandInfo({"); resultsBldr.AppendLine("width:\"10%\","); resultsBldr.AppendLine("intervalUnit: Timeline.DateTime.DECADE,"); resultsBldr.AppendLine("intervalPixels: 50,"); resultsBldr.AppendLine("eventSource: eventSource1,"); resultsBldr.AppendLine("date: d,"); resultsBldr.AppendLine("theme: theme1,"); resultsBldr.AppendLine("layout: 'overview' // original, overview, detailed"); resultsBldr.AppendLine("}),"); // Year resultsBldr.AppendLine("Timeline.createBandInfo({"); resultsBldr.AppendLine("width: \"10%\","); resultsBldr.AppendLine("intervalUnit: Timeline.DateTime.YEAR,"); resultsBldr.AppendLine("intervalPixels: 50,"); resultsBldr.AppendLine("eventSource: eventSource1,"); resultsBldr.AppendLine("date: d,"); resultsBldr.AppendLine("theme: theme1,"); resultsBldr.AppendLine("layout: 'overview' // original, overview, detailed"); resultsBldr.AppendLine("}),"); // Month resultsBldr.AppendLine("Timeline.createBandInfo({"); resultsBldr.AppendLine("width:\"10%\","); resultsBldr.AppendLine("intervalUnit: Timeline.DateTime.MONTH,"); resultsBldr.AppendLine("intervalPixels: 100,"); resultsBldr.AppendLine("eventSource: eventSource1,"); resultsBldr.AppendLine("date: d,"); resultsBldr.AppendLine("theme: theme1,"); resultsBldr.AppendLine("layout: 'overview' // original, overview, detailed"); resultsBldr.AppendLine("}),"); // Day resultsBldr.AppendLine("Timeline.createBandInfo({"); resultsBldr.AppendLine("width: \"70% \", "); resultsBldr.AppendLine("intervalUnit: Timeline.DateTime.DAY, "); resultsBldr.AppendLine("intervalPixels: 150,"); resultsBldr.AppendLine("eventSource: eventSource1,"); resultsBldr.AppendLine("date: d,"); resultsBldr.AppendLine("theme: theme1,"); resultsBldr.AppendLine("layout: 'original' // original, overview, detailed"); resultsBldr.AppendLine("}),"); resultsBldr.AppendLine("];"); resultsBldr.AppendLine("bandInfos[0].syncWith = 3;"); resultsBldr.AppendLine("bandInfos[0].highlight = true;"); resultsBldr.AppendLine("bandInfos[1].syncWith = 3;"); resultsBldr.AppendLine("bandInfos[1].highlight = true;"); resultsBldr.AppendLine("bandInfos[2].syncWith = 3;"); resultsBldr.AppendLine("bandInfos[2].highlight = true;"); resultsBldr.AppendLine("bandInfos[3].highlight = true;"); // end of band resultsBldr.AppendLine("console.log(\"the bandInfos.\");"); resultsBldr.AppendLine("console.log(bandInfos);"); resultsBldr.AppendLine("console.log(\"create the timeline.\");"); resultsBldr.AppendLine("// create the Timeline"); resultsBldr.AppendLine("tl = Timeline.create(tl_el, bandInfos, Timeline.HORIZONTAL);"); resultsBldr.AppendLine("var url = '.'; // The base url for image, icon and background image"); resultsBldr.AppendLine("console.log(\"load the json data from [\" + url + \"].\");"); resultsBldr.AppendLine("// references in the data"); resultsBldr.AppendLine("eventSource1.loadJSON(timeline_data, url); // The data was stored into the"); resultsBldr.AppendLine("// timeline_data variable."); resultsBldr.AppendLine("console.log(\"display the timeline.\");"); resultsBldr.AppendLine("tl.layout(); // display the Timeline"); // setup the controls resultsBldr.AppendLine("console.log(\"setup the filter/highlight controls.\");"); //resultsBldr.AppendLine("var theme = Timeline.ClassicTheme.create();"); resultsBldr.AppendLine("theme1.mouseWheel='scroll';"); resultsBldr.AppendLine("setupFilterHighlightControls(document.getElementById(\"controls\"), tl, [0,0], theme1);"); // resultsBldr.AppendLine("}"); resultsBldr.AppendLine(""); resultsBldr.AppendLine("var resizeTimerID = null;"); resultsBldr.AppendLine("function onResize() {"); resultsBldr.AppendLine("console.log(\"onresize...\");"); resultsBldr.AppendLine("if (resizeTimerID == null)"); resultsBldr.AppendLine("{"); resultsBldr.AppendLine("resizeTimerID = window.setTimeout(function() {"); resultsBldr.AppendLine("resizeTimerID = null;"); resultsBldr.AppendLine("tl.layout();"); resultsBldr.AppendLine("}, 500);"); resultsBldr.AppendLine("}"); resultsBldr.AppendLine("}"); resultsBldr.AppendLine("</script>"); //< body onload = "onLoad();" onresize = "onResize();" > if (debug) { logme("Adding document ready..."); } resultsBldr.AppendLine("<script>"); resultsBldr.AppendLine("$(document).ready(function()"); resultsBldr.AppendLine("{"); resultsBldr.AppendLine("\tconsole.log(\"ready!\");"); resultsBldr.AppendLine("\tconsole.log(\"calling onload...\");"); resultsBldr.AppendLine("\tonLoad();"); resultsBldr.AppendLine("\tconsole.log(\"returned from calling onload...\");"); resultsBldr.AppendLine("\t$(\"body\").attr(\"onresize\",\"onResize();\")"); resultsBldr.AppendLine("\t$(\"#controls > table > tbody > tr > td:nth-child(2):first\").attr('colspan','4').css('text-align','left').css('padding-left','9%');"); // .timeline-event-bubble-title > a:nth-child(1) resultsBldr.AppendLine("console.log(\"count of titles > links=[\" + $(\".timeline-event-bubble-title > a:nth-child(1)\").length + \"].\");"); resultsBldr.AppendLine("\t$(\".timeline-event-bubble-title > a:nth-child(1)\").attr(\"target\",\"_blank\");"); resultsBldr.AppendLine("\tconsole.log(\"timeline_data variable...\");"); resultsBldr.AppendLine("\tconsole.log(timeline_data);"); resultsBldr.AppendLine("\t$(\"span#tl_ver\").text('[' + Timeline.writeVersion('tl_ver') + ']');"); DateTime earliest_date = earliest_time_by_decade[decadesDistinct[0]]; SimileDate initialDate = new SimileDate(earliest_date); //SimileDate initialDate = getEarliestDateByDecade(ref dateList, mymin, Tracer); Tracer.Add_Trace("timeline", "initial date=" + initialDate.monthnum + "-" + initialDate.daynum + "-" + initialDate.yearnum); //resultsBldr.AppendLine("javascript:centerSimileAjax('" + initialDate.monthnum + "," + initialDate.daynum + "," + mymin + "');"); resultsBldr.AppendLine("$(\".sbkPrsw_ResultsPanel\").css('width','95%');"); //resultsBldr.AppendLine("document.getElementById(\"timeline-band-0\").removeEventListener(\"DOMMouseScroll\",arguments.callee,false);"); resultsBldr.AppendLine("console.log(\"displaying timrline-band-0 object.\");"); resultsBldr.AppendLine("var joe=document.getElementById(\"timeline-band-0\");"); resultsBldr.AppendLine("console.log(joe);"); resultsBldr.AppendLine("console.log($._data( $('#timeline-band-0')[0], 'events' ));"); resultsBldr.AppendLine("adjustSliderControls('" + initialDate.monthnum + "," + initialDate.daynum + "," + initialDate.yearnum + "');"); resultsBldr.AppendLine("}); <!-- end of doc ready -->"); resultsBldr.AppendLine("</script>"); if (hasMissingDates && count_missing_date > 0) { resultsBldr.AppendLine("<div id=\"exclusiondiv\"><p>Note: " + count_missing_date + " items were excluded from the timeilne because they were missing dates. <a href=\"/all/brief?o=10\">Click here</a> to see them included in the brief results view."); // ability to access query string from request url? if (debug) { resultsBldr.AppendLine("<span style=\"color:red;\">[PagedResults count=" + pagedresults_itemcount + ", item count=" + count_total + "].</span>"); } resultsBldr.AppendLine("</p>"); resultsBldr.AppendLine("</div> <!-- end of exclusionsdiv -->"); } if (debug) { logme("Total item count=[" + count_total + "]."); } if (debug) { logme("Total missing date count=[" + count_missing_date + "]."); } if (debug) { logme("Adding temp debug data..."); } resultsBldr.AppendLine("<!-- "); resultsBldr.AppendLine("<br/><br/><br/><p>temp: <a target=\"_blank\" href=\"http://" + getMyIP() + "/temp/" + tlsn + "-" + unixTimestamp + ".js\">data js file</a></p>"); resultsBldr.AppendLine("<p>temp: id=[" + tlsn + "-" + unixTimestamp + "].</p>"); resultsBldr.AppendLine("<p>temp: User IP (?): " + getUserIP() + "</p>"); resultsBldr.AppendLine("<p>temp: RequestSpecificValues.Current_Mode.Result_Display_Type=[" + RequestSpecificValues.Current_Mode.Result_Display_Type + "].</p>"); resultsBldr.AppendLine("<p>temp: PagedResults count=[" + PagedResults.Count + "].</p>"); resultsBldr.AppendLine("<p>temp: ResultsStats.Total_Items=[" + ResultsStats.Total_Items + "]."); resultsBldr.AppendLine("<p>temp: ResultsStats.Total_Titles=[" + ResultsStats.Total_Titles + "]."); resultsBldr.AppendLine("<p>temp: Results_Per_Page=[" + Results_Per_Page + "]."); resultsBldr.AppendLine("<p>temp: total_results=[" + Total_Results + "]."); resultsBldr.AppendLine("-->"); resultsBldr.AppendLine("</div> <!-- end of doc3 -->"); // Add this to the html table mainLiteral = new Literal { Text = resultsBldr.ToString() }; MainPlaceHolder.Controls.Add(mainLiteral); logme("Done with Add_HTML..."); }