private bool set_file_information(string[] FileExtensions) { // Find the page information BriefItem_FileGrouping imagePage = BriefItem.Images[page - 1]; if (imagePage.Files != null) { // Step through each file in this page foreach (BriefItem_File thisFile in imagePage.Files) { // Get this file extension string extension = thisFile.File_Extension.Replace(".", ""); // Step through all permissable file extensions foreach (string thisPossibleFileExtension in FileExtensions) { if (String.Compare(extension, thisPossibleFileExtension, StringComparison.OrdinalIgnoreCase) == 0) { // Get the TEXT information filename = thisFile.Name; return(true); } } } } return(false); }
private void print_pages(bool include_brief_citation, int from_page, int to_page, TextWriter Output) { if (include_brief_citation) { print_brief_citation("700", Output); } int page_index = from_page - 1; while (page_index < to_page) { // Get this page BriefItem_FileGrouping thisPage = currentItem.Images[page_index]; // Find the jpeg image and show the image foreach (BriefItem_File thisFile in thisPage.Files) { if (thisFile.Name.IndexOf(".jpg") > 0) { if (page_index > from_page - 1) { Output.WriteLine("<br />"); } Output.WriteLine("<img src=\"" + currentItem.Web.Source_URL + "/" + thisFile.Name + "\" />"); break; } } // Go to next page page_index++; } }
private void print_thumbnails(bool include_brief_citation, TextWriter Output) { if (include_brief_citation) { print_brief_citation("550", Output); } Output.WriteLine("<table cellspacing=\"10px\" class=\"thumbnails\">"); Output.WriteLine(" <tr align=\"center\" valign=\"top\">"); int page_index = 0; int col = 0; while (page_index < currentItem.Images.Count) { BriefItem_FileGrouping thisPage = currentItem.Images[page_index]; // Find the jpeg image foreach (BriefItem_File thisFile in thisPage.Files.Where(thisFile => thisFile.Name.IndexOf(".jpg") > 0)) { // Should a new row be started if (col == 3) { col = 0; Output.WriteLine(" </tr>\n"); Output.WriteLine(" <tr align=\"center\" valign=\"top\">"); } Output.WriteLine(" <td><img src=\"" + currentItem.Web.Source_URL + "/" + thisFile.Name.Replace(".jpg", "thm.jpg") + "\" border=\"1\" /><br />" + thisPage.Label + "</td>"); col++; break; } // Go to next page page_index++; } if (col == 1) { Output.WriteLine(" <td colspan=\"2\"> </td>"); } if (col == 2) { Output.WriteLine(" <td> </td>"); } Output.WriteLine(" </tr>\n"); Output.WriteLine("</table>\n"); }
private bool set_file_information(string[] FileExtensions, bool zoomableViewerIncluded, string[] zoomableFileExtensions) { bool returnValue = false; includeLinkToZoomable = false; bool width_found = false; // Find the page information BriefItem_FileGrouping imagePage = BriefItem.Images[page - 1]; if (imagePage.Files != null) { // Step through each file in this page foreach (BriefItem_File thisFile in imagePage.Files) { // Get this file extension string extension = thisFile.File_Extension.Replace(".", ""); // Step through all permissable file extensions foreach (string thisPossibleFileExtension in FileExtensions) { if (String.Compare(extension, thisPossibleFileExtension, StringComparison.OrdinalIgnoreCase) == 0) { // If a return value was already found, look to see if this one is bigger, in which case it will be used // This is a convenient way to get around thumbnails issue without looking for "thm.jpg" if (returnValue) { // Are their widths present? if (width_found && thisFile.Width.HasValue) { if (thisFile.Width.Value > width) { // THis file is bigger (wider) filename = thisFile.Name; width = thisFile.Width.Value; if (thisFile.Height.HasValue) { height = thisFile.Height.Value; } } } else { // Since no width was found, just go for a shorter filename if (filename.Length > thisFile.Name.Length) { // This name is shorter... assuming it doesn't include thm.jpg then filename = thisFile.Name; if (thisFile.Width.HasValue) { width = thisFile.Width.Value; width_found = true; } else { width = 500; } if (thisFile.Height.HasValue) { height = thisFile.Height.Value; } } } } else { // Get the JPEG information filename = thisFile.Name; if (thisFile.Width.HasValue) { width = thisFile.Width.Value; width_found = true; } if (thisFile.Height.HasValue) { height = thisFile.Height.Value; } } // Found a value to return returnValue = true; } } // Also look for the JPEG2000 viewers if (zoomableViewerIncluded) { // Step through all JPEG2000 extensions foreach (string thisPossibleFileExtension in zoomableFileExtensions) { if (String.Compare(extension, thisPossibleFileExtension, StringComparison.OrdinalIgnoreCase) == 0) { // Found a jpeg2000 includeLinkToZoomable = true; break; } } } } // Finished looking at all the page files and found the file to display, so return TRUE if (returnValue) { return(true); } } return(false); }
/// <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 void Write_Main_Viewer_Section(TextWriter Output, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("Related_Images_ItemViewer.Write_Main_Viewer_Section", ""); } int images_per_page = thumbnailsPerPage; int size_of_thumbnails = thumbnailSize; // Save the current viewer code string current_view_code = currentRequest.ViewerCode; ushort current_view_page = currentRequest.Page.HasValue ? currentRequest.Page.Value : ((ushort)1); // Start the citation table Output.WriteLine("\t\t<td>"); Output.WriteLine("\t\t<!-- RELATED IMAGES VIEWER OUTPUT -->"); // Start the main div for the thumbnails ushort page = (ushort)(currentRequest.Page - 1); if (page > (pageCount - 1) / images_per_page) { page = (ushort)((pageCount - 1) / images_per_page); } //Outer div which contains all the thumbnails Output.WriteLine("<div style=\"margin:5px;text-align:center;\">"); // Get any search terms for highlighting purposes List <string> terms = new List <string>(); if (!String.IsNullOrWhiteSpace(currentRequest.Text_Search)) { string[] splitter = currentRequest.Text_Search.Replace("\"", "").Split(" ".ToCharArray()); terms.AddRange(from thisSplit in splitter where thisSplit.Trim().Length > 0 select thisSplit.Trim()); } // Step through each page in the item for (int page_index = page * images_per_page; (page_index < (page + 1) * images_per_page) && (page_index < pageCount); page_index++) { // Get this page BriefItem_FileGrouping thisPage = briefItem.Images[page_index]; // Find the jpeg and thumbnail images string jpeg = String.Empty; string thumbnail = String.Empty; foreach (BriefItem_File thisFile in thisPage.Files) { if (String.Compare(thisFile.File_Extension, ".jpg", StringComparison.OrdinalIgnoreCase) == 0) { if (thisFile.Name.ToLower().IndexOf("thm.jpg") > 0) { thumbnail = thisFile.Name; } else { jpeg = thisFile.Name; } } } // If the thumbnail is not in the METS, just guess its existence if (thumbnail.Length == 0) { thumbnail = jpeg.ToLower().Replace(".jpg", "thm.jpg"); } // Get the image URL currentRequest.Page = (ushort)(page_index + 1); currentRequest.ViewerCode = (page_index + 1).ToString(); string url = UrlWriterHelper.Redirect_URL(currentRequest); // Determine the width information and the URL for the image string image_url; // = (briefItem.Web.Source_URL + "/" + thumbnail).Replace("\\", "/").Replace("//", "/").Replace("http:/", "http://"); int width = -1; switch (size_of_thumbnails) { case 2: image_url = (briefItem.Web.Source_URL + "/" + jpeg).Replace("\\", "/").Replace("//", "/").Replace("http:/", "http://").Replace("https:/", "https://"); width = 315; break; case 3: image_url = (briefItem.Web.Source_URL + "/" + jpeg).Replace("\\", "/").Replace("//", "/").Replace("http:/", "http://").Replace("https:/", "https://"); width = 472; break; case 4: image_url = (briefItem.Web.Source_URL + "/" + jpeg).Replace("\\", "/").Replace("//", "/").Replace("http:/", "http://").Replace("https:/", "https://"); break; default: image_url = (briefItem.Web.Source_URL + "/" + thumbnail).Replace("\\", "/").Replace("//", "/").Replace("http:/", "http://").Replace("https:/", "https://"); width = 150; break; } if (width > 0) { Output.WriteLine(" <table class=\"sbkRi_Thumbnail\" id=\"span" + page_index + "\" style=\"width:" + (width + 15) + "px\">"); } else { Output.WriteLine(" <table class=\"sbkRi_Thumbnail\" id=\"span" + page_index + "\">"); } Output.WriteLine(" <tr>"); Output.WriteLine(" <td>"); Output.WriteLine(" <a id=\"" + page_index + "\" href=\"" + url + "\" title=\"" + thisPage.Label + "\">"); if (width > 0) { Output.WriteLine(" <img src=\"" + image_url + "\" style=\"width:" + width + "px;\" alt=\"MISSING THUMBNAIL\" />"); } else { Output.WriteLine(" <img src=\"" + image_url + "\" alt=\"MISSING THUMBNAIL\" />"); } Output.WriteLine(" </a>"); Output.WriteLine(" </td>"); Output.WriteLine(" </tr>"); Output.WriteLine(" <tr>"); Output.WriteLine(" <td style=\"text-align:center\">" + Text_Search_Term_Highlighter.Hightlight_Term_In_HTML(thisPage.Label, terms, "<span class=\"sbkRi_TextHighlight\">", "</span>") + "</td>"); Output.WriteLine(" </tr>"); Output.WriteLine(" </table>"); Output.WriteLine(); } //Close the outer div Output.WriteLine("</div>"); // Restore the mode currentRequest.ViewerCode = current_view_code; currentRequest.Page = current_view_page; Output.WriteLine("<script type=\"text/javascript\"> WindowResizeActions();</script>"); // Finish the citation table Output.WriteLine("\t\t</td>"); Output.WriteLine("\t\t<!-- END RELATED IMAGES VIEWER OUTPUT -->"); }
private bool recurse_through_nodes(abstract_TreeNode Node, List <BriefItem_FileGrouping> Groupings, List <BriefItem_TocElement> Toc, Stack <BriefItem_TocElement> CurrDivStack, int Level) { // Was this node a page? if (Node.Page) { // Cast back to the PAGE node Page_TreeNode pageNode = (Page_TreeNode)Node; // If no files, do not add this back if (pageNode.Files.Count == 0) { return(false); } // Create the file grouping object for this BriefItem_FileGrouping newNode = new BriefItem_FileGrouping(pageNode.Label); // Add a filenode for each file foreach (SobekCM_File_Info thisFile in pageNode.Files) { BriefItem_File newFile = new BriefItem_File(thisFile.System_Name); if (thisFile.Width > 0) { newFile.Width = thisFile.Width; } if (thisFile.Height > 0) { newFile.Height = thisFile.Height; } newNode.Files.Add(newFile); } // Add this to the list of images Groupings.Add(newNode); // Since this was a page with files, return TRUE return(true); } else { // Get what will be the sequence (if it turned out to have pages under it) int sequence = Groupings.Count + 1; // This was a division node Division_TreeNode divNode = (Division_TreeNode)Node; // Create the brief item TOC element BriefItem_TocElement divToc = new BriefItem_TocElement { Level = Level, Name = divNode.Label }; if (string.IsNullOrEmpty(divToc.Name)) { divToc.Name = divNode.Type; } // Add to the stack CurrDivStack.Push(divToc); // Look for children nodes bool some_files_under = false; foreach (abstract_TreeNode childNode in divNode.Nodes) { // Visit each child node if (recurse_through_nodes(childNode, Groupings, Toc, CurrDivStack, Level + 1)) { some_files_under = true; } } // Were there some files under here? if (some_files_under) { // Now, pop-up all the nodes in the queue and add them if (CurrDivStack.Count > 0) { IEnumerable <BriefItem_TocElement> reversed = CurrDivStack.Reverse(); foreach (BriefItem_TocElement revDiv in reversed) { revDiv.Sequence = sequence; Toc.Add(revDiv); } CurrDivStack.Clear(); } } else { // If this division (with NO pages under it apparently) is on the stack, // just pop it off if ((CurrDivStack.Count > 0) && (CurrDivStack.Peek() == divToc)) { CurrDivStack.Pop(); } } // Return whether there were any files under this return(some_files_under); } }