/// <summary> Displays item group information in plain text </summary>
        /// <param name="Output"> Stream to which to write the text for this main writer </param>
        protected internal void display_group(TextWriter Output)
        {
            // Go back to the database and get the datatable
            DataSet thisItem = SobekCM_Database.Get_Item_Group_Details(currentMode.BibID, null);

            // If null returned, write that and end
            if (thisItem == null)
            {
                Output.Write("<b>Invalid Group</b>");
                return;
            }

            // Add the links first
            Output.Write("<a href=\"?b=" + currentMode.BibID + "\" target=\"_BLANK\" >View Group</a>" + Environment.NewLine);
            Output.Write("<br /><br />" + Environment.NewLine);

            Output.WriteLine("<font size=-1>" + Environment.NewLine);
            Output.Write("   <a href=\"#group_table\" >Group</a> | " + Environment.NewLine);
            Output.Write("   <a href=\"#item_table\" >Items</a> | " + Environment.NewLine);
            Output.Write("   <a href=\"#icon_table\" >Icons</a> | " + Environment.NewLine);
            Output.Write("   <a href=\"#interface_table\" >Interfaces</a> " + Environment.NewLine);
            Output.Write("</font>" + Environment.NewLine);
            Output.Write("<br /><br />" + Environment.NewLine);

            // Display the item information table from this dataset
            Output.Write("<a name=\"group_table\"></a>" + Environment.NewLine);
            Output.Write("<b>GROUP table</b>" + Environment.NewLine);
            Output.Write("<table border=\"1\" >" + Environment.NewLine);
            Output.Write("   <tr bgcolor=\"#EEEEEE\">" + Environment.NewLine);
            Output.Write("      <th>GroupTitle</th>" + Environment.NewLine);
            Output.Write("      <th>BibID</th>" + Environment.NewLine);
            Output.Write("      <th>Type</th>" + Environment.NewLine);
            Output.Write("      <th>Default_Collection</th>" + Environment.NewLine);
            Output.Write("      <th>File_Root</th>" + Environment.NewLine);
            Output.Write("      <th>Greenstone_Code</th>" + Environment.NewLine);
            Output.Write("   </tr>" + Environment.NewLine);
            //foreach ( Database.DataSets.Group_Information.GroupRow itemRow in thisItem.Group)
            //{
            //    Output.Write("   <tr>" + Environment.NewLine );
            //    Output.Write("      <td>" + itemRow.GroupTitle + "</td>" + Environment.NewLine );
            //    Output.Write("      <td>" + itemRow.BibID + "</td>" + Environment.NewLine );
            //    Output.Write("      <td>" + itemRow.Type + "</td>" + Environment.NewLine );
            //    Output.Write("      <td>" + itemRow.Default_Collection + "</td>" + Environment.NewLine );
            //    Output.Write("      <td>" + itemRow.File_Location + "</td>" + Environment.NewLine );
            //    Output.Write("      <td>" + itemRow.Greenstone_Cde + "</td>" + Environment.NewLine );
            //    Output.Write("   </tr>" + Environment.NewLine );
            //}
            Output.Write("</table>" + Environment.NewLine);
            Output.Write("<br /><br />" + Environment.NewLine);


            // Display the item information table from this dataset
            Output.Write("<a name=\"item_table\"></a>" + Environment.NewLine);
            Output.Write("<b>ITEM table</b>" + Environment.NewLine);
            Output.Write("<table border=\"1\" width=\"2000\" >" + Environment.NewLine);
            Output.Write("   <tr bgcolor=\"#EEEEEE\">" + Environment.NewLine);
            Output.Write("      <th>ItemID</th>" + Environment.NewLine);
            Output.Write("      <th>Title</th>" + Environment.NewLine);
            Output.Write("      <th>Level1_Text</th>" + Environment.NewLine);
            Output.Write("      <th>Level1_Index</th>" + Environment.NewLine);
            Output.Write("      <th>Level2_Text</th>" + Environment.NewLine);
            Output.Write("      <th>Level2_Index</th>" + Environment.NewLine);
            Output.Write("      <th>Level3_Text</th>" + Environment.NewLine);
            Output.Write("      <th>Level3_Index</th>" + Environment.NewLine);
            Output.Write("      <th>Level4_Text</th>" + Environment.NewLine);
            Output.Write("      <th>Level4_Index</th>" + Environment.NewLine);
            Output.Write("      <th>Level5_Text</th>" + Environment.NewLine);
            Output.Write("      <th>Level5_Text</th>" + Environment.NewLine);
            Output.Write("   </tr>" + Environment.NewLine);
            //foreach ( Database.DataSets.Group_Information._ItemRow itemRow in thisItem._Item)
            //{
            //    Output.Write("   <tr>" + Environment.NewLine );
            //    Output.Write("      <td><a href=\"?i=" + itemRow.ItemID + "\">" + itemRow.ItemID + "</a></td>" + Environment.NewLine );
            //    Output.Write("      <td>" + itemRow.Title + "</td>" + Environment.NewLine );
            //    Output.Write("      <td>" + itemRow.Level1_Index + "</td>" + Environment.NewLine );
            //    Output.Write("      <td>" + itemRow.Level1_Text + "</td>" + Environment.NewLine );
            //    Output.Write("      <td>" + itemRow.Level2_Index + "</td>" + Environment.NewLine );
            //    Output.Write("      <td>" + itemRow.Level2_Text + "</td>" + Environment.NewLine );
            //    Output.Write("      <td>" + itemRow.Level3_Index + "</td>" + Environment.NewLine );
            //    Output.Write("      <td>" + itemRow.Level3_Text + "</td>" + Environment.NewLine );
            //    Output.Write("      <td>" + itemRow.Level4_Index + "</td>" + Environment.NewLine );
            //    Output.Write("      <td>" + itemRow.Level4_Text + "</td>" + Environment.NewLine );
            //    Output.Write("      <td>" + itemRow.Level5_Index + "</td>" + Environment.NewLine );
            //    Output.Write("      <td>" + itemRow.Level5_Text + "</td>" + Environment.NewLine );
            //    Output.Write("   </tr>" + Environment.NewLine );
            //}
            Output.Write("</table>" + Environment.NewLine);
            Output.Write("<br /><br />" + Environment.NewLine);

            // Display the icon table from this dataset
            Output.Write("<a name=\"icon_table\"></a>" + Environment.NewLine);
            Output.Write("<b>ICON table</b>" + Environment.NewLine);
            Output.Write("<table border=\"1\">" + Environment.NewLine);
            Output.Write("   <tr bgcolor=\"#EEEEEE\">" + Environment.NewLine);
            Output.Write("      <th>Icon_URL</th>" + Environment.NewLine);
            Output.Write("      <th>Link</th>" + Environment.NewLine);
            Output.Write("      <th>Icon_Name</th>" + Environment.NewLine);
            Output.Write("   </tr>" + Environment.NewLine);
            //foreach ( Database.DataSets.Group_Information.IconRow iconRow in thisItem.Icon)
            //{
            //    Output.Write("   <tr>" + Environment.NewLine );
            //    Output.Write("      <td>" + iconRow.Icon_URL + "</td>" + Environment.NewLine );
            //    Output.Write("      <td>" + iconRow.Link + "</td>" + Environment.NewLine );
            //    Output.Write("      <td>" + iconRow.Icon_Name + "</td>" + Environment.NewLine );
            //    Output.Write("   </tr>" + Environment.NewLine );
            //}
            Output.Write("</table>" + Environment.NewLine);
            Output.Write("<br /><br />" + Environment.NewLine);

            // Display the interface table from this dataset
            Output.Write("<a name=\"interface_table\"></a>" + Environment.NewLine);
            Output.Write("<b>INTERFACE table</b>" + Environment.NewLine);
            Output.Write("<br /><br />" + Environment.NewLine);
        }
        /// <summary> Constructor for a new instance of the MySobek_HtmlSubwriter class </summary>
        /// <param name="Results_Statistics"> Information about the entire set of results for a browse of a user's bookshelf folder </param>
        /// <param name="Paged_Results"> Single page of results for a browse of a user's bookshelf folder, within the entire set </param>
        /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param>
        /// <param name="All_Items_Lookup"> Lookup object used to pull basic information about any item loaded into this library </param>
        /// <param name="Hierarchy_Object"> Current item aggregation object to display </param>
        /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param>
        /// <param name="Translator"> Language support object which handles simple translational duties </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Current_Item">Current item to edit, if the user is requesting to edit an item</param>
        /// <param name="Aggregation_Aliases"> List of all existing aliases for existing aggregations </param>
        /// <param name="Web_Skin_Collection"> Collection of all the web skins </param>
        /// <param name="Current_User"> Currently logged on user </param>
        /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param>
        /// <param name="IP_Restrictions"> List of all IP Restriction ranges in use by this digital library </param>
        /// <param name="URL_Portals"> List of all web portals into this system </param>
        /// <param name="Stats_Date_Range"> Object contains the start and end dates for the statistical data in the database </param>
        /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the home page are organized </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        public MySobek_HtmlSubwriter(Search_Results_Statistics Results_Statistics,
                                     List <iSearch_Title_Result> Paged_Results,
                                     Aggregation_Code_Manager Code_Manager,
                                     Item_Lookup_Object All_Items_Lookup,
                                     Item_Aggregation Hierarchy_Object,
                                     SobekCM_Skin_Object HTML_Skin,
                                     Language_Support_Info Translator,
                                     SobekCM_Navigation_Object Current_Mode,
                                     SobekCM_Item Current_Item,
                                     Dictionary <string, string> Aggregation_Aliases,
                                     SobekCM_Skin_Collection Web_Skin_Collection,
                                     User_Object Current_User,
                                     IP_Restriction_Ranges IP_Restrictions,
                                     Dictionary <string, Wordmark_Icon> Icon_Table,
                                     Portal_List URL_Portals,
                                     Statistics_Dates Stats_Date_Range,
                                     List <Thematic_Heading> Thematic_Headings,
                                     Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Saving values and geting user object back from the session");

            resultsStatistics = Results_Statistics;
            pagedResults      = Paged_Results;
            codeManager       = Code_Manager;
            itemList          = All_Items_Lookup;
            htmlSkin          = HTML_Skin;
            translator        = Translator;
            currentCollection = Hierarchy_Object;
            currentItem       = Current_Item;
            user           = Current_User;
            ipRestrictions = IP_Restrictions;
            iconTable      = Icon_Table;
            statsDates     = Stats_Date_Range;


            if (Current_Mode.My_Sobek_Type == My_Sobek_Type_Enum.Log_Out)
            {
                Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Performing logout");

                HttpContext.Current.Session["user"] = null;
                HttpContext.Current.Response.Redirect("?");
            }

            if ((Current_Mode.My_Sobek_Type != My_Sobek_Type_Enum.Logon) && (user != null) && (user.Is_Temporary_Password))
            {
                Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.New_Password;
            }

            if (Current_Mode.Logon_Required)
            {
                Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Logon;
            }

            Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Building the my sobek viewer object");
            switch (Current_Mode.My_Sobek_Type)
            {
            case My_Sobek_Type_Enum.Home:
                mySobekViewer = new Home_MySobekViewer(user, Tracer);
                break;

            case My_Sobek_Type_Enum.New_Item:
                mySobekViewer = new New_Group_And_Item_MySobekViewer(user, Current_Mode, itemList, codeManager, iconTable, htmlSkin, translator, Tracer);
                break;

            case My_Sobek_Type_Enum.Folder_Management:
                mySobekViewer = new Folder_Mgmt_MySobekViewer(user, resultsStatistics, pagedResults, codeManager, itemList, currentCollection, htmlSkin, translator, Current_Mode, Tracer);
                break;

            case My_Sobek_Type_Enum.Saved_Searches:
                mySobekViewer = new Saved_Searches_MySobekViewer(user, translator, Current_Mode, Tracer);
                break;

            case My_Sobek_Type_Enum.Preferences:
                mySobekViewer = new Preferences_MySobekViewer(user, Tracer);
                break;

            case My_Sobek_Type_Enum.Logon:
                mySobekViewer = new Logon_MySobekViewer(Current_Mode, Tracer);
                break;

            case My_Sobek_Type_Enum.New_Password:
                mySobekViewer = new NewPassword_MySobekViewer(user, Tracer);
                break;

            case My_Sobek_Type_Enum.Delete_Item:
                mySobekViewer = new Delete_Item_MySobekViewer(user, Current_Mode, All_Items_Lookup, Tracer);
                break;

            case My_Sobek_Type_Enum.Edit_Item_Behaviors:
                mySobekViewer = new Edit_Item_Behaviors_MySobekViewer(user, Current_Mode, currentItem, codeManager, Tracer);
                break;

            case My_Sobek_Type_Enum.Edit_Item_Metadata:
                mySobekViewer = new Edit_Item_Metadata_MySobekViewer(user, Current_Mode, itemList, currentItem, codeManager, iconTable, htmlSkin, Tracer);
                break;

            case My_Sobek_Type_Enum.File_Management:
                mySobekViewer = new File_Management_MySobekViewer(user, Current_Mode, Current_Item, itemList, codeManager, iconTable, htmlSkin, translator, Tracer);
                break;

            case My_Sobek_Type_Enum.Edit_Group_Behaviors:
                mySobekViewer = new Edit_Group_Behaviors_MySobekViewer(user, Current_Mode, currentItem, codeManager, Tracer);
                break;

            case My_Sobek_Type_Enum.Edit_Group_Serial_Hierarchy:
                mySobekViewer = new Edit_Serial_Hierarchy_MySobekViewer(user);
                break;

            case My_Sobek_Type_Enum.Group_Add_Volume:
                // Pull the list of items tied to this group
                SobekCM_Items_In_Title itemsInTitle = Cached_Data_Manager.Retrieve_Items_In_Title(currentItem.BibID, Tracer);
                if (itemsInTitle == null)
                {
                    // Get list of information about this item group and save the item list
                    DataSet itemDetails = SobekCM_Database.Get_Item_Group_Details(currentItem.BibID, Tracer);
                    itemsInTitle = new SobekCM_Items_In_Title(itemDetails.Tables[1]);

                    // Store in cache if retrieved
                    Cached_Data_Manager.Store_Items_In_Title(currentItem.BibID, itemsInTitle, Tracer);
                }
                mySobekViewer = new Group_Add_Volume_MySobekViewer(user, Current_Mode, itemList, currentItem, codeManager, iconTable, htmlSkin, itemsInTitle, translator, Tracer);
                break;

            case My_Sobek_Type_Enum.Group_AutoFill_Volumes:
                mySobekViewer = new Group_AutoFill_Volume_MySobekViewer(user);
                break;

            case My_Sobek_Type_Enum.Group_Mass_Update_Items:
                mySobekViewer = new Mass_Update_Items_MySobekViewer(user, Current_Mode, currentItem, codeManager, Tracer);
                break;

            case My_Sobek_Type_Enum.User_Tags:
                mySobekViewer = new User_Tags_MySobekViewer(user, Tracer);
                break;

            case My_Sobek_Type_Enum.User_Usage_Stats:
                mySobekViewer = new User_Usage_Stats_MySobekViewer(user, Current_Mode, statsDates, Tracer);
                break;
            }

            // Pass in the navigation and translator information
            mySobekViewer.CurrentMode = Current_Mode;
            mySobekViewer.Translator  = translator;
        }
Пример #3
0
        /// <summary> Builds an item group object, from a METS file </summary>
        /// <param name="BibID"> Bibliographic identifier for the item group to retrieve </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <param name="Item_Group_Object"> [OUT] Fully built item group object </param>
        /// <param name="Items_In_Title"> [OUT] List of all the items in this title </param>
        public void Build_Item_Group(string BibID, Custom_Tracer Tracer, out SobekCM_Items_In_Title Items_In_Title, out SobekCM_Item Item_Group_Object)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("SobekCM_METS_Based_ItemBuilder.Build_Item_Group", "Create the requested item group");
            }

            // Set to NULL by default
            Item_Group_Object = null;
            Items_In_Title    = null;

            // Get the basic information about this item
            DataSet itemDetails = SobekCM_Database.Get_Item_Group_Details(BibID, Tracer);

            // If this is NULL then there was an error
            if (itemDetails == null)
            {
                return;
            }

            // Get the location for the METS file from the returned value
            DataRow mainItemRow  = itemDetails.Tables[0].Rows[0];
            string  metsLocation = mainItemRow["File_Location"].ToString();

            // Get the response object for this METS file
            string metsFile = metsLocation.Replace("\\", "/") + "/" + BibID + ".xml";

            if (metsFile.IndexOf("http:") < 0)
            {
                metsFile = SobekCM_Library_Settings.Image_Server_Network + metsFile;
            }

            // Try to read this METS file
            bool pulledFromMETSFile = true;

            Item_Group_Object = Build_Item_From_METS(metsFile, BibID + ".xml", Tracer);

            // If this failed, just create an item from scratch
            if (Item_Group_Object == null)
            {
                Item_Group_Object = new SobekCM_Item();
                Item_Group_Object.METS_Header.RecordStatus_Enum = METS_Record_Status.BIB_LEVEL;
                Item_Group_Object.Bib_Info.SobekCM_Type         = TypeOfResource_SobekCM_Enum.Serial;
                Item_Group_Object.BibID = BibID;
                pulledFromMETSFile      = false;
            }

            // Pull values from the database
            Item_Group_Object.Behaviors.GroupTitle = String.Empty;
            Item_Group_Object.Behaviors.Set_Primary_Identifier(mainItemRow["Primary_Identifier_Type"].ToString(), mainItemRow["Primary_Identifier"].ToString());
            Item_Group_Object.Behaviors.Text_Searchable = false;

            Item_Group_Object.Web.File_Root             = String.Empty;
            Item_Group_Object.Web.Image_Root            = SobekCM_Library_Settings.Image_URL;
            Item_Group_Object.Web.Siblings              = 2;
            Item_Group_Object.Web.Static_PageCount      = 0;
            Item_Group_Object.Web.Static_Division_Count = 0;
            Item_Group_Object.Web.AssocFilePath         = "/" + BibID.Substring(0, 2) + "/" + BibID[2] + BibID[6] + "/" + BibID[4] + BibID[8] + "/" + BibID[3] + BibID[7] + "/" + BibID[5] + BibID[9] + "/";
            Item_Group_Object.Web.GroupID = Convert.ToInt32(mainItemRow["GroupID"]);

            // Add the full citation view and google map if pulled from the METS file
            if (pulledFromMETSFile)
            {
                // GEt the geospatial metadata module
                GeoSpatial_Information geoInfo = Item_Group_Object.Get_Metadata_Module(GlobalVar.GEOSPATIAL_METADATA_MODULE_KEY) as GeoSpatial_Information;
                if ((geoInfo != null) && (geoInfo.hasData))
                {
                    // In addition, if there is a latitude or longitude listed, add the Google Maps
                    if ((geoInfo.Point_Count > 0) || (geoInfo.Polygon_Count > 0))
                    {
                        Item_Group_Object.Behaviors.Insert_View(0, View_Enum.GOOGLE_MAP);
                    }
                }

                Item_Group_Object.Behaviors.Insert_View(0, View_Enum.CITATION);
            }

            // If this has more than 1 sibling (this count includes itself), add the multi-volumes viewer
            Item_Group_Object.Behaviors.Default_View = Item_Group_Object.Behaviors.Insert_View(0, View_Enum.ALL_VOLUMES, String.Empty, Item_Group_Object.Bib_Info.SobekCM_Type_String);

            // Pull the data from the database
            Item_Group_Object.Behaviors.GroupType  = mainItemRow["Type"].ToString();
            Item_Group_Object.Behaviors.GroupTitle = mainItemRow["GroupTitle"].ToString();
            Item_Group_Object.Web.File_Root        = mainItemRow["File_Location"].ToString();

            // Create the list of items in this title
            Items_In_Title = new SobekCM_Items_In_Title(itemDetails.Tables[1]);

            // Add the database information to the icons now
            Item_Group_Object.Behaviors.Clear_Wordmarks();
            foreach (DataRow thisIconRow in itemDetails.Tables[2].Rows)
            {
                Wordmark_Info newIcon = new Wordmark_Info();
                if (thisIconRow["Link"].ToString().Length == 0)
                {
                    newIcon.Title = thisIconRow["Icon_Name"].ToString();
                    newIcon.Link  = thisIconRow["Link"].ToString();
                    newIcon.HTML  = "<img class=\"SobekItemWordmark\" src=\"<%BASEURL%>design/wordmarks/" + thisIconRow["Icon_URL"].ToString().Replace("&", "&amp;") + "\" title=\"" + newIcon.Title.Replace("&", "&amp;").Replace("\"", "&quot;") + "\" alt=\"" + newIcon.Title.Replace("&", "&amp;").Replace("\"", "&quot;") + "\" />";
                }
                else
                {
                    newIcon.Title = thisIconRow["Icon_Name"].ToString();
                    newIcon.Link  = thisIconRow["Link"].ToString();
                    newIcon.HTML  = "<a href=\"" + newIcon.Link + "\" target=\"_blank\"><img class=\"SobekItemWordmark\" src=\"<%BASEURL%>design/wordmarks/" + thisIconRow["Icon_URL"].ToString().Replace("&", "&amp;").Replace("\"", "&quot;") + "\" title=\"" + newIcon.Title.Replace("&", "&amp;").Replace("\"", "&quot;") + "\" alt=\"" + newIcon.Title.Replace("&", "&amp;").Replace("\"", "&quot;") + "\" /></a>";
                }
                Item_Group_Object.Behaviors.Add_Wordmark(newIcon);
            }

            // Add the web skin codes to this bib-level item as well
            Item_Group_Object.Behaviors.Clear_Web_Skins();
            foreach (DataRow thisRow in itemDetails.Tables[3].Rows)
            {
                Item_Group_Object.Behaviors.Add_Web_Skin(thisRow[0].ToString().ToUpper());
            }

            // Set the aggregations in the package to the aggregation links from the database
            if (itemDetails.Tables.Count == 6)
            {
                Item_Group_Object.Behaviors.Clear_Aggregations();
                foreach (DataRow thisRow in itemDetails.Tables[4].Rows)
                {
                    Item_Group_Object.Behaviors.Add_Aggregation(thisRow[0].ToString());
                }

                // Add the related titles, if there are some
                foreach (DataRow thisRow in itemDetails.Tables[5].Rows)
                {
                    string relationship   = thisRow["Relationship"].ToString();
                    string title          = thisRow["GroupTitle"].ToString();
                    string bibid          = thisRow["BibID"].ToString();
                    string link_and_title = "<a href=\"<%BASEURL%>" + bibid + "<%URL_OPTS%>\">" + title + "</a>";
                    Item_Group_Object.Web.All_Related_Titles.Add(new Related_Titles(relationship, link_and_title));
                }
            }
        }