/// <summary> Wites a section of citation from a provided digital resource </summary> /// <param name="ElementInfo"> Additional possible data about this citation element </param> /// <param name="Output"> Response stream for the item viewer to write directly to </param> /// <param name="Item"> Digital resource with all the data to write </param> /// <param name="LeftColumnWidth"> Number of pixels of the left column, or the definition terms </param> /// <param name="SearchLink"> Beginning of the search link that can be used to allow the web patron to select a term and run a search against this instance </param> /// <param name="SearchLinkEnd"> End of the search link that can be used to allow the web patron to select a term and run a search against this instance </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public void Write_Citation_Section(CitationElement ElementInfo, StringBuilder Output, BriefItemInfo Item, int LeftColumnWidth, string SearchLink, string SearchLinkEnd, Custom_Tracer Tracer) { BriefItem_DescriptiveTerm creatorList = Item.Get_Description("Creator"); bool first_creator = true; string displayLabel = (String.IsNullOrEmpty(ElementInfo.DisplayTerm)) ? "Creators" : ElementInfo.DisplayTerm; Output.AppendLine(" <dt class=\"sbk_CivCREATOR_Element\" style=\"width:" + LeftColumnWidth + "px;\" >" + displayLabel + ": </dt>"); Output.Append(" <dd class=\"sbk_CivCREATOR_Element\" style=\"margin-left:" + LeftColumnWidth + "px;\" >"); // Determine if ths standard itemprop was overriden string itemProp = (!String.IsNullOrWhiteSpace(ElementInfo.ItemProp)) ? ElementInfo.ItemProp : "creator"; // Determine if the standard search code was overriden string searchCode = (!String.IsNullOrWhiteSpace(ElementInfo.SearchCode)) ? ElementInfo.SearchCode : "AU"; foreach (BriefItem_DescTermValue thisValue in creatorList.Values) { // Was this the first? if (first_creator) first_creator = false; else Output.AppendLine("<br />"); // It is possible a different search term is valid for this item, so check it string searchTerm = (!String.IsNullOrWhiteSpace(thisValue.SearchTerm)) ? thisValue.SearchTerm : thisValue.Value; Output.Append("<span itemprop=\"" + itemProp + "\">" + SearchLink.Replace("<%VALUE%>", search_link_from_value(searchTerm)).Replace("<%CODE%>", searchCode) + display_text_from_value(thisValue.Value) + SearchLinkEnd); if (!String.IsNullOrEmpty(thisValue.Authority)) { Output.Append(" ( " + display_text_from_value(thisValue.Authority) + " ) "); } if (!String.IsNullOrEmpty(thisValue.SubTerm)) { Output.Append(" ( <i>" + display_text_from_value(thisValue.SubTerm) + "</i> ) "); } Output.AppendLine("</span>"); } }
private static bool HTML_Send_Email(string Recepient_List, string CcList, string Comments, string User_Name, string SobekCM_Instance_Name, BriefItemInfo Item, string URL, int UserID) { try { StringBuilder messageBuilder = new StringBuilder(); messageBuilder.AppendLine("<span style=\"font-family:Arial, Helvetica, sans-serif;\">"); if (Comments.Length > 0) { messageBuilder.AppendLine(User_Name + " wanted you to see this item on " + SobekCM_Instance_Name + " and included the following comments.<br /><br />\n"); messageBuilder.AppendLine(Comments.Replace("<", "(").Replace(">", ")").Replace("\"", """) + ".<br /><br />\n"); } else { messageBuilder.AppendLine(User_Name + " wanted you to see this item on " + SobekCM_Instance_Name + ".<br /><br />\n"); } messageBuilder.AppendLine("<table cellspacing=\"0px\" cellpadding=\"0px\">\n"); messageBuilder.AppendLine("<tr><td colspan=\"2\" style=\"background: black; color: white; font-family:Arial, Helvetica, sans-serif;\"><b>ITEM INFORMATION</b></td></tr>\n"); // Include the thumbnail, if one exists if (String.IsNullOrEmpty(Item.Behaviors.Main_Thumbnail)) messageBuilder.AppendLine("<tr>"); else messageBuilder.AppendLine("<tr valign=\"top\"><td><a href=\"" + URL + "\"><img src=\"" + Item.Web.Source_URL.Replace("\\", "/") + "/" + Item.Behaviors.Main_Thumbnail + "\" alt=\"BLOCKED THUMBNAIL IMAGE\" border=\"1px\" /></a></td>\n"); messageBuilder.AppendLine("<td>"); messageBuilder.AppendLine("<table style=\"font-family:Arial, Helvetica, sans-serif; font-size:smaller;\">"); // Step through the citation configuration here CitationSet citationSet = UI_ApplicationCache_Gateway.Configuration.UI.CitationViewer.Get_CitationSet("EMAIL"); foreach (CitationFieldSet fieldsSet in citationSet.FieldSets) { // Check to see if any of the values indicated in this field set exist bool foundExistingData = false; foreach (CitationElement thisField in fieldsSet.Elements) { // Look for a match in the item description BriefItem_DescriptiveTerm briefTerm = Item.Get_Description(thisField.MetadataTerm); // If no match, just continue if ((briefTerm != null) && (briefTerm.Values.Count > 0)) { foundExistingData = true; break; } } // If no data was found to put in this field set, skip it if (!foundExistingData) continue; // 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 = Item.Get_Description(thisField.MetadataTerm); // If no match, just continue if ((briefTerm == null) || (briefTerm.Values.Count == 0)) continue; // If they can all be listed one after the other do so now if (!thisField.IndividualFields) { List<string> valueArray = new List<string>(); foreach (BriefItem_DescTermValue thisValue in briefTerm.Values) { if (String.IsNullOrEmpty(thisValue.Authority)) { if (String.IsNullOrEmpty(thisValue.Language)) { valueArray.Add(HttpUtility.HtmlEncode(thisValue.Value)); } else { valueArray.Add(HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Language + " )"); } } else { if (String.IsNullOrEmpty(thisValue.Language)) { valueArray.Add(HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Authority + " )"); } else { valueArray.Add(HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Authority + ", " + thisValue.Language + " )"); } } } // Now, add this to the citation HTML Add_Citation_HTML_Rows(thisField.DisplayTerm, valueArray, messageBuilder); } else { // In this case, each individual value gets its own citation html row foreach (BriefItem_DescTermValue thisValue in briefTerm.Values) { // Determine the label string label = thisField.DisplayTerm; if (thisField.OverrideDisplayTerm == CitationElement_OverrideDispayTerm_Enum.subterm) { if (!String.IsNullOrEmpty(thisValue.SubTerm)) label = thisValue.SubTerm; } if (String.IsNullOrEmpty(thisValue.Authority)) { if (String.IsNullOrEmpty(thisValue.Language)) { messageBuilder.Append(Single_Citation_HTML_Row(label, HttpUtility.HtmlEncode(thisValue.Value))); } else { messageBuilder.Append(Single_Citation_HTML_Row(label, HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Language + " )")); } } else { if (String.IsNullOrEmpty(thisValue.Language)) { messageBuilder.Append(Single_Citation_HTML_Row(label, HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Authority + " )")); } else { messageBuilder.Append(Single_Citation_HTML_Row(label, HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Authority + ", " + thisValue.Language + " )")); } } } } } } messageBuilder.AppendLine("</table>"); messageBuilder.AppendLine("</td></tr></table>"); messageBuilder.AppendLine("</span>\n"); string[] email_recepients = Recepient_List.Split(";,".ToCharArray()); string subject = Item.Title.Replace(""", "\""); if (Item.Title.Length > 40) { subject = Item.Title.Substring(0, 35).Replace(""", "\"") + "..."; } int error_count = 0; foreach (string thisReceipient in email_recepients) { EmailInfo newEmail = new EmailInfo { Body = messageBuilder.ToString(), isContactUs = false, isHTML = true, Subject = subject, RecipientsList = thisReceipient, FromAddress = SobekCM_Instance_Name + " <" + UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromAddress + ">", UserID = UserID }; if (! String.IsNullOrEmpty(UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromDisplay)) newEmail.FromAddress = UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromDisplay + " <" + UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromAddress + ">"; if (CcList.Length > 0) newEmail.RecipientsList = thisReceipient.Trim() + "," + CcList; string error; if (!Email_Helper.SendEmail(newEmail, out error)) error_count++; } return error_count <= 0; } catch { return false; } }
private static bool Text_Send_Email(string Recepient_List, string CcList, string Comments, string User_Name, string SobekCM_Instance_Name, BriefItemInfo Item, string URL, int UserID ) { try { StringBuilder messageBuilder = new StringBuilder(); if (Comments.Length > 0) { messageBuilder.Append(User_Name + " wanted you to see this item on " + SobekCM_Instance_Name + " and included the following comments:\n\n"); messageBuilder.Append("\"" + Comments + "\"\n\n"); } else { messageBuilder.Append(User_Name + " wanted you to see this item on " + SobekCM_Instance_Name + ".\n\n"); } messageBuilder.Append("ITEM INFORMATION\n"); messageBuilder.Append("------------------------------------------------------\n"); // Step through the citation configuration here CitationSet citationSet = UI_ApplicationCache_Gateway.Configuration.UI.CitationViewer.Get_CitationSet("EMAIL"); foreach (CitationFieldSet fieldsSet in citationSet.FieldSets) { // Check to see if any of the values indicated in this field set exist bool foundExistingData = false; foreach (CitationElement thisField in fieldsSet.Elements) { // Look for a match in the item description BriefItem_DescriptiveTerm briefTerm = Item.Get_Description(thisField.MetadataTerm); // If no match, just continue if ((briefTerm != null) && (briefTerm.Values.Count > 0)) { foundExistingData = true; break; } } // If no data was found to put in this field set, skip it if (!foundExistingData) continue; // 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 = Item.Get_Description(thisField.MetadataTerm); // If no match, just continue if ((briefTerm == null) || (briefTerm.Values.Count == 0)) continue; // If they can all be listed one after the other do so now if (!thisField.IndividualFields) { List<string> valueArray = new List<string>(); foreach (BriefItem_DescTermValue thisValue in briefTerm.Values) { if (String.IsNullOrEmpty(thisValue.Authority)) { if (String.IsNullOrEmpty(thisValue.Language)) { valueArray.Add(HttpUtility.HtmlEncode(thisValue.Value)); } else { valueArray.Add(HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Language + " )"); } } else { if (String.IsNullOrEmpty(thisValue.Language)) { valueArray.Add(HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Authority + " )"); } else { valueArray.Add(HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Authority + ", " + thisValue.Language + " )"); } } } // Now, add this to the citation HTML Add_Citation_Text_Rows(thisField.DisplayTerm, valueArray, messageBuilder); } else { // In this case, each individual value gets its own citation html row foreach (BriefItem_DescTermValue thisValue in briefTerm.Values) { // Determine the label string label = thisField.DisplayTerm; if (thisField.OverrideDisplayTerm == CitationElement_OverrideDispayTerm_Enum.subterm) { if (!String.IsNullOrEmpty(thisValue.SubTerm)) label = thisValue.SubTerm; } if (String.IsNullOrEmpty(thisValue.Authority)) { if (String.IsNullOrEmpty(thisValue.Language)) { messageBuilder.Append(Single_Citation_Text_Row(label, HttpUtility.HtmlEncode(thisValue.Value))); } else { messageBuilder.Append(Single_Citation_Text_Row(label, HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Language + " )")); } } else { if (String.IsNullOrEmpty(thisValue.Language)) { messageBuilder.Append(Single_Citation_Text_Row(label, HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Authority + " )")); } else { messageBuilder.Append(Single_Citation_Text_Row(label, HttpUtility.HtmlEncode(thisValue.Value) + " ( " + thisValue.Authority + ", " + thisValue.Language + " )")); } } } } } } string[] email_recepients = Recepient_List.Split(";,".ToCharArray()); string subject = Item.Title.Replace(""", "\""); if (Item.Title.Length > 40) { subject = Item.Title.Substring(0, 35).Replace(""", "\"") + "..."; } int error_count = 0; foreach (string thisReceipient in email_recepients) { EmailInfo newEmail = new EmailInfo { Body = messageBuilder.ToString(), isContactUs = false, isHTML = false, Subject = subject, RecipientsList = thisReceipient, FromAddress = SobekCM_Instance_Name + " <" + UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromAddress + ">", UserID = UserID }; if (!String.IsNullOrEmpty(UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromDisplay)) newEmail.FromAddress = UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromDisplay + " <" + UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromAddress + ">"; if (CcList.Length > 0) newEmail.RecipientsList = thisReceipient.Trim() + "," + CcList; string error; if (!Email_Helper.SendEmail(newEmail, out error)) error_count++; } return error_count <= 0; } catch { return false; } }
/// <summary> Wites a section of citation from a provided digital resource </summary> /// <param name="ElementInfo"> Additional possible data about this citation element </param> /// <param name="Output"> Response stream for the item viewer to write directly to </param> /// <param name="Item"> Digital resource with all the data to write </param> /// <param name="LeftColumnWidth"> Number of pixels of the left column, or the definition terms </param> /// <param name="SearchLink"> Beginning of the search link that can be used to allow the web patron to select a term and run a search against this instance </param> /// <param name="SearchLinkEnd"> End of the search link that can be used to allow the web patron to select a term and run a search against this instance </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public void Write_Citation_Section(CitationElement ElementInfo, StringBuilder Output, BriefItemInfo Item, int LeftColumnWidth, string SearchLink, string SearchLinkEnd, Custom_Tracer Tracer) { string displayLabel = (String.IsNullOrEmpty(ElementInfo.DisplayTerm)) ? "Spatial Coverage" : ElementInfo.DisplayTerm; Output.AppendLine(" <dt class=\"sbk_CivSPATIAL_COVERAGE_Element\" style=\"width:" + LeftColumnWidth + "px;\" >" + displayLabel + ": </dt>"); Output.Append(" <dd class=\"sbk_CivSPATIAL_COVERAGE_Element\" style=\"margin-left:" + LeftColumnWidth + "px;\">"); int spatial_count = 1; while (true) { // Determine the term to use string term = "Hierarchical Spatial"; if (spatial_count > 1) term = term + " (" + spatial_count + ")"; // Look for the match BriefItem_DescriptiveTerm thisSpatial = Item.Get_Description(term); // If no match, break out of this while loop if ((thisSpatial == null) || (thisSpatial.Values == null)) break; // Past the first complex spatial subject? if ( spatial_count > 1 ) Output.AppendLine("<br />"); // Step through each subterm StringBuilder spatial_builder = new StringBuilder(); foreach (BriefItem_DescTermValue thisValue in thisSpatial.Values) { if (spatial_builder.Length > 0) spatial_builder.Append(" -- "); switch (thisValue.SubTerm) { case "Continent": case "Province": case "Region": case "Territory": case "City Section": case "Island": case "Area": spatial_builder.Append(thisValue.Value); break; case "Country": spatial_builder.Append(SearchLink.Replace("<%VALUE%>", HttpUtility.HtmlEncode(thisValue.Value.Replace("&", "&").Replace("&", "").Replace(" ", " ")).Replace(",", "").Replace("&", "&").Replace("&", "").Replace(" ", "+")).Replace("<%CODE%>", "CO") + thisValue.Value + SearchLinkEnd); break; case "State": spatial_builder.Append(SearchLink.Replace("<%VALUE%>", HttpUtility.HtmlEncode(thisValue.Value.Replace("&", "&").Replace("&", "").Replace(" ", " ")).Replace(",", "").Replace("&", "&").Replace("&", "").Replace(" ", "+")).Replace("<%CODE%>", "ST") + thisValue.Value + SearchLinkEnd); break; case "County": spatial_builder.Append(SearchLink.Replace("<%VALUE%>", HttpUtility.HtmlEncode(thisValue.Value.Replace("&", "&").Replace("&", "").Replace(" ", " ")).Replace(",", "").Replace("&", "&").Replace("&", "").Replace(" ", "+")).Replace("<%CODE%>", "CT") + thisValue.Value + SearchLinkEnd); break; case "City": spatial_builder.Append(SearchLink.Replace("<%VALUE%>", HttpUtility.HtmlEncode(thisValue.Value.Replace("&", "&").Replace("&", "").Replace(" ", " ")).Replace(",", "").Replace("&", "&").Replace("&", "").Replace(" ", "+")).Replace("<%CODE%>", "CI") + thisValue.Value + SearchLinkEnd); break; } } // Display this Output.Append(" " + spatial_builder); // Move to check the next spatial spatial_count++; } Output.AppendLine("</dd>"); Output.AppendLine(); }
/// <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> 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> Wites a section of citation from a provided digital resource </summary> /// <param name="ElementInfo"> Additional possible data about this citation element </param> /// <param name="Output"> Response stream for the item viewer to write directly to </param> /// <param name="Item"> Digital resource with all the data to write </param> /// <param name="LeftColumnWidth"> Number of pixels of the left column, or the definition terms </param> /// <param name="SearchLink"> Beginning of the search link that can be used to allow the web patron to select a term and run a search against this instance </param> /// <param name="SearchLinkEnd"> End of the search link that can be used to allow the web patron to select a term and run a search against this instance </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public void Write_Citation_Section(CitationElement ElementInfo, StringBuilder Output, BriefItemInfo Item, int LeftColumnWidth, string SearchLink, string SearchLinkEnd, Custom_Tracer Tracer) { // Set the default (since this always displays) string rights_statement = "All applicable rights reserved by the source institution and holding location."; string rights_image = String.Empty; string uri = String.Empty; const string SEE_TEXT = "See License Deed"; // Look for a match in the item description BriefItem_DescriptiveTerm rightsTerm = Item.Get_Description("Rights Management"); if ((rightsTerm != null) && (rightsTerm.Values.Count > 0)) { rights_statement = rightsTerm.Values[0].Value; if ((rightsTerm.Values[0].URIs != null) && (rightsTerm.Values[0].URIs.Count == 1)) { uri = rightsTerm.Values[0].URIs[0]; switch (uri) { case "http://creativecommons.org/licenses/by-nc-nd/3.0/": rights_image = UI_ApplicationCache_Gateway.Configuration.UI.StaticResources.Cc_By_Nc_Nd_Img; break; case "http://creativecommons.org/licenses/by-nc-sa/3.0/": rights_image = UI_ApplicationCache_Gateway.Configuration.UI.StaticResources.Cc_By_Nc_Sa_Img; break; case "http://creativecommons.org/licenses/by-nc/3.0/": rights_image = UI_ApplicationCache_Gateway.Configuration.UI.StaticResources.Cc_By_Nc_Img; break; case "http://creativecommons.org/licenses/by-nd/3.0/": rights_image = UI_ApplicationCache_Gateway.Configuration.UI.StaticResources.Cc_By_Nd_Img; break; case "http://creativecommons.org/licenses/by-sa/3.0/": rights_image = UI_ApplicationCache_Gateway.Configuration.UI.StaticResources.Cc_By_Sa_Img; break; case "http://creativecommons.org/licenses/by/3.0/": rights_image = UI_ApplicationCache_Gateway.Configuration.UI.StaticResources.Cc_By_Img; break; case "http://creativecommons.org/publicdomain/zero/1.0/": rights_image = UI_ApplicationCache_Gateway.Configuration.UI.StaticResources.Cc_Zero_Img; break; } } } string displayLabel = (String.IsNullOrEmpty(ElementInfo.DisplayTerm)) ? "Rights Management" : ElementInfo.DisplayTerm; Output.AppendLine(" <dt class=\"sbk_CivRIGHTS_Element\" style=\"width:" + LeftColumnWidth + "px;\" >" + displayLabel + ": </dt>"); Output.Append(" <dd class=\"sbk_CivRIGHTS_Element\" style=\"margin-left:" + LeftColumnWidth + "px;\"><span itemprop=\"rights\">"); if ((rights_statement.IndexOf("http://") == 0) || (rights_statement.IndexOf("https://") == 0)) { Output.Append("<a href=\"" + rights_statement + "\" target=\"RIGHTS\" >" + rights_statement + "</a>"); } else { // Show the rights image? if (String.IsNullOrEmpty(rights_image)) { if (!String.IsNullOrEmpty(uri)) { Output.Append(rights_statement + " ( <a href=\"" + uri + "\" alt=\"" + SEE_TEXT + "\" target=\"license\">link</a> )"); } else { Output.Append(rights_statement); } } else { // Since the image is derived from the URI, there must be a URI here Output.Append("<a href=\"" + uri + "\" alt=\"" + SEE_TEXT + "\" target=\"cc_license\"><img src=\"" + rights_image + "\" /></a> " + rights_statement); } } Output.AppendLine("</span></dd>"); Output.AppendLine(); }