Example #1
0
 /// <summary> Constructor for a new instance of the View_Object class </summary>
 /// <param name="View_Type">Standard type of SobekCM View</param>
 /// <param name="Label">Label for this SobekCM View</param>
 /// <param name="Attributes">Any additional attribures needed for this SobekCM View</param>
 /// <param name="FileName">Name of the file</param>
 public View_Object(View_Enum View_Type, string Label, string Attributes, string FileName)
 {
     view_type  = View_Type;
     label      = Label;
     attributes = Attributes;
     filename   = FileName;
 }
Example #2
0
 /// <summary> Checks to see if the viewer type is in use for this digital resource </summary>
 /// <param name="viewerEnum"> Viewer type to check for </param>
 /// <returns> TRUE if this item has a viewer of that type, otherwise FALSE </returns>
 public bool Has_Viewer_Type(View_Enum viewerEnum)
 {
     if (views == null)
     {
         return(false);
     }
     return(views.Any(thisView => thisView.View_Type == viewerEnum));
 }
        /// <summary>Add a new SobekCM View to this resource </summary>
        /// <param name="Index">Index where to insert this view</param>
        /// <param name="View_Type">Standard type of SobekCM View</param>
        /// <returns>Built view object</returns>
        public View_Object Insert_View(int Index, View_Enum View_Type)
        {
            if (View_Type != View_Enum.None)
            {
                if (views == null)
                {
                    views = new List <View_Object>();
                }

                View_Object newView = new View_Object(View_Type, String.Empty, String.Empty);
                views.Insert(Index, newView);
                return(newView);
            }
            return(null);
        }
        /// <summary>Add a new SobekCM View to this resource </summary>
        /// <param name="View_Type">Standard type of SobekCM View</param>
        /// <param name="Label">Label for this SobekCM View</param>
        /// <param name="Attributes">Any additional attribures needed for thie SobekCM View</param>
        /// <returns>Built view object</returns>
        public View_Object Add_View(View_Enum View_Type, string Label, string Attributes)
        {
            if (View_Type != View_Enum.None)
            {
                if (views == null)
                {
                    views = new List <View_Object>();
                }

                View_Object newView = new View_Object(View_Type, Label, Attributes);
                views.Add(newView);
                return(newView);
            }

            return(null);
        }
        /// <summary>Add a new SobekCM View to this resource </summary>
        /// <param name="Index">Index where to insert this view</param>
        /// <param name="View_Type">Standard type of SobekCM View</param>
        /// <param name="Label">Label for this SobekCM View</param>
        /// <param name="Attributes">Any additional attribures needed for thie SobekCM View</param>
        /// <returns>Built view object</returns>
        public View_Object Insert_View(int Index, View_Enum View_Type, string Label, string Attributes)
        {
            if (View_Type != View_Enum.None)
            {
                if (views == null)
                {
                    views = new List <View_Object>();
                }

                View_Object newView = new View_Object(View_Type, Label, Attributes);
                views.Insert(Index, newView);
                return(newView);
            }

            return(null);
        }
Example #6
0
 /// <summary> Constructor for a new instance of the View_Object class </summary>
 /// <param name="View_Type">Standard type of SobekCM View</param>
 /// <param name="Label">Label for this SobekCM View</param>
 /// <param name="Attributes">Any additional attribures needed for thie SobekCM View</param>
 public View_Object(View_Enum View_Type, string Label, string Attributes)
 {
     view_type  = View_Type;
     label      = Label;
     attributes = Attributes;
 }
Example #7
0
 /// <summary> Constructor for a new instance of the View_Object class </summary>
 /// <param name="View_Type">Standard type of SobekCM View</param>
 public View_Object(View_Enum View_Type)
 {
     view_type = View_Type;
 }
Example #8
0
        /// <summary> Gets the SobekCM viewer code, by viewer type </summary>
        public static string[] Viewer_Code_By_Type(View_Enum View_Type)
        {
            switch (View_Type)
            {
            case View_Enum.ALL_VOLUMES:
                return(new string[] { "allvolumes", "allvolumes1", "allvolumes2", "allvolumes3" });

            case View_Enum.CITATION:
                return(new string[] { "citation", "marc", "metadata", "usage" });

            case View_Enum.TRACKING:
                return(new string[] { "milestones", "tracking", "directory", "media", "archive" });

            case View_Enum.DOWNLOADS:
                return(new string[] { "downloads" });

            case View_Enum.EPHEMERAL_CITIES:
                return(new string[] { "ep" });

            case View_Enum.FEATURES:
                return(new string[] { "features" });

            case View_Enum.FLASH:
                return(new string[] { "flash" });

            case View_Enum.GOOGLE_MAP:
                return(new string[] { "map", "mapsearch" });

            case View_Enum.GOOGLE_COORDINATE_ENTRY:
                return(new string[] { "mapedit" });

            case View_Enum.HTML:
                return(new string[] { "html" });

            case View_Enum.HTML_MAP:
                return(new string[] { "htmlmap" });

            case View_Enum.JPEG:
                return(new string[] { "j" });

            case View_Enum.JPEG2000:
                return(new string[] { "x" });

            case View_Enum.RELATED_IMAGES:
                return(new string[] { "thumbs" });

            case View_Enum.QUALITY_CONTROL:
                return(new string[] { "qc" });

            case View_Enum.SEARCH:
                return(new string[] { "search" });

            case View_Enum.SIMPLE_HTML_LINK:
                return(new string[] { "" });

            case View_Enum.STREETS:
                return(new string[] { "streets" });

            case View_Enum.TEXT:
                return(new string[] { "t" });

            case View_Enum.TOC:
                return(new string[] { "toc" });

            case View_Enum.PDF:
                return(new string[] { "pdf" });

            case View_Enum.EAD_CONTAINER_LIST:
                return(new string[] { "container" });

            case View_Enum.EAD_DESCRIPTION:
                return(new string[] { "description" });

            case View_Enum.PAGE_TURNER:
                return(new string[] { "pageturner" });

            case View_Enum.YOUTUBE_VIDEO:
                return(new string[] { "youtube" });


            case View_Enum.EMBEDDED_VIDEO:
                return(new string[] { "video" });
            }

            return(new string[] { "" });
        }
        /// <summary>Add a new SobekCM View to this resource </summary>
        /// <param name="Index">Index where to insert this view</param>
        /// <param name="View_Type">Standard type of SobekCM View</param>
        /// <param name="Label">Label for this SobekCM View</param>
        /// <param name="Attributes">Any additional attribures needed for thie SobekCM View</param>
        /// <returns>Built view object</returns>
        public View_Object Insert_View(int Index, View_Enum View_Type, string Label, string Attributes)
        {
            if (View_Type != View_Enum.None)
            {
                if (views == null)
                    views = new List<View_Object>();

                View_Object newView = new View_Object(View_Type, Label, Attributes);
                views.Insert(Index, newView);
                return newView;
            }

            return null;
        }
        /// <summary>Add a new SobekCM View to this resource </summary>
        /// <param name="View_Type">Standard type of SobekCM View</param>
        /// <param name="Label">Label for this SobekCM View</param>
        /// <param name="FileName">Name of the file</param>
        /// <param name="Attributes">Any additional attribures needed for thie SobekCM View</param>
        /// <returns>Built view object</returns>
        public View_Object Add_View(View_Enum View_Type, string Label, string FileName, string Attributes)
        {
            if (View_Type != View_Enum.None)
            {
                if (views == null)
                    views = new List<View_Object>();

                View_Object newView = new View_Object(View_Type, Label, Attributes) {FileName = FileName};
                views.Add(newView);
                return newView;
            }

            return null;
        }
 /// <summary>Add a new SobekCM View to this resource </summary>
 /// <param name="View_Type">Standard type of SobekCM View</param>
 /// <returns>Built view object</returns>
 public View_Object Add_View(View_Enum View_Type)
 {
     return Add_View(View_Type, String.Empty, String.Empty);
 }
 /// <summary> Checks to see if the viewer type is in use for this digital resource </summary>
 /// <param name="viewerEnum"> Viewer type to check for </param>
 /// <returns> TRUE if this item has a viewer of that type, otherwise FALSE </returns>
 public bool Has_Viewer_Type( View_Enum viewerEnum )
 {
     if (views == null) return false;
     return views.Any(thisView => thisView.View_Type == viewerEnum);
 }
Example #13
0
        private void Finish_Building_Item(SobekCM_Item thisPackage, DataSet databaseInfo, bool multiple)
        {
            // Copy over some basic values
            DataRow mainItemRow = databaseInfo.Tables[2].Rows[0];

            thisPackage.Behaviors.Set_Primary_Identifier(mainItemRow["Primary_Identifier_Type"].ToString(), mainItemRow["Primary_Identifier"].ToString());
            thisPackage.Behaviors.GroupTitle = mainItemRow["GroupTitle"].ToString();
            thisPackage.Web.File_Root        = mainItemRow["File_Location"].ToString();
            thisPackage.Web.AssocFilePath    = mainItemRow["File_Location"] + "\\" + thisPackage.VID + "\\";
            thisPackage.Behaviors.IP_Restriction_Membership = Convert.ToInt16(mainItemRow["IP_Restriction_Mask"]);
            thisPackage.Behaviors.CheckOut_Required         = Convert.ToBoolean(mainItemRow["CheckoutRequired"]);
            thisPackage.Behaviors.Text_Searchable           = Convert.ToBoolean(mainItemRow["TextSearchable"]);
            thisPackage.Web.ItemID  = Convert.ToInt32(mainItemRow["ItemID"]);
            thisPackage.Web.GroupID = Convert.ToInt32(mainItemRow["GroupID"]);
            thisPackage.Behaviors.Suppress_Endeca = Convert.ToBoolean(mainItemRow["SuppressEndeca"]);
            //thisPackage.Behaviors.Expose_Full_Text_For_Harvesting = Convert.ToBoolean(mainItemRow["SuppressEndeca"]);
            thisPackage.Tracking.Internal_Comments = mainItemRow["Comments"].ToString();
            thisPackage.Behaviors.Dark_Flag        = Convert.ToBoolean(mainItemRow["Dark"]);
            thisPackage.Tracking.Born_Digital      = Convert.ToBoolean(mainItemRow["Born_Digital"]);
            //thisPackage.Divisions.Page_Count = Convert.ToInt32(mainItemRow["Pages"]);
            if (mainItemRow["Disposition_Advice"] != DBNull.Value)
            {
                thisPackage.Tracking.Disposition_Advice = Convert.ToInt16(mainItemRow["Disposition_Advice"]);
            }
            else
            {
                thisPackage.Tracking.Disposition_Advice = -1;
            }
            if (mainItemRow["Material_Received_Date"] != DBNull.Value)
            {
                thisPackage.Tracking.Material_Received_Date = Convert.ToDateTime(mainItemRow["Material_Received_Date"]);
            }
            else
            {
                thisPackage.Tracking.Material_Received_Date = null;
            }
            if (mainItemRow["Material_Recd_Date_Estimated"] != DBNull.Value)
            {
                thisPackage.Tracking.Material_Rec_Date_Estimated = Convert.ToBoolean(mainItemRow["Material_Recd_Date_Estimated"]);
            }
            if (databaseInfo.Tables[2].Columns.Contains("Tracking_Box"))
            {
                if (mainItemRow["Tracking_Box"] != DBNull.Value)
                {
                    thisPackage.Tracking.Tracking_Box = mainItemRow["Tracking_Box"].ToString();
                }
            }


            // Set more of the sobekcm web portions in the item
            thisPackage.Web.Set_BibID_VID(thisPackage.BibID, thisPackage.VID);
            thisPackage.Web.Image_Root = SobekCM_Library_Settings.Image_URL;
            if (multiple)
            {
                thisPackage.Web.Siblings = 2;
            }

            // Set the serial hierarchy from the database (if multiple)
            if ((multiple) && (mainItemRow["Level1_Text"].ToString().Length > 0))
            {
                bool found = false;

                // Get the values from the database first
                string level1_text  = mainItemRow["Level1_Text"].ToString();
                string level2_text  = mainItemRow["Level2_Text"].ToString();
                string level3_text  = mainItemRow["Level3_Text"].ToString();
                int    level1_index = Convert.ToInt32(mainItemRow["Level1_Index"]);
                int    level2_index = Convert.ToInt32(mainItemRow["Level2_Index"]);
                int    level3_index = Convert.ToInt32(mainItemRow["Level3_Index"]);

                // Does this match the enumeration
                if (level1_text.ToUpper().Trim() == thisPackage.Bib_Info.Series_Part_Info.Enum1.ToUpper().Trim())
                {
                    // Copy the database values to the enumeration portion
                    thisPackage.Bib_Info.Series_Part_Info.Enum1       = level1_text;
                    thisPackage.Bib_Info.Series_Part_Info.Enum1_Index = level1_index;
                    thisPackage.Bib_Info.Series_Part_Info.Enum2       = level2_text;
                    thisPackage.Bib_Info.Series_Part_Info.Enum2_Index = level2_index;
                    thisPackage.Bib_Info.Series_Part_Info.Enum3       = level3_text;
                    thisPackage.Bib_Info.Series_Part_Info.Enum3_Index = level3_index;
                    found = true;
                }

                // Does this match the chronology
                if ((!found) && (level1_text.ToUpper().Trim() == thisPackage.Bib_Info.Series_Part_Info.Year.ToUpper().Trim()))
                {
                    // Copy the database values to the chronology portion
                    thisPackage.Bib_Info.Series_Part_Info.Year        = level1_text;
                    thisPackage.Bib_Info.Series_Part_Info.Year_Index  = level1_index;
                    thisPackage.Bib_Info.Series_Part_Info.Month       = level2_text;
                    thisPackage.Bib_Info.Series_Part_Info.Month_Index = level2_index;
                    thisPackage.Bib_Info.Series_Part_Info.Day         = level3_text;
                    thisPackage.Bib_Info.Series_Part_Info.Day_Index   = level3_index;
                    found = true;
                }

                if (!found)
                {
                    // No match.  If it is numeric, move it to the chronology, otherwise, enumeration
                    bool charFound = level1_text.Trim().Any(thisChar => !Char.IsNumber(thisChar));

                    if (charFound)
                    {
                        // Copy the database values to the enumeration portion
                        thisPackage.Bib_Info.Series_Part_Info.Enum1       = level1_text;
                        thisPackage.Bib_Info.Series_Part_Info.Enum1_Index = level1_index;
                        thisPackage.Bib_Info.Series_Part_Info.Enum2       = level2_text;
                        thisPackage.Bib_Info.Series_Part_Info.Enum2_Index = level2_index;
                        thisPackage.Bib_Info.Series_Part_Info.Enum3       = level3_text;
                        thisPackage.Bib_Info.Series_Part_Info.Enum3_Index = level3_index;
                    }
                    else
                    {
                        // Copy the database values to the chronology portion
                        thisPackage.Bib_Info.Series_Part_Info.Year        = level1_text;
                        thisPackage.Bib_Info.Series_Part_Info.Year_Index  = level1_index;
                        thisPackage.Bib_Info.Series_Part_Info.Month       = level2_text;
                        thisPackage.Bib_Info.Series_Part_Info.Month_Index = level2_index;
                        thisPackage.Bib_Info.Series_Part_Info.Day         = level3_text;
                        thisPackage.Bib_Info.Series_Part_Info.Day_Index   = level3_index;
                    }
                }

                // Copy the database values to the simple serial portion (used to actually determine serial heirarchy)
                thisPackage.Behaviors.Serial_Info.Clear();
                thisPackage.Behaviors.Serial_Info.Add_Hierarchy(1, level1_index, level1_text);
                if (level2_text.Length > 0)
                {
                    thisPackage.Behaviors.Serial_Info.Add_Hierarchy(2, level2_index, level2_text);
                    if (level3_text.Length > 0)
                    {
                        thisPackage.Behaviors.Serial_Info.Add_Hierarchy(3, level3_index, level3_text);
                    }
                }
            }

            // See if this can be described
            bool can_describe = false;

            foreach (DataRow thisRow in databaseInfo.Tables[1].Rows)
            {
                int thisAggregationValue = Convert.ToInt16(thisRow["Items_Can_Be_Described"]);
                if (thisAggregationValue == 0)
                {
                    can_describe = false;
                    break;
                }
                if (thisAggregationValue == 2)
                {
                    can_describe = true;
                }
            }
            thisPackage.Behaviors.Can_Be_Described = can_describe;

            // Look for user descriptions
            foreach (DataRow thisRow in databaseInfo.Tables[0].Rows)
            {
                string   first_name = thisRow["FirstName"].ToString();
                string   nick_name  = thisRow["NickName"].ToString();
                string   last_name  = thisRow["LastName"].ToString();
                int      userid     = Convert.ToInt32(thisRow["UserID"]);
                string   tag        = thisRow["Description_Tag"].ToString();
                int      tagid      = Convert.ToInt32(thisRow["TagID"]);
                DateTime dateAdded  = Convert.ToDateTime(thisRow["Date_Modified"]);

                if (nick_name.Length > 0)
                {
                    thisPackage.Behaviors.Add_User_Tag(userid, nick_name + " " + last_name, tag, dateAdded, tagid);
                }
                else
                {
                    thisPackage.Behaviors.Add_User_Tag(userid, first_name + " " + last_name, tag, dateAdded, tagid);
                }
            }

            // Look for ticklers
            foreach (DataRow thisRow in databaseInfo.Tables[3].Rows)
            {
                thisPackage.Behaviors.Add_Tickler(thisRow["MetadataValue"].ToString().Trim());
            }

            // Set the aggregations in the package to the aggregation links from the database
            thisPackage.Behaviors.Clear_Aggregations();
            foreach (DataRow thisRow in databaseInfo.Tables[1].Rows)
            {
                if (!Convert.ToBoolean(thisRow["impliedLink"]))
                {
                    thisPackage.Behaviors.Add_Aggregation(thisRow["Code"].ToString());
                }
            }

            // If no collections, add some regardless of whether it was IMPLIED
            if (thisPackage.Behaviors.Aggregation_Count == 0)
            {
                foreach (DataRow thisRow in databaseInfo.Tables[1].Rows)
                {
                    if (thisRow["Type"].ToString().ToUpper() == "COLLECTION")
                    {
                        thisPackage.Behaviors.Add_Aggregation(thisRow["Code"].ToString());
                    }
                }
            }

            // Step through each page and set the static page count
            pageseq = 0;
            List <Page_TreeNode> pages_encountered = new List <Page_TreeNode>();

            foreach (abstract_TreeNode rootNode in thisPackage.Divisions.Physical_Tree.Roots)
            {
                recurse_through_nodes(thisPackage, rootNode, pages_encountered);
            }
            thisPackage.Web.Static_PageCount      = pages_encountered.Count;
            thisPackage.Web.Static_Division_Count = divseq;

            // Make sure no icons were retained from the METS file itself
            thisPackage.Behaviors.Clear_Wordmarks();

            // Add the icons from the database information
            foreach (DataRow iconRow in databaseInfo.Tables[5].Rows)
            {
                string image = iconRow[0].ToString();
                string link  = iconRow[1].ToString().Replace("&", "&amp;").Replace("\"", "&quot;");
                string code  = iconRow[2].ToString();
                string name  = code.Replace("&", "&amp;").Replace("\"", "&quot;");

                string html;
                if (link.Length == 0)
                {
                    html = "<img class=\"SobekItemWordmark\" src=\"<%BASEURL%>design/wordmarks/" + image + "\" title=\"" + name + "\" alt=\"" + name + "\" />";
                }
                else
                {
                    if (link[0] == '?')
                    {
                        html = "<a href=\"" + link + "\"><img class=\"SobekItemWordmark\" src=\"<%BASEURL%>design/wordmarks/" + image + "\" title=\"" + name + "\" alt=\"" + name + "\" /></a>";
                    }
                    else
                    {
                        html = "<a href=\"" + link + "\" target=\"_blank\"><img class=\"SobekItemWordmark\" src=\"<%BASEURL%>design/wordmarks/" + image + "\" title=\"" + name + "\" alt=\"" + name + "\" /></a>";
                    }
                }

                Wordmark_Info newIcon = new Wordmark_Info {
                    HTML = html, Link = link, Title = name, Code = code
                };
                thisPackage.Behaviors.Add_Wordmark(newIcon);
            }

            // Make sure no web skins were retained from the METS file itself
            thisPackage.Behaviors.Clear_Web_Skins();

            // Add the web skins from the database
            foreach (DataRow skinRow in databaseInfo.Tables[6].Rows)
            {
                thisPackage.Behaviors.Add_Web_Skin(skinRow[0].ToString().ToUpper());
            }

            // Make sure no views were retained from the METS file itself
            thisPackage.Behaviors.Clear_Views();

            // If this has more than 1 sibling (this count includes itself), add the multi-volumes viewer
            if (multiple)
            {
                thisPackage.Behaviors.Add_View(View_Enum.ALL_VOLUMES, String.Empty, thisPackage.Bib_Info.SobekCM_Type_String);
            }

            // Add the full citation view and the (hidden) tracking view
            thisPackage.Behaviors.Add_View(View_Enum.CITATION);
            thisPackage.Behaviors.Add_View(View_Enum.TRACKING);

            // Add the full text
            if (thisPackage.Behaviors.Text_Searchable)
            {
                thisPackage.Behaviors.Add_View(View_Enum.SEARCH);
            }

            // Is there an embedded video?
            if (thisPackage.Behaviors.Embedded_Video.Length > 0)
            {
                thisPackage.Behaviors.Add_View(View_Enum.EMBEDDED_VIDEO);
            }

            // If there is no PURL, add one based on how SobekCM operates
            if (thisPackage.Bib_Info.Location.PURL.Length == 0)
            {
                thisPackage.Bib_Info.Location.PURL = SobekCM_Library_Settings.System_Base_URL + thisPackage.BibID + "/" + thisPackage.VID;
            }

            // IF this is dark, add no other views
            if (!thisPackage.Behaviors.Dark_Flag)
            {
                // Check to see which views were present from the database, and build the list
                Dictionary <View_Enum, View_Object> viewsFromDb = new Dictionary <View_Enum, View_Object>();
                foreach (DataRow viewRow in databaseInfo.Tables[4].Rows)
                {
                    string viewType  = viewRow[0].ToString();
                    string attribute = viewRow[1].ToString();
                    string label     = viewRow[2].ToString();

                    View_Enum viewTypeEnum = View_Enum.None;
                    switch (viewType)
                    {
                    case "JPEG":
                        viewTypeEnum = View_Enum.JPEG;
                        break;

                    case "JPEG2000":
                        viewTypeEnum = View_Enum.JPEG2000;
                        break;

                    case "Text":
                        viewTypeEnum = View_Enum.TEXT;
                        break;

                    case "Page Turner":
                        viewTypeEnum = View_Enum.PAGE_TURNER;
                        break;

                    case "Google Map":
                        viewTypeEnum = View_Enum.GOOGLE_MAP;
                        break;

                    case "HTML Viewer":
                        viewTypeEnum = View_Enum.HTML;
                        break;

                    case "HTML Map Viewer":
                        viewTypeEnum = View_Enum.HTML_MAP;
                        break;

                    case "Related Images":
                        viewTypeEnum = View_Enum.RELATED_IMAGES;
                        break;

                    case "TOC":
                        viewTypeEnum = View_Enum.TOC;
                        break;

                    case "TEI":
                        viewTypeEnum = View_Enum.TEI;
                        break;
                    }

                    if (viewTypeEnum != View_Enum.None)
                    {
                        viewsFromDb[viewTypeEnum] = new View_Object(viewTypeEnum, label, attribute);
                    }
                }

                // Add the thumbnail view, if requested and has multiple pages
                if (thisPackage.Divisions.Page_Count > 1)
                {
                    if (viewsFromDb.ContainsKey(View_Enum.RELATED_IMAGES))
                    {
                        thisPackage.Behaviors.Add_View(viewsFromDb[View_Enum.RELATED_IMAGES]);
                        viewsFromDb.Remove(View_Enum.RELATED_IMAGES);
                    }

                    thisPackage.Behaviors.Add_View(View_Enum.QUALITY_CONTROL);
                }
                else
                {
                    if (viewsFromDb.ContainsKey(View_Enum.RELATED_IMAGES))
                    {
                        viewsFromDb.Remove(View_Enum.RELATED_IMAGES);
                    }
                }

                // If this item has more than one division, look for the TOC viewer
                if ((thisPackage.Divisions.Has_Multiple_Divisions) && (!thisPackage.Bib_Info.ImageClass))
                {
                    if (viewsFromDb.ContainsKey(View_Enum.TOC))
                    {
                        thisPackage.Behaviors.Add_View(viewsFromDb[View_Enum.TOC]);
                        viewsFromDb.Remove(View_Enum.TOC);
                    }
                }

                // In addition, if there is a latitude or longitude listed, look for the Google Maps
                bool hasCoords = false;
                GeoSpatial_Information geoInfo = (GeoSpatial_Information)thisPackage.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY);
                if ((geoInfo != null) && (geoInfo.hasData))
                {
                    if ((geoInfo.Point_Count > 0) || (geoInfo.Polygon_Count > 0))
                    {
                        hasCoords = true;
                    }
                }
                if (!hasCoords)
                {
                    List <abstract_TreeNode> pageList = thisPackage.Divisions.Physical_Tree.Pages_PreOrder;
                    foreach (abstract_TreeNode thisPage in pageList)
                    {
                        GeoSpatial_Information geoInfo2 = (GeoSpatial_Information)thisPage.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY);
                        if ((geoInfo2 != null) && (geoInfo2.hasData))
                        {
                            if ((geoInfo2.Point_Count > 0) || (geoInfo2.Polygon_Count > 0))
                            {
                                hasCoords = true;
                                break;
                            }
                        }
                    }
                }

                if (hasCoords)
                {
                    if (viewsFromDb.ContainsKey(View_Enum.GOOGLE_MAP))
                    {
                        thisPackage.Behaviors.Add_View(viewsFromDb[View_Enum.GOOGLE_MAP]);
                        viewsFromDb.Remove(View_Enum.GOOGLE_MAP);
                    }
                    else
                    {
                        thisPackage.Behaviors.Add_View(View_Enum.GOOGLE_MAP);
                    }
                }

                // Step through each download and make sure it is fully built
                if (thisPackage.Divisions.Download_Tree.Has_Files)
                {
                    string ead_file                        = String.Empty;
                    int    pdf_download                    = 0;
                    string pdf_download_url                = String.Empty;
                    int    non_flash_downloads             = 0;
                    List <abstract_TreeNode> downloadPages = thisPackage.Divisions.Download_Tree.Pages_PreOrder;
                    foreach (Page_TreeNode downloadPage in downloadPages)
                    {
                        // Was this an EAD page?
                        if ((downloadPage.Label == GlobalVar.EAD_METADATA_MODULE_KEY) && (downloadPage.Files.Count == 1))
                        {
                            ead_file = downloadPage.Files[0].System_Name;
                        }

                        // Was this an XSL/EAD page?
                        if ((downloadPage.Label == "XSL") && (downloadPage.Files.Count == 1))
                        {
                        }

                        // Step through each download file
                        foreach (SobekCM_File_Info thisFile in downloadPage.Files)
                        {
                            if (thisFile.File_Extension == "SWF")
                            {
                                string      flashlabel = downloadPage.Label;
                                View_Object newView    = thisPackage.Behaviors.Add_View(View_Enum.FLASH, flashlabel, String.Empty, thisFile.System_Name);
                                thisPackage.Behaviors.Default_View = newView;
                            }
                            else
                            {
                                non_flash_downloads++;
                            }

                            if (thisFile.File_Extension == "PDF")
                            {
                                pdf_download++;
                                pdf_download_url = thisFile.System_Name;
                            }
                        }
                    }

                    if (((non_flash_downloads > 0) && (pdf_download != 1)) || ((non_flash_downloads > 1) && (pdf_download == 1)))
                    {
                        if (thisPackage.Web.Static_PageCount == 0)
                        {
                            thisPackage.Behaviors.Default_View = thisPackage.Behaviors.Add_View(View_Enum.DOWNLOADS);
                        }
                        else
                        {
                            thisPackage.Behaviors.Add_View(View_Enum.DOWNLOADS);
                        }
                    }

                    if (pdf_download == 1)
                    {
                        if ((thisPackage.Web.Static_PageCount == 0) && (thisPackage.Behaviors.Default_View == null))
                        {
                            thisPackage.Behaviors.Default_View          = thisPackage.Behaviors.Add_View(View_Enum.PDF);
                            thisPackage.Behaviors.Default_View.FileName = pdf_download_url;
                        }
                        else
                        {
                            thisPackage.Behaviors.Add_View(View_Enum.PDF).FileName = pdf_download_url;
                        }
                    }

                    // Some special code for EAD objects
                    if ((thisPackage.Bib_Info.SobekCM_Type == TypeOfResource_SobekCM_Enum.Archival) && (ead_file.Length > 0))
                    {
                        // Now, read this EAD file information
                        string ead_file_location     = SobekCM_Library_Settings.Image_Server_Network + thisPackage.Web.AssocFilePath + ead_file;
                        EAD_File_ReaderWriter reader = new EAD_File_ReaderWriter();
                        string Error_Message;
                        Dictionary <string, object> options = new Dictionary <string, object>();
                        options["EAD_File_ReaderWriter:XSL_Location"] = SobekCM_Library_Settings.System_Base_URL + "default/sobekcm_default.xsl";
                        reader.Read_Metadata(ead_file_location, thisPackage, options, out Error_Message);

                        // Clear all existing views
                        thisPackage.Behaviors.Clear_Views();
                        thisPackage.Behaviors.Add_View(View_Enum.CITATION);
                        thisPackage.Behaviors.Default_View = thisPackage.Behaviors.Add_View(View_Enum.EAD_DESCRIPTION);

                        // Get the metadata module for EADs
                        EAD_Info eadInfo = (EAD_Info)thisPackage.Get_Metadata_Module(GlobalVar.EAD_METADATA_MODULE_KEY);
                        if ((eadInfo != null) && (eadInfo.Container_Hierarchy.Containers.Count > 0))
                        {
                            thisPackage.Behaviors.Add_View(View_Enum.EAD_CONTAINER_LIST);
                        }
                    }
                }
                else
                {
                    if (thisPackage.Bib_Info.SobekCM_Type == TypeOfResource_SobekCM_Enum.Aerial)
                    {
                        thisPackage.Behaviors.Add_View(View_Enum.DOWNLOADS);
                    }
                }

                // If there is a RELATED URL with youtube, add that viewer
                if ((thisPackage.Bib_Info.hasLocationInformation) && (thisPackage.Bib_Info.Location.Other_URL.ToLower().IndexOf("www.youtube.com") >= 0))
                {
                    View_Object newViewObj = new View_Object(View_Enum.YOUTUBE_VIDEO);
                    thisPackage.Behaviors.Add_View(newViewObj);
                    thisPackage.Behaviors.Default_View = newViewObj;
                }

                // Look for the HTML type views next, and possible set some defaults
                if (viewsFromDb.ContainsKey(View_Enum.HTML))
                {
                    thisPackage.Behaviors.Add_View(viewsFromDb[View_Enum.HTML]);
                    thisPackage.Behaviors.Default_View = viewsFromDb[View_Enum.HTML];
                    viewsFromDb.Remove(View_Enum.HTML);
                }

                // Look for the HTML MAP type views next, and possible set some defaults
                if (viewsFromDb.ContainsKey(View_Enum.HTML_MAP))
                {
                    thisPackage.Behaviors.Add_View(viewsFromDb[View_Enum.HTML_MAP]);
                    thisPackage.Behaviors.Default_View = viewsFromDb[View_Enum.HTML_MAP];
                    viewsFromDb.Remove(View_Enum.HTML_MAP);
                }

                // Copy the TEI flag
                if (viewsFromDb.ContainsKey(View_Enum.TEI))
                {
                    thisPackage.Behaviors.Add_View(viewsFromDb[View_Enum.TEI]);
                    viewsFromDb.Remove(View_Enum.HTML);
                }

                // Look to add any index information here ( such as on SANBORN maps)
                Map_Info mapInfo = (Map_Info)thisPackage.Get_Metadata_Module(GlobalVar.SOBEKCM_MAPS_METADATA_MODULE_KEY);
                if (mapInfo != null)
                {
                    // Was there a HTML map here?
                    if (mapInfo.Index_Count > 0)
                    {
                        Map_Index   thisIndex      = mapInfo.Get_Index(0);
                        View_Object newMapSanbView = thisPackage.Behaviors.Add_View(View_Enum.HTML_MAP, thisIndex.Title, thisIndex.Image_File + ";" + thisIndex.HTML_File);
                        thisPackage.Behaviors.Default_View = newMapSanbView;
                    }

                    //// Were there streets?
                    //if (thisPackage.Map.Streets.Count > 0)
                    //{
                    //    returnValue.Item_Views.Add(new ViewerFetcher.Streets_ViewerFetcher());
                    //}

                    //// Were there features?
                    //if (thisPackage.Map.Features.Count > 0)
                    //{
                    //    returnValue.Item_Views.Add(new ViewerFetcher.Features_ViewerFetcher());
                    //}
                }

                // Look for the RELATED IMAGES view next
                if (viewsFromDb.ContainsKey(View_Enum.RELATED_IMAGES))
                {
                    thisPackage.Behaviors.Add_View(viewsFromDb[View_Enum.RELATED_IMAGES]);
                    viewsFromDb.Remove(View_Enum.RELATED_IMAGES);
                }

                // Look for the PAGE TURNER view next
                if (viewsFromDb.ContainsKey(View_Enum.PAGE_TURNER))
                {
                    thisPackage.Behaviors.Add_View(viewsFromDb[View_Enum.PAGE_TURNER]);
                    viewsFromDb.Remove(View_Enum.PAGE_TURNER);
                }

                // Finally, add all the ITEM VIEWS
                foreach (View_Object thisObject in viewsFromDb.Values)
                {
                    switch (thisObject.View_Type)
                    {
                    case View_Enum.TEXT:
                    case View_Enum.JPEG:
                    case View_Enum.JPEG2000:
                        thisPackage.Behaviors.Add_Item_Level_Page_View(thisObject);
                        break;
                    }
                }
            }
        }
        /// <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("JPEG_ItemViewer.Write_Main_Viewer_Section", "");
            }

            // Determine if there is a zoomable version of this page
            bool isZoomable = false;

            if (CurrentItem.Web.Pages_By_Sequence.Count > CurrentMode.Page - 1)
            {
                foreach (View_Object thisPageView in CurrentItem.Behaviors.Item_Level_Page_Views)
                {
                    View_Enum thisViewType = thisPageView.View_Type;
                    foreach (SobekCM_File_Info thisFile in CurrentItem.Web.Pages_By_Sequence[CurrentMode.Page - 1].Files)
                    {
                        View_Object fileObject = thisFile.Get_Viewer();
                        if ((fileObject != null) && (fileObject.View_Type == View_Enum.JPEG2000))
                        {
                            isZoomable = true;
                            break;
                        }
                    }
                }
            }

            string displayFileName = CurrentItem.Web.Source_URL + "/" + FileName;

            // MAKE THIS USE THE FILES.ASPX WEB PAGE if this is restricted (or dark)
            if ((CurrentItem.Behaviors.Dark_Flag) || (CurrentItem.Behaviors.IP_Restriction_Membership > 0))
            {
                displayFileName = CurrentMode.Base_URL + "files/" + CurrentItem.BibID + "/" + CurrentItem.VID + "/" + FileName;
            }


            string name_for_image = HttpUtility.HtmlEncode(CurrentItem.Bib_Info.Main_Title.ToString());


            if ((CurrentItem.Web.Pages_By_Sequence.Count > 1) && (Current_Page - 1 < CurrentItem.Web.Pages_By_Sequence.Count))
            {
                string name_of_page = CurrentItem.Web.Pages_By_Sequence[Current_Page - 1].Label;
                name_for_image = name_for_image + " - " + HttpUtility.HtmlEncode(name_of_page);
            }



            // Add the HTML for the image
            if (isZoomable)
            {
                string currViewer = CurrentMode.ViewerCode;
                CurrentMode.ViewerCode = CurrentMode.ViewerCode.ToLower().Replace("j", "") + "x";
                string toZoomable = CurrentMode.Redirect_URL();
                CurrentMode.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=\"MISSING 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=\"MISSING IMAGE\" title=\"" + name_for_image + "\" />");
            }

            Output.WriteLine("\t\t</td>");
        }
 /// <summary> Checks to see if the viewer type is in use for this digital resource </summary>
 /// <param name="ViewerEnum"> Viewer type to check for </param>
 /// <returns> TRUE if this item has a viewer of that type, otherwise FALSE </returns>
 public bool Has_Viewer_Type( View_Enum ViewerEnum )
 {
     return views != null && views.Any(ThisView => ThisView.View_Type == ViewerEnum);
 }
        /// <summary> Saves the data rendered by this element to the provided bibliographic object during postback </summary>
        /// <param name="Bib"> Object into which to save the user's data, entered into the html rendered by this element </param>
        public override void Save_To_Bib(SobekCM_Item Bib)
        {
            // Save each view
            string[] getKeys = HttpContext.Current.Request.Form.AllKeys;
            foreach (string thisKey in getKeys)
            {
                if (thisKey.IndexOf("viewer_type") == 0)
                {
                    string key       = thisKey.Replace("viewer_type", "");
                    string file_key  = "viewer_file" + key;
                    string label_key = "viewer_label" + key;

                    string    type     = HttpContext.Current.Request.Form[thisKey].Trim();
                    string    file     = String.Empty;
                    string    label    = String.Empty;
                    View_Enum viewType = View_Enum.None;
                    switch (type)
                    {
                    case "html":
                        viewType = View_Enum.HTML;
                        break;

                    case "htmlmap":
                        viewType = View_Enum.HTML_MAP;
                        break;

                    case "jpeg":
                        viewType = View_Enum.JPEG;
                        break;

                    case "jpeg2000":
                        viewType = View_Enum.JPEG2000;
                        break;

                    case "map":
                        viewType = View_Enum.GOOGLE_MAP;
                        break;

                    case "pageturner":
                        viewType = View_Enum.PAGE_TURNER;
                        break;

                    case "related":
                        viewType = View_Enum.RELATED_IMAGES;
                        break;

                    case "text":
                        viewType = View_Enum.TEXT;
                        break;

                    case "tei":
                        viewType = View_Enum.TEI;
                        break;
                    }

                    // Get the details information for html and html map
                    if ((viewType == View_Enum.HTML_MAP) || (viewType == View_Enum.HTML))
                    {
                        if (HttpContext.Current.Request.Form[file_key] != null)
                        {
                            file = HttpContext.Current.Request.Form[file_key].Trim();
                        }
                        if (HttpContext.Current.Request.Form[label_key] != null)
                        {
                            label = HttpContext.Current.Request.Form[label_key].Trim();
                        }
                    }

                    // Add this view
                    Bib.Behaviors.Add_View(viewType, label, file);
                }
            }
        }
        /// <summary>Add a new SobekCM View to this resource </summary>
        /// <param name="Index">Index where to insert this view</param>
        /// <param name="View_Type">Standard type of SobekCM View</param>
        /// <returns>Built view object</returns>
        public View_Object Insert_View(int Index, View_Enum View_Type)
        {
            if (View_Type != View_Enum.None)
            {
                if (views == null)
                    views = new List<View_Object>();

                View_Object newView = new View_Object(View_Type, String.Empty, String.Empty);
                views.Insert(Index, newView);
                return newView;
            }
            return null;
        }
Example #18
0
 /// <summary>Add a new SobekCM View to this resource </summary>
 /// <param name="View_Type">Standard type of SobekCM View</param>
 /// <returns>Built view object</returns>
 public View_Object Add_View(View_Enum View_Type)
 {
     return(Add_View(View_Type, String.Empty, String.Empty));
 }
 /// <summary> Checks to see if the viewer type is in use for this digital resource </summary>
 /// <param name="ViewerEnum"> Viewer type to check for </param>
 /// <returns> TRUE if this item has a viewer of that type, otherwise FALSE </returns>
 public bool Has_Viewer_Type(View_Enum ViewerEnum)
 {
     return(views != null && views.Any(ThisView => ThisView.View_Type == ViewerEnum));
 }