/// <summary> Constructor for a new instance of the Citation_ItemViewer class </summary> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="User_Can_Edit_Item"> Flag indicates if the current user can edit the citation information </param> public Citation_ItemViewer(Language_Support_Info Translator, Aggregation_Code_Manager Code_Manager, bool User_Can_Edit_Item ) { translator = Translator; this.Code_Manager = Code_Manager; userCanEditItem = User_Can_Edit_Item; citationType = Citation_Type.Standard; }
/// <summary> Stream to which to write the HTML for this subwriter </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("Citation_ItemViewer.Write_Main_Viewer_Section", "Write the citation information directly to the output stream"); } // Determine if user can edit userCanEditItem = false; if (CurrentUser != null) { userCanEditItem = CurrentUser.Can_Edit_This_Item(CurrentItem.BibID, CurrentItem.Bib_Info.SobekCM_Type_String, CurrentItem.Bib_Info.Source.Code, CurrentItem.Bib_Info.HoldingCode, CurrentItem.Behaviors.Aggregation_Code_List); ; } // Add the HTML for the citation Output.WriteLine(" <!-- CITATION ITEM VIEWER OUTPUT -->"); Output.WriteLine(" <td>"); // If this is DARK and the user cannot edit and the flag is not set to show citation, show nothing here if ((CurrentItem.Behaviors.Dark_Flag) && (!userCanEditItem) && (!UI_ApplicationCache_Gateway.Settings.Resources.Show_Citation_For_Dark_Items)) { Output.WriteLine(" <div id=\"darkItemSuppressCitationMsg\">This item is DARK and cannot be viewed at this time</div>" + Environment.NewLine + "</td>" + Environment.NewLine + " <!-- END CITATION VIEWER OUTPUT -->"); return; } // Determine the citation type citationType = Citation_Type.Standard; switch (CurrentMode.ViewerCode) { case "marc": citationType = Citation_Type.MARC; break; case "metadata": citationType = Citation_Type.Metadata; break; case "usage": citationType = Citation_Type.Statistics; break; } // Restricted users can only see the MARC or the standard if (Item_Restricted) { if ((citationType != Citation_Type.Standard) && (citationType != Citation_Type.MARC)) citationType = Citation_Type.Standard; } // Get the robot flag (if this is rendering for robots, the other citation views are not available) bool isRobot = CurrentMode.Is_Robot; string viewer_code = CurrentMode.ViewerCode; // Get any search terms List<string> terms = new List<string>(); if ( !String.IsNullOrWhiteSpace(CurrentMode.Text_Search)) { string[] splitter = CurrentMode.Text_Search.Replace("\"", "").Split(" ".ToCharArray()); terms.AddRange(from thisSplit in splitter where thisSplit.Trim().Length > 0 select thisSplit.Trim()); } // Add the main wrapper division if ( citationType != Citation_Type.Standard ) Output.WriteLine("<div id=\"sbkCiv_Citation\">"); else { // Determine the material type string microdata_type = "CreativeWork"; switch (CurrentItem.Bib_Info.SobekCM_Type) { case TypeOfResource_SobekCM_Enum.Book: case TypeOfResource_SobekCM_Enum.Serial: case TypeOfResource_SobekCM_Enum.Newspaper: microdata_type = "Book"; break; case TypeOfResource_SobekCM_Enum.Map: microdata_type = "Map"; break; case TypeOfResource_SobekCM_Enum.Photograph: case TypeOfResource_SobekCM_Enum.Aerial: microdata_type = "Photograph"; break; } // Add the main wrapper division, with microdata information Output.WriteLine("<div id=\"sbkCiv_Citation\" itemprop=\"about\" itemscope itemtype=\"http://schema.org/" + microdata_type + "\">"); } if ( !CurrentMode.Is_Robot ) Add_Citation_View_Tabs(Output); // Now, add the text Output.WriteLine(); switch (citationType) { case Citation_Type.Standard: if ( terms.Count > 0 ) { Output.WriteLine(Text_Search_Term_Highlighter.Hightlight_Term_In_HTML(Standard_Citation_String(!isRobot, Tracer), terms, "<span class=\"sbkCiv_TextHighlight\">", "</span>") + Environment.NewLine + " </td>" + Environment.NewLine + " <!-- END CITATION VIEWER OUTPUT -->"); } else { Output.WriteLine(Standard_Citation_String(!isRobot, Tracer) + Environment.NewLine + " </td>" + Environment.NewLine + " <div id=\"sbkCiv_EmptyRobotDiv\" />" + Environment.NewLine + " <!-- END CITATION VIEWER OUTPUT -->"); } break; case Citation_Type.MARC: if ( terms.Count > 0 ) { Output.WriteLine(Text_Search_Term_Highlighter.Hightlight_Term_In_HTML(MARC_String(Tracer), terms, "<span class=\"sbkCiv_TextHighlight\">", "</span>") + Environment.NewLine + " </td>" + Environment.NewLine + " <!-- END CITATION VIEWER OUTPUT -->"); } else { Output.WriteLine( MARC_String(Tracer) + Environment.NewLine + " </td>" + Environment.NewLine + " <!-- END CITATION VIEWER OUTPUT -->"); } break; case Citation_Type.Metadata: Output.WriteLine( Metadata_String( Tracer ) + " </td>" + Environment.NewLine + " <!-- END CITATION VIEWER OUTPUT -->"); break; case Citation_Type.Statistics: Output.WriteLine( Statistics_String(Tracer) + " </td>" + Environment.NewLine + " <!-- END CITATION VIEWER OUTPUT -->"); break; } CurrentMode.ViewerCode = viewer_code; }
/// <summary> Stream to which to write the HTML for this subwriter </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("Citation_ItemViewer.Write_Main_Viewer_Section", "Write the citation information directly to the output stream"); } // If this is an internal user or can edit this item, ensure the extra information // has been pulled for this item if ((userCanEditItem) || (CurrentMode.Internal_User) || ( CurrentMode.ViewerCode == "tracking" ) || ( CurrentMode.ViewerCode == "media" ) || ( CurrentMode.ViewerCode == "archive" )) { if (!CurrentItem.Tracking.Tracking_Info_Pulled) { DataSet data = SobekCM_Database.Tracking_Get_History_Archives(CurrentItem.Web.ItemID, Tracer); CurrentItem.Tracking.Set_Tracking_Info(data); } } // Determine the citation type citationType = Citation_Type.Standard; switch (CurrentMode.ViewerCode) { case "marc": citationType = Citation_Type.MARC; break; case "metadata": citationType = Citation_Type.Metadata; break; case "usage": citationType = Citation_Type.Statistics; break; } // Restricted users can only see the MARC or the standard if (Item_Restricted) { if ((citationType != Citation_Type.Standard) && (citationType != Citation_Type.MARC)) citationType = Citation_Type.Standard; } // Add the HTML for the citation Output.WriteLine(" <!-- CITATION ITEM VIEWER OUTPUT -->" ); Output.WriteLine(" <td>" ); // Get the robot flag (if this is rendering for robots, the other citation views are not available) bool isRobot = CurrentMode.Is_Robot; string viewer_code = CurrentMode.ViewerCode; // Get any search terms List<string> terms = new List<string>(); if (CurrentMode.Text_Search.Trim().Length > 0) { string[] splitter = CurrentMode.Text_Search.Replace("\"", "").Split(" ".ToCharArray()); terms.AddRange(from thisSplit in splitter where thisSplit.Trim().Length > 0 select thisSplit.Trim()); } // Add the main wrapper division if ( citationType != Citation_Type.Standard ) Output.WriteLine("<div id=\"sbkCiv_Citation\">"); else { // Determine the material type string microdata_type = "CreativeWork"; switch (CurrentItem.Bib_Info.SobekCM_Type) { case TypeOfResource_SobekCM_Enum.Book: case TypeOfResource_SobekCM_Enum.Serial: case TypeOfResource_SobekCM_Enum.Newspaper: microdata_type = "Book"; break; case TypeOfResource_SobekCM_Enum.Map: microdata_type = "Map"; break; case TypeOfResource_SobekCM_Enum.Photograph: case TypeOfResource_SobekCM_Enum.Aerial: microdata_type = "Photograph"; break; } // Add the main wrapper division, with microdata information Output.WriteLine("<div id=\"sbkCiv_Citation\" itemprop=\"about\" itemscope itemtype=\"http://schema.org/" + microdata_type + "\">"); } if ( !CurrentMode.Is_Robot ) Add_Citation_View_Tabs(Output); // Now, add the text Output.WriteLine(); switch (citationType) { case Citation_Type.Standard: if ( terms.Count > 0 ) { Output.WriteLine(Text_Search_Term_Highlighter.Hightlight_Term_In_HTML(Standard_Citation_String(!isRobot, Tracer), terms, "<span class=\"sbkCiv_TextHighlight\">", "</span>") + Environment.NewLine + " </td>" + Environment.NewLine + " <!-- END CITATION VIEWER OUTPUT -->"); } else { Output.WriteLine(Standard_Citation_String(!isRobot, Tracer) + Environment.NewLine + " </td>" + Environment.NewLine + " <!-- END CITATION VIEWER OUTPUT -->" ); } break; case Citation_Type.MARC: if ( terms.Count > 0 ) { Output.WriteLine(Text_Search_Term_Highlighter.Hightlight_Term_In_HTML(MARC_String(Tracer), terms, "<span class=\"sbkCiv_TextHighlight\">", "</span>") + Environment.NewLine + " </td>" + Environment.NewLine + " <!-- END CITATION VIEWER OUTPUT -->"); } else { Output.WriteLine( MARC_String(Tracer) + Environment.NewLine + " </td>" + Environment.NewLine + " <!-- END CITATION VIEWER OUTPUT -->"); } break; case Citation_Type.Metadata: Output.WriteLine( Metadata_String( Tracer ) + " </td>" + Environment.NewLine + " <!-- END CITATION VIEWER OUTPUT -->"); break; case Citation_Type.Statistics: Output.WriteLine( Statistics_String(Tracer) + " </td>" + Environment.NewLine + " <!-- END CITATION VIEWER OUTPUT -->"); break; } CurrentMode.ViewerCode = viewer_code; }