/// <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) { // Get the URL for this string previous_code = CurrentRequest.ViewerCode; CurrentRequest.ViewerCode = ViewerCode; string url = UrlWriterHelper.Redirect_URL(CurrentRequest); CurrentRequest.ViewerCode = previous_code; // Start with the default label on the menu string label = "Page Turner"; // Allow the label to be implemented for this viewer 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))) { label = thisViewerInfo.Label; } // Add the item menu information Item_MenuItem menuItem = new Item_MenuItem(label, null, null, url, ViewerCode); MenuItems.Add(menuItem); }
/// <summary> Map one or more data elements from the original METS-based object to the /// BriefItem object </summary> /// <param name="Original"> Original METS-based object </param> /// <param name="New"> New object to populate some data from the original </param> /// <returns> TRUE if successful, FALSE if an exception is encountered </returns> public bool MapToBriefItem(SobekCM_Item Original, BriefItemInfo New) { // Add all the origination information, primarily dates ) if (Original.Bib_Info.Origin_Info != null) { // Add the creation date if ((!String.IsNullOrWhiteSpace(Original.Bib_Info.Origin_Info.Date_Created)) && (Original.Bib_Info.Origin_Info.Date_Created.Trim() != "-1")) { New.Add_Description("Creation Date", Original.Bib_Info.Origin_Info.Date_Created); } // Add the publication date, looking under DATE ISSUED, or under MARC DATE ISSUED if (!String.IsNullOrWhiteSpace(Original.Bib_Info.Origin_Info.Date_Issued)) { if (Original.Bib_Info.Origin_Info.Date_Issued.Trim() != "-1") { New.Add_Description("Publication Date", Original.Bib_Info.Origin_Info.Date_Issued); } } else if (!String.IsNullOrWhiteSpace(Original.Bib_Info.Origin_Info.MARC_DateIssued)) { New.Add_Description("Publication Date", Original.Bib_Info.Origin_Info.MARC_DateIssued); } // Add the copyright date if ((!String.IsNullOrWhiteSpace(Original.Bib_Info.Origin_Info.Date_Copyrighted)) && (Original.Bib_Info.Origin_Info.Date_Copyrighted.Trim() != "-1")) { New.Add_Description("Copyright Date", Original.Bib_Info.Origin_Info.Date_Copyrighted); } } return(true); }
/// <summary> Constructor for a new instance of the UF_Archives_ItemViewer class, used display /// the tracking milestones information 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> public UF_Archives_ItemViewer(BriefItemInfo BriefItem, User_Object CurrentUser, Navigation_Object CurrentRequest, Custom_Tracer Tracer) { // 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 archives information Tracer.Add_Trace("UF_Archives_ItemViewer.Constructor", "Try to pull the archives details for this item"); DataSet data = Engine_Database.Tracking_Get_History_Archives(BriefItem.Web.ItemID, Tracer); if ((data == null) || (data.Tables.Count < 3)) { Tracer.Add_Trace("Constructor.Constructor", "Unable to pull tracking details"); CurrentRequest.Mode = Display_Mode_Enum.Error; CurrentRequest.Error_Message = "Internal Error : Unable to pull tracking information for " + BriefItem.BibID + ":" + BriefItem.VID; return; } // Save this table archiveTable = data.Tables[2]; }
/// <summary> Returns flag that indicates this citation section writer /// will be writing alues to the output stream </summary> /// <param name="Item"> Digital resource to analyze for data to write </param> /// <param name="ElementInfo"> Additional possible data about this citation element </param> public bool Has_Data_To_Write(CitationElement ElementInfo, BriefItemInfo Item) { // Look for a match in the item description BriefItem_DescriptiveTerm firstSpatial = Item.Get_Description("Hierarchical Spatial"); return((firstSpatial != null) && (firstSpatial.Values.Count > 0)); }
/// <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 virtual bool Include_Viewer(BriefItemInfo CurrentItem) { // If the downloads is null, then return FALSE if (CurrentItem.Downloads == null) { return(false); } // Any download files are really good enoughh if (CurrentItem.Downloads.Any(DownloadGroup => DownloadGroup.Files.Count > 0)) { return(true); } // Otherwise, if this is an aerial, and there are JPEG2000 files, add it (UF legacy code) if ((CurrentItem.Behaviors.Page_File_Extensions_For_Download != null) && (CurrentItem.Behaviors.Page_File_Extensions_For_Download.Length > 0) && (CurrentItem.Images != null)) { // Just double check that some of those files exist though! foreach (string extensionToAdd in CurrentItem.Behaviors.Page_File_Extensions_For_Download) { if (CurrentItem.Web.Contains_File_Extension(extensionToAdd)) { return(true); } } } // Finally, return false return(false); }
/// <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) { // Get the URL for this string previous_code = CurrentRequest.ViewerCode; CurrentRequest.ViewerCode = ViewerCode; string url = UrlWriterHelper.Redirect_URL(CurrentRequest); CurrentRequest.ViewerCode = previous_code; // Allow the label to be implemented for this viewer BriefItem_BehaviorViewer thisViewerInfo = CurrentItem.Behaviors.Get_Viewer(ViewerCode); // If this is null, or no label, use the default if ((thisViewerInfo == null) || (String.IsNullOrWhiteSpace(thisViewerInfo.Label))) { // Add the item menu information using the default label Item_MenuItem menuItem = new Item_MenuItem("Video", null, null, url, ViewerCode); MenuItems.Add(menuItem); } else { // Add the item menu information using the custom level Item_MenuItem menuItem = new Item_MenuItem(thisViewerInfo.Label, null, null, url, ViewerCode); MenuItems.Add(menuItem); } }
/// <summary> Create the BriefItemInfo from a full METS-based SobekCM_Item object, /// using the default mapping set </summary> /// <param name="Original"> Original METS-based object to use </param> /// <param name="MappingSetId"> Name of the mapping set to use (if there are more than one)</param> /// <param name="Tracer"> Custom tracer to record general process flow </param> /// <returns> Completely built BriefItemInfo object from the METS-based SobekCM_Item object </returns> public static BriefItemInfo Create(SobekCM_Item Original, string MappingSetId, Custom_Tracer Tracer) { // Try to get the brief mapping set List <IBriefItemMapper> mappingSet = get_mapping_set(MappingSetId); // Create the mostly empty new brief item Tracer.Add_Trace("BriefItem_Factory.Create", "Create the mostly empty new brief item"); BriefItemInfo newItem = new BriefItemInfo { BibID = Original.BibID, VID = Original.VID, Title = Original.Bib_Info.Main_Title.Title }; // Build the new item using the selected mapping set Tracer.Add_Trace("BriefItem_Factory.Create", "Use the set of mappers to map data to the brief item"); foreach (IBriefItemMapper thisMapper in mappingSet) { Tracer.Add_Trace("BriefItem_Factory.Create", "...." + thisMapper.GetType().ToString().Replace("SobekCM.Engine_Library.Items.BriefItems.Mappers.", "")); thisMapper.MapToBriefItem(Original, newItem); } Tracer.Add_Trace("BriefItem_Factory.Create", "Finished using all instatiated and configued mappers"); return(newItem); }
/// <summary> Map one or more data elements from the original METS-based object to the /// BriefItem object </summary> /// <param name="Original"> Original METS-based object </param> /// <param name="New"> New object to populate some data from the original </param> /// <returns> TRUE if successful, FALSE if an exception is encountered </returns> public bool MapToBriefItem(SobekCM_Item Original, BriefItemInfo New) { // If not URL, jsut return if (String.IsNullOrEmpty(Original.Bib_Info.Location.Other_URL)) { return(true); } string mainEntry = Original.Bib_Info.Location.Other_URL; if (!String.IsNullOrEmpty(Original.Bib_Info.Location.Other_URL_Note)) { mainEntry = Original.Bib_Info.Location.Other_URL_Note; } // Add this other URL BriefItem_DescTermValue otherUrlObj = New.Add_Description("Other Item", mainEntry); otherUrlObj.Add_URI(Original.Bib_Info.Location.Other_URL); // Add display label, if one exists if (!String.IsNullOrEmpty(Original.Bib_Info.Location.Other_URL_Display_Label)) { otherUrlObj.SubTerm = Original.Bib_Info.Location.Other_URL_Display_Label; } return(true); }
/// <summary> Read to the end of a (text-based) file and return the contents </summary> /// <param name="DigitalResource"> The digital resource object </param> /// <param name="FileName"> Name of the file to open, and read </param> /// <returns> Full contexts of the text-based file </returns> public string ReadToEnd(BriefItemInfo DigitalResource, string FileName) { // Read the HTML file if ((FileName.IndexOf("http:") == 0) || (FileName.IndexOf("https:") == 0)) { // the html retrieved from the page String strResult; WebRequest objRequest = WebRequest.Create(FileName); WebResponse objResponse = objRequest.GetResponse(); // the using keyword will automatically dispose the object // once complete using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { strResult = sr.ReadToEnd(); // Close and clean up the StreamReader sr.Close(); } return(strResult); } // Just read the network string fullFilePath = Path.Combine(Resource_Network_Uri(DigitalResource.BibID, DigitalResource.VID), FileName); return(File.ReadAllText(fullFilePath)); }
/// <summary> Map one or more data elements from the original METS-based object to the /// BriefItem object </summary> /// <param name="Original"> Original METS-based object </param> /// <param name="New"> New object to populate some data from the original </param> /// <returns> TRUE if successful, FALSE if an exception is encountered </returns> public bool MapToBriefItem(SobekCM_Item Original, BriefItemInfo New) { // Add the IDENTIFIERS if (Original.Bib_Info.Identifiers_Count > 0) { foreach (Identifier_Info thisIdentifier in Original.Bib_Info.Identifiers) { // Add this identifier if (!String.IsNullOrWhiteSpace(thisIdentifier.Type)) { New.Add_Description("Resource Identifier", thisIdentifier.Identifier).Authority = thisIdentifier.Type; // Special code for accession number if (thisIdentifier.Type.IndexOf("ACCESSION", StringComparison.OrdinalIgnoreCase) >= 0) { New.Add_Description("Accession Number", thisIdentifier.Identifier).Authority = thisIdentifier.Type; } } else { New.Add_Description("Resource Identifier", thisIdentifier.Identifier); } } } return(true); }
/// <summary> Return a flag if the file specified exists within the digital resource </summary> /// <param name="DigitalResource"> The digital resource object </param> /// <param name="FileName"> Filename to check for</param> /// <returns> URI for the web resource </returns> public bool FileExists(BriefItemInfo DigitalResource, string FileName) { string path = Resource_Network_Uri(DigitalResource.BibID, DigitalResource.VID); string filePath = Path.Combine(path, FileName); return(File.Exists(filePath)); }
/// <summary> Map one or more data elements from the original METS-based object to the /// BriefItem object </summary> /// <param name="Original"> Original METS-based object </param> /// <param name="New"> New object to populate some data from the original </param> /// <returns> TRUE if successful, FALSE if an exception is encountered </returns> public bool MapToBriefItem(SobekCM_Item Original, BriefItemInfo New) { // Create the main title for this, which includes the non-sort value string final_title = Original.Bib_Info.Main_Title.Title; if (Original.Bib_Info.Main_Title.NonSort.Length > 0) { if (Original.Bib_Info.Main_Title.NonSort[Original.Bib_Info.Main_Title.NonSort.Length - 1] == ' ') { final_title = Original.Bib_Info.Main_Title.NonSort + Original.Bib_Info.Main_Title.Title; } else { if (Original.Bib_Info.Main_Title.NonSort[Original.Bib_Info.Main_Title.NonSort.Length - 1] == '\'') { final_title = Original.Bib_Info.Main_Title.NonSort + Original.Bib_Info.Main_Title.Title; } else { final_title = Original.Bib_Info.Main_Title.NonSort + " " + Original.Bib_Info.Main_Title.Title; } } } New.Title = final_title; return(true); }
/// <summary> Map one or more data elements from the original METS-based object to the /// BriefItem object </summary> /// <param name="Original"> Original METS-based object </param> /// <param name="New"> New object to populate some data from the original </param> /// <returns> TRUE if successful, FALSE if an exception is encountered </returns> public bool MapToBriefItem(SobekCM_Item Original, BriefItemInfo New) { // Add the HOLDING LOCATION information if ((Original.Bib_Info.hasLocationInformation) && (!String.IsNullOrWhiteSpace(Original.Bib_Info.Location.Holding_Name))) { // Add the source institution BriefItem_DescTermValue sourceValue = New.Add_Description("Holding Location", Original.Bib_Info.Location.Holding_Name); // Was the code present, and active? if (!String.IsNullOrWhiteSpace(Original.Bib_Info.Location.Holding_Code)) { if ((Engine_ApplicationCache_Gateway.Codes != null) && (Engine_ApplicationCache_Gateway.Codes.isValidCode("i" + Original.Bib_Info.Location.Holding_Code))) { Item_Aggregation_Related_Aggregations sourceAggr = Engine_ApplicationCache_Gateway.Codes["i" + Original.Bib_Info.Location.Holding_Code]; if (sourceAggr.Active) { sourceValue.Add_URI("[%BASEURL%]" + "i" + Original.Bib_Info.Location.Holding_Code + "[%URLOPTS%]"); } // Was there an external link on this agggreation? if (!String.IsNullOrWhiteSpace(sourceAggr.External_Link)) { sourceValue.Add_URI(sourceAggr.External_Link); } } } } return(true); }
/// <summary> Map one or more data elements from the original METS-based object to the /// BriefItem object </summary> /// <param name="Original"> Original METS-based object </param> /// <param name="New"> New object to populate some data from the original </param> /// <returns> TRUE if successful, FALSE if an exception is encountered </returns> public bool MapToBriefItem(SobekCM_Item Original, BriefItemInfo New) { // Add the TYPE New.Add_Description("Type", Original.Bib_Info.SobekCM_Type_String); return(true); }
/// <summary> Constructor for a new instance of the Text_Search_ItemViewer class, which allows the full text of an /// individual resource to be searched and individual matching pages are displayed with page thumbnails </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> public Text_Search_ItemViewer(BriefItemInfo BriefItem, User_Object CurrentUser, Navigation_Object CurrentRequest, Custom_Tracer Tracer) { Tracer.Add_Trace("Text_Search_ItemViewer.Constructor"); // 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; if (!String.IsNullOrWhiteSpace(CurrentRequest.Text_Search)) { List <string> terms = new List <string>(); List <string> web_fields = new List <string>(); // Split the terms correctly SobekCM_Assistant.Split_Clean_Search_Terms_Fields(CurrentRequest.Text_Search, "ZZ", Search_Type_Enum.Basic, terms, web_fields, null, Search_Precision_Type_Enum.Contains, '|'); Tracer.Add_Trace("Text_Search_ItemViewer.Constructor", "Performing Solr/Lucene search"); int page = CurrentRequest.SubPage.HasValue ? Math.Max(CurrentRequest.SubPage.Value, ((ushort)1)) : 1; results = Solr_Page_Results.Search(BriefItem.BibID, BriefItem.VID, terms, 20, page, false); Tracer.Add_Trace("Text_Search_ItemViewer.Constructor", "Completed Solr/Lucene search in " + results.QueryTime + "ms"); } }
/// <summary> Map one or more data elements from the original METS-based object to the /// BriefItem object </summary> /// <param name="Original"> Original METS-based object </param> /// <param name="New"> New object to populate some data from the original </param> /// <returns> TRUE if successful, FALSE if an exception is encountered </returns> public bool MapToBriefItem(SobekCM_Item Original, BriefItemInfo New) { // Add the aggregations if ((Original.Behaviors.Aggregation_Count > 0) && (Engine_ApplicationCache_Gateway.Codes != null)) { foreach (Aggregation_Info thisAggr in Original.Behaviors.Aggregations) { // Look for the aggregation in the current aggregation codes Item_Aggregation_Related_Aggregations aggrObj = Engine_ApplicationCache_Gateway.Codes[thisAggr.Code]; // If the aggregation is NULL, as it may have been deleted, skip it if (aggrObj == null) { continue; } // If active, add with the URL, otherwise just add the short name if (aggrObj.Active) { New.Add_Description("Aggregations", aggrObj.ShortName).Add_URI("[%BASEURL%]" + aggrObj.Code + "[%URLOPTS%]"); } else { New.Add_Description("Aggregations", aggrObj.ShortName); } } } return(true); }
/// <summary> Flag indicates if the current user has access to this viewer for the item </summary> /// <param name="CurrentItem"> Digital resource to see if the current user has correct permissions to use this viewer </param> /// <param name="CurrentUser"> Current user, who may or may not be logged on </param> /// <param name="IpRestricted"> Flag indicates if this item is IP restricted AND if the current user is outside the ranges </param> /// <returns> TRUE if the user has access to use this viewer, otherwise FALSE </returns> public virtual bool Has_Access(BriefItemInfo CurrentItem, User_Object CurrentUser, bool IpRestricted) { // If there is no user (or they aren't logged in) then obviously, they can't edit this if ((CurrentUser == null) || (!CurrentUser.LoggedOn)) { return(false); } // If INTERNAL, user has access if ((CurrentUser.Is_Host_Admin) || (CurrentUser.Is_System_Admin) || (CurrentUser.Is_Portal_Admin) || (CurrentUser.Is_Internal_User)) { return(true); } // See if this user can edit this item bool userCanEditItem = CurrentUser.Can_Edit_This_Item(CurrentItem.BibID, CurrentItem.Type, CurrentItem.Behaviors.Source_Institution_Aggregation, CurrentItem.Behaviors.Holding_Location_Aggregation, CurrentItem.Behaviors.Aggregation_Code_List); if (!userCanEditItem) { // Can't edit, so don't show and return FALSE return(false); } // Apparently it can be shown return(true); }
/// <summary> Gets the list of all the files associated with this digital resource </summary> /// <param name="DigitalResource"> The digital resource object </param> /// <returns> List of the file information for this digital resource, or NULL if this does not exist somehow </returns> public List <SobekFileSystem_FileInfo> GetFiles(BriefItemInfo DigitalResource) { string directory = Resource_Network_Uri(DigitalResource); try { if (Directory.Exists(directory)) { FileInfo[] files = (new DirectoryInfo(directory)).GetFiles(); List <SobekFileSystem_FileInfo> returnValue = new List <SobekFileSystem_FileInfo>(); foreach (FileInfo thisFile in files) { SobekFileSystem_FileInfo returnFile = new SobekFileSystem_FileInfo { Name = thisFile.Name, LastWriteTime = thisFile.LastWriteTime, Extension = thisFile.Extension, Length = thisFile.Length }; returnValue.Add(returnFile); } return(returnValue); } } catch (Exception ee) { return(null); } return(null); }
/// <summary> Map one or more data elements from the original METS-based object to the /// BriefItem object </summary> /// <param name="Original"> Original METS-based object </param> /// <param name="New"> New object to populate some data from the original </param> /// <returns> TRUE if successful, FALSE if an exception is encountered </returns> public bool MapToBriefItem(SobekCM_Item Original, BriefItemInfo New) { // Add each language if (Original.Bib_Info.Languages_Count > 0) { foreach (Language_Info thisLanguage in Original.Bib_Info.Languages) { if (!String.IsNullOrWhiteSpace(thisLanguage.Language_Text)) { string language_text = thisLanguage.Language_Text; string from_possible_code = thisLanguage.Get_Language_By_Code(language_text); if (from_possible_code.Length > 0) { language_text = from_possible_code; } New.Add_Description("Language", language_text); } else { if (!String.IsNullOrWhiteSpace(thisLanguage.Language_ISO_Code)) { string language_text = thisLanguage.Get_Language_By_Code(thisLanguage.Language_ISO_Code); if (language_text.Length > 0) { New.Add_Description("Language", language_text); } } } } } return(true); }
/// <summary> Returns flag that indicates this citation section writer /// will be writing alues to the output stream </summary> /// <param name="ElementInfo"> Additional possible data about this citation element </param> /// <param name="Item"> Digital resource to analyze for data to write </param> public bool Has_Data_To_Write(CitationElement ElementInfo, BriefItemInfo Item) { // Look for a match in the item description BriefItem_DescriptiveTerm firstCreator = Item.Get_Description("Creator"); return((firstCreator != null) && (firstCreator.Values.Count > 0)); }
/// <summary> Map one or more data elements from the original METS-based object to the /// BriefItem object </summary> /// <param name="Original"> Original METS-based object </param> /// <param name="New"> New object to populate some data from the original </param> /// <returns> TRUE if successful, FALSE if an exception is encountered </returns> public bool MapToBriefItem(SobekCM_Item Original, BriefItemInfo New) { // Try to get the VRA Core metadata VRACore_Info vraInfo = Original.Get_Metadata_Module(GlobalVar.VRACORE_METADATA_MODULE_KEY) as VRACore_Info; // Add the learning object metadata if it exists if ((vraInfo != null) && (vraInfo.hasData)) { // Collect the state/edition information if (vraInfo.State_Edition_Count > 0) { New.Add_Description("State / Edition", vraInfo.State_Editions); } // Collect and display all the material information if (vraInfo.Material_Count > 0) { foreach (VRACore_Materials_Info materials in vraInfo.Materials) { New.Add_Description("Materials", materials.Materials); } } // Collect and display all the measurements information if (vraInfo.Measurement_Count > 0) { foreach (VRACore_Measurement_Info measurement in vraInfo.Measurements) { New.Add_Description("Measurements", measurement.Measurements); } } // Display all cultural context information if (vraInfo.Cultural_Context_Count > 0) { New.Add_Description("Cultural Context", vraInfo.Cultural_Contexts); } // Display all style/period information if (vraInfo.Style_Period_Count > 0) { New.Add_Description("Style/Period", vraInfo.Style_Periods); } // Display all technique information if (vraInfo.Technique_Count > 0) { New.Add_Description("Technique", vraInfo.Techniques); } // Add the inscriptions if (vraInfo.Inscription_Count > 0) { New.Add_Description("Inscription", vraInfo.Inscriptions); } } return(true); }
/// <summary> Gets the appropriate item viewer prototyper ( <see cref="SobekCM.Library.ItemViewer.Viewer.iItemViewerPriority"/> ) /// class for an individual item, based on the requested viewer code </summary> /// <param name="CurrentItem">The current item.</param> /// <param name="ViewerCode">The viewer code.</param> /// <returns> Item viewer prototyper class, which can then be used to create the viewer, if applicable </returns> public static iItemViewerPrototyper Get_Item_Viewer(BriefItemInfo CurrentItem, string ViewerCode) { // Get the viewer type from the item string validType = CurrentItem.UI.Get_Viewer_Type(ViewerCode); // Now, return this prototype return(Get_Viewer_By_ViewType(validType)); }
/// <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> Constructor for a new instance of the Flash_ItemViewer class, used to display a /// flash file, or flash video, 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 Flash_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; // Find the appropriate flash files and label flash_file = String.Empty; flash_label = String.Empty; string first_label = String.Empty; string first_file = String.Empty; int current_flash_index = 0; const int FLASH_INDEX = 0; foreach (BriefItem_FileGrouping thisPage in BriefItem.Downloads) { // Look for a flash file on each page foreach (BriefItem_File thisFile in thisPage.Files) { if (String.Compare(thisFile.File_Extension, ".SWF", StringComparison.OrdinalIgnoreCase) == 0) { // If this is the first one, assign it if (String.IsNullOrEmpty(first_file)) { first_file = thisFile.Name; first_label = thisPage.Label; } if (current_flash_index == FLASH_INDEX) { flash_file = thisFile.Name; flash_label = thisPage.Label; break; } current_flash_index++; } } } // If none found, but a first was found, use that if ((String.IsNullOrEmpty(flash_file)) && (!String.IsNullOrEmpty(first_file))) { flash_file = first_file; flash_label = first_label; } // If this is not already a link format, make it one if ((!String.IsNullOrEmpty(flash_file)) && (flash_file.IndexOf("http:") < 0)) { flash_file = BriefItem.Web.Source_URL + "/" + flash_file; } }
/// <summary> Return the WEB uri for a digital resource </summary> /// <param name="DigitalResource"> The digital resource object </param> /// <returns> URI for the web resource </returns> public string Resource_Web_Uri(BriefItemInfo DigitalResource) { if (rootWebUri[rootWebUri.Length - 1] == '/') { return(rootWebUri + DigitalResource.BibID.Substring(0, 2) + "/" + DigitalResource.BibID.Substring(2, 2) + "/" + DigitalResource.BibID.Substring(4, 2) + "/" + DigitalResource.BibID.Substring(6, 2) + "/" + DigitalResource.BibID.Substring(8, 2) + "/" + DigitalResource.VID + "/"); } return(rootWebUri + "/" + DigitalResource.BibID.Substring(0, 2) + "/" + DigitalResource.BibID.Substring(2, 2) + "/" + DigitalResource.BibID.Substring(4, 2) + "/" + DigitalResource.BibID.Substring(6, 2) + "/" + DigitalResource.BibID.Substring(8, 2) + "/" + DigitalResource.VID + "/"); }
/// <summary> Map one or more data elements from the original METS-based object to the /// BriefItem object </summary> /// <param name="Original"> Original METS-based object </param> /// <param name="New"> New object to populate some data from the original </param> /// <returns> TRUE if successful, FALSE if an exception is encountered </returns> public bool MapToBriefItem(SobekCM_Item Original, BriefItemInfo New) { // Add the physical description if ((Original.Bib_Info.Original_Description != null) && (!String.IsNullOrWhiteSpace(Original.Bib_Info.Original_Description.Extent))) { New.Add_Description("Physical Description", Original.Bib_Info.Original_Description.Extent); } return(true); }
/// <summary> Constructor for a new instance of the GnuBooks_PageTurner_ItemViewer class, used to display the /// jpegs images attached to an item in the GnuBooks viewer </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 GnuBooks_PageTurner_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; }
/// <summary> Map one or more data elements from the original METS-based object to the /// BriefItem object </summary> /// <param name="Original"> Original METS-based object </param> /// <param name="New"> New object to populate some data from the original </param> /// <returns> TRUE if successful, FALSE if an exception is encountered </returns> public bool MapToBriefItem(SobekCM_Item Original, BriefItemInfo New) { // Add the donor if ((Original.Bib_Info.hasDonor) && (!String.IsNullOrWhiteSpace(Original.Bib_Info.Donor.Full_Name))) { New.Add_Description("Donor", Original.Bib_Info.Donor.ToString(false)).SubTerm = "donor"; } return(true); }
/// <summary> Constructor for a new instance of the PDF_ItemViewer class, used to display a PDF 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> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <param name="FileExtensions"> List of file extensions this video viewer should show </param> public PDF_ItemViewer(BriefItemInfo BriefItem, User_Object CurrentUser, Navigation_Object CurrentRequest, Custom_Tracer Tracer, string[] FileExtensions) { // Save the arguments for use later this.BriefItem = BriefItem; this.CurrentUser = CurrentUser; this.CurrentRequest = CurrentRequest; // Determine if this should be written as an iFrame writeAsIframe = ((!String.IsNullOrEmpty(CurrentRequest.Browser_Type)) && (CurrentRequest.Browser_Type.IndexOf("CHROME") == 0)); // Set the behavior properties Behaviors = new List <HtmlSubwriter_Behaviors_Enum> { HtmlSubwriter_Behaviors_Enum.Suppress_Footer }; // Determine if a particular video was selected pdf = 1; if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["pdf"])) { int tryPdf; if (Int32.TryParse(HttpContext.Current.Request.QueryString["pdf"], out tryPdf)) { if (tryPdf < 1) { tryPdf = 1; } pdf = tryPdf; } } // Collect the list of pdf by stepping through each download page pdfFileNames = new List <string>(); pdfLabels = new List <string>(); foreach (BriefItem_FileGrouping downloadPage in BriefItem.Downloads) { foreach (BriefItem_File thisFileInfo in downloadPage.Files) { string extension = thisFileInfo.File_Extension.Replace(".", ""); foreach (string thisPossibleFileExtension in FileExtensions) { if (String.Compare(extension, thisPossibleFileExtension, StringComparison.OrdinalIgnoreCase) == 0) { pdfFileNames.Add(thisFileInfo.Name); pdfLabels.Add(downloadPage.Label); } } } } // Ensure the pdf count wasn't too large if (pdf > pdfFileNames.Count) { pdf = 1; } }
/// <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) { // Must be at least two pages, with JPEGS, included if ((CurrentItem.Images == null) || (CurrentItem.Images.Count < 2)) { return(false); } // Do the pages have JPEGs? return(CurrentItem.Web.Contains_File_Extension("JPG")); }