예제 #1
0
        /// <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("EAD_Description_ItemViewer.Write_Main_Viewer_Section", "");
            }

            // Get the metadata module for EADs
            EAD_Info eadInfo = (EAD_Info)CurrentItem.Get_Metadata_Module(GlobalVar.EAD_METADATA_MODULE_KEY);

            // Build the value
            Output.WriteLine("          <td>");
            Output.WriteLine("            <div id=\"sbkEad_MainArea\">");

            if (CurrentMode.Text_Search.Length > 0)
            {
                // 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());
                }

                Output.Write(Text_Search_Term_Highlighter.Hightlight_Term_In_HTML(eadInfo.Full_Description, terms));
            }
            else
            {
                Output.Write(eadInfo.Full_Description);
            }

            Output.WriteLine("            </div>");
            Output.WriteLine("          </td>");
        }
        /// <summary> Adds the main view section to the page turner </summary>
        /// <param name="placeHolder"> Main place holder ( &quot;mainPlaceHolder&quot; ) in the itemNavForm form into which the the bulk of the item viewer's output is displayed</param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        public override void Add_Main_Viewer_Section(PlaceHolder placeHolder, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("EAD_Description_ItemViewer.Add_Main_Viewer_Section", "Adds one literal with all the html");
            }

            // Get the metadata module for EADs
            EAD_Info eadInfo = (EAD_Info)CurrentItem.Get_Metadata_Module(GlobalVar.EAD_METADATA_MODULE_KEY);

            // Build the value
            StringBuilder builder = new StringBuilder(15000);

            builder.AppendLine("          <td align=\"left\"><span class=\"SobekViewerTitle\">Archival Description</span></td>");
            builder.AppendLine("        </tr>");
            builder.AppendLine("        <tr>");
            builder.AppendLine("          <td>");
            builder.AppendLine("            <div class=\"SobekCitation\">");
            builder.AppendLine("              <br />");
            builder.AppendLine("              <blockquote>");

            if (CurrentMode.Text_Search.Length > 0)
            {
                // 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());
                }

                builder.Append(Text_Search_Term_Highlighter.Hightlight_Term_In_HTML(eadInfo.Full_Description, terms));
            }
            else
            {
                builder.Append(eadInfo.Full_Description);
            }

            builder.AppendLine("              </blockquote>");
            builder.AppendLine("              <br />");
            builder.AppendLine("            </div>");

            // Add the HTML for the image
            Literal mainLiteral = new Literal {
                Text = builder.ToString()
            };

            placeHolder.Controls.Add(mainLiteral);
        }
        /// <summary> Method performs the actual search against the polygon/coordinates
        /// in the METS file for the current item  </summary>
        protected void Perform_Coordinate_Search()
        {
            mapBuilder = new StringBuilder();
            if (CurrentMode.ViewerCode == "mapsearch")
            {
                googleItemSearch = true;
            }

            // If coordinates were passed in, pull the actual coordinates out of the URL
            validCoordinateSearchFound = false;
            if (CurrentMode.Coordinates.Length > 0)
            {
                string[] splitter = CurrentMode.Coordinates.Split(",".ToCharArray());
                if (((splitter.Length > 1) && (splitter.Length < 4)) || ((splitter.Length == 4) && (splitter[2].Length == 0) && (splitter[3].Length == 0)))
                {
                    if ((Double.TryParse(splitter[0], out providedMaxLat)) && (Double.TryParse(splitter[1], out providedMaxLong)))
                    {
                        validCoordinateSearchFound = true;
                    }
                    providedMinLat  = providedMaxLat;
                    providedMinLong = providedMaxLong;
                }
                else if (splitter.Length >= 4)
                {
                    if ((Double.TryParse(splitter[0], out providedMaxLat)) && (Double.TryParse(splitter[1], out providedMaxLong)) &&
                        (Double.TryParse(splitter[2], out providedMinLat)) && (Double.TryParse(splitter[3], out providedMinLong)))
                    {
                        validCoordinateSearchFound = true;
                    }
                }
            }

            // Get the google map API
            mapBuilder.AppendLine("<script type=\"text/javascript\" src=\"http://maps.google.com/maps/api/js?sensor=false\"></script>");
            mapBuilder.AppendLine("<script type=\"text/javascript\" src=\"" + CurrentMode.Base_URL + "default/scripts/sobekcm_map_search.js\"></script>");
            mapBuilder.AppendLine("<script type=\"text/javascript\" src=\"" + CurrentMode.Base_URL + "default/scripts/sobekcm_map_tool.js\"></script>");

            // Set some values for the map key
            string search_type  = "geographic";
            bool   areas_shown  = false;
            bool   points_shown = false;
            string areas_name   = "Sheet";

            if (CurrentItem.Bib_Info.SobekCM_Type == TypeOfResource_SobekCM_Enum.Aerial)
            {
                areas_name = "Tile";
            }

            // Load the map
            mapBuilder.AppendLine("<script type=\"text/javascript\">");
            mapBuilder.AppendLine("  //<![CDATA[");
            mapBuilder.AppendLine("  function load() {");
            mapBuilder.AppendLine(googleItemSearch
                                      ? "    load_search_map(6, 19.5, 3, \"map1\");"
                                      : "    load_map(6, 19.5, 3, \"map1\");");

            // Keep track of any matching tiles
            matchingTilesList = new List <string>();

            // Add the points
            if (CurrentItem != null)
            {
                allPolygons = new List <Coordinate_Polygon>();
                allPoints   = new List <Coordinate_Point>();
                allLines    = new List <Coordinate_Line>();

                // Add the search rectangle first
                if ((validCoordinateSearchFound) && (!googleItemSearch))
                {
                    if ((providedMaxLat != providedMinLat) || (providedMaxLong != providedMinLong))
                    {
                        search_type = "rectangle";
                        mapBuilder.AppendLine("    add_rectangle(" + providedMaxLat + ", " + providedMaxLong + ", " + providedMinLat + ", " + providedMinLong + ");");
                    }
                    else
                    {
                        search_type = "point";
                    }
                }

                // Build the matching polygon HTML to overlay the matches over the non-matches
                StringBuilder matchingPolygonsBuilder = new StringBuilder();

                // Collect all the polygons, points, and lines
                GeoSpatial_Information geoInfo = CurrentItem.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information;
                if ((geoInfo != null) && (geoInfo.hasData))
                {
                    if (geoInfo.Polygon_Count > 0)
                    {
                        foreach (Coordinate_Polygon thisPolygon in geoInfo.Polygons)
                        {
                            allPolygons.Add(thisPolygon);
                        }
                    }
                    if (geoInfo.Line_Count > 0)
                    {
                        foreach (Coordinate_Line thisLine in geoInfo.Lines)
                        {
                            allLines.Add(thisLine);
                        }
                    }
                    if (geoInfo.Point_Count > 0)
                    {
                        foreach (Coordinate_Point thisPoint in geoInfo.Points)
                        {
                            allPoints.Add(thisPoint);
                        }
                    }
                }
                List <abstract_TreeNode> pages = CurrentItem.Divisions.Physical_Tree.Pages_PreOrder;
                for (int i = 0; i < pages.Count; i++)
                {
                    abstract_TreeNode      pageNode = pages[i];
                    GeoSpatial_Information geoInfo2 = pageNode.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information;
                    if ((geoInfo2 != null) && (geoInfo2.hasData))
                    {
                        if (geoInfo2.Polygon_Count > 0)
                        {
                            foreach (Coordinate_Polygon thisPolygon in geoInfo2.Polygons)
                            {
                                thisPolygon.Page_Sequence = (ushort)(i + 1);
                                allPolygons.Add(thisPolygon);
                            }
                        }
                        if (geoInfo2.Line_Count > 0)
                        {
                            foreach (Coordinate_Line thisLine in geoInfo2.Lines)
                            {
                                allLines.Add(thisLine);
                            }
                        }
                        if (geoInfo2.Point_Count > 0)
                        {
                            foreach (Coordinate_Point thisPoint in geoInfo2.Points)
                            {
                                allPoints.Add(thisPoint);
                            }
                        }
                    }
                }


                // Add all the polygons now
                if ((allPolygons.Count > 0) && (allPolygons[0].Edge_Points_Count > 1))
                {
                    areas_shown = true;

                    // Determine a base URL for pointing for any polygons that correspond to a page sequence
                    string currentViewerCode = CurrentMode.ViewerCode;
                    CurrentMode.ViewerCode = "XXXXXXXX";
                    string redirect_url = CurrentMode.Redirect_URL();
                    CurrentMode.ViewerCode = currentViewerCode;

                    // Add each polygon
                    foreach (Coordinate_Polygon itemPolygon in allPolygons)
                    {
                        // Determine if this polygon is within the search
                        bool in_coordinates_search = false;
                        if ((validCoordinateSearchFound) && (!googleItemSearch))
                        {
                            // Was this a point search or area search?
                            if ((providedMaxLong == providedMinLong) && (providedMaxLat == providedMinLat))
                            {
                                // Check this point
                                if (itemPolygon.is_In_Bounding_Box(providedMaxLat, providedMaxLong))
                                {
                                    in_coordinates_search = true;
                                }
                            }
                            else
                            {
                                // Chieck this area search
                                if (itemPolygon.is_In_Bounding_Box(providedMaxLat, providedMaxLong, providedMinLat, providedMinLong))
                                {
                                    in_coordinates_search = true;
                                }
                            }
                        }

                        // Look for a link for this item
                        string link = String.Empty;
                        if ((itemPolygon.Page_Sequence > 0) && (!googleItemSearch))
                        {
                            link = redirect_url.Replace("XXXXXXXX", itemPolygon.Page_Sequence.ToString());
                        }

                        // If this is an item search, don't show labels (too distracting)
                        string label = itemPolygon.Label;
                        if (googleItemSearch)
                        {
                            label = String.Empty;
                        }

                        if (in_coordinates_search)
                        {
                            // Start to call the add polygon method
                            matchingPolygonsBuilder.AppendLine("    add_polygon([");
                            foreach (Coordinate_Point thisPoint in itemPolygon.Edge_Points)
                            {
                                matchingPolygonsBuilder.AppendLine("      new google.maps.LatLng(" + thisPoint.Latitude + ", " + thisPoint.Longitude + "),");
                            }
                            matchingPolygonsBuilder.Append("      new google.maps.LatLng(" + itemPolygon.Edge_Points[0].Latitude + ", " + itemPolygon.Edge_Points[0].Longitude + ")],");
                            matchingPolygonsBuilder.AppendLine("true, '" + label + "', '" + link + "' );");

                            // Also add to the list of matching titles
                            matchingTilesList.Add("<a href=\"" + link + "\">" + itemPolygon.Label + "</a>");
                        }
                        else
                        {
                            // Start to call the add polygon method
                            mapBuilder.AppendLine("    add_polygon([");
                            foreach (Coordinate_Point thisPoint in itemPolygon.Edge_Points)
                            {
                                mapBuilder.AppendLine("      new google.maps.LatLng(" + thisPoint.Latitude + ", " + thisPoint.Longitude + "),");
                            }

                            mapBuilder.Append("      new google.maps.LatLng(" + itemPolygon.Edge_Points[0].Latitude + ", " + itemPolygon.Edge_Points[0].Longitude + ")],");

                            // If just one polygon, still show the red outline
                            if (allPolygons.Count == 1)
                            {
                                mapBuilder.AppendLine("true, '', '" + link + "' );");
                            }
                            else
                            {
                                mapBuilder.AppendLine("false, '" + label + "', '" + link + "' );");
                            }
                        }
                    }

                    // Add any matching polygons last
                    mapBuilder.Append(matchingPolygonsBuilder.ToString());
                }

                // Draw all the single points
                if (allPoints.Count > 0)
                {
                    points_shown = true;
                    for (int point = 0; point < allPoints.Count; point++)
                    {
                        mapBuilder.AppendLine("    add_point(" + allPoints[point].Latitude + ", " + allPoints[point].Longitude + ", '" + allPoints[point].Label + "' );");
                    }
                }

                // If this was a point search, also add the point
                if (validCoordinateSearchFound)
                {
                    if ((providedMaxLat == providedMinLat) && (providedMaxLong == providedMinLong))
                    {
                        search_type = "point";
                        mapBuilder.AppendLine("    add_selection_point(" + providedMaxLat + ", " + providedMaxLong + ", 8 );");
                    }
                }

                // Add the searchable, draggable polygon last (if in search mode)
                if ((validCoordinateSearchFound) && (googleItemSearch))
                {
                    if ((providedMaxLat != providedMinLat) || (providedMaxLong != providedMinLong))
                    {
                        mapBuilder.AppendLine("    add_selection_rectangle(" + providedMaxLat + ", " + providedMaxLong + ", " + providedMinLat + ", " + providedMinLong + " );");
                    }
                }

                // Add the map key
                if (!googleItemSearch)
                {
                    mapBuilder.AppendLine("    add_key(" + search_type + ", " + areas_shown.ToString().ToLower() + ", " + points_shown.ToString().ToLower() + ", '" + areas_name + "');");
                }

                // Zoom appropriately
                mapBuilder.AppendLine(matchingPolygonsBuilder.Length > 0 ? "    zoom_to_selected();" : "    zoom_to_bounds();");
            }


            mapBuilder.AppendLine("  }");
            mapBuilder.AppendLine("  //]]>");
            mapBuilder.AppendLine("</script>");
        }
        /// <summary> Adds the main view section to the page turner </summary>
        /// <param name="placeHolder"> Main place holder ( &quot;mainPlaceHolder&quot; ) in the itemNavForm form into which the the bulk of the item viewer's output is displayed</param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        public override void Add_Main_Viewer_Section(PlaceHolder placeHolder, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("EAD_Container_List_ItemViewer.Add_Main_Viewer_Section", "Adds one literal with all the html");
            }

            // Get the metadata module for EADs
            EAD_Info eadInfo = (EAD_Info)CurrentItem.Get_Metadata_Module(GlobalVar.EAD_METADATA_MODULE_KEY);

            // Build any search terms
            List <string> terms = new List <string>();

            if (CurrentMode.Text_Search.Length > 0)
            {
                // Get any search terms
                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());
                }
            }

            // Build the value
            StringBuilder builder = new StringBuilder(15000);

            builder.AppendLine("          <td align=\"left\"><span class=\"SobekViewerTitle\">Container List</span></td>");
            builder.AppendLine("        </tr>");
            builder.AppendLine("        <tr>");
            builder.AppendLine("          <td>");
            builder.AppendLine("            <div class=\"SobekCitation\">");
            builder.AppendLine("              <br />");
            builder.AppendLine("              <blockquote>");


            // Step through the top level first
            foreach (Container_Info container in eadInfo.Container_Hierarchy.Containers)
            {
                // Add this container title and date information first
                builder.Append("<h2>" + container.Unit_Title);
                if (container.Unit_Date.Length > 0)
                {
                    builder.Append(", " + container.Unit_Date);
                }
                builder.AppendLine("</h2>");

                // Add physical extent, if it exists
                if (container.Extent.Length > 0)
                {
                    builder.AppendLine("<strong>" + container.Extent + "</strong><br />");
                }

                // Add the scope content next
                if (container.Scope_And_Content.Length > 0)
                {
                    builder.AppendLine(container.Scope_And_Content);
                }

                // Add any bioghist next
                if (container.Biographical_History.Length > 0)
                {
                    builder.AppendLine(container.Biographical_History);
                }

                // Are there children to this top container
                if (container.Children.Count > 0)
                {
                    // Dump the current builder into a literal
                    Literal newLiteral = new Literal
                    {
                        Text = Text_Search_Term_Highlighter.Hightlight_Term_In_HTML(builder.ToString(), terms)
                    };
                    placeHolder.Controls.Add(newLiteral);

                    // Clear the contents of the builder
                    builder.Remove(0, builder.Length);

                    // Now, add this as a tree
                    TreeView treeView1 = new TreeView
                    {
                        Width = new Unit(700), NodeWrap = true, EnableClientScript = true, PopulateNodesFromClient = false
                    };

                    // Set some tree view properties
                    treeView1.TreeNodePopulate += treeView1_TreeNodePopulate;

                    // Add each child tree node
                    foreach (Container_Info child in container.Children)
                    {
                        // Add this node
                        TreeNode childNode = new TreeNode(child.Unit_Title)
                        {
                            SelectAction = TreeNodeSelectAction.None
                        };
                        if (child.DAO_Link.Length > 0)
                        {
                            if (child.DAO_Title.Length > 0)
                            {
                                childNode.Text = child.Unit_Title + " &nbsp; <a href=\"" + child.DAO_Link + "\">" + child.DAO_Title + "</a>";
                            }
                            else
                            {
                                childNode.Text = "<a href=\"" + child.DAO_Link + "\">" + child.Unit_Title + "</a>";
                            }
                        }

                        treeView1.Nodes.Add(childNode);

                        // Add the description, if there is one
                        if (child.Scope_And_Content.Length > 0)
                        {
                            TreeNode scopeContentNode = new TreeNode(child.Scope_And_Content)
                            {
                                SelectAction = TreeNodeSelectAction.None
                            };
                            childNode.ChildNodes.Add(scopeContentNode);
                        }

                        // Add the grand children
                        if (child.Children_Count > 0)
                        {
                            foreach (Container_Info grandChild in child.Children)
                            {
                                // Add this node
                                TreeNode grandChildNode = new TreeNode(grandChild.Unit_Title)
                                {
                                    SelectAction = TreeNodeSelectAction.None
                                };
                                if (grandChild.DAO_Link.Length > 0)
                                {
                                    if (grandChild.DAO_Title.Length > 0)
                                    {
                                        grandChildNode.Text = grandChild.Unit_Title + " &nbsp; <a href=\"" + grandChild.DAO_Link + "\">" + grandChild.DAO_Title + "</a>";
                                    }
                                    else
                                    {
                                        grandChildNode.Text = "<a href=\"" + grandChild.DAO_Link + "\">" + grandChild.Unit_Title + "</a>";
                                    }
                                }
                                childNode.ChildNodes.Add(grandChildNode);
                            }
                        }
                    }

                    // Configure the tree view collapsed nodes
                    treeView1.CollapseAll();

                    // Add this tree view to the place holder
                    placeHolder.Controls.Add(treeView1);
                }

                // Put some spaces for now
                builder.AppendLine("<br /><br />");
            }

            builder.AppendLine("              </blockquote>");
            builder.AppendLine("              <br />");
            builder.AppendLine("            </div>");

            // Add the HTML for the image
            Literal mainLiteral = new Literal {
                Text = builder.ToString()
            };

            placeHolder.Controls.Add(mainLiteral);
        }