/// <summary> Builds a brief version of a digital resource, used when displaying the 'FULL VIEW' in 
        /// a search result or browse list </summary>
        /// <param name="METS_Location"> Location (URL) of the METS file to read via HTTP </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <returns> Briefly built version of a digital resource </returns>
        public SobekCM_Item Build_Brief_Item(string METS_Location, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("SobekCM_METS_Based_ItemBuilder.Build_Brief_Item", "Create the requested item");
            }

            try
            {
                // Get the response object for this METS file
                string mets_file = METS_Location.Replace("\\", "/") + "/citation_mets.xml";

                SobekCM_Item thisPackage = Build_Item_From_METS(mets_file, "citation_mets.xml", Tracer);

                if (thisPackage == null)
                {
                    if (Tracer != null)
                        Tracer.Add_Trace("SobekCM_METS_Based_ItemBuilder.Build_Brief_Item", "Unable to find/read either METS file", Custom_Trace_Type_Enum.Error);
                }

                if (Tracer != null)
                {
                    Tracer.Add_Trace("SobekCM_METS_Based_ItemBuilder.Build_Brief_Item", "Finished building this item");
                }

                return thisPackage;
            }
            catch (Exception ee)
            {
                if (Tracer != null)
                    Tracer.Add_Trace("SobekCM_METS_Based_ItemBuilder.Build_Brief_Item", ee.ToString().Replace("\n", "<br />"), Custom_Trace_Type_Enum.Error);
                return null;
            }
        }
        /// <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("YouTube_Embedded_Video_ItemViewer.Write_Main_Viewer_Section", "");
            }

            //Determine the name of the FLASH file
            string youtube_url = CurrentItem.Bib_Info.Location.Other_URL;
             if ( youtube_url.IndexOf("watch") > 0 )
                 youtube_url = youtube_url.Replace("watch?v=","v/") + "?fs=1&amp;hl=en_US";
            const int width = 600;
            const int height = 480;

            // Add the HTML for the image
            StringBuilder result = new StringBuilder(500);
            Output.WriteLine("          <td><div id=\"sbkEmv_ViewerTitle\">Streaming Video</div></td>");
            Output.WriteLine("        </tr>");
            Output.WriteLine("        <tr>");
            Output.WriteLine("          <td id=\"sbkEmv_MainArea\">");
            Output.WriteLine("            <object style=\"width:" + width + ";height:" + height + "\">");
            Output.WriteLine("              <param name=\"allowscriptaccess\" value=\"always\" />");
            Output.WriteLine("              <param name=\"movie\" value=\"" + youtube_url + "\" />");
            Output.WriteLine("              <param name=\"allowFullScreen\" value=\"true\"></param>");
            Output.WriteLine("              <embed src=\"" + youtube_url + "\" type=\"application/x-shockwave-flash\" AllowScriptAccess=\"always\" allowfullscreen=\"true\" width=\"" + width + "\" height=\"" + height + "\"></embed>");
            Output.WriteLine("            </object>");
            Output.WriteLine("          </td>" );
        }
        /// <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("Feature_ItemViewer.Write_Main_Viewer_Section", "");
            }

            // Save the current viewer code
            string current_view_code = CurrentMode.ViewerCode;

            // Start the citation table
            Output.WriteLine("\t\t<!-- FEATURE VIEWER OUTPUT -->" );
            Output.WriteLine("\t\t<td align=\"left\" height=\"40px\" ><span class=\"SobekViewerTitle\"><b>Index of Features</b></span></td></tr>" );
            Output.WriteLine("\t\t<tr><td class=\"SobekDocumentDisplay\">");
            Output.WriteLine("\t\t\t<div class=\"SobekCitation\">");

            // Get the list of streets from the database
            Map_Features_DataSet features = SobekCM_Database.Get_All_Features_By_Item( CurrentItem.Web.ItemID, Tracer );
            Create_Feature_Index( Output, features );

            // Finish the citation table
            Output.WriteLine( "\t\t\t</div>"  );
            Output.WriteLine("\t\t</td>" );
            Output.WriteLine("\t\t<!-- END FEATURE VIEWER OUTPUT -->" );

            // Restore the mode
            CurrentMode.ViewerCode = current_view_code;
        }
        /// <summary> Writes the style references and other data to the HEAD portion of the web page </summary>
        /// <param name="Output"> Stream to which to write the text for this main writer </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public void Write_Within_HTML_Head(TextWriter Output, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Html_Echo_MainWriter.Write_Within_HTML_Head", "Adding style references to HTML");

            Output.WriteLine("  <meta name=\"robots\" content=\"index, follow\">");

            // Write the style sheet to use
            #if DEBUG
            Output.WriteLine("  <link href=\"" + currentMode.Base_URL + "default/SobekCM.css\" rel=\"stylesheet\" type=\"text/css\" />");
            #else
            Output.WriteLine("  <link href=\"" + currentMode.Base_URL + "default/SobekCM.min.css\" rel=\"stylesheet\" type=\"text/css\" />");

            #endif
            // Write the main SobekCM item style sheet to use
            #if DEBUG
            Output.WriteLine("  <link href=\"" + currentMode.Base_URL + "default/SobekCM_Item.css\" rel=\"stylesheet\" type=\"text/css\" />");
            #else
            Output.WriteLine("  <link href=\"" + currentMode.Base_URL + "default/SobekCM_Item.min.css\" rel=\"stylesheet\" type=\"text/css\" title=\"standard\" />");
            #endif

            // Always add jQuery library (changed as of 7/8/2013)
            if ((currentMode.Mode != Display_Mode_Enum.Item_Display) || (currentMode.ViewerCode != "pageturner"))
            {
            #if DEBUG
                Output.WriteLine("  <script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/jquery/jquery-1.10.2.js\"></script>");
                Output.WriteLine("  <script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/sobekcm_full.js\"></script>");
            #else
                Output.WriteLine("  <script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/jquery/jquery-1.10.2.min.js\"></script>");
                Output.WriteLine("  <script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/sobekcm_full.min.js\"></script>");
            #endif
            }

            // Include the interface's style sheet if it has one
            Output.WriteLine("  <link href=\"" + currentMode.Base_URL + "design/skins/" + currentMode.Base_Skin + "/" + currentMode.Base_Skin + ".css\" rel=\"stylesheet\" type=\"text/css\" />");
        }
        /// <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("YouTube_Embedded_Video_ItemViewer.Add_Main_Viewer_Section", "Adds one literal with all the html");
            }

            //Determine the name of the FLASH file
            string youtube_url = CurrentItem.Bib_Info.Location.Other_URL;
             if ( youtube_url.IndexOf("watch") > 0 )
                 youtube_url = youtube_url.Replace("watch?v=","v/") + "?fs=1&amp;hl=en_US";
            const int width = 600;
            const int height = 480;

            // Add the HTML for the image
            StringBuilder result = new StringBuilder(500);
            result.AppendLine("        <!-- YOU TUBE VIEWER OUTPUT -->");
            result.AppendLine("          <td align=\"left\"><span class=\"SobekViewerTitle\"><b>Streaming Video</b></span></td>");
            result.AppendLine("        </tr>");
            result.AppendLine("        <tr>");
            result.AppendLine("          <td class=\"SobekCitationDisplay\">");
            result.AppendLine("            <object width=\"" + width + "\" height=\"" + height + "\">");
            result.AppendLine("              <param name=\"allowscriptaccess\" value=\"always\" />");
            result.AppendLine("              <param name=\"movie\" value=\"" + youtube_url + "\" />");
            result.AppendLine("              <param name=\"allowFullScreen\" value=\"true\"></param>");
            result.AppendLine("              <embed src=\"" + youtube_url + "\" type=\"application/x-shockwave-flash\" AllowScriptAccess=\"always\" allowfullscreen=\"true\" width=\"" + width + "\" height=\"" + height + "\"></embed>");
            result.AppendLine("            </object>");
            result.AppendLine("          </td>" );
            result.AppendLine("        <!-- END YOU TUBE VIEWER OUTPUT -->" );

            Literal mainLiteral = new Literal {Text = result.ToString()};
            placeHolder.Controls.Add(mainLiteral);
        }
        /// <summary> Perform all the work of adding text directly to the response stream back to the web user </summary>
        /// <param name="Output"> Stream to which to write the text for this main writer </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        public override void Add_Text_To_Page(TextWriter Output, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Html_Echo_MainWriter.Add_Text_To_Page", "Reading the text from the file and echoing back to the output stream");

            try
            {
                FileStream fileStream = new FileStream(fileToEcho, FileMode.Open, FileAccess.Read);
                StreamReader reader = new StreamReader(fileStream);
                string line = reader.ReadLine();
                while ( line != null )
                {
                    Output.WriteLine(line);
                    line = reader.ReadLine();
                }
                reader.Close();
            }
            catch
            {
                Output.WriteLine("ERROR READING THE SOURCE FILE");
            }

            Tracer.Add_Trace("Html_Echo_MainWriter.Add_Text_To_Page", "Finished reading and writing the file");

            Output.WriteLine("<br /><br /><b>TRACE ROUTE</b>");
            Output.WriteLine("<br /><br />Total Execution Time: " + Tracer.Milliseconds + " Milliseconds<br /><br />");
            Output.WriteLine(Tracer.Complete_Trace + "<br />");
        }
        /// <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("EmbeddedVideo_ItemViewer.Add_Main_Viewer_Section", "Adds one literal with all the html");
            }

            //Determine the name of the FLASH file
            string youtube_url = CurrentItem.Bib_Info.Location.Other_URL;
            if (youtube_url.IndexOf("watch") > 0)
                youtube_url = youtube_url.Replace("watch?v=", "v/") + "?fs=1&amp;hl=en_US";
            const int width = 600;
            const int height = 480;

            // Add the HTML for the image
            StringBuilder result = new StringBuilder(500);
            result.AppendLine("        <!-- EMBEDDED VIDEO VIEWER OUTPUT -->");
            result.AppendLine("          <td align=\"left\"><span class=\"SobekViewerTitle\"><b>Streaming Video</b></span></td>");
            result.AppendLine("        </tr>");
            result.AppendLine("        <tr>");
            result.AppendLine("          <td class=\"SobekCitationDisplay\">");

            result.AppendLine(CurrentItem.Behaviors.Embedded_Video);

            result.AppendLine("          </td>");
            result.AppendLine("        <!-- END EMBEDDED VIDEO VIEWER OUTPUT -->");

            Literal mainLiteral = new Literal { Text = result.ToString() };
            placeHolder.Controls.Add(mainLiteral);
        }
        /// <summary> Gets a page from an existing digital resource, by page sequence </summary>
        /// <param name="Current_Item"> Digital resource from which to pull the current page, by sequence </param>
        /// <param name="Sequence"> Sequence for the page to retrieve from this item </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <returns> Page tree node object for the requested page </returns>
        public static Page_TreeNode Get_Current_Page(SobekCM_Item Current_Item, int Sequence, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("SobekCM_Item_Factory.Get_Current_Page", "Requesting the page (by sequence) from the item");
            }

            Page_TreeNode returnValue = null;

            try
            {
                // Set the current page
                if (Sequence >= 1)
                {
                    int requested_page = Sequence - 1;
                    if ((requested_page < 0) || (requested_page > Current_Item.Web.Static_PageCount - 1))
                        requested_page = 0;

                    if (requested_page <= Current_Item.Web.Static_PageCount - 1)
                    {
                        returnValue = Current_Item.Web.Pages_By_Sequence[requested_page];
                    }
                }
            }
            catch (Exception ee)
            {
                throw new ApplicationException("Error assigning the current page sequence", ee);
            }

            return returnValue;
        }
        /// <summary> Read the source browse and info static html files and create the
        /// appropriate <see cref="HTML_Based_Content"/> object with all the bibliographic information
        /// (author, keywords, description, title, code) loaded from the header in the HTML file</summary>
        /// <param name="Source_URL"> URL to the source HTML document, retrievable via the web</param>
        /// <param name="Retain_Entire_Display_Text"> Flag indicates whether the entire display text should be retained (as it is about to be displayed) or just the basic information from the HEAD of the file </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        /// <returns> Fully built browse info object with all the bibliographic information</returns>
        public static HTML_Based_Content Read_Web_Document(string Source_URL,  bool Retain_Entire_Display_Text, Custom_Tracer Tracer)
        {
            try
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("HTML_Based_Content_Reader.Read_Web_Document", "Reading source file via web response");
                }

                // the html retrieved from the page
                string displayText;
                WebRequest objRequest = WebRequest.Create(Source_URL);
                WebResponse objResponse = objRequest.GetResponse();

                // the using keyword will automatically dispose the object once complete
                using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
                {
                    displayText = sr.ReadToEnd();
                    // Close and clean up the StreamReader
                    sr.Close();
                }

                // Convert this to the object
                return Text_To_HTML_Based_Content(displayText, Retain_Entire_Display_Text, String.Empty);
            }
            catch
            {
                return null;
            }
        }
        /// <summary> Constructor for a new instance of the Saved_Searches_MySobekViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Translator"> Translation / language support object for writing the user interface is multiple languages</param>
        /// <param name="currentMode"> Mode / navigation information for the current request</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Saved_Searches_MySobekViewer(User_Object User, 
            Language_Support_Info Translator, 
            SobekCM_Navigation_Object currentMode,
            Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("Saved_Searches_MySobekViewer.Constructor", String.Empty);

            user = User;
            base.Translator = Translator;

            if (currentMode.isPostBack)
            {
                // Pull the standard values
                NameValueCollection form = HttpContext.Current.Request.Form;

                string item_action = form["item_action"].ToUpper().Trim();
                string folder_id = form["folder_id"].Trim();

                if (item_action == "REMOVE")
                {
                    int folder_id_int;
                    if (Int32.TryParse(folder_id, out folder_id_int))
                        SobekCM_Database.Delete_User_Search(folder_id_int, Tracer);
                }

                HttpContext.Current.Response.Redirect(HttpContext.Current.Items["Original_URL"].ToString());
            }
        }
        /// <summary> Writes the HTML generated by this error html subwriter directly to the response stream </summary>
        /// <param name="Output"> Stream to which to write the HTML for this subwriter </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        /// <returns> TRUE -- Value indicating if html writer should finish the page immediately after this, or if there are other controls or routines which need to be called first </returns>
        public override bool Write_HTML(TextWriter Output, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Error_HtmlSubwriter.Write_HTML", "Rendering HTML");

            // Start the page container
            Output.WriteLine("<div id=\"pagecontainer\">");
            Output.WriteLine("<br />");

                Output.WriteLine("<center>");

                Output.WriteLine("  <br /><br />");
                Output.WriteLine("<span style=\"font-size:large; color:red\">");
                Output.WriteLine("    <b>Deprecated URL detected</b>");
                Output.WriteLine("</span>");
                Output.WriteLine("<span style=\"font-size:1.2em\">");
                Output.WriteLine("  <br /><br />");
                Output.WriteLine("The URL you entered is a legacy URL.  Support for this URL will end shortly.<br /><br />Please update your records to the new URL below:<br /><br />");
                Output.WriteLine("<a href=\"" + currentMode.Error_Message + "\">" + currentMode.Error_Message + "</a>");
                Output.WriteLine("  <br /><br /><br /><br />");
                Output.WriteLine("</span>");
                Output.WriteLine("</center>");
                Output.WriteLine();

                Output.WriteLine("<!-- Close the pagecontainer div -->");
                Output.WriteLine("</div>");
                Output.WriteLine();

            return true;
        }
        /// <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("Feature_ItemViewer.Add_Main_Viewer_Section", "Adds one literal with all the html");
            }

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

            // Save the current viewer code
            string current_view_code = CurrentMode.ViewerCode;

            // Start the citation table
            builder.AppendLine("\t\t<!-- FEATURE VIEWER OUTPUT -->" );
            builder.AppendLine("\t\t<td align=\"left\" height=\"40px\" ><span class=\"SobekViewerTitle\"><b>Index of Features</b></span></td></tr>" );
            builder.AppendLine("\t\t<tr><td class=\"SobekDocumentDisplay\">");
            builder.AppendLine("\t\t\t<div class=\"SobekCitation\">");

            // Get the list of streets from the database
            Map_Features_DataSet features = SobekCM_Database.Get_All_Features_By_Item( CurrentItem.Web.ItemID, Tracer );
            Create_Feature_Index( builder, features );

            // Finish the citation table
            builder.AppendLine( "\t\t\t</div>"  );
            builder.AppendLine("\t\t</td>" );
            builder.AppendLine("\t\t<!-- END FEATURE VIEWER OUTPUT -->" );

            // Restore the mode
            CurrentMode.ViewerCode = current_view_code;

            // Add the HTML for the image
            Literal mainLiteral = new Literal {Text = builder.ToString()};
            placeHolder.Controls.Add( mainLiteral );
        }
        /// <summary> Add the HTML to be displayed in the main SobekCM viewer area (outside of the forms)</summary>
        /// <param name="Output"> Textwriter to write the HTML for this viewer</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> This class does nothing, since the interface list is added as controls, not HTML </remarks>
        public override void Write_HTML(TextWriter Output, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Edit_Serial_Hierarchy_MySobekViewer.Write_HTML", "Do nothing");

            Output.WriteLine("<br /><br />");
            Output.WriteLine("<strong>EDIT SERIAL HIERARCHY</strong><br /><br />");
            Output.WriteLine("Implementation for this feature is currently pending.<br /><br /><br />");
        }
        /// <summary> Constructor for a new instance of the User_Tags_MySobekViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Stats_Date_Range"> Object contains the start and end dates for the statistical data in the database </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public User_Usage_Stats_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Statistics_Dates Stats_Date_Range, Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("User_Usage_Stats_MySobekViewer.Constructor", String.Empty);

            currentMode = Current_Mode;
            statsDates = Stats_Date_Range;
        }
        /// <summary> Constructor for a new instance of the Preferences_MySobekViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Preferences_MySobekViewer(User_Object User, Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("Preferences_MySobekViewer.Constructor", String.Empty);

            // Do nothing
            validationErrors = new List<string>();
        }
        /// <summary> Add the HTML to be displayed in the main SobekCM viewer area (outside of the forms)</summary>
        /// <param name="Output"> Textwriter to write the HTML for this viewer</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> This class does nothing, since the interface list is added as controls, not HTML </remarks>
        public override void Write_HTML(TextWriter Output, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Group_AutoFill_Volume_MySobekViewer.Write_HTML", "Do nothing");

            Output.WriteLine("<br /><br />");
            Output.WriteLine("<strong>AUTO-FILL NEW VOLUMES</strong><br /><br />");
            Output.WriteLine("Implementation for this feature is currently pending.<br /><br /><br />");
        }
        /// <summary> Add the HTML to be displayed in the search box </summary>
        /// <param name="Output"> Textwriter to write the HTML for this viewer</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> This adds the title of the static browse or info into the box </remarks>
        public override void Add_Search_Box_HTML(TextWriter Output, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("Static_Browse_Info_AggregationViewer.Add_Search_Box_HTML", "Adding HTML");
            }

            Output.WriteLine("  <h1>" + browseObject.Get_Label(currentMode.Language) + "</h1>");
        }
        /// <summary> Add the HTML to be displayed in the search box </summary>
        /// <param name="Output"> Textwriter to write the HTML for this viewer</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public override void Add_Search_Box_HTML(TextWriter Output, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("No_Search_AggregationViewer.Add_Search_Box_HTML", "Adding html for search box");
            }

            Output.WriteLine("<h1>" + currentCollection.Name + " Home</h1>");
        }
        /// <summary> Writes the HTML generated by this error html subwriter directly to the response stream </summary>
        /// <param name="Output"> Stream to which to write the HTML for this subwriter </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        /// <returns> TRUE -- Value indicating if html writer should finish the page immediately after this, or if there are other controls or routines which need to be called first </returns>
        public override bool Write_HTML(TextWriter Output, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Error_HtmlSubwriter.Write_HTML", "Rendering HTML");

            // Start the page container
            Output.WriteLine("<div id=\"pagecontainer\">");
            Output.WriteLine("<br />");

            string url_options = currentMode.URL_Options();
            if (url_options.Length > 0)
                url_options = "?" + url_options;

            if (invalidItem)
            {
                Output.WriteLine("<span class=\"UfdcGeneralError\">");
                Output.WriteLine("  <br /><br />");
                Output.WriteLine("  The item indicated was not valid.");
                Output.WriteLine("  <br /><br />");

                Output.WriteLine("  Click <a href=\"" + currentMode.Base_URL + "contact\">here</a> to report an error.");
                Output.WriteLine("  <br /><br /><br /><br />");
                Output.WriteLine("</span>");
                Output.WriteLine();
            }
            else
            {
                Output.WriteLine("<br />");
                Output.WriteLine("<div class=\"SobekHomeText\">");
                Output.WriteLine("<table width=\"700\" border=\"0\" align=\"center\">");
                Output.WriteLine("  <tr>");
                Output.WriteLine("    <td align=\"center\" >");
                string error_message = "Unknown error occurred";
                if ((currentMode != null) && (currentMode.Error_Message.Length > 0))
                {
                    error_message = currentMode.Error_Message;
                }

                Output.WriteLine("      <b><h4>" + error_message + "</h4></b>");
                Output.WriteLine("      <h5>We apologize for the inconvenience.</h5>");
                Output.WriteLine("      <h5>Click <a href=\"" + currentMode.Base_URL + url_options + "\">here</a> to return to the library.</h5>");
                string returnurl = currentMode.Base_URL + "contact?em=" + error_message.Replace(" ", "%20") + currentMode.URL_Options();
                Output.WriteLine("      <h5>Click <a href=\"" + returnurl + "\">here</a> to report the problem.</h5>");
                Output.WriteLine("    </td>");
                Output.WriteLine("  </tr>");
                Output.WriteLine("</table>");
                Output.WriteLine("<br /><br />");
                Output.WriteLine("</div>");
            }

            Output.WriteLine("<!-- Close the pagecontainer div -->");
            Output.WriteLine("</div>");
            Output.WriteLine();

            return true;
        }
        /// <summary> Adds the main view section to the page turner </summary>
        /// <param name="MainPlaceHolder"> 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 MainPlaceHolder, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("TOC_ItemViewer.Add_Main_Viewer_Section", "");
            }

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

            // Save the current viewer code
            string current_view_code = CurrentMode.ViewerCode;

            // Start the citation table
            builder.AppendLine("\t\t<!-- TABLE OF CONTENTS VIEWER OUTPUT -->" );
            builder.AppendLine("\t\t<td align=\"left\"><span class=\"SobekViewerTitle\"><b>Table of Contents</b></span></td></tr>" );
            builder.AppendLine("\t\t<tr><td class=\"SobekDocumentDisplay\">");
            builder.AppendLine("\t\t\t<div class=\"SobekTOC\">");
            builder.AppendLine("\t\t\t\t<table cellpadding=\"5px\">");
            builder.AppendLine("\t\t\t\t\t<tr height=\"5\"> <td> </td> </tr>" );
            builder.AppendLine("\t\t\t\t\t<tr>" );
            builder.AppendLine("\t\t\t\t\t\t<td width=\"15\"> </td>" );
            builder.AppendLine("\t\t\t\t\t\t<td valign=\"top\">");

            builder.AppendLine("\t\t\t\t\t\t\t<b>" + CurrentItem.Bib_Info.Main_Title.Title + "</b><br />" );

            // Create the tree structure
               // ArrayList nodes = Create_Tree_From_DataTable(currentItem.Divisions);

            // Recursively build the result
            builder.AppendLine("\t\t\t\t\t\t\t<table>" + Environment.NewLine);
            //foreach ( TOC_TreeNode thisNode in nodes )
            //{
            //    Add_TOC_TreeNode_HTML( thisNode, builder, "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; " );
            //}
            builder.AppendLine("\t\t\t\t\t\t\t</table>" + Environment.NewLine);

            // Finish the citation table
            builder.AppendLine("\t\t\t\t\t\t</td>" );
            builder.AppendLine("\t\t\t\t\t\t<td width=\"15\"> </td>" );
            builder.AppendLine("\t\t\t\t\t</tr>");
            builder.AppendLine("\t\t\t\t\t<tr height=\"5\"> <td> </td> </tr>");
            builder.AppendLine("\t\t\t\t</table>");
            builder.AppendLine("\t\t\t</div>");
            builder.AppendLine("\t\t</td>");
            builder.AppendLine( "\t\t<!-- END TABLE OF CONTENTS VIEWER OUTPUT -->" );

            // Restore the mode
            CurrentMode.ViewerCode = current_view_code;

            // Add the HTML for the image
            Literal mainLiteral = new Literal {Text = builder.ToString()};
            MainPlaceHolder.Controls.Add( mainLiteral );
        }
        /// <summary> Constructor for a new instance of the Home_AdminViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Current_Mode">Mode / navigation information for the current request</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Home_AdminViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("Home_AdminViewer.Constructor", String.Empty);

            if ((User == null) || ((!User.Is_Portal_Admin) && (!User.Is_System_Admin)))
            {
                Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                HttpContext.Current.Response.Redirect(Current_Mode.Redirect_URL(), false);
            }
        }
        /// <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("PDF_ItemViewer.Add_Main_Viewer_Section", "Adds one literal with all the html");
            }

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

            // Save the current viewer code
            string current_view_code = CurrentMode.ViewerCode;

            // Find the PDF download
            string displayFileName = FileName;
            if (displayFileName.IndexOf("http") < 0)
            {
                displayFileName = CurrentItem.Web.Source_URL + "/" + displayFileName;
            }
            displayFileName = displayFileName.Replace("\\", "/").Replace("//", "/").Replace("http:/", "http://");

            // 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;

            // Start the citation table
            builder.AppendLine("\t\t<!-- PDF ITEM VIEWER OUTPUT -->" );
            builder.AppendLine("\t\t<td align=\"left\">" );
            builder.AppendLine("<table width=\"95%\"><tr>" );
            builder.AppendLine("<td align=\"left\"> &nbsp; &nbsp; <a href=\"" + displayFileName + "\">Download this PDF</a></td>");
            builder.AppendLine("<td align=\"right\"><a href=\"http://get.adobe.com/reader/\"><img src=\"" + CurrentMode.Base_URL + "default/images/get_adobe_reader.png\" /></a></td>" );
            builder.AppendLine("</tr></table>");
            builder.AppendLine("</td></tr>");
            builder.AppendLine("\t\t<tr><td>");

            if (CurrentMode.Text_Search.Length > 0)
            {
                displayFileName = displayFileName + "#search=&quot;" + CurrentMode.Text_Search.Replace("\"", "").Replace("+", " ").Replace("-", " ") + "&quot;";
            }

            builder.AppendLine("                  <embed src=\"" + displayFileName + "\" width=\"100%\" height=\"700px\" href=\"" + FileName + "\"></embed>");

            // Finish the table
            builder.AppendLine("\t\t</td>");
            builder.AppendLine("\t\t<!-- END PDF VIEWER OUTPUT -->" );

            // Restore the mode
            CurrentMode.ViewerCode = current_view_code;

            // Add the HTML for the image
            Literal mainLiteral = new Literal {Text = builder.ToString()};
            placeHolder.Controls.Add(mainLiteral);
        }
        /// <summary> Writes the style references and other data to the HEAD portion of the web page </summary>
        /// <param name="Output"> Stream to which to write the text for this main writer </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public void Add_Style_References(TextWriter Output, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Html_Echo_MainWriter.Add_Style_References", "Adding style references to HTML");

            Output.WriteLine("  <meta name=\"robots\" content=\"index, nofollow\">");
            Output.WriteLine("  <link href=\"" + currentMode.Base_URL + "default/SobekCM.css\" rel=\"stylesheet\" type=\"text/css\" title=\"standard\" />");

            // Include the interface's style sheet if it has one
            Output.WriteLine("  <style type=\"text/css\" media=\"screen\">");
            Output.WriteLine("    @import url( " + currentMode.Base_URL + "design/skins/" + currentMode.Base_Skin + "/" + currentMode.Base_Skin + ".css );");
            Output.WriteLine("  </style>");
        }
        /// <summary> Constructor for a new instance of the Home_AdminViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Current_Mode">Mode / navigation information for the current request</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Home_AdminViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("Home_AdminViewer.Constructor", String.Empty);

            if ((User == null) || ((!User.Is_Portal_Admin) && (!User.Is_System_Admin)))
            {
                Current_Mode.Mode = Display_Mode_Enum.My_Sobek;
                Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                currentMode.Redirect();
            }
        }
        /// <summary> Builds a digital resource object for the given BibID and VID </summary>
        /// <param name="BibID"> Bibliographic identifier for the digital resource to build </param>
        /// <param name="VID"> Volume identifier for the digital resource to builder </param>
        /// <param name="Icon_Dictionary"> Dictionary of information about every wordmark/icon in this digital library, used to build the HTML for the icons linked to this digital resource</param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <returns> Fully built digital resource object for a single volume </returns>
        /// <remarks> This method relies heavily upon the <see cref="SobekCM_METS_Based_ItemBuilder"/> class to actually
        /// read the METS files and build the items. </remarks>
        public static SobekCM_Item Get_Item(string BibID, string VID, Dictionary<string, Wordmark_Icon> Icon_Dictionary, List<string> Item_Viewer_Priority, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("SobekCM_Item_Factory.Get_Item", "Build this item");
            }

            // Get the METS based item builder
            SobekCM_METS_Based_ItemBuilder builder = new SobekCM_METS_Based_ItemBuilder();

            // Allow the builder to build the item
            return builder.Build_Item( BibID, VID, Icon_Dictionary, Item_Viewer_Priority, Tracer);
        }
        /// <summary> Adds controls to the main navigational page </summary>
        /// <param name="placeHolder"> Main place holder ( &quot;mainPlaceHolder&quot; ) in the itemNavForm form, widely used throughout the application</param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        /// <param name="populate_node_event"> Event is used to populate the a tree node without doing a full refresh of the page </param>
        /// <returns> Sorted tree with the results in hierarchical structure with volumes and issues under the titles </returns>
        /// <remarks> This uses a <see cref="PagedResults_HtmlSubwriter"/> instance to render the browse  </remarks>
        public void Add_Controls(PlaceHolder placeHolder, Custom_Tracer Tracer, TreeNodeEventHandler populate_node_event)
        {
            if ((pagedResults != null) && (resultsStatistics != null))
            {
                if (writeResult == null)
                {
                    Tracer.Add_Trace("Public_Folder_HtmlSubwriter.Add_Controls", "Building Result DataSet Writer");

                    writeResult = new PagedResults_HtmlSubwriter(resultsStatistics, pagedResults, codeManager, translations, allItemsTable, currentUser, currentMode, Tracer)
                                      {
                                          Hierarchy_Object = Hierarchy_Object,
                                          Skin = htmlSkin,
                                          Mode = currentMode,
                                          Browse_Title = publicFolder.FolderName,
                                          Folder_Owner_Name = publicFolder.Name,
                                          Folder_Owner_Email = publicFolder.Email
                                      };
                }

                Tracer.Add_Trace("Public_Folder_HtmlSubwriter.Add_Controls", "Add controls");
                writeResult.Add_Controls(placeHolder, Tracer);
            }
        }
        /// <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("Street_ItemViewer.Add_Main_Viewer_Section", "Adds one literal with all the html");
            }

            // Build the value
            StringBuilder builder = new StringBuilder(5000);
            Map_Streets_DataSet streets = SobekCM_Database.Get_All_Streets_By_Item(CurrentItem.Web.ItemID, Tracer);

            if (streets == null)
            {
                builder.AppendLine("<br />");
                builder.AppendLine("<center><b>UNABLE TO LOAD STREETS FROM DATABASE</b></center>");
                builder.AppendLine("<br />");
                CurrentMode.Mode = Display_Mode_Enum.Contact;
                builder.AppendLine("<center>Click <a href=\"" + CurrentMode.Redirect_URL() + "\">here</a> to report this issue.</center>");
                builder.AppendLine("<br />");
                CurrentMode.Mode = Display_Mode_Enum.Item_Display;
            }
            else
            {
                // Save the current viewer code
                string current_view_code = CurrentMode.ViewerCode;

                // Start the citation table
                builder.AppendLine("\t\t<!-- STREET VIEWER OUTPUT -->" );
                builder.AppendLine("\t\t<td align=\"left\" height=\"40px\" ><span class=\"SobekViewerTitle\"><b>Index of Streets</b></span></td></tr>" );
                builder.AppendLine("\t\t<tr><td class=\"SobekDocumentDisplay\">");
                builder.AppendLine("\t\t\t<div class=\"SobekCitation\">" );

                // Get the list of streets from the database
                Create_Street_Index(builder, streets);

                // Finish the citation table
                builder.AppendLine("\t\t\t</div>" );
                builder.AppendLine("\t\t</td>" );
                builder.AppendLine("\t\t<!-- END STREET VIEWER OUTPUT -->" );

                // Restore the mode
                CurrentMode.ViewerCode = current_view_code;
            }

            // Add the HTML for the image
            Literal mainLiteral = new Literal {Text = builder.ToString()};
            placeHolder.Controls.Add( mainLiteral );
        }
        /// <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("EmbeddedVideo_ItemViewer.Write_Main_Viewer_Section", "");
            }

            // Add the HTML for the image
            Output.WriteLine("          <td><div id=\"sbkEmv_ViewerTitle\">Streaming Video</div></td>");
            Output.WriteLine("        </tr>");
            Output.WriteLine("        <tr>");
            Output.WriteLine("          <td id=\"sbkEmv_MainArea\">");

            Output.WriteLine(CurrentItem.Behaviors.Embedded_Video);

            Output.WriteLine("          </td>");
        }
        /// <summary> This provides an opportunity for the viewer to perform any pre-display work
        /// which is necessary before entering any of the rendering portions </summary>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        /// <remarks> This method his class pulls any full-text search results for this single item from the Solr/Lucene engine </remarks>
        public override void Perform_PreDisplay_Work(Custom_Tracer Tracer)
        {
            if (CurrentMode.Text_Search.Length > 0)
            {
                List<string> terms = new List<string>();
                List<string> web_fields = new List<string>();

                // Split the terms correctly
                SobekCM_Assistant.Split_Clean_Search_Terms_Fields(CurrentMode.Text_Search, "ZZ", Search_Type_Enum.Basic, terms, web_fields, null, Search_Precision_Type_Enum.Contains, '|');

                Tracer.Add_Trace("Text_Search_Item_Viewer.Perform_PreDisplay_Work", "Performing Solr/Lucene search");

                results = Solr_Page_Results.Search(CurrentItem.BibID, CurrentItem.VID, terms, 20, CurrentMode.SubPage, false);

                Tracer.Add_Trace("Text_Search_Item_Viewer.Perform_PreDisplay_Work", "Completed Solr/Lucene search in " + results.QueryTime + "ms");
            }
        }
示例#31
0
 /// <summary> Add the HTML to be displayed in the main SobekCM viewer area </summary>
 /// <param name="Output"> Textwriter to write the HTML for this viewer</param>
 /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
 /// <remarks> This class does nothing, since the interface list is added as controls, not HTML </remarks>
 public override void Write_HTML(TextWriter Output, Custom_Tracer Tracer)
 {
     Tracer.Add_Trace("Default_Metadata_AdminViewer.Write_HTML", "Do nothing");
 }
        /// <summary> This is an opportunity to write HTML directly into the main form, without
        /// using the pop-up html form architecture </summary>
        /// <param name="Output"> Textwriter to write the pop-up form HTML for this viewer </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> This text will appear within the ItemNavForm form tags </remarks>
        public override void Write_ItemNavForm_Closing(TextWriter Output, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Skins_AdminViewer.Write_ItemNavForm_Closing", "Add any popup divisions for form elements");

            Output.WriteLine("<!-- Skins_AdminViewer.Write_ItemNavForm_Closing -->");
            Output.WriteLine("<script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/jquery/jquery-ui-1.10.3.custom.min.js\"></script>");

            // Add the hidden field
            Output.WriteLine("<!-- Hidden field is used for postbacks to indicate what to save and reset -->");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_interface_tosave\" name=\"admin_interface_tosave\" value=\"\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_interface_reset\" name=\"admin_interface_reset\" value=\"\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_interface_delete\" name=\"admin_interface_delete\" value=\"\" />");
            Output.WriteLine();

            Output.WriteLine("<!-- HTML Skins Edit Form -->");
            Output.WriteLine("<div class=\"sbkSav_PopupDiv\" id=\"form_interface\" style=\"display:none;\">");
            Output.WriteLine("  <div class=\"sbkAdm_PopupTitle\"><table style=\"width:100%;\"><tr><td style=\"text-align:left;\">EDIT WEB SKIN</td><td style=\"text-align:right;\"> <a href=\"#template\" alt=\"CLOSE\" onclick=\"interface_form_close()\">X</a> &nbsp; </td></tr></table></div>");
            Output.WriteLine("  <br />");
            Output.WriteLine("  <table class=\"sbkAdm_PopupTable\">");

            // Add line for interface code and base interface code
            Output.WriteLine("    <tr style=\"height:25px;\">");
            Output.WriteLine("      <td style=\"width:112px;\"><label for=\"form_interface_code\">Web Skin Code:</label></td>");
            Output.WriteLine("      <td style=\"width:220px;\"><span class=\"form_linkline admin_existing_code_line\" id=\"form_interface_code\"></span></td>");
            Output.WriteLine("      <td style=\"text-align:right;\"><label for=\"form_interface_basecode\">Base Skin Code:</label> &nbsp; <input class=\"sbkSav_small_input1 sbkAdmin_Focusable\" name=\"form_interface_basecode\" id=\"form_interface_basecode\" type=\"text\" value=\"\" /></td>");
            Output.WriteLine("    </tr>");

            // Add line for banner link
            Output.WriteLine("    <tr style=\"height:25px;\"><td><label for=\"form_interface_link\">Banner Link:</label></td><td colspan=\"2\"><input class=\"sbkSav_large_input sbkAdmin_Focusable\" name=\"form_interface_link\" id=\"form_interface_link\" type=\"text\" value=\"\" /></td></tr>");

            // Add line for notes
            Output.WriteLine("    <tr style=\"height:25px;\"><td><label for=\"form_interface_notes\">Notes:</label></td><td colspan=\"2\"><input class=\"sbkSav_large_input sbkAdmin_Focusable\" name=\"form_interface_notes\" id=\"form_interface_notes\" type=\"text\" value=\"\" /></td></tr>");

            // Add checkboxes for overriding the header/footer and overriding banner
            Output.WriteLine("          <tr style=\"height:15px;\"><td>Flags:</td><td><input class=\"sbkSav_checkbox\" type=\"checkbox\" name=\"form_interface_header_override\" id=\"form_interface_header_override\" checked=\"checked\" /> <label for=\"form_interface_header_override\">Override header and footer?</label></td><td><input class=\"sbkSav_checkbox\" type=\"checkbox\" name=\"form_interface_banner_override\" id=\"form_interface_banner_override\" /> <label for=\"form_interface_banner_override\">Override banner?</label></td></tr>");
            Output.WriteLine("          <tr style=\"height:15px;\"><td>&nbsp;</td><td><input class=\"sbkSav_checkbox\" type=\"checkbox\" name=\"form_interface_top_nav\" id=\"form_interface_top_nav\" /> <label for=\"form_interface_top_nav\">Suppress top-level navigation?</label></td><td><input class=\"sbkSav_checkbox\" type=\"checkbox\" name=\"form_interface_buildlaunch\" id=\"form_interface_buildlaunch\" /> <label for=\"form_interface_buildlaunch\">Build on launch?</label></td></tr>");


            // Add the buttons
            Output.WriteLine("    <tr style=\"height:35px; text-align: center; vertical-align: bottom;\">");
            Output.WriteLine("      <td colspan=\"3\">");
            Output.WriteLine("        <button title=\"Do not apply changes\" class=\"sbkAdm_RoundButton\" onclick=\"return interface_form_close();\"><img src=\"" + currentMode.Base_URL + "default/images/button_previous_arrow.png\" class=\"sbkAdm_RoundButton_LeftImg\" alt=\"\" /> CANCEL</button> &nbsp; &nbsp; ");
            Output.WriteLine("        <button title=\"Save changes to this existing web skin\" class=\"sbkAdm_RoundButton\" type=\"submit\">SAVE <img src=\"" + currentMode.Base_URL + "default/images/button_next_arrow.png\" class=\"sbkAdm_RoundButton_RightImg\" alt=\"\" /></button>");
            Output.WriteLine("      </td>");
            Output.WriteLine("    </tr>");
            Output.WriteLine("  </table>");
            Output.WriteLine("</div>");
            Output.WriteLine();

            Output.WriteLine("<script src=\"" + currentMode.Base_URL + "default/scripts/sobekcm_admin.js\" type=\"text/javascript\"></script>");
            Output.WriteLine("<div class=\"sbkAdm_HomeText\">");

            if (!String.IsNullOrEmpty(actionMessage))
            {
                Output.WriteLine("  <br />");
                Output.WriteLine("  <div id=\"sbkAdm_ActionMessage\">" + actionMessage + "</div>");
            }

            Output.WriteLine("  <p>For clarification of any terms on this form, <a href=\"" + SobekCM_Library_Settings.Help_URL(currentMode.Base_URL) + "adminhelp/webskins\" target=\"ADMIN_INTERFACE_HELP\" >click here to view the help page</a>.</p>");

            Output.WriteLine("  <h2>New Web Skin</h2>");
            Output.WriteLine("  <div class=\"sbkSav_NewDiv\">");
            Output.WriteLine("    <table class=\"sbkAdm_PopupTable\">");

            // Add line for interface code and base interface code
            Output.WriteLine("      <tr style=\"height:25px;\">");
            Output.WriteLine("        <td style=\"width:112px;\"><label for=\"admin_interface_code\">Web Skin Code:</label></td>");
            Output.WriteLine("        <td style=\"width:220px;\"><input class=\"sbkSav_small_input sbkAdmin_Focusable\" name=\"admin_interface_code\" id=\"admin_interface_code\" type=\"text\" value=\"\" /></td>");
            Output.WriteLine("        <td style=\"text-align:right;\"><label for=\"admin_interface_basecode\">Base Skin Code:</label> &nbsp; <input class=\"sbkSav_small_input2 sbkAdmin_Focusable\" name=\"admin_interface_basecode\" id=\"admin_interface_basecode\" type=\"text\" value=\"\" /></td>");
            Output.WriteLine("      </tr>");

            // Add line for banner link
            Output.WriteLine("      <tr style=\"height:25px;\"><td><label for=\"admin_interface_link\">Banner Link:</label></td><td colspan=\"2\"><input class=\"sbkSav_large_input sbkAdmin_Focusable\" name=\"admin_interface_link\" id=\"admin_interface_link\" type=\"text\" value=\"\" /></td></tr>");

            // Add line for notes
            Output.WriteLine("      <tr style=\"height:25px;\"><td><label for=\"admin_interface_notes\">Notes:</label></td><td colspan=\"2\"><input class=\"sbkSav_large_input sbkAdmin_Focusable\" name=\"admin_interface_notes\" id=\"admin_interface_notes\" type=\"text\" value=\"\" /></td></tr>");

            // Add checkboxes for overriding the header/footer and overriding banner
            Output.WriteLine("      <tr style=\"height:15px;\"><td>Flags:</td><td><input class=\"sbkSav_checkbox\" type=\"checkbox\" name=\"admin_interface_header_override\" id=\"admin_interface_header_override\" checked=\"checked\" /> <label for=\"admin_interface_header_override\">Override header and footer?</label></td><td><input class=\"sbkSav_checkbox\" type=\"checkbox\" name=\"admin_interface_banner_override\" id=\"admin_interface_banner_override\" /> <label for=\"admin_interface_banner_override\">Override banner?</label></td></tr>");
            Output.WriteLine("      <tr style=\"height:15px;\"><td>&nbsp;</td><td><input class=\"sbkSav_checkbox\" type=\"checkbox\" name=\"admin_interface_top_nav\" id=\"admin_interface_top_nav\" /> <label for=\"admin_interface_top_nav\">Suppress top-level navigation?</label></td><td><input class=\"sbkSav_checkbox\" type=\"checkbox\" name=\"admin_interface_buildlaunch\" id=\"admin_interface_buildlaunch\" /> <label for=\"admin_interface_buildlaunch\">Build on launch?</label></td></tr>");
            Output.WriteLine("      <tr style=\"height:15px;\"><td>&nbsp;</td><td colspan=\"2\"><input class=\"sbkSav_checkbox\" type=\"checkbox\" name=\"admin_interface_copycurrent\" id=\"admin_interface_copycurrent\" /> <label for=\"admin_interface_copycurrent\">Copy current files for this new web skin if folder does not exist?</label></td></tr>");

            // Add the SAVE button
            Output.WriteLine("      <tr style=\"height:30px; text-align: center;\"><td colspan=\"3\"><button title=\"Save new web skin\" class=\"sbkAdm_RoundButton\" onclick=\"return save_new_interface();\">SAVE <img src=\"" + currentMode.Base_URL + "default/images/button_next_arrow.png\" class=\"sbkAdm_RoundButton_RightImg\" alt=\"\" /></button></td></tr>");
            Output.WriteLine("    </table>");
            Output.WriteLine("  </div>");
            Output.WriteLine();
            Output.WriteLine("  <h2>Existing Web Skins</h2>");

            // Get the list of all aggregations
            Output.WriteLine("  <table class=\"sbkSav_Table sbkAdm_Table\">");
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <th class=\"sbkSav_TableHeader1\">ACTIONS</th>");
            Output.WriteLine("      <th class=\"sbkSav_TableHeader2\">CODE</th>");
            Output.WriteLine("      <th class=\"sbkSav_TableHeader3\">BASE</th>");
            Output.WriteLine("      <th class=\"sbkSav_TableHeader4\">NOTES</th>");
            Output.WriteLine("    </tr>");
            Output.WriteLine("    <tr><td class=\"sbkAdm_TableRule\" colspan=\"4\"></td></tr>");

            // Get the view URL
            string current_skin = currentMode.Skin;

            currentMode.Skin = "TESTSKINCODE";
            string view_url = currentMode.Redirect_URL();

            currentMode.Skin = current_skin;

            // Write the data for each interface
            foreach (DataRow thisRow in skinCollection.Skin_Table.Rows)
            {
                // Pull all these values
                string code           = thisRow["WebSkinCode"].ToString();
                string base_code      = thisRow["BaseInterface"].ToString();
                string notes          = thisRow["Notes"].ToString();
                bool   overrideHeader = Convert.ToBoolean(thisRow["OverrideHeaderFooter"]);
                bool   overrideBanner = Convert.ToBoolean(thisRow["OverrideBanner"]);
                bool   buildOnLaunch  = Convert.ToBoolean(thisRow["Build_On_Launch"]);
                bool   suppressTopNav = Convert.ToBoolean(thisRow["SuppressTopNavigation"]);
                string bannerLink     = thisRow["BannerLink"].ToString();

                // Build the action links
                Output.WriteLine("    <tr>");
                Output.Write("      <td class=\"sbkAdm_ActionLink\" >( ");
                Output.Write("<a title=\"Click to edit\" href=\"" + currentMode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return interface_form_popup('" + code + "','" + base_code + "','" + bannerLink + "','" + notes + "','" + overrideBanner + "','" + overrideHeader + "','" + suppressTopNav + "','" + buildOnLaunch + "');\">edit</a> | ");
                Output.Write("<a title=\"Click to view\" href=\"" + view_url.Replace("testskincode", code) + "\" >view</a> | ");
                Output.Write("<a title=\"Click to reset\" href=\"" + currentMode.Base_URL + "l/technical/javascriptrequired\" onclick=\"reset_interface('" + code + "');\">reset</a> | ");

                if (user.Is_System_Admin)
                {
                    Output.WriteLine("<a title=\"Click to delete this web skin\" href=\"" + currentMode.Base_URL + "l/technical/javascriptrequired\"  onclick=\"return delete_interface('" + code + "');\">delete</a> )</td>");
                }
                else
                {
                    Output.WriteLine("<a title=\"Only SYSTEM administrators can delete web skins\" href=\"" + currentMode.Base_URL + "l/technical/javascriptrequired\"  onclick=\"alert('Only SYSTEM administrators can delete web skins'); return false;\">delete</a> )</td>");
                }


                // Add the rest of the row with data
                Output.WriteLine("      <td>" + code + "</span></td>");
                Output.WriteLine("      <td>" + base_code + "</span></td>");
                Output.WriteLine("      <td>" + notes + "</span></td>");
                Output.WriteLine("    </tr>");
                Output.WriteLine("    <tr><td class=\"sbkAdm_TableRule\" colspan=\"4\"></td></tr>");
            }

            Output.WriteLine("  </table>");
            Output.WriteLine("  <br />");
            Output.WriteLine("</div>");
            Output.WriteLine();
        }
        /// <summary> Constructor for a new instance of the Skins_AdminViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="CurrentMode"> Mode / navigation information for the current request</param>
        /// <param name="Web_Skin_Collection"> Contains the collection of all the default skins and the data to create any additional skins on request</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> Postback from handling an edit or new html skin is handled here in the constructor </remarks>
        public Skins_AdminViewer(User_Object User, SobekCM_Navigation_Object CurrentMode, SobekCM_Skin_Collection Web_Skin_Collection, Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("Skins_AdminViewer.Constructor", String.Empty);

            // Save the mode and settings  here
            currentMode    = CurrentMode;
            skinCollection = Web_Skin_Collection;

            // Set action message to nothing to start
            actionMessage = String.Empty;

            // If the user cannot edit this, go back
            if ((!user.Is_System_Admin) && (!user.Is_Portal_Admin))
            {
                currentMode.Mode          = Display_Mode_Enum.My_Sobek;
                currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                currentMode.Redirect();
                return;
            }

            // If this is a postback, handle any events first
            if (currentMode.isPostBack)
            {
                try
                {
                    // Pull the standard values
                    NameValueCollection form = HttpContext.Current.Request.Form;

                    string reset_value        = form["admin_interface_reset"].ToLower();
                    string save_value         = form["admin_interface_tosave"].ToUpper().Trim();
                    string delete_value       = form["admin_interface_delete"].ToUpper().Trim();
                    string new_interface_code = form["admin_interface_code"].ToUpper().Trim();

                    // Was this a reset request?
                    if (reset_value.Length > 0)
                    {
                        Tracer.Add_Trace("Skins_AdminViewer.Constructor", "Reset html skin '" + reset_value + "'");

                        if (Web_Skin_Collection.Remove(reset_value))
                        {
                            actionMessage = "Removed skin <i>" + reset_value.ToUpper() + "</i> from the semi-permanent skin collection";
                        }
                        else
                        {
                            int values_cleared = Cached_Data_Manager.Remove_Skin(reset_value, Tracer);

                            if (values_cleared == 0)
                            {
                                actionMessage = "Html skin <i>" + reset_value.ToUpper() + "</i> was not in the application cache";
                            }
                            else
                            {
                                actionMessage = "Removed " + values_cleared + " values from the cache for <i>" + reset_value.ToUpper() + "</i>";
                            }
                        }
                    }
                    else if (delete_value.Length > 0)
                    {
                        if (user.Is_System_Admin)
                        {
                            Tracer.Add_Trace("Skins_AdminViewer.Constructor", "Delete skin '" + delete_value + "' from the database");

                            // Delete from the database
                            if (SobekCM_Database.Delete_Web_Skin(delete_value, false, Tracer))
                            {
                                // Set the deleted wordmark message
                                actionMessage = "Deleted web skin <i>" + delete_value + "</i>";

                                // Remove this web skin from the collection
                                SobekCM_Skin_Collection_Builder.Populate_Default_Skins(Web_Skin_Collection, Tracer);
                            }
                            else
                            {
                                // Report the error
                                if (SobekCM_Database.Last_Exception == null)
                                {
                                    actionMessage = "Unable to delete web skin <i>" + delete_value + "</i> since it is linked to an item, aggregation, or portal";
                                }
                                else
                                {
                                    actionMessage = "Unknown error while deleting web skin <i>" + delete_value + "</i>";
                                }
                            }
                        }
                    }
                    else
                    {
                        // Or.. was this a save request
                        if (save_value.Length > 0)
                        {
                            Tracer.Add_Trace("Skins_AdminViewer.Constructor", "Save html skin '" + save_value + "'");

                            bool   override_banner  = false;
                            bool   override_header  = false;
                            bool   build_on_launch  = false;
                            bool   suppress_top_nav = false;
                            bool   copycurrent      = false;
                            object temp_object;

                            // Was this to save a new interface (from the main page) or edit an existing (from the popup form)?
                            if (save_value == new_interface_code)
                            {
                                string new_base_code   = form["admin_interface_basecode"].ToUpper().Trim();
                                string new_banner_link = form["admin_interface_link"].Trim();
                                string new_notes       = form["admin_interface_notes"].Trim();

                                temp_object = form["admin_interface_banner_override"];
                                if (temp_object != null)
                                {
                                    override_banner = true;
                                }

                                temp_object = form["admin_interface_header_override"];
                                if (temp_object != null)
                                {
                                    override_header = true;
                                }

                                temp_object = form["admin_interface_buildlaunch"];
                                if (temp_object != null)
                                {
                                    build_on_launch = true;
                                }

                                temp_object = form["admin_interface_top_nav"];
                                if (temp_object != null)
                                {
                                    suppress_top_nav = true;
                                }

                                temp_object = form["admin_interface_copycurrent"];
                                if (temp_object != null)
                                {
                                    copycurrent = true;
                                }

                                // Save this new interface
                                if (SobekCM_Database.Save_Web_Skin(save_value, new_base_code, override_banner, override_header, new_banner_link, new_notes, build_on_launch, suppress_top_nav, Tracer))
                                {
                                    // Ensure a folder exists for this, otherwise create one
                                    try
                                    {
                                        string folder = SobekCM_Library_Settings.Base_Design_Location + "skins/" + save_value.ToLower();
                                        if (!Directory.Exists(folder))
                                        {
                                            // Create this directory and the necessary subdirectories
                                            Directory.CreateDirectory(folder);

                                            // Create a default stylesheet
                                            StreamWriter writer = new StreamWriter(folder + "\\" + save_value.ToLower() + ".css");
                                            writer.WriteLine("/*  Skin-specific stylesheet used to override values from the base stylesheets */");
                                            writer.WriteLine();
                                            writer.WriteLine();
                                            writer.Flush();
                                            writer.Close();

                                            // Create the html subdirectory
                                            Directory.CreateDirectory(folder + "/html");

                                            // Do the rest differently depending on whether we should copy the current files
                                            if (!copycurrent)
                                            {
                                                // Write the default header file
                                                writer = new StreamWriter(folder + "\\html\\header.html");
                                                writer.WriteLine("<div id=\"container-inner\">");
                                                writer.WriteLine();
                                                writer.WriteLine("<!-- Add the standard header buttons -->");
                                                writer.WriteLine("<div style=\"width: 100%; background-color: #eeeeee; color: Black; height:30px;\">");
                                                writer.WriteLine("<%BREADCRUMBS%>");
                                                writer.WriteLine("<div style=\"float: right\"><%MYSOBEK%></div>");
                                                writer.WriteLine("</div>");
                                                writer.WriteLine();
                                                writer.WriteLine("<%BANNER%>");
                                                writer.WriteLine();
                                                writer.WriteLine("<div id=\"pagecontainer\">");
                                                writer.WriteLine();
                                                writer.WriteLine("<!-- Blankets out the rest of the web form when a pop-up form is envoked -->");
                                                writer.WriteLine("<div id=\"blanket_outer\" style=\"display:none;\"></div>");
                                                writer.Flush();
                                                writer.Close();

                                                // Write the default header_item file
                                                writer = new StreamWriter(folder + "/html/header_item.html");
                                                writer.WriteLine("<!-- Blankets out the rest of the web form when a pop-up form is envoked -->");
                                                writer.WriteLine("<div id=\"blanket_outer\" style=\"display:none;\"></div>");
                                                writer.WriteLine();
                                                writer.WriteLine("<!-- Add the standard header buttons -->");
                                                writer.WriteLine("<div style=\"width: 100%; background-color: #eeeeee; color: Black; height:30px;\">");
                                                writer.WriteLine("<%BREADCRUMBS%>");
                                                writer.WriteLine("<div style=\"float: right\"><%MYSOBEK%></div>");
                                                writer.WriteLine("</div>");
                                                writer.WriteLine();
                                                writer.WriteLine("<%BANNER%>");
                                                writer.Flush();
                                                writer.Close();

                                                // Write the default footer file
                                                writer = new StreamWriter(folder + "/html/footer.html");
                                                writer.WriteLine("</div> <!-- END PAGE CONTAINER DIV -->");
                                                writer.WriteLine();
                                                writer.WriteLine("<!-- Add most the standard footer buttons -->");
                                                writer.WriteLine("<center>");
                                                writer.WriteLine("<a href=\"<%BASEURL%>contact<%?URLOPTS%>\">Contact Us</a> | ");
                                                writer.WriteLine("<a href=\"<%BASEURL%>preferences<%?URLOPTS%>\">Preferences</a> | ");
                                                writer.WriteLine("<a href=\"http://ufdc.ufl.edu/sobekcm\">Technical Aspects</a> | ");
                                                writer.WriteLine("<a href=\"<%BASEURL%>stats<%?URLOPTS%>\">Statistics</a> | ");
                                                writer.WriteLine("<a href=\"<%BASEURL%>internal<%?URLOPTS%>\">Internal</a> | ");
                                                writer.WriteLine("<a href=\"<%BASEURL%>admin<%?URLOPTS%>\">Admin</a>");
                                                writer.WriteLine("</center>");
                                                writer.WriteLine("<br />");
                                                writer.WriteLine("<br />");
                                                writer.WriteLine("<span style=\"color: Gray; font-size: 0.8em;\">");
                                                writer.WriteLine("To edit this footer or header, edit header.html or footer.html at:  " + folder + "\\html\\ <br />");
                                                writer.WriteLine("</span>");
                                                writer.WriteLine();
                                                writer.WriteLine("</div> <!-- END CONTAINER INNER -->");
                                                writer.Flush();
                                                writer.Close();

                                                // Write the default footer item file
                                                writer = new StreamWriter(folder + "/html/footer_item.html");
                                                writer.WriteLine("<!-- Add most the standard footer buttons -->");
                                                writer.WriteLine("<center>");
                                                writer.WriteLine("<a href=\"<%BASEURL%>contact<%?URLOPTS%>\">Contact Us</a> | ");
                                                writer.WriteLine("<a href=\"<%BASEURL%>preferences<%?URLOPTS%>\">Preferences</a> | ");
                                                writer.WriteLine("<a href=\"http://ufdc.ufl.edu/sobekcm\">Technical Aspects</a> | ");
                                                writer.WriteLine("<a href=\"<%BASEURL%>stats<%?URLOPTS%>\">Statistics</a> | ");
                                                writer.WriteLine("<a href=\"<%BASEURL%>internal<%?URLOPTS%>\">Internal</a> | ");
                                                writer.WriteLine("<a href=\"<%BASEURL%>admin<%?URLOPTS%>\">Admin</a>");
                                                writer.WriteLine("</center>");
                                                writer.WriteLine("<br />");
                                                writer.WriteLine("<br />");
                                                writer.WriteLine("<span style=\"color: Gray; font-size: 0.8em;\">");
                                                writer.WriteLine("To edit this footer or header, edit header.html or footer.html at:  " + folder + "\\html\\ <br />");
                                                writer.WriteLine("</span>");
                                                writer.Flush();
                                                writer.Close();
                                            }
                                            else
                                            {
                                                // Copy the web skin information over?
                                                string current_web_skin   = currentMode.Skin;
                                                string current_web_folder = SobekCM_Library_Settings.Base_Design_Location + "skins/" + current_web_skin;
                                                copy_entire_folder(current_web_folder, folder);
                                                //if (File.Exists(current_web_folder + "\\" + current_web_skin + ".css"))
                                                //{
                                                //    File.Copy(current_web_folder + "\\" + current_web_skin + ".css", folder + "\\" + new_interface_code + ".css", true );
                                                //}
                                                //if (File.Exists(current_web_folder + "\\html\\header.html"))
                                                //{
                                                //    File.Copy(current_web_folder + "\\html\\header.html", folder + "\\html\\header.html");
                                                //}
                                                //if (File.Exists(current_web_folder + "\\html\\header_item.html"))
                                                //{
                                                //    File.Copy(current_web_folder + "\\html\\header_item.html", folder + "\\html\\header_item.html");
                                                //}
                                                //if (File.Exists(current_web_folder + "\\html\\footer.html"))
                                                //{
                                                //    File.Copy(current_web_folder + "\\html\\footer.html", folder + "\\html\\footer.html");
                                                //}
                                                //if (File.Exists(current_web_folder + "\\html\\footer_item.html"))
                                                //{
                                                //    File.Copy(current_web_folder + "\\html\\footer_item.html", folder + "\\html\\footer_item.html");
                                                //}
                                                if (File.Exists(folder + "\\" + current_web_skin + ".css"))
                                                {
                                                    if (File.Exists(folder + "\\" + new_interface_code + ".css"))
                                                    {
                                                        File.Delete(folder + "\\" + new_interface_code + ".css");
                                                    }
                                                    File.Move(folder + "\\" + current_web_skin + ".css", folder + "\\" + new_interface_code + ".css");
                                                }
                                            }

                                            // Irregardless of the user's choice on whether to copy the current skin, if there is NO base skin
                                            // provided and the folder does not exist, then we'll copy over the base skin type of stuff, such
                                            // as buttons, tabs, etc...
                                            if (new_base_code.Length == 0)
                                            {
                                                // What is the current base skin folder then?
                                                string base_skin_folder = SobekCM_Library_Settings.Base_Design_Location + "skins/" + currentMode.Base_Skin;
                                                copy_entire_folder(base_skin_folder + "/buttons", folder + "/buttons");
                                                copy_entire_folder(base_skin_folder + "/tabs", folder + "/tabs");
                                                copy_entire_folder(base_skin_folder + "/zoom_controls", folder + "/zoom_controls");
                                            }
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        actionMessage = "Error creating some of the files for the new web skin";
                                    }

                                    // Reload the list of all skins from the database, to include this new skin
                                    lock (skinCollection)
                                    {
                                        SobekCM_Skin_Collection_Builder.Populate_Default_Skins(skinCollection, Tracer);
                                    }
                                    if (String.IsNullOrEmpty(actionMessage))
                                    {
                                        actionMessage = "Saved new html skin <i>" + save_value + "</i>";
                                    }
                                }
                                else
                                {
                                    actionMessage = "Unable to save new html skin <i>" + save_value + "</i>";
                                }

                                // Try to create the directory
                                try
                                {
                                    if (!Directory.Exists(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value))
                                    {
                                        Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value);
                                    }
                                    if (!Directory.Exists(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\html"))
                                    {
                                        Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\html");
                                    }
                                    if (new_base_code.Length == 0)
                                    {
                                        if (!Directory.Exists(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\buttons"))
                                        {
                                            Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\buttons");
                                        }
                                        if (!Directory.Exists(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\tabs"))
                                        {
                                            Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\tabs");
                                        }
                                        if (!Directory.Exists(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\zoom_controls"))
                                        {
                                            Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\zoom_controls");
                                        }
                                    }
                                }
                                catch (Exception)
                                {
                                    actionMessage = "Error creating all the necessary folders";
                                }
                            }
                            else
                            {
                                string edit_base_code   = form["form_interface_basecode"].ToUpper().Trim();
                                string edit_banner_link = form["form_interface_link"].Trim();
                                string edit_notes       = form["form_interface_notes"].Trim();

                                temp_object = form["form_interface_banner_override"];
                                if (temp_object != null)
                                {
                                    override_banner = true;
                                }

                                temp_object = form["form_interface_header_override"];
                                if (temp_object != null)
                                {
                                    override_header = true;
                                }

                                temp_object = form["form_interface_buildlaunch"];
                                if (temp_object != null)
                                {
                                    build_on_launch = true;
                                }

                                temp_object = form["form_interface_top_nav"];
                                if (temp_object != null)
                                {
                                    suppress_top_nav = true;
                                }

                                // Save this existing interface
                                if (SobekCM_Database.Save_Web_Skin(save_value, edit_base_code, override_banner, override_header, edit_banner_link, edit_notes, build_on_launch, suppress_top_nav, Tracer))
                                {
                                    lock (skinCollection)
                                    {
                                        SobekCM_Skin_Collection_Builder.Populate_Default_Skins(skinCollection, Tracer);
                                    }
                                    Cached_Data_Manager.Remove_Skin(save_value, Tracer);

                                    actionMessage = "Edited existing html skin <i>" + save_value + "</i>";
                                }
                                else
                                {
                                    actionMessage = "Unable to edit existing html skin <i>" + save_value + "</i>";
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    actionMessage = "Unknown error caught while handing your request.";
                }
            }
        }
        private void add_collection_usage_history(TextWriter Output, DataTable StatsCount, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Usage_Statistics_AggregationViewer.add_collection_history", "Rendering HTML");

            Output.WriteLine("<div class=\"SobekText\">");
            Output.WriteLine("<p>Usage history for this collection is displayed below. This history includes just the top-level views of the collection.</p>");

            currentMode.Info_Browse_Mode = "definitions";
            Output.WriteLine("<p>The <a href=\"" + currentMode.Redirect_URL() + "\">Definitions page</a> provides more details about the statistics and words used below.</p>");
            Output.WriteLine("</div>");
            Output.WriteLine("<center>");

            Output.WriteLine("  <table border=\"0px\" cellspacing=\"0px\" class=\"statsTable\">");
            Output.WriteLine("    <tr align=\"right\" bgcolor=\"#0022a7\" >");
            Output.WriteLine("      <th width=\"120px\" align=\"left\"><span style=\"color: White\">DATE</span></th>");
            Output.WriteLine("      <th width=\"90px\" align=\"right\"><span style=\"color: White\">TOTAL<br />VIEWS</span></th>");
            Output.WriteLine("      <th width=\"90px\" align=\"right\"><span style=\"color: White\">VISITS</span></th>");
            Output.WriteLine("      <th width=\"90px\" align=\"right\"><span style=\"color: White\">MAIN <br />PAGES</span></th>");
            Output.WriteLine("      <th width=\"90px\" align=\"right\"><span style=\"color: White\">BROWSES</span></th>");
            Output.WriteLine("      <th width=\"90px\" align=\"right\"><span style=\"color: White\">SEARCH<br />RESULTS</span></th>");
            Output.WriteLine("      <th width=\"90px\" align=\"right\"><span style=\"color: White\">TITLE<br />VIEWS</span></th>");
            Output.WriteLine("      <th width=\"90px\" align=\"right\"><span style=\"color: White\">ITEM<br />VIEWS</span></th>");
            Output.WriteLine("    </tr>");

            const int COLUMNS       = 8;
            string    lastYear      = String.Empty;
            int       hits          = 0;
            int       sessions      = 0;
            int       mainPages     = 0;
            int       browses       = 0;
            int       searchResults = 0;
            int       titleHits     = 0;
            int       itemHits      = 0;

            // Add the collection level information
            if (StatsCount != null)
            {
                foreach (DataRow thisRow in StatsCount.Rows)
                {
                    if (thisRow[0].ToString() != lastYear)
                    {
                        Output.WriteLine("    <tr><td bgcolor=\"#7d90d5\" colspan=\"" + COLUMNS + "\"><span style=\"color: White\"><b> " + thisRow[0] + " STATISTICS</b></span></td></tr>");
                        lastYear = thisRow[0].ToString();
                    }
                    else
                    {
                        Output.WriteLine("    <tr><td bgcolor=\"#e7e7e7\" colspan=\"" + COLUMNS + "\"></td></tr>");
                    }
                    Output.WriteLine("    <tr align=\"right\" >");
                    Output.WriteLine("      <td align=\"left\">" + Month_From_Int(Convert.ToInt32(thisRow[1])) + " " + thisRow[0] + "</td>");

                    hits += Convert.ToInt32(thisRow[2]);
                    Output.WriteLine("      <td>" + thisRow[2] + "</td>");

                    sessions += Convert.ToInt32(thisRow[3]);
                    Output.WriteLine("      <td>" + thisRow[3] + "</td>");

                    int thisRowMainPage = Convert.ToInt32(thisRow[4]) + Convert.ToInt32(thisRow[6]);
                    mainPages += thisRowMainPage;
                    Output.WriteLine("      <td>" + thisRowMainPage + "</td>");

                    browses += Convert.ToInt32(thisRow[5]);
                    Output.WriteLine("      <td>" + thisRow[5] + "</td>");

                    searchResults += Convert.ToInt32(thisRow[7]);
                    Output.WriteLine("      <td>" + thisRow[7] + "</td>");

                    if (thisRow[8] != DBNull.Value)
                    {
                        titleHits += Convert.ToInt32(thisRow[8]);
                        Output.WriteLine("      <td>" + thisRow[8] + "</td>");
                    }
                    else
                    {
                        Output.WriteLine("      <td>0</td>");
                    }
                    if (thisRow[9] != DBNull.Value)
                    {
                        itemHits += Convert.ToInt32(thisRow[9]);
                        Output.WriteLine("      <td>" + thisRow[9] + "</td>");
                    }
                    else
                    {
                        Output.WriteLine("      <td>0</td>");
                    }

                    Output.WriteLine("    </tr>");
                }
                Output.WriteLine("    <tr><td bgcolor=\"Black\" colspan=\"" + COLUMNS + "\"></td></tr>");
                Output.WriteLine("    <tr align=\"right\" >");
                Output.WriteLine("      <td align=\"left\"><b>TOTAL</b></td>");
                Output.WriteLine("      <td><b>" + hits + "</td>");
                Output.WriteLine("      <td><b>" + sessions + "</td>");
                Output.WriteLine("      <td><b>" + mainPages + "</td>");
                Output.WriteLine("      <td><b>" + browses + "</td>");
                Output.WriteLine("      <td><b>" + searchResults + "</td>");
                Output.WriteLine("      <td><b>" + titleHits + "</td>");
                Output.WriteLine("      <td><b>" + itemHits + "</td>");
                Output.WriteLine("    </tr>");
                Output.WriteLine("  </table>");
            }

            Output.WriteLine("  <br /> <br />");
            Output.WriteLine("</center>");
        }
        private void add_item_usage_history(TextWriter Output, DataTable StatsCount, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Usage_Statistics_AggregationViewer.add_collection_history", "Rendering HTML");

            Output.WriteLine("<div class=\"SobekText\">");
            Output.WriteLine("<p>Usage history for the items within this collection are displayed below.</p>");

            currentMode.Info_Browse_Mode = "definitions";
            Output.WriteLine("<p>The <a href=\"" + currentMode.Redirect_URL() + "\">Definitions page</a> provides more details about the statistics and words used below.</p>");
            Output.WriteLine("</div>");
            Output.WriteLine("<center>");


            int jpegViews       = 0;
            int zoomViews       = 0;
            int thumbViews      = 0;
            int flashViews      = 0;
            int googleMapViews  = 0;
            int downloadViews   = 0;
            int citationViews   = 0;
            int textSearchViews = 0;
            int staticViews     = 0;

            Output.WriteLine("  <table border=\"0px\" cellspacing=\"0px\" class=\"statsTable\">");
            Output.WriteLine("    <tr align=\"right\" bgcolor=\"#0022a7\" >");
            Output.WriteLine("      <th width=\"120px\" align=\"left\"><span style=\"color: White\">DATE</span></th>");
            Output.WriteLine("      <th width=\"90px\" align=\"right\"><span style=\"color: White\">JPEG<br />VIEWS</span></th>");
            Output.WriteLine("      <th width=\"90px\" align=\"right\"><span style=\"color: White\">ZOOMABLE<br />VIEWS</span></th>");
            Output.WriteLine("      <th width=\"90px\" align=\"right\"><span style=\"color: White\">CITATION<br />VIEWS</span></th>");
            Output.WriteLine("      <th width=\"90px\" align=\"right\"><span style=\"color: White\">THUMBNAIL<br />VIEWS</span></th>");
            Output.WriteLine("      <th width=\"90px\" align=\"right\"><span style=\"color: White\">TEXT<br />SEARCHES</span></th>");
            Output.WriteLine("      <th width=\"90px\" align=\"right\"><span style=\"color: White\">FLASH<br />VIEWS</span></th>");
            Output.WriteLine("      <th width=\"90px\" align=\"right\"><span style=\"color: White\">MAP<br />VIEWS</span></th>");
            Output.WriteLine("      <th width=\"90px\" align=\"right\"><span style=\"color: White\">DOWNLOAD<br />VIEWS</span></th>");
            Output.WriteLine("      <th width=\"90px\" align=\"right\"><span style=\"color: White\">STATIC<br />VIEWS</span></th>");
            Output.WriteLine("    </tr>");

            const int COLUMNS  = 10;
            string    lastYear = String.Empty;

            if (StatsCount != null)
            {
                foreach (DataRow thisRow in StatsCount.Rows)
                {
                    if (thisRow[0].ToString() != lastYear)
                    {
                        Output.WriteLine("    <tr><td bgcolor=\"#7d90d5\" colspan=\"" + COLUMNS + "\"><span style=\"color: White\"><b> " + thisRow[0] + " STATISTICS</b></span></td></tr>");
                        lastYear = thisRow[0].ToString();
                    }
                    else
                    {
                        Output.WriteLine("    <tr><td bgcolor=\"#e7e7e7\" colspan=\"" + COLUMNS + "\"></td></tr>");
                    }
                    Output.WriteLine("    <tr align=\"right\" >");
                    Output.WriteLine("      <td align=\"left\">" + Month_From_Int(Convert.ToInt32(thisRow[1])) + " " + thisRow[0] + "</td>");

                    if (thisRow[10] != DBNull.Value)
                    {
                        jpegViews += Convert.ToInt32(thisRow[10]);
                        Output.WriteLine("      <td>" + thisRow[10] + "</td>");
                    }
                    else
                    {
                        Output.WriteLine("      <td>0</td>");
                    }
                    if (thisRow[11] != DBNull.Value)
                    {
                        zoomViews += Convert.ToInt32(thisRow[11]);
                        Output.WriteLine("      <td>" + thisRow[11] + "</td>");
                    }
                    else
                    {
                        Output.WriteLine("      <td>0</td>");
                    }
                    if (thisRow[12] != DBNull.Value)
                    {
                        citationViews += Convert.ToInt32(thisRow[12]);
                        Output.WriteLine("      <td>" + thisRow[12] + "</td>");
                    }
                    else
                    {
                        Output.WriteLine("      <td>0</td>");
                    }
                    if (thisRow[13] != DBNull.Value)
                    {
                        thumbViews += Convert.ToInt32(thisRow[13]);
                        Output.WriteLine("      <td>" + thisRow[13] + "</td>");
                    }
                    else
                    {
                        Output.WriteLine("      <td>0</td>");
                    }
                    if (thisRow[14] != DBNull.Value)
                    {
                        textSearchViews += Convert.ToInt32(thisRow[14]);
                        Output.WriteLine("      <td>" + thisRow[14] + "</td>");
                    }
                    else
                    {
                        Output.WriteLine("      <td>0</td>");
                    }
                    if (thisRow[15] != DBNull.Value)
                    {
                        flashViews += Convert.ToInt32(thisRow[15]);
                        Output.WriteLine("      <td>" + thisRow[15] + "</td>");
                    }
                    else
                    {
                        Output.WriteLine("      <td>0</td>");
                    }
                    if (thisRow[16] != DBNull.Value)
                    {
                        googleMapViews += Convert.ToInt32(thisRow[16]);
                        Output.WriteLine("      <td>" + thisRow[16] + "</td>");
                    }
                    else
                    {
                        Output.WriteLine("      <td>0</td>");
                    }
                    if (thisRow[17] != DBNull.Value)
                    {
                        downloadViews += Convert.ToInt32(thisRow[17]);
                        Output.WriteLine("      <td>" + thisRow[17] + "</td>");
                    }
                    else
                    {
                        Output.WriteLine("      <td>0</td>");
                    }
                    if (thisRow[18] != DBNull.Value)
                    {
                        staticViews += Convert.ToInt32(thisRow[18]);
                        Output.WriteLine("      <td>" + thisRow[18] + "</td>");
                    }
                    else
                    {
                        Output.WriteLine("      <td>0</td>");
                    }
                    Output.WriteLine("    </tr>");
                }

                Output.WriteLine("    <tr><td bgcolor=\"Black\" colspan=\"" + COLUMNS + "\"></td></tr>");
                Output.WriteLine("    <tr align=\"right\" >");
                Output.WriteLine("      <td align=\"left\"><b>TOTAL</b></td>");
                Output.WriteLine("      <td><b>" + jpegViews + "</td>");
                Output.WriteLine("      <td><b>" + zoomViews + "</td>");
                Output.WriteLine("      <td><b>" + citationViews + "</td>");
                Output.WriteLine("      <td><b>" + thumbViews + "</td>");
                Output.WriteLine("      <td><b>" + textSearchViews + "</td>");
                Output.WriteLine("      <td><b>" + flashViews + "</td>");
                Output.WriteLine("      <td><b>" + googleMapViews + "</td>");
                Output.WriteLine("      <td><b>" + downloadViews + "</td>");
                Output.WriteLine("      <td><b>" + staticViews + "</td>");
                Output.WriteLine("    </tr>");
                Output.WriteLine("  </table>");
            }
            Output.WriteLine("  <br /> <br />");
            Output.WriteLine("</center>");
        }
        /// <summary> Constructor for a new instance of the Aliases_AdminViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="currentMode"> Mode / navigation information for the current request</param>
        /// <param name="IP_Restrictions"> List of all IP restrictions ranges used in this digital library to restrict access to certain digital resources </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> Postback from handling an edit or new item aggregation alias is handled here in the constructor </remarks>
        public IP_Restrictions_AdminViewer(User_Object User, SobekCM_Navigation_Object currentMode, IP_Restriction_Ranges IP_Restrictions, Custom_Tracer Tracer) : base(User)
        {
            Tracer.Add_Trace("IP_Restrictions_AdminViewer.Constructor", String.Empty);

            ipRestrictionInfo = IP_Restrictions;
            this.currentMode  = currentMode;

            // Ensure the user is the system admin
            if ((User == null) || (!User.Is_System_Admin))
            {
                currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                HttpContext.Current.Response.Redirect(currentMode.Redirect_URL(), false);
            }

            // Determine if there is an specific IP address range for editing
            index = -1;
            if (currentMode.My_Sobek_SubMode.Length > 0)
            {
                if (!Int32.TryParse(currentMode.My_Sobek_SubMode, out index))
                {
                    index = -1;
                }
            }

            // If there was an index included, try to pull the information about it
            thisRange = null;
            details   = null;
            if ((index >= 1) && (index <= ipRestrictionInfo.Count))
            {
                thisRange = ipRestrictionInfo[index - 1];
                if (thisRange != null)
                {
                    details = SobekCM_Database.Get_IP_Restriction_Range_Details(thisRange.RangeID, Tracer);
                }
            }

            if ((currentMode.isPostBack) && (details != null) && (thisRange != null))
            {
                try
                {
                    // Get a reference to this form
                    NameValueCollection form = HttpContext.Current.Request.Form;

                    // Pull the main values
                    string title   = form["admin_title"].Trim();
                    string notes   = form["admin_notes"].Trim();
                    string message = form["admin_message"].Trim();

                    if (title.Length == 0)
                    {
                        title = thisRange.Title;
                    }

                    // Edit the main values in the database
                    SobekCM_Database.Edit_IP_Range(thisRange.RangeID, title, notes, message, Tracer);
                    thisRange.Title = title;
                    thisRange.Notes = notes;
                    thisRange.Item_Restricted_Statement = message;

                    // Now check each individual IP address range
                    string[] getKeys         = form.AllKeys;
                    int      single_ip_index = 0;
                    foreach (string thisKey in getKeys)
                    {
                        // Is this for a new ip address?
                        if (thisKey.IndexOf("admin_ipstart_") == 0)
                        {
                            // Get the basic information for this single ip address
                            string ip_index    = thisKey.Replace("admin_ipstart_", "");
                            string thisIpStart = form["admin_ipstart_" + ip_index].Trim();
                            string thisIpEnd   = form["admin_ipend_" + ip_index].Trim();
                            string thisIpNote  = form["admin_iplabel_" + ip_index].Trim();

                            // Does this match an existing IP range?
                            if ((ip_index.IndexOf("new") < 0) && (single_ip_index < details.Tables[1].Rows.Count))
                            {
                                // Get the pre-existing IP row
                                DataRow ipRow      = details.Tables[1].Rows[single_ip_index];
                                int     singleIpId = Convert.ToInt32(ipRow[0]);
                                if (thisIpStart.Length == 0)
                                {
                                    SobekCM_Database.Delete_Single_IP(singleIpId, Tracer);
                                }
                                else
                                {
                                    // Is this the same?
                                    if ((thisIpStart != ipRow[1].ToString().Trim()) || (thisIpEnd != ipRow[2].ToString().Trim()) || (thisIpNote != ipRow[3].ToString().Trim()))
                                    {
                                        int edit_point_count = thisIpStart.Count(thisChar => thisChar == '.');

                                        if (edit_point_count == 3)
                                        {
                                            SobekCM_Database.Edit_Single_IP(singleIpId, thisRange.RangeID, thisIpStart, thisIpEnd, thisIpNote, Tracer);
                                        }
                                    }
                                }

                                // Be ready to look at the next pre-existing IP range
                                single_ip_index++;
                            }
                            else
                            {
                                // Just add this as a new single ip address
                                if (thisIpStart.Length > 0)
                                {
                                    int add_point_count = thisIpStart.Count(thisChar => thisChar == '.');

                                    if (add_point_count == 3)
                                    {
                                        SobekCM_Database.Edit_Single_IP(-1, thisRange.RangeID, thisIpStart, thisIpEnd, thisIpNote, Tracer);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    // Some error caught while handling postback
                }

                // Repopulate the restriction table
                DataTable ipRestrictionTbl = SobekCM_Database.Get_IP_Restriction_Ranges(Tracer);
                if (ipRestrictionTbl != null)
                {
                    IP_Restrictions.Populate_IP_Ranges(ipRestrictionTbl);
                }

                // Forward back to the main form
                currentMode.My_Sobek_SubMode = String.Empty;
                HttpContext.Current.Response.Redirect(currentMode.Redirect_URL());
            }
        }
        /// <summary> Add the HTML to be displayed </summary>
        /// <param name="Output"> Textwriter to write the HTML for this viewer </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public override void Add_HTML(TextWriter Output, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("Work_History_WebContentViewer.Add_HTML", "No html added");
            }

            Output.WriteLine("<div class=\"Wchs_Text\">");
            Output.WriteLine("  <p>The list of changes, including the user that performed the change, appear below.</p>");
            Output.WriteLine("</div>");

            // Get the stats
            int webcontentid = -1;

            if (RequestSpecificValues.Current_Mode.WebContentID.HasValue)
            {
                webcontentid = RequestSpecificValues.Current_Mode.WebContentID.Value;
            }

            Single_WebContent_Change_Report stats;

            try
            {
                stats = SobekEngineClient.WebContent.Get_Single_Milestones(webcontentid, Tracer);
            }
            catch (Exception ee)
            {
                Output.WriteLine("<div id=\"apiExceptionMsg\">Exception caught: " + ee.Message + "</div>");
                return;
            }


            // If no stats, show a message for that
            if ((stats == null) || (stats.Changes == null) || (stats.Changes.Count == 0))
            {
                Output.WriteLine("<div id=\"sbkWchs_NoDataMsg\">No change history</div>");
                return;
            }

            Output.WriteLine("  <br />");
            Output.WriteLine("  <table class=\"sbkStatsTbl\" style=\"width: 500px; margin-left:auto; margin-right: auto;\">");
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <th style=\"text-align:left;\">DATE</th>");
            Output.WriteLine("      <th>USER</th>");
            Output.WriteLine("      <th>CHANGE</th>");
            Output.WriteLine("    </tr>");


            // Add the usage data rows
            foreach (Milestone_Entry change in stats.Changes)
            {
                // Add the data row
                Output.WriteLine("    <tr>");
                Output.WriteLine("      <td style=\"text-align:left;\">" + change.MilestoneDate + "</td>");
                Output.WriteLine("      <td>" + change.User + "</td>");
                Output.WriteLine("      <td>" + change.Notes + "</td>");
                Output.WriteLine("    </tr>");
            }
            Output.WriteLine("  </table>");

            Output.WriteLine("  <br /> <br />");
        }
示例#38
0
        /// <summary> Write the item viewer main section as HTML directly to the HTTP output stream </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 void Write_Main_Viewer_Section(TextWriter Output, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("Related_Images_ItemViewer.Write_Main_Viewer_Section", "");
            }

            int images_per_page    = thumbnailsPerPage;
            int size_of_thumbnails = thumbnailSize;

            // Save the current viewer code
            string current_view_code = currentRequest.ViewerCode;
            ushort current_view_page = currentRequest.Page.HasValue ? currentRequest.Page.Value : ((ushort)1);

            // Start the citation table
            Output.WriteLine("\t\t<td>");
            Output.WriteLine("\t\t<!-- RELATED IMAGES VIEWER OUTPUT -->");

            // Start the main div for the thumbnails

            ushort page = (ushort)(currentRequest.Page - 1);

            if (page > (pageCount - 1) / images_per_page)
            {
                page = (ushort)((pageCount - 1) / images_per_page);
            }

            //Outer div which contains all the thumbnails
            Output.WriteLine("<div style=\"margin:5px;text-align:center;\">");

            // Get any search terms for highlighting purposes
            List <string> terms = new List <string>();

            if (!String.IsNullOrWhiteSpace(currentRequest.Text_Search))
            {
                string[] splitter = currentRequest.Text_Search.Replace("\"", "").Split(" ".ToCharArray());
                terms.AddRange(from thisSplit in splitter where thisSplit.Trim().Length > 0 select thisSplit.Trim());
            }


            // Step through each page in the item
            for (int page_index = page * images_per_page; (page_index < (page + 1) * images_per_page) && (page_index < pageCount); page_index++)
            {
                // Get this page
                BriefItem_FileGrouping thisPage = briefItem.Images[page_index];

                // Find the jpeg and thumbnail images
                string jpeg      = String.Empty;
                string thumbnail = String.Empty;

                foreach (BriefItem_File thisFile in thisPage.Files)
                {
                    if (String.Compare(thisFile.File_Extension, ".jpg", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        if (thisFile.Name.ToLower().IndexOf("thm.jpg") > 0)
                        {
                            thumbnail = thisFile.Name;
                        }
                        else
                        {
                            jpeg = thisFile.Name;
                        }
                    }
                }

                // If the thumbnail is not in the METS, just guess its existence
                if (thumbnail.Length == 0)
                {
                    thumbnail = jpeg.ToLower().Replace(".jpg", "thm.jpg");
                }

                // Get the image URL
                currentRequest.Page       = (ushort)(page_index + 1);
                currentRequest.ViewerCode = (page_index + 1).ToString();
                string url = UrlWriterHelper.Redirect_URL(currentRequest);

                // Determine the width information and the URL for the image
                string image_url; // = (briefItem.Web.Source_URL + "/" + thumbnail).Replace("\\", "/").Replace("//", "/").Replace("http:/", "http://");
                int    width = -1;
                switch (size_of_thumbnails)
                {
                case 2:
                    image_url = (briefItem.Web.Source_URL + "/" + jpeg).Replace("\\", "/").Replace("//", "/").Replace("http:/", "http://").Replace("https:/", "https://");
                    width     = 315;
                    break;

                case 3:
                    image_url = (briefItem.Web.Source_URL + "/" + jpeg).Replace("\\", "/").Replace("//", "/").Replace("http:/", "http://").Replace("https:/", "https://");
                    width     = 472;
                    break;

                case 4:
                    image_url = (briefItem.Web.Source_URL + "/" + jpeg).Replace("\\", "/").Replace("//", "/").Replace("http:/", "http://").Replace("https:/", "https://");
                    break;

                default:
                    image_url = (briefItem.Web.Source_URL + "/" + thumbnail).Replace("\\", "/").Replace("//", "/").Replace("http:/", "http://").Replace("https:/", "https://");
                    width     = 150;
                    break;
                }

                if (width > 0)
                {
                    Output.WriteLine("  <table class=\"sbkRi_Thumbnail\" id=\"span" + page_index + "\" style=\"width:" + (width + 15) + "px\">");
                }
                else
                {
                    Output.WriteLine("  <table class=\"sbkRi_Thumbnail\" id=\"span" + page_index + "\">");
                }

                Output.WriteLine("    <tr>");
                Output.WriteLine("      <td>");
                Output.WriteLine("        <a id=\"" + page_index + "\" href=\"" + url + "\" title=\"" + thisPage.Label + "\">");
                if (width > 0)
                {
                    Output.WriteLine("          <img src=\"" + image_url + "\" style=\"width:" + width + "px;\" alt=\"MISSING THUMBNAIL\" />");
                }
                else
                {
                    Output.WriteLine("          <img src=\"" + image_url + "\" alt=\"MISSING THUMBNAIL\" />");
                }
                Output.WriteLine("        </a>");
                Output.WriteLine("      </td>");
                Output.WriteLine("    </tr>");
                Output.WriteLine("    <tr>");
                Output.WriteLine("      <td style=\"text-align:center\">" + Text_Search_Term_Highlighter.Hightlight_Term_In_HTML(thisPage.Label, terms, "<span class=\"sbkRi_TextHighlight\">", "</span>") + "</td>");
                Output.WriteLine("    </tr>");
                Output.WriteLine("  </table>");
                Output.WriteLine();
            }

            //Close the outer div
            Output.WriteLine("</div>");

            // Restore the mode
            currentRequest.ViewerCode = current_view_code;
            currentRequest.Page       = current_view_page;

            Output.WriteLine("<script type=\"text/javascript\"> WindowResizeActions();</script>");

            // Finish the citation table
            Output.WriteLine("\t\t</td>");
            Output.WriteLine("\t\t<!-- END RELATED IMAGES VIEWER OUTPUT -->");
        }
示例#39
0
        /// <summary> Perform an search for documents with matching parameters </summary>
        /// <param name="AggregationCode"> Aggregation code within which to search </param>
        /// <param name="QueryString"> Quert string for the actual search to perform aggainst the Solr/Lucene engine </param>
        /// <param name="ResultsPerPage"> Number of results to display per a "page" of results </param>
        /// <param name="Page_Number"> Which page of results to return ( one-based, so the first page is page number of one )</param>
        /// <param name="Sort"> Sort to apply before returning the results of the search </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        /// <param name="Complete_Result_Set_Info"> [OUT] Information about the entire set of results </param>
        /// <param name="Paged_Results"> [OUT] List of search results for the requested page of results </param>
        /// <returns> Page search result object with all relevant result information </returns>
        public static bool Search(string AggregationCode, string QueryString, int ResultsPerPage, int Page_Number, ushort Sort, Custom_Tracer Tracer, out Search_Results_Statistics Complete_Result_Set_Info, out List <iSearch_Title_Result> Paged_Results)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("Solr_Documents_Searcher.Search", String.Empty);
            }

            // Set output initially to null
            Paged_Results            = new List <iSearch_Title_Result>();
            Complete_Result_Set_Info = null;

            try
            {
                // Ensure page is not erroneously set to zero or negative
                if (Page_Number <= 0)
                {
                    Page_Number = 1;
                }

                // Create the solr worker to query the document index
                var solrWorker = Solr_Operations_Cache <Solr_Document_Result> .GetSolrOperations(SobekCM_Library_Settings.Document_Solr_Index_URL);

                // Create the query options
                QueryOptions options = new QueryOptions
                {
                    Rows      = ResultsPerPage,
                    Start     = (Page_Number - 1) * ResultsPerPage,
                    Fields    = new[] { "did", "score", "url", "aleph", "donor", "edition", "format", "holdinglocation", "sourceinstitution", "maintitle", "materialtype", "oclc", "pubdate_display", "author_display", "publisher_display", "mainthumbnail" },
                    Highlight = new HighlightingParameters {
                        Fields = new[] { "fulltext" },
                    },
                    ExtraParams = new Dictionary <string, string> {
                        { "hl.useFastVectorHighlighter", "true" }
                    }
                };

                // Set the sort value
                if (Sort != 0)
                {
                    options.OrderBy.Clear();
                    switch (Sort)
                    {
                    case 1:
                        options.OrderBy.Add(new SortOrder("maintitle_sort"));
                        break;

                    case 2:
                        options.OrderBy.Add(new SortOrder("bibid", Order.ASC));
                        break;

                    case 3:
                        options.OrderBy.Add(new SortOrder("bibid", Order.DESC));
                        break;

                    case 10:
                        options.OrderBy.Add(new SortOrder("pubdate", Order.ASC));
                        break;

                    case 11:
                        options.OrderBy.Add(new SortOrder("pubdate", Order.DESC));
                        break;
                    }
                }

                // If there was an aggregation code included, put that at the beginning of the search
                if ((AggregationCode.Length > 0) && (AggregationCode.ToUpper() != "ALL"))
                {
                    QueryString = "(aggregation_code:" + AggregationCode.ToUpper() + ")AND(" + QueryString + ")";
                }

                // Perform this search
                SolrQueryResults <Solr_Document_Result> results = solrWorker.Query(QueryString, options);

                // Create the search statistcs
                List <string> metadataLabels = new List <string> {
                    "Author", "Publisher", "Format", "Edition", "Institution", "Donor"
                };

                Complete_Result_Set_Info = new Search_Results_Statistics(metadataLabels)
                {
                    Total_Titles = results.NumFound,
                    Total_Items  = results.NumFound,
                    QueryTime    = results.Header.QTime
                };

                // Pass all the results into the List and add the highlighted text to each result as well
                foreach (Solr_Document_Result thisResult in results)
                {
                    // Add the highlight snipper
                    if ((results.Highlights.ContainsKey(thisResult.DID)) && (results.Highlights[thisResult.DID].Count > 0) && (results.Highlights[thisResult.DID].ElementAt(0).Value.Count > 0))
                    {
                        thisResult.Snippet = results.Highlights[thisResult.DID].ElementAt(0).Value.ElementAt(0);
                    }

                    // Add this results
                    Paged_Results.Add(thisResult);
                }

                return(true);
            }
            catch (Exception ee)
            {
                return(false);
            }
        }
示例#40
0
        /// <summary> Add controls directly to the form, either to the main control area or to the file upload placeholder </summary>
        /// <param name="placeHolder"> Main place holder to which all main controls are added </param>
        /// <param name="uploadFilesPlaceHolder"> Place holder is used for uploading file </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        ///  <remarks> No controls are added here, although some children class override this virtual method to add controls </remarks>
        public override void Add_Controls(PlaceHolder placeHolder, PlaceHolder uploadFilesPlaceHolder, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Logon_MySobekViewer.Add_Controls", String.Empty);
            StringBuilder literalBuilder = new StringBuilder();

            // Get ready to draw the tabs
            string sobek_home = currentMode.SobekCM_Instance_Abbreviation.ToUpper() + " HOME";
            string my_sobek   = "my" + currentMode.SobekCM_Instance_Abbreviation;

            literalBuilder.AppendLine("<div class=\"ViewsBrowsesRow\">");
            literalBuilder.AppendLine("");

            // Write the Sobek home tab
            currentMode.Mode = Display_Mode_Enum.Aggregation_Home;
            literalBuilder.AppendLine("  <a href=\"" + currentMode.Redirect_URL() + "\">" + Unselected_Tab_Start + sobek_home + Unselected_Tab_End + "</a>");
            currentMode.Mode = Display_Mode_Enum.My_Sobek;
            literalBuilder.AppendLine("");
            literalBuilder.AppendLine("</div>");
            literalBuilder.AppendLine();

            literalBuilder.AppendLine("<div class=\"SobekSearchPanel\">");
            literalBuilder.AppendLine("  <h1>Logon to " + my_sobek + "</h1>");
            literalBuilder.AppendLine("</div>");
            literalBuilder.AppendLine();

            literalBuilder.AppendLine("<script src=\"" + currentMode.Base_URL + "default/scripts/sobekcm_metadata.js\" type=\"text/javascript\"></script>");
            literalBuilder.AppendLine("<div class=\"SobekHomeText\" >");
            literalBuilder.AppendLine("<br />");
            literalBuilder.AppendLine("<blockquote>");
            literalBuilder.AppendLine("The feature you are trying to access requires a valid logon.<br /><br />Please choose the appropriate logon directly below.  <br /><br />");
            literalBuilder.AppendLine("<ul>");
            if (currentMode.SobekCM_Instance_Abbreviation == "dLOC")
            {
                literalBuilder.AppendLine("<li><b>If you have a valid myDLOC logon</b>, <a id=\"form_logon_term\" href=\"" + currentMode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return popup_focus('form_logon', 'form_logon_term', 'logon_username', 280, 400 );\">Sign on with myDLOC authentication</a>.<br /><br /></li>");

                if ((SobekCM_Library_Settings.Shibboleth_System_URL.Length > 0) && (SobekCM_Library_Settings.Shibboleth_System_Name.Length > 0))
                {
                    literalBuilder.AppendLine("<li><b>If you have a valid " + SobekCM_Library_Settings.Shibboleth_System_Name + " ID</b>, <a href=\"" + SobekCM_Library_Settings.Shibboleth_System_URL + "\">Sign on with your " + SobekCM_Library_Settings.Shibboleth_System_Name + " here</a>.<br /><br /></li>");
                }
            }
            else
            {
                if ((SobekCM_Library_Settings.Shibboleth_System_URL.Length > 0) && (SobekCM_Library_Settings.Shibboleth_System_Name.Length > 0))
                {
                    literalBuilder.AppendLine("<li><b>If you have a valid " + SobekCM_Library_Settings.Shibboleth_System_Name + " ID</b>, <a href=\"" + SobekCM_Library_Settings.Shibboleth_System_URL + "\">Sign on with your " + SobekCM_Library_Settings.Shibboleth_System_Name + " here</a>.<br /><br /></li>");
                }

                literalBuilder.AppendLine("<li><b>If you have a valid my" + currentMode.SobekCM_Instance_Abbreviation + " logon</b>, <a id=\"form_logon_term\" href=\"" + currentMode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return popup_focus('form_logon', 'form_logon_term', 'logon_username', 280, 400 );\">Sign on with my" + currentMode.SobekCM_Instance_Abbreviation + " authentication here</a>.<br /><br /></li>");
            }

            currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Preferences;
            literalBuilder.Append("<li><b>Not registered yet?</b> <a href=\"" + currentMode.Redirect_URL() + "\">Register now</a> or ");

            currentMode.Mode = Display_Mode_Enum.Contact;
            literalBuilder.AppendLine(" <a href=\"" + currentMode.Redirect_URL() + "\">Contact Us</a></li>");
            currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Logon;
            currentMode.Mode          = Display_Mode_Enum.My_Sobek;

            literalBuilder.AppendLine("</ul>");
            literalBuilder.AppendLine("</blockquote>");
            literalBuilder.AppendLine("<br />");

            literalBuilder.AppendLine("</div>");
            literalBuilder.AppendLine("<br />");
            literalBuilder.AppendLine("<br />");

            LiteralControl literal2 = new LiteralControl(literalBuilder.ToString());

            placeHolder.Controls.Add(literal2);
        }
        /// <summary> Writes the HTML generated by this contact us html subwriter directly to the response stream </summary>
        /// <param name="Output"> Stream to which to write the HTML for this subwriter </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        /// <returns> TRUE -- Value indicating if html writer should finish the page immediately after this, or if there are other controls or routines which need to be called first </returns>
        public override bool Write_HTML(TextWriter Output, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Contact_HtmlSubwriter.Write_HTML", "Rendering HTML");

            Output.WriteLine("<br /><br />");
            Output.WriteLine();

            if (currentMode.Mode == Display_Mode_Enum.Contact_Sent)
            {
                Output.WriteLine("<div class=\"SobekHomeText\">");
                Output.WriteLine("<table width=\"700\" border=\"0\" align=\"center\">");
                Output.WriteLine("  <tr>");
                Output.WriteLine("    <td align=\"center\" >");
                Output.WriteLine("      <b>Your email has been sent.</b>");
                Output.WriteLine("      <br /><br />");
                Output.WriteLine("      <a href=\"" + currentMode.Base_URL + "\">Click here to return to the digital collection home</a>");
                Output.WriteLine("      <br /><br />");
                if (currentMode.Browser_Type.IndexOf("IE") >= 0)
                {
                    Output.WriteLine("      <a href=\"javascript:window.close();\">Click here to close this tab in your browser</a>");
                }
                Output.WriteLine("    </td>");
                Output.WriteLine("  </tr>");
                Output.WriteLine("</table>");
                Output.WriteLine("<br /><br />");
                Output.WriteLine("</div>");
            }
            else
            {
                string contact_us_title = "Contact Us";
                string please_complete  = "Please complete the following required fields:";
                string subject_text     = "Enter a subject here:";
                string notes_text       = "Describe your question or problem here:";
                string may_we           = "May we contact you?  If so, please provide the following information:";
                string name             = "Enter your name here:";
                string email            = "Enter your e-mail address here:";
                string submit           = "Submit";
                string cancel           = "Cancel";

                if (currentMode.Language == Web_Language_Enum.French)
                {
                    contact_us_title = "Contactez Nous";
                    please_complete  = "Veuillez remplir les champs obligatoires indiqués:";
                    subject_text     = "Entrez votre sujet ici:";
                    notes_text       = "Décrivez votre question ici:";
                    may_we           = "Mai-nous communiquer avec vous? Dans l'affirmative, s’il vous plaît fournir les informations suivantes:";
                    name             = "Votre nom ici:";
                    email            = "Votre addresse de courriel electronique ici:";
                    submit           = "Soumettre";
                    cancel           = "Annuler";
                }

                if (currentMode.Language == Web_Language_Enum.Spanish)
                {
                    contact_us_title = "Contáctenos";
                    please_complete  = "Por Favor llene la información Requerida:";
                    subject_text     = "Ponga un Sujeto Aquí:";
                    notes_text       = "Describa su problema or pregunta Aquí:";
                    may_we           = "¿Podemos comunicarnos con usted? En caso afirmativo, sírvase proporcionar la siguiente información:";
                    name             = "Su Nombre Aquí:";
                    email            = "Su Dirección de Correo Electrónico (Email) Aquí:";
                    submit           = "Mandar";
                    cancel           = "Cancelar";
                }

                // Determine any initial values
                string name_value    = string.Empty;
                string email_value   = string.Empty;
                string notes_value   = String.Empty;
                string subject_value = String.Empty;
                if ((!currentMode.isPostBack) && (HttpContext.Current.Session["user"] != null))
                {
                    User_Object user = (User_Object)HttpContext.Current.Session["user"];
                    name_value  = user.Full_Name;
                    email_value = user.Email;
                }
                if (currentMode.Error_Message.Length > 0)
                {
                    subject_value = currentMode.SobekCM_Instance_Abbreviation + " Error";
                    notes_value   = currentMode.Error_Message;
                }

                // Start this form
                string post_url = HttpUtility.HtmlEncode(HttpContext.Current.Items["Original_URL"].ToString());
                Output.WriteLine("<form name=\"email_form\" method=\"post\" action=\"" + post_url + "\" id=\"addedForm\" >");

                // Add the hidden field
                Output.WriteLine("<!-- Hidden field is used for postbacks to indicate what to save and reset -->");
                Output.WriteLine("<input type=\"hidden\" id=\"item_action\" name=\"item_action\" value=\"\" />");


                Output.WriteLine("<div class=\"SobekSearchPanel\">");
                Output.WriteLine("<h1>" + contact_us_title + "</h1>");

                Output.WriteLine("<blockquote>");

                if ((currentMode.Aggregation == "juv") || (currentMode.Aggregation == "alice"))
                {
                    Output.WriteLine("<a href=\"" + currentMode.Base_URL + "bookvalue\" target=\"_bookvalue\">Click here if you are asking about your own copy of a book.</a><br /><br />");
                }

                Output.WriteLine("<strong>" + please_complete + "</strong>");
                Output.WriteLine("<br /><br />");
                Output.WriteLine("<blockquote>");
                Output.WriteLine("<label for=\"subjectTextBox\">" + subject_text + "</label> ");
                Output.WriteLine("<input name=\"subjectTextBox\" value=\"" + subject_value + "\" type=\"text\" id=\"subjectTextBox\" class=\"SobekContactBox\" onfocus=\"textbox_enter('subjectTextBox', 'SobekContactBox_focused')\" onblur=\"textbox_leave('subjectTextBox', 'SobekContactBox')\" />");
                Output.WriteLine("<br /> <br />");
                Output.WriteLine("<label for=\"notesTextBox\">" + notes_text + "</label> <br />");
                Output.WriteLine("<textarea name=\"notesTextBox\" rows=\"8\" cols=\"100\" id=\"notesTextBox\" class=\"SobekContactCommentBox\" onfocus=\"textbox_enter('notesTextBox', 'SobekContactCommentBox_focused')\" onblur=\"textbox_leave('notesTextBox', 'SobekContactCommentBox')\">" + notes_value + "</textarea>");
                Output.WriteLine("<br /><br />");
                Output.WriteLine("</blockquote>");
                Output.WriteLine("<strong>" + may_we + "</strong>");
                Output.WriteLine("<blockquote>");
                Output.WriteLine("<label for=\"nameTextBox\">" + name + "</label>");
                Output.WriteLine("<input name=\"nameTextBox\" type=\"text\" value=\"" + name_value + "\" id=\"nameTextBox\" class=\"SobekContactBox\" onfocus=\"textbox_enter('nameTextBox', 'SobekContactBox_focused')\" onblur=\"textbox_leave('nameTextBox', 'SobekContactBox')\" />");
                Output.WriteLine("<br /><br />");
                Output.WriteLine("<label for=\"emailTextBox\">" + email + "</label><input name=\"emailTextBox\" type=\"text\" value=\"" + email_value + "\" id=\"emailTextBox\" class=\"SobekContactBox\" onfocus=\"textbox_enter('emailTextBox', 'SobekContactBox_focused')\" onblur=\"textbox_leave('emailTextBox', 'SobekContactBox')\" />");
                Output.WriteLine("<br /><br /><br />");
                Output.WriteLine("<center>");

                if (lastMode.Length > 0)
                {
                    Output.Write("<a href=\"?" + lastMode + "\">");
                }
                else
                {
                    currentMode.Mode = Display_Mode_Enum.Aggregation_Home;
                    Output.Write("<a href=\"" + currentMode.Redirect_URL() + "\">");
                    currentMode.Mode = Display_Mode_Enum.Contact;
                }

                Output.WriteLine("<img src=\"" + currentMode.Base_URL + "design/skins/" + currentMode.Base_Skin + "/buttons/cancel_button_g.gif\" alt=\"" + cancel + "\" /></a> &nbsp; &nbsp; ");
                Output.WriteLine("<a href=\"?\" onclick=\"return send_contact_email();\" ><img src=\"" + currentMode.Base_URL + "design/skins/" + currentMode.Base_Skin + "/buttons/send_button_g.gif\" alt=\"" + submit + "\" /></a>");
                Output.WriteLine("</center>");
                Output.WriteLine("</blockquote>");
                Output.WriteLine("</blockquote>");
                Output.WriteLine("</div>");
                Output.WriteLine("");
                Output.WriteLine("<!-- Focus on subject text box -->");
                Output.WriteLine("<script type=\"text/javascript\">focus_element('subjectTextBox');</script>");
                Output.WriteLine("");
                Output.WriteLine("<br />");
                Output.WriteLine("");
                Output.WriteLine("</form>");
            }

            return(true);
        }
        /// <summary> Constructor for a new instance of the Portals_AdminViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="URL_Portals"> List of all web portals into this system </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Portals_AdminViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Portal_List URL_Portals, Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("Portals_AdminViewer.Constructor", String.Empty);

            portals = URL_Portals;

            // Save the mode
            currentMode = Current_Mode;

            // Set action message to nothing to start
            actionMessage = String.Empty;

            // If the user cannot edit this, go back
            if (!user.Is_System_Admin)
            {
                Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                HttpContext.Current.Response.Redirect(Current_Mode.Redirect_URL());
            }

            // Handle any post backs
            if (Current_Mode.isPostBack)
            {
                try
                {
                    // Pull the standard values from the form
                    NameValueCollection form = HttpContext.Current.Request.Form;
                    string save_value        = form["admin_portal_tosave"];
                    string action_value      = form["admin_portal_action"];

                    // Switch, depending on the request
                    if (action_value != null)
                    {
                        switch (action_value.Trim().ToLower())
                        {
                        case "edit":
                            // Get the values from the form for this new portal
                            string edit_name = form["form_portal_name"].Trim();
                            string edit_abbr = form["form_portal_abbr"].Trim();
                            string edit_skin = form["form_portal_skin"].Trim();
                            string edit_aggr = form["form_portal_aggregation"].Trim();
                            string edit_url  = form["form_portal_url"].Trim();
                            string edit_purl = form["form_portal_purl"].Trim();
                            int    portalid  = Convert.ToInt32(save_value);

                            // Look for this to see if this was the pre-existing default
                            bool isDefault = false;
                            if (portals.Default_Portal.ID == portalid)
                            {
                                isDefault = true;
                            }


                            // Don't edit if the URL segment is empty and this is NOT default
                            if ((!isDefault) && (edit_url.Trim().Length == 0))
                            {
                                actionMessage = "ERROR: Non default portals MUST have a url segment associated.";
                            }
                            else
                            {
                                // Now, save this portal information
                                int edit_id = SobekCM_Database.Edit_URL_Portal(portalid, edit_url, true, isDefault, edit_abbr, edit_name, edit_aggr, edit_skin, edit_purl, Tracer);
                                if (edit_id > 0)
                                {
                                    actionMessage = "Edited existing URL portal '" + edit_name + "'";
                                }
                                else
                                {
                                    actionMessage = "Error editing URL portal.";
                                }
                            }
                            break;

                        case "delete":
                            actionMessage = SobekCM_Database.Delete_URL_Portal(Convert.ToInt32(save_value), Tracer) ? "URL portal deleted" : "Error deleting the URL portal";
                            break;

                        case "new":
                            // Get the values from the form for this new portal
                            string new_name = form["admin_portal_name"];
                            string new_abbr = form["admin_portal_abbr"];
                            string new_skin = form["admin_portal_skin"];
                            string new_aggr = form["admin_portal_aggregation"];
                            string new_url  = form["admin_portal_url"];
                            string new_purl = form["admin_portal_purl"];

                            // Save this to the database
                            int new_id = SobekCM_Database.Edit_URL_Portal(-1, new_url, true, false, new_abbr, new_name, new_aggr, new_skin, new_purl, Tracer);
                            if (new_id > 0)
                            {
                                actionMessage = "Saved new URL portal '" + new_name + "'";
                            }
                            else
                            {
                                actionMessage = "Error saving URL portal.";
                            }
                            break;
                        }
                    }
                }
                catch (Exception)
                {
                    actionMessage = "Exception caught while handling request";
                }

                // Reload all the URL portals
                SobekCM_Database.Populate_URL_Portals(portals, Tracer);
            }
        }
        /// <summary> This is an opportunity to write HTML directly into the main form, without
        /// using the pop-up html form architecture </summary>
        /// <param name="Output"> Textwriter to write the pop-up form HTML for this viewer </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> This text will appear within the ItemNavForm form tags </remarks>
        public override void Add_HTML_In_Main_Form(TextWriter Output, Custom_Tracer Tracer)
        {
            // Set the help for these subelements
            const string PORTAL_NAME_HELP  = "Name for the system when accessed through this url portal.  This additionally identifies this url portal to administrators.\n\nFor example, Digital Library of the Caribbean, or University of Florida Digital Collections.";
            const string ABBREVIATION_HELP = "Abbreviation for the system, when accessed through this url portal.\n\nFor example, 'dLOC', or UFDC.";
            const string WEB_SKIN_HELP     = "Default web skin under which this url portal should be displayed.  If none is probided, it will default to the system web skin.";
            const string AGGREGATION_HELP  = "Default aggregation which should be displayed under this url portal.  If none is provided, this url portal will display the main system home page.";
            const string URL_SEGMENT_HELP  = "URL segment used for matching purposes to determine which url portal a user is accessing this system from.\n\nA blank URL portal will make this the default portal.";
            const string BASE_PURL_HELP    = "Base permanent link URL to be used when constructing permanent URLs for items which do not have itt explicitly entered.\n\nA blank value here will result in the current URL being used as the base for the purl.";

            Tracer.Add_Trace("Portals_AdminViewer.Add_HTML_In_Main_Form", "Adds the portal information to the main form");

            Output.WriteLine("<script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/jquery/jquery-1.6.2.min.js\"></script>");
            Output.WriteLine("<script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/jquery/jquery-ui-1.8.16.custom.min.js\"></script>");
            Output.WriteLine("<script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/sobekcm_form.js\" ></script>");

            // Add the hidden field
            Output.WriteLine("<!-- Hidden field is used for postbacks to indicate what to save and reset -->");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_portal_action\" name=\"admin_portal_action\" value=\"\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_portal_tosave\" name=\"admin_portal_tosave\" value=\"\" />");
            Output.WriteLine();

            Output.WriteLine("<!-- URL Portal Edit Form -->");
            Output.WriteLine("<div class=\"admin_portal_popup_div\" id=\"form_portal\" style=\"display:none;\">");
            Output.WriteLine("  <div class=\"popup_title\"><table width=\"100%\"><tr><td align=\"left\">EDIT URL PORTAL</td><td align=\"right\"> <a href=\"#template\" alt=\"CLOSE\" onclick=\"portal_form_close()\">X</a> &nbsp; </td></tr></table></div>");
            Output.WriteLine("  <br />");
            Output.WriteLine("  <table class=\"popup_table\">");

            // Add the line for the url portal name
            Output.WriteLine("    <tr height=\"30px\">");
            Output.WriteLine("          <td width=\"145px\"><label for=\"form_portal_name\">Portal Name:</label></td>");
            Output.WriteLine("          <td><input class=\"admin_portal_input\" name=\"form_portal_name\" id=\"form_portal_name\" type=\"text\" value=\"\"  onfocus=\"javascript:textbox_enter('form_portal_name', 'admin_portal_input_focused')\" onblur=\"javascript:textbox_leave('form_portal_name', 'admin_portal_input')\" /></td>");
            Output.WriteLine("          <td><img border=\"0px\" style=\"padding-left:5px; margin-top:3px; cursor:pointer; cursor:hand;\" src=\"" + currentMode.Base_URL + "default/images/help_button.jpg\" onclick=\"alert('" + PORTAL_NAME_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" /></td>");
            Output.WriteLine("    </tr>");

            // Add the line for the url portal abbreviation
            Output.WriteLine("    <tr height=\"30px\">");
            Output.WriteLine("          <td><label for=\"form_portal_abbr\">System Abbreviation:</label></td>");
            Output.WriteLine("          <td><input class=\"admin_portal_input\" name=\"form_portal_abbr\" id=\"form_portal_abbr\" type=\"text\" value=\"\"  onfocus=\"javascript:textbox_enter('form_portal_abbr', 'admin_portal_input_focused')\" onblur=\"javascript:textbox_leave('form_portal_abbr', 'admin_portal_input')\" /></td>");
            Output.WriteLine("          <td><img border=\"0px\" style=\"padding-left:5px; margin-top:3px; cursor:pointer; cursor:hand;\" src=\"" + currentMode.Base_URL + "default/images/help_button.jpg\" onclick=\"alert('" + ABBREVIATION_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" /></td>");
            Output.WriteLine("    </tr>");

            // Add the line for the default web skin
            Output.WriteLine("    <tr height=\"30px\">");
            Output.WriteLine("          <td><label for=\"form_portal_skin\">Default Web Skin:</label></td>");
            Output.WriteLine("          <td><input class=\"admin_portal_input\" name=\"form_portal_skin\" id=\"form_portal_skin\" type=\"text\" value=\"\"  onfocus=\"javascript:textbox_enter('form_portal_skin', 'admin_portal_input_focused')\" onblur=\"javascript:textbox_leave('form_portal_skin', 'admin_portal_input')\" /></td>");
            Output.WriteLine("          <td><img border=\"0px\" style=\"padding-left:5px; margin-top:3px; cursor:pointer; cursor:hand;\" src=\"" + currentMode.Base_URL + "default/images/help_button.jpg\" onclick=\"alert('" + WEB_SKIN_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" /></td>");
            Output.WriteLine("    </tr>");

            // Add the line for the default aggregation
            Output.WriteLine("    <tr height=\"30px\">");
            Output.WriteLine("          <td><label for=\"form_portal_aggregation\">Default Aggregation:</label></td>");
            Output.WriteLine("          <td><input class=\"admin_portal_input\" name=\"form_portal_aggregation\" id=\"form_portal_aggregation\" type=\"text\" value=\"\"  onfocus=\"javascript:textbox_enter('form_portal_aggregation', 'admin_portal_input_focused')\" onblur=\"javascript:textbox_leave('form_portal_aggregation', 'admin_portal_input')\" /></td>");
            Output.WriteLine("          <td><img border=\"0px\" style=\"padding-left:5px; margin-top:3px; cursor:pointer; cursor:hand;\" src=\"" + currentMode.Base_URL + "default/images/help_button.jpg\" onclick=\"alert('" + AGGREGATION_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" /></td>");
            Output.WriteLine("    </tr>");

            // Add the line for the base url segment
            Output.WriteLine("    <tr height=\"30px\">");
            Output.WriteLine("          <td><label for=\"form_portal_url\">URL Segment:</label></td>");
            Output.WriteLine("          <td><input class=\"admin_portal_input\" name=\"form_portal_url\" id=\"form_portal_url\" type=\"text\" value=\"\"  onfocus=\"javascript:textbox_enter('form_portal_url', 'admin_portal_input_focused')\" onblur=\"javascript:textbox_leave('form_portal_url', 'admin_portal_input')\" /></td>");
            Output.WriteLine("          <td><img border=\"0px\" style=\"padding-left:5px; margin-top:3px; cursor:pointer; cursor:hand;\" src=\"" + currentMode.Base_URL + "default/images/help_button.jpg\" onclick=\"alert('" + URL_SEGMENT_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" /></td>");
            Output.WriteLine("    </tr>");

            // Add the line for the base purl
            Output.WriteLine("    <tr height=\"30px\">");
            Output.WriteLine("          <td><label for=\"form_portal_purl\">Base PURL:</label></td>");
            Output.WriteLine("          <td><input class=\"admin_portal_input\" name=\"form_portal_purl\" id=\"form_portal_purl\" type=\"text\" value=\"\"  onfocus=\"javascript:textbox_enter('form_portal_purl', 'admin_portal_input_focused')\" onblur=\"javascript:textbox_leave('form_portal_purl', 'admin_portal_input')\" /></td>");
            Output.WriteLine("          <td><img border=\"0px\" style=\"padding-left:5px; margin-top:3px; cursor:pointer; cursor:hand;\" src=\"" + currentMode.Base_URL + "default/images/help_button.jpg\" onclick=\"alert('" + BASE_PURL_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" /></td>");
            Output.WriteLine("    </tr>");
            Output.WriteLine("  </table>");
            Output.WriteLine("  <br />");
            Output.WriteLine("  <center><a href=\"\" onclick=\"return portal_form_close();\"><img border=\"0\" src=\"" + currentMode.Base_URL + "design/skins/" + currentMode.Base_Skin + "/buttons/cancel_button_g.gif\" alt=\"CLOSE\" /></a> &nbsp; &nbsp; <input type=\"image\" src=\"" + currentMode.Base_URL + "design/skins/" + currentMode.Base_Skin + "/buttons/save_button_g.gif\" value=\"Submit\" alt=\"Submit\"></center>");
            Output.WriteLine("</div>");

            Output.WriteLine("<!-- Portals_AdminViewer.Add_HTML_In_Main_Form -->");
            Output.WriteLine("<script src=\"" + currentMode.Base_URL + "default/scripts/sobekcm_admin.js\" type=\"text/javascript\"></script>");
            Output.WriteLine("<div class=\"SobekHomeText\">");

            if (!String.IsNullOrEmpty(actionMessage))
            {
                Output.WriteLine("  <strong>" + actionMessage + "</strong>");
            }

            Output.WriteLine("  <blockquote>");
            Output.WriteLine("    URL portals allow the same SobekCM library to have a very different look and feel and encompass different item aggregations.  Each portal is defined by the incoming URL and the URL for each incoming request is analyzed to ensure it is handled correctly.<br /><br />");
            Output.WriteLine("    For more information about URL portals, <a href=\"" + SobekCM_Library_Settings.Help_URL(currentMode.Base_URL) + "admin/portals\" target=\"ADMIN_USER_HELP\" >click here to view the help page</a>.");
            Output.WriteLine("  </blockquote>");

            Output.WriteLine("  <span class=\"SobekAdminTitle\">New URL Portal</span>");
            Output.WriteLine("  <blockquote>");
            Output.WriteLine("  To add a new URL portal to this system, enter the information below and press SAVE.<br /><br />");
            Output.WriteLine("    <div class=\"admin_portal_new_div\">");
            Output.WriteLine("      <table class=\"popup_table\">");

            Portal newPortal = new Portal(-1, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, String.Empty);



            // Add the line for the url portal name
            Output.WriteLine("        <tr height=\"30px\">");
            Output.WriteLine("          <td width=\"145px\"><label for=\"admin_portal_name\">Portal Name:</label></td>");
            Output.WriteLine("          <td><input class=\"admin_portal_input\" name=\"admin_portal_name\" id=\"admin_portal_name\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(newPortal.Name) + "\"  onfocus=\"javascript:textbox_enter('admin_portal_name', 'admin_portal_input_focused')\" onblur=\"javascript:textbox_leave('admin_portal_name', 'admin_portal_input')\" /></td>");
            Output.WriteLine("          <td><img border=\"0px\" style=\"padding-left:5px; margin-top:3px; cursor:pointer; cursor:hand;\" src=\"" + currentMode.Base_URL + "default/images/help_button.jpg\" onclick=\"alert('" + PORTAL_NAME_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" /></td>");
            Output.WriteLine("        </tr>");

            // Add the line for the url portal abbreviation
            Output.WriteLine("        <tr height=\"30px\">");
            Output.WriteLine("          <td><label for=\"admin_portal_abbr\">System Abbreviation:</label></td>");
            Output.WriteLine("          <td><input class=\"admin_portal_input\" name=\"admin_portal_abbr\" id=\"admin_portal_abbr\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(newPortal.Abbreviation) + "\"  onfocus=\"javascript:textbox_enter('admin_portal_abbr', 'admin_portal_input_focused')\" onblur=\"javascript:textbox_leave('admin_portal_abbr', 'admin_portal_input')\" /></td>");
            Output.WriteLine("          <td><img border=\"0px\" style=\"padding-left:5px; margin-top:3px; cursor:pointer; cursor:hand;\" src=\"" + currentMode.Base_URL + "default/images/help_button.jpg\" onclick=\"alert('" + ABBREVIATION_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" /></td>");
            Output.WriteLine("        </tr>");

            // Add the line for the default web skin
            Output.WriteLine("        <tr height=\"30px\">");
            Output.WriteLine("          <td><label for=\"admin_portal_skin\">Default Web Skin:</label></td>");
            Output.WriteLine("          <td><input class=\"admin_portal_input\" name=\"admin_portal_skin\" id=\"admin_portal_skin\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(newPortal.Default_Web_Skin) + "\"  onfocus=\"javascript:textbox_enter('admin_portal_skin', 'admin_portal_input_focused')\" onblur=\"javascript:textbox_leave('admin_portal_skin', 'admin_portal_input')\" /></td>");
            Output.WriteLine("          <td><img border=\"0px\" style=\"padding-left:5px; margin-top:3px; cursor:pointer; cursor:hand;\" src=\"" + currentMode.Base_URL + "default/images/help_button.jpg\" onclick=\"alert('" + WEB_SKIN_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" /></td>");
            Output.WriteLine("        </tr>");

            // Add the line for the default aggregation
            Output.WriteLine("        <tr height=\"30px\">");
            Output.WriteLine("          <td><label for=\"admin_portal_aggregation\">Default Aggregation:</label></td>");
            Output.WriteLine("          <td><input class=\"admin_portal_input\" name=\"admin_portal_aggregation\" id=\"admin_portal_aggregation\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(newPortal.Default_Aggregation) + "\"  onfocus=\"javascript:textbox_enter('admin_portal_aggregation', 'admin_portal_input_focused')\" onblur=\"javascript:textbox_leave('admin_portal_aggregation', 'admin_portal_input')\" /></td>");
            Output.WriteLine("          <td><img border=\"0px\" style=\"padding-left:5px; margin-top:3px; cursor:pointer; cursor:hand;\" src=\"" + currentMode.Base_URL + "default/images/help_button.jpg\" onclick=\"alert('" + AGGREGATION_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" /></td>");
            Output.WriteLine("        </tr>");

            // Add the line for the base url segment
            Output.WriteLine("        <tr height=\"30px\">");
            Output.WriteLine("          <td><label for=\"admin_portal_url\">URL Segment:</label></td>");
            Output.WriteLine("          <td><input class=\"admin_portal_input\" name=\"admin_portal_url\" id=\"admin_portal_url\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(newPortal.URL_Segment) + "\"  onfocus=\"javascript:textbox_enter('admin_portal_url', 'admin_portal_input_focused')\" onblur=\"javascript:textbox_leave('admin_portal_url', 'admin_portal_input')\" /></td>");
            Output.WriteLine("          <td><img border=\"0px\" style=\"padding-left:5px; margin-top:3px; cursor:pointer; cursor:hand;\" src=\"" + currentMode.Base_URL + "default/images/help_button.jpg\" onclick=\"alert('" + URL_SEGMENT_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" /></td>");
            Output.WriteLine("        </tr>");

            // Add the line for the base purl
            Output.WriteLine("        <tr height=\"30px\">");
            Output.WriteLine("          <td><label for=\"admin_portal_purl\">Base PURL:</label></td>");
            Output.WriteLine("          <td><input class=\"admin_portal_input\" name=\"admin_portal_purl\" id=\"admin_portal_purl\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(newPortal.Base_PURL) + "\"  onfocus=\"javascript:textbox_enter('admin_portal_purl', 'admin_portal_input_focused')\" onblur=\"javascript:textbox_leave('admin_portal_purl', 'admin_portal_input')\" /></td>");
            Output.WriteLine("          <td><img border=\"0px\" style=\"padding-left:5px; margin-top:3px; cursor:pointer; cursor:hand;\" src=\"" + currentMode.Base_URL + "default/images/help_button.jpg\" onclick=\"alert('" + BASE_PURL_HELP.Replace("'", "").Replace("\\", "\\\\").Replace("\n", "\\n") + "');\" /></td>");
            Output.WriteLine("        </tr>");

            Output.WriteLine("        </table>");

            Output.WriteLine("        <center><input type=\"image\" src=\"" + currentMode.Base_URL + "design/skins/" + currentMode.Base_Skin + "/buttons/save_button.gif\" value=\"Submit\" alt=\"Submit\" onclick=\"return save_new_portal();\"/></center>");

            Output.WriteLine("      </div>");
            Output.WriteLine("    </blockquote>");


            Output.WriteLine("  <span class=\"SobekAdminTitle\">Existing URL Portals</span>");
            Output.WriteLine("  <blockquote>");
            Output.WriteLine("    The following URL portals are currently cached in this web application.<br /><br />");
            Output.WriteLine("  </blockquote>");

            Output.WriteLine("<table border=\"0px\" cellspacing=\"0px\" class=\"statsTable\">");
            Output.WriteLine("  <tr align=\"left\" bgcolor=\"#0022a7\" >");
            Output.WriteLine("    <th width=\"85px\" align=\"left\"><span style=\"color: White\"> &nbsp; ACTIONS</span></th>");
            Output.WriteLine("    <th width=\"130px\" align=\"left\"><span style=\"color: White\">URL<br />SEGMENT</span></th>");
            Output.WriteLine("    <th width=\"110px\" align=\"left\"><span style=\"color: White\">SYSTEM<br />ABBREVIATION</span></th>");
            Output.WriteLine("    <th width=\"85px\" align=\"left\"><span style=\"color: White\">DEFAULT<br />WEB SKIN</span></th>");
            Output.WriteLine("    <th width=\"105px\" align=\"left\"><span style=\"color: White\">DEFAULT<br />AGGREGATION</span></th>");
            Output.WriteLine("    <th width=\"180px\" align=\"left\"><span style=\"color: White\">BASE<br />PURL</span></th>");
            Output.WriteLine("   </tr>");
            Output.WriteLine("  <tr><td bgcolor=\"#e7e7e7\" colspan=\"6\"></td></tr>");

            // Write the default portal first
            Output.WriteLine("  <tr align=\"left\" >");
            if (portals.Default_Portal.ID > 0)
            {
                Output.Write("    <td class=\"SobekAdminActionLink\" >( ");
                Portal thisPortal = portals.Default_Portal;
                Output.WriteLine("      <a title=\"Edit this portal\" id=\"VIEW_0\" href=\"" + currentMode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return portal_form_popup('VIEW_0','" + thisPortal.ID + "','" + HttpUtility.HtmlEncode(thisPortal.Name.Replace("'", "")) + "','" + thisPortal.Abbreviation + "','" + thisPortal.Default_Web_Skin + "','" + thisPortal.Default_Aggregation + "','" + thisPortal.URL_Segment + "','" + thisPortal.Base_PURL + "');\">edit</a> ) </td>");
            }
            else
            {
                Output.WriteLine("    <td>&nbsp;</td>");
            }
            Output.WriteLine("    <td><i><b>default</b></i></span></td>");
            Output.WriteLine("    <td>" + portals.Default_Portal.Abbreviation + "</span></td>");
            Output.WriteLine("    <td>" + portals.Default_Portal.Default_Web_Skin + "</span></td>");
            Output.WriteLine("    <td>" + portals.Default_Portal.Default_Aggregation + "</span></td>");
            Output.WriteLine("    <td>" + portals.Default_Portal.Base_PURL + "</span></td>");
            Output.WriteLine("   </tr>");
            Output.WriteLine("  <tr><td bgcolor=\"#e7e7e7\" colspan=\"6\"></td></tr>");

            // Write the data for each portal
            foreach (Portal thisPortal in portals.All_Portals)
            {
                if (thisPortal != portals.Default_Portal)
                {
                    Output.WriteLine("  <tr align=\"left\" >");
                    Output.Write("    <td class=\"SobekAdminActionLink\" >( ");
                    Output.Write("<a title=\"Edit this portal\" id=\"VIEW_" + thisPortal.ID + "\" href=\"" + currentMode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return portal_form_popup('VIEW_" + thisPortal.ID + "','" + thisPortal.ID + "','" + HttpUtility.HtmlEncode(thisPortal.Name.Replace("'", "")) + "','" + thisPortal.Abbreviation + "','" + thisPortal.Default_Web_Skin + "','" + thisPortal.Default_Aggregation + "','" + thisPortal.URL_Segment + "','" + thisPortal.Base_PURL + "');\">edit</a> | ");
                    Output.WriteLine("<a title=\"Delete this portal\" href=\"" + currentMode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return delete_portal('" + thisPortal.ID + "','" + HttpUtility.HtmlEncode(thisPortal.Name.Replace("'", "")) + "');\">delete</a> )</td>");
                    Output.WriteLine("    <td>" + thisPortal.URL_Segment + "</span></td>");
                    Output.WriteLine("    <td>" + thisPortal.Abbreviation + "</span></td>");
                    Output.WriteLine("    <td>" + thisPortal.Default_Web_Skin + "</span></td>");
                    Output.WriteLine("    <td>" + thisPortal.Default_Aggregation + "</span></td>");
                    Output.WriteLine("    <td>" + thisPortal.Base_PURL + "</span></td>");
                    Output.WriteLine("   </tr>");
                    Output.WriteLine("  <tr><td bgcolor=\"#e7e7e7\" colspan=\"6\"></td></tr>");
                }
            }
            Output.WriteLine("  </table>");
            Output.WriteLine("  <br /><br />");
            Output.WriteLine("</div>");
        }
示例#44
0
        /// <summary> This is an opportunity to write HTML directly into the main form, without
        /// using the pop-up html form architecture </summary>
        /// <param name="Output"> Textwriter to write the pop-up form HTML for this viewer </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> This text will appear within the ItemNavForm form tags </remarks>
        public override void Write_ItemNavForm_Closing(TextWriter Output, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Aggregations_Mgmt_AdminViewer.Write_ItemNavForm_Closing", "");

            Output.WriteLine("<script type=\"text/javascript\" src=\"" + Static_Resources_Gateway.Jquery_Ui_1_10_3_Custom_Js + "\"></script>");

            // Add the hidden field
            Output.WriteLine("<!-- Hidden field is used for postbacks to indicate what to save and reset -->");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_aggr_tosave\" name=\"admin_aggr_tosave\" value=\"\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_aggr_reset\" name=\"admin_aggr_reset\" value=\"\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_aggr_delete\" name=\"admin_aggr_delete\" value=\"\" />");
            Output.WriteLine();

            Output.WriteLine("<!-- Aggregations_Mgmt_AdminViewer.Write_ItemNavForm_Closing -->");
            Output.WriteLine("<script src=\"" + Static_Resources_Gateway.Sobekcm_Admin_Js + "\" type=\"text/javascript\"></script>");
            Output.WriteLine("<div class=\"sbkAdm_HomeText\">");

            // Add the action message, if there is one
            if (!String.IsNullOrEmpty(actionMessage))
            {
                // If this is an error, show it differently
                if (actionMessage.IndexOf("Error", StringComparison.InvariantCultureIgnoreCase) >= 0)
                {
                    Output.WriteLine("  <br />");
                    Output.WriteLine("  <div id=\"sbkAdm_ActionMessageError\">" + actionMessage + "</div>");
                }
                else
                {
                    Output.WriteLine("  <br />");
                    Output.WriteLine("  <div id=\"sbkAdm_ActionMessageSuccess\">" + actionMessage + "</div>");
                }
            }

            Output.WriteLine("  <p>For clarification of any terms on this form, <a href=\"" + UI_ApplicationCache_Gateway.Settings.System.Help_URL(RequestSpecificValues.Current_Mode.Base_URL) + "adminhelp/aggregations\" target=\"ADMIN_INTERFACE_HELP\" >click here to view the help page</a>.</p>");


            Output.WriteLine("  <h2>New Item Aggregation</h2>");

            RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Add_Collection_Wizard;
            string wizard_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Aggregations_Mgmt;

            Output.WriteLine("  <table>");
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <td>");
            Output.WriteLine("        <p>Use the new <a href=\"" + wizard_url + "\">Add New Collection Wizard</a> to add a single new collection.</p>");
            if (!addedNewCollection)
            {
                Output.WriteLine("        <span id=\"oldnewdivprompt\" style=\"display:block;\"><p>Alternatively, you can use the reduced interface below by <a href=\"\" onclick=\"$('#oldnewdiv').css('display', 'block');$('#oldnewdivprompt').css('display', 'none');return false;\">clicking here</a>.</p></span>");
            }

            Output.WriteLine("      </td>");
            Output.WriteLine("      <td style=\"padding-left: 30px;\">");
            Output.WriteLine("        <button title=\"Use the wizard to add a new collection\" class=\"sbkAdm_RoundButton\" onclick=\"window.location.href='" + wizard_url + "';return false;\"> &nbsp; NEW COLLECTION &nbsp; <br />WIZARD</button>");
            Output.WriteLine("      </td>");
            Output.WriteLine("    </tr>");
            Output.WriteLine("  </table>");

            if (addedNewCollection)
            {
                Output.WriteLine("  <div class=\"sbkAsav_NewDiv\" id=\"oldnewdiv\" style=\"display:block;\">");
            }
            else
            {
                Output.WriteLine("  <div class=\"sbkAsav_NewDiv\" id=\"oldnewdiv\" style=\"display:none;\">");
            }

            Output.WriteLine("    <br /><br />");
            Output.WriteLine("    <table class=\"sbkAdm_PopupTable\">");

            // Add line for aggregation code and aggregation type
            Output.WriteLine("      <tr>");
            Output.WriteLine("        <td style=\"width:120px;\"><label for=\"admin_aggr_code\">Code:</label></td>");
            Output.WriteLine("        <td><input class=\"sbkAsav_small_input sbkAdmin_Focusable\" name=\"admin_aggr_code\" id=\"admin_aggr_code\" type=\"text\" value=\"" + enteredCode + "\" /></td>");
            Output.WriteLine("        <td style=\"width:300px;text-align:right;\">");
            Output.WriteLine("          <label for=\"admin_aggr_type\">Type:</label> &nbsp; ");
            Output.WriteLine("          <select class=\"sbkAsav_select \" name=\"admin_aggr_type\" id=\"admin_aggr_type\" onchange=\"return aggr_display_external_link(this);\">");
            if (enteredType == String.Empty)
            {
                Output.WriteLine("            <option value=\"\" selected=\"selected\" ></option>");
            }

            Output.WriteLine(enteredType == "coll"
                ? "            <option value=\"coll\" selected=\"selected\" >Collection</option>"
                : "            <option value=\"coll\">Collection</option>");

            Output.WriteLine(enteredType == "group"
                ? "            <option value=\"group\" selected=\"selected\" >Collection Group</option>"
                : "            <option value=\"group\">Collection Group</option>");

            Output.WriteLine(enteredType == "exhibit"
                ? "            <option value=\"exhibit\" selected=\"selected\" >Exhibit</option>"
                : "            <option value=\"exhibit\">Exhibit</option>");

            Output.WriteLine(enteredType == "inst"
                ? "            <option value=\"inst\" selected=\"selected\" >Institution</option>"
                : "            <option value=\"inst\">Institution</option>");

            Output.WriteLine(enteredType == "subinst"
                ? "            <option value=\"subinst\" selected=\"selected\" >Institutional Division</option>"
                : "            <option value=\"subinst\">Institutional Division</option>");

            Output.WriteLine(enteredType == "subcoll"
                ? "            <option value=\"subcoll\" selected=\"selected\" >SubCollection</option>"
                : "            <option value=\"subcoll\">SubCollection</option>");

            Output.WriteLine("          </select>");
            Output.WriteLine("        </td>");
            Output.WriteLine("      </tr>");

            // Add the parent line
            Output.WriteLine("      <tr>");
            Output.WriteLine("        <td>");
            Output.WriteLine("          <label for=\"admin_aggr_parent\">Parent:</label></td><td colspan=\"2\">");
            Output.WriteLine("          <select class=\"sbkAsav_select_large\" name=\"admin_aggr_parent\" id=\"admin_aggr_parent\">");
            if (enteredParent == String.Empty)
            {
                Output.WriteLine("            <option value=\"\" selected=\"selected\" ></option>");
            }
            foreach (Item_Aggregation_Related_Aggregations thisAggr in UI_ApplicationCache_Gateway.Aggregations.All_Aggregations)
            {
                // For aggregations, this retains the initial i as lower case (easier to recognize)
                string aggrCode = thisAggr.Code;
                if ((aggrCode[0] == 'I') && (thisAggr.Type.IndexOf("Institution", StringComparison.InvariantCultureIgnoreCase) >= 0))
                {
                    aggrCode = "i" + aggrCode.Substring(1);
                }

                if (enteredParent == thisAggr.Code)
                {
                    Output.WriteLine("            <option value=\"" + thisAggr.Code + "\" selected=\"selected\" >" + aggrCode + " - " + thisAggr.Name + "</option>");
                }
                else
                {
                    Output.WriteLine("            <option value=\"" + thisAggr.Code + "\" >" + aggrCode + " - " + thisAggr.Name + "</option>");
                }
            }
            Output.WriteLine("          </select>");
            Output.WriteLine("        </td>");
            Output.WriteLine("      </tr>");

            // Add the full name line
            Output.WriteLine("      <tr><td><label for=\"admin_aggr_name\">Name (full):</label></td><td colspan=\"2\"><input class=\"sbkAsav_large_input sbkAdmin_Focusable\" name=\"admin_aggr_name\" id=\"admin_aggr_name\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(enteredName) + "\" onchange=\"if ( $('#admin_aggr_shortname').val().length == 0 ) { $('#admin_aggr_shortname').val(this.value); }\" /></td></tr>");

            // Add the short name line
            Output.WriteLine("      <tr><td><label for=\"admin_aggr_shortname\">Name (short):</label></td><td colspan=\"2\"><input class=\"sbkAsav_large_input sbkAdmin_Focusable\" name=\"admin_aggr_shortname\" id=\"admin_aggr_shortname\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(enteredShortname) + "\" onchange=\"if ( $('#admin_aggr_name').val().length == 0 ) { $('#admin_aggr_name').val(this.value); }\" /></td></tr>");

            // Add the link line
            Output.WriteLine("      <tr id=\"external_link_row\" style=\"display:none;\"><td><label for=\"admin_aggr_link\">External Link:</label></td><td colspan=\"2\"><input class=\"sbkAsav_large_input sbkAdmin_Focusable\" name=\"admin_aggr_link\" id=\"admin_aggr_link\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(enteredLink) + "\" /></td></tr>");

            // Add the thematic heading line
            Output.WriteLine("      <tr>");
            Output.WriteLine("        <td><label for=\"admin_aggr_heading\">Thematic Heading:</label></td>");
            Output.WriteLine("        <td colspan=\"2\">");
            Output.WriteLine("          <select class=\"sbkAsav_select_large\" name=\"admin_aggr_heading\" id=\"admin_aggr_heading\">");
            Output.WriteLine("            <option value=\"-1\" selected=\"selected\" ></option>");
            foreach (Thematic_Heading thisHeading in UI_ApplicationCache_Gateway.Thematic_Headings)
            {
                if (thisHeading.Text == enteredThematicHeading)
                {
                    Output.Write("            <option value=\"" + thisHeading.ID + "\" selected=\"selected\">" + HttpUtility.HtmlEncode(thisHeading.Text) + "</option>");
                }
                else
                {
                    Output.Write("            <option value=\"" + thisHeading.ID + "\">" + HttpUtility.HtmlEncode(thisHeading.Text) + "</option>");
                }
            }
            Output.WriteLine("          </select>");
            Output.WriteLine("        </td>");
            Output.WriteLine("      </tr>");



            // Add the description box
            Output.WriteLine("      <tr style=\"vertical-align:top\"><td><label for=\"admin_aggr_desc\">Description:</label></td><td colspan=\"2\"><textarea rows=\"6\" name=\"admin_aggr_desc\" id=\"admin_aggr_desc\" class=\"sbkAsav_input sbkAdmin_Focusable\">" + HttpUtility.HtmlEncode(enteredDescription) + "</textarea></td></tr>");

            // Add checkboxes for is active and is hidden
            Output.Write(enteredIsActive
                ? "          <tr style=\"height:30px\"><td>Behavior:</td><td colspan=\"2\"><input class=\"sbkAsav_checkbox\" type=\"checkbox\" name=\"admin_aggr_isactive\" id=\"admin_aggr_isactive\" checked=\"checked\" /> <label for=\"admin_aggr_isactive\">Active?</label></td></tr> "
                : "          <tr style=\"height:30px\"><td>Behavior:</td><td colspan=\"2\"><input class=\"sbkAsav_checkbox\" type=\"checkbox\" name=\"admin_aggr_isactive\" id=\"admin_aggr_isactive\" /> <label for=\"admin_aggr_isactive\">Active?</label></td></tr> ");


            Output.Write(!enteredIsHidden
                ? "          <tr><td></td><td colspan=\"2\"><input class=\"sbkAsav_checkbox\" type=\"checkbox\" name=\"admin_aggr_ishidden\" id=\"admin_aggr_ishidden\" checked=\"checked\" /> <label for=\"admin_aggr_ishidden\">Show in parent collection home page?</label></td></tr> "
                : "          <tr><td></td><td colspan=\"2\"><input class=\"sbkAsav_checkbox\" type=\"checkbox\" name=\"admin_aggr_ishidden\" id=\"admin_aggr_ishidden\" /> <label for=\"admin_aggr_ishidden\">Show in parent collection home page?</label></td></tr> ");


            // Add the SAVE button
            Output.WriteLine("      <tr style=\"height:30px; text-align: center;\"><td colspan=\"3\"><button title=\"Save new item aggregation\" class=\"sbkAdm_RoundButton\" onclick=\"return save_new_aggr();\">SAVE <img src=\"" + Static_Resources_Gateway.Button_Next_Arrow_Png + "\" class=\"sbkAdm_RoundButton_RightImg\" alt=\"\" /></button></td></tr>");
            Output.WriteLine("    </table>");
            Output.WriteLine("  </div>");
            Output.WriteLine();


            Output.WriteLine("  <h2>Existing Aggregations</h2>");

            Output.WriteLine("  <table class=\"sbkAsav_Table display\" id=\"adminMgmtTable\">");
            Output.WriteLine("    <thead>");
            Output.WriteLine("      <tr>");
            Output.WriteLine("        <th class=\"sbkAsav_TableHeader1\">ACTIONS</th>");
            Output.WriteLine("        <th class=\"sbkAsav_TableHeader2\">CODE</th>");
            Output.WriteLine("        <th class=\"sbkAsav_TableHeader3\">TYPE</th>");
            Output.WriteLine("        <th class=\"sbkAsav_TableHeader4\">NAME</th>");
            Output.WriteLine("        <th class=\"sbkAsav_TableHeader5\">ACTIVE</th>");
            Output.WriteLine("        <th class=\"sbkAsav_TableHeader6\">ON HOME</th>");
            Output.WriteLine("        <th class=\"sbkAsav_TableHeader7\">PARENT</th>");
            Output.WriteLine("      </tr>");
            Output.WriteLine("    </thead>");

            Output.WriteLine("    <tfoot>");
            Output.WriteLine("      <tr>");
            Output.WriteLine("        <th></th>");
            Output.WriteLine("        <th><input id=\"adminMgmtCodeSearch\" type=\"text\" placeholder=\"Search Code\" /></th>");
            Output.WriteLine("        <th>TYPE</th>");
            Output.WriteLine("        <th><input id=\"adminMgmtNameSearch\"  type=\"text\" placeholder=\"Search Name\" /></th>");
            Output.WriteLine("        <th>ACTIVE</th>");
            Output.WriteLine("        <th>ON HOME</th>");
            Output.WriteLine("        <th>PARENT</th>");
            Output.WriteLine("      </tr>");
            Output.WriteLine("    </tfoot>");

            Output.WriteLine("    <tbody>");

            // Show all the aggregations
            string last_code = String.Empty;

            foreach (Item_Aggregation_Related_Aggregations thisAggr in UI_ApplicationCache_Gateway.Aggregations.All_Aggregations)
            {
                if (thisAggr.Code != last_code)
                {
                    last_code = thisAggr.Code;

                    // Build the action links
                    Output.WriteLine("      <tr>");
                    Output.Write("        <td class=\"sbkAsav_ActionLink\" >( ");

                    Output.Write("<a title=\"Click to edit this item aggregation\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/admin/editaggr/" + thisAggr.Code + "\">edit</a> | ");

                    if (thisAggr.Active)
                    {
                        Output.Write("<a title=\"Click to view this item aggregation\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/" + thisAggr.Code + "\">view</a> | ");
                    }
                    else
                    {
                        Output.Write("view | ");
                    }

                    if (String.Compare(thisAggr.Code, "ALL", StringComparison.InvariantCultureIgnoreCase) != 0)
                    {
                        Output.Write("<a title=\"Click to delete this item aggregation\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return delete_aggr('" + thisAggr.Code + "');\">delete</a> | ");
                    }

                    Output.WriteLine("<a title=\"Click to reset the instance in the application cache\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return reset_aggr('" + thisAggr.Code + "');\">reset</a> )</td>");

                    // Special code to start istitutions with a small letter 'i'
                    string code = thisAggr.Code;
                    if ((thisAggr.Type.IndexOf("Institution", StringComparison.InvariantCultureIgnoreCase) >= 0) && (code[0] == 'I') && (code.Length > 1))
                    {
                        code = "i" + code.Substring(1);
                    }

                    // Add the rest of the row with data
                    Output.WriteLine("        <td>" + code + "</td>");
                    Output.WriteLine("        <td>" + thisAggr.Type + "</td>");
                    Output.WriteLine("        <td>" + thisAggr.Name + "</td>");

                    if (thisAggr.Active)
                    {
                        Output.WriteLine("        <td>Y</td>");
                    }
                    else
                    {
                        Output.WriteLine("        <td>N</td>");
                    }

                    if (thisAggr.Thematic_Heading != null)
                    {
                        Output.WriteLine("        <td>Y</td>");
                    }
                    else
                    {
                        Output.WriteLine("        <td>N</td>");
                    }
                    if (thisAggr.Parent_Count > 0)
                    {
                        Output.WriteLine("        <td>" + thisAggr.Parents[0].Code + "</td>");
                    }
                    else
                    {
                        Output.WriteLine("        <td></td>");
                    }
                    Output.WriteLine("      </tr>");
                }
            }

            Output.WriteLine("    </tbody>");
            Output.WriteLine("  </table>");

            Output.WriteLine("<script type=\"text/javascript\">");
            Output.WriteLine("    $(document).ready(function() { ");
            Output.WriteLine("        var table = $('#adminMgmtTable').DataTable({ ");

            // If 100 or less aggregations, suppress paging
            if (UI_ApplicationCache_Gateway.Aggregations.All_Aggregations.Count <= 100)
            {
                Output.WriteLine("            \"paging\":   false, ");
                Output.WriteLine("            \"info\":   false, ");
            }
            else
            {
                Output.WriteLine("            \"lengthMenu\": [ [50, 100, -1], [50, 100, \"All\"] ], ");
                Output.WriteLine("            \"pageLength\":  50, ");
            }

            Output.WriteLine("            initComplete: function () {");
            Output.WriteLine("                var api = this.api();");

            Output.WriteLine("                api.columns().indexes().flatten().each( function ( i ) {");
            Output.WriteLine("                    if (( i == 2 || i == 4 || i == 5 || i == 6 )) {");
            Output.WriteLine("                        var column = api.column( i );");
            Output.WriteLine("                        var select = $('<select><option value=\"\"></option></select>')");
            Output.WriteLine("                                 .appendTo( $(column.footer()).empty() )");
            Output.WriteLine("                                 .on( 'change', function () {");
            Output.WriteLine("                                       var val = $.fn.dataTable.util.escapeRegex($(this).val());");
            Output.WriteLine("                                       column.search( val ? '^'+val+'$' : '', true, false ).draw();");
            Output.WriteLine("                                        } );");
            Output.WriteLine("                                 column.data().unique().sort().each( function ( d, j ) {");
            Output.WriteLine("                                      select.append( '<option value=\"'+d+'\">'+d+'</option>' )");
            Output.WriteLine("                                 } );");
            Output.WriteLine("                        }");
            Output.WriteLine("                    } );");
            Output.WriteLine("               }");
            Output.WriteLine("         });");

            Output.WriteLine("         $('#adminMgmtCodeSearch').on( 'keyup change', function () { table.column( 1 ).search( this.value ).draw(); } );");
            Output.WriteLine("         $('#adminMgmtNameSearch').on( 'keyup change', function () { table.column( 3 ).search( this.value ).draw(); } );");
            Output.WriteLine("    } );");

            Output.WriteLine("</script>");
            Output.WriteLine();


            Output.WriteLine("  <br />");
            Output.WriteLine("</div>");
            Output.WriteLine();
        }
        /// <summary> Add the sitemap tree-view control, if there is a site map included in this object </summary>
        /// <param name="placeHolder"> Main place holder ( &quot;mainPlaceHolder&quot; ) in the itemNavForm form, widely used throughout the application</param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        public void Add_Controls(PlaceHolder placeHolder, Custom_Tracer Tracer)
        {
            if ((siteMap == null) || (currentMode.Is_Robot))
            {
                return;
            }

            Tracer.Add_Trace("Web_Content_HtmlSubwriter.Add_Controls", "Adding site map tree nav view");

            // Create the treeview
            TreeView treeView1 = new TreeView
            {
                CssClass                = "SobekSiteMapTreeView",
                ExpandDepth             = 0,
                NodeIndent              = 15,
                ShowLines               = true,
                EnableClientScript      = true,
                PopulateNodesFromClient = true
            };

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


            // Determine the base URL
            string base_url = currentMode.Base_URL;

            if (currentMode.Writer_Type == Writer_Type_Enum.HTML_LoggedIn)
            {
                base_url = base_url + "l/";
            }

            // Find the selected node
            int selected_node = siteMap.Selected_NodeValue(currentMode.Info_Browse_Mode);

            foreach (SobekCM_SiteMap_Node rootSiteMapNode in siteMap.RootNodes)
            {
                // Add the sitemaps root node first
                TreeNode rootNode = new TreeNode
                {
                    SelectAction = TreeNodeSelectAction.None,
                    Text         = string.Format("<a href='{0}{1}' title='{2}'>{3}</a>", base_url, rootSiteMapNode.URL, rootSiteMapNode.Description, rootSiteMapNode.Title)
                };
                treeView1.Nodes.Add(rootNode);

                // Was this node currently selected?
                if (rootSiteMapNode.URL == currentMode.Info_Browse_Mode)
                {
                    rootNode.Text = string.Format("<span Title='{0}'>{1}</span>", rootSiteMapNode.Description, rootSiteMapNode.Title);
                    rootNode.Expand();
                }

                // Now add all the children recursively
                add_child_nodes(rootNode, rootSiteMapNode, base_url, selected_node);
            }

            // Always expand the top node
            //rootNode.Expand();

            // Add the tree to the view
            placeHolder.Controls.Add(treeView1);
        }
        /// <summary> Add the HTML to be displayed in the main SobekCM viewer area </summary>
        /// <param name="Output"> Textwriter to write the HTML for this viewer</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public override void Write_ItemNavForm_Opening(TextWriter Output, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Home_AdminViewer.Write_ItemNavForm_Opening", String.Empty);

            // Add the hidden field
            Output.WriteLine("<!-- Hidden field is used for postbacks to indicate what to save and reset -->");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_menu_preference\" name=\"admin_menu_preference\" value=\"\" />");
            Output.WriteLine();

            Output.WriteLine("<div class=\"sbkHav_ViewPrerence\">");
            Output.WriteLine("  <span style=\"font-weight:bold\">View Type:</span>");
            Output.WriteLine("  <select id=\"viewTypeSelect\" name=\"viewTypeSelect\" onchange=\"$('#admin_menu_preference').val(this.value);$('form#itemNavForm').submit();\">");

            if (menu_preference == "alphabetical")
            {
                Output.WriteLine("    <option value=\"alphabetical\" selected=\"selected\">Alphabetical</option>");
            }
            else
            {
                Output.WriteLine("    <option value=\"alphabetical\">Alphabetical</option>");
            }

            if (menu_preference == "brief")
            {
                Output.WriteLine("    <option value=\"brief\" selected=\"selected\">Brief View</option>");
            }
            else
            {
                Output.WriteLine("    <option value=\"brief\">Brief View</option>");
            }

            if (menu_preference == "categories")
            {
                Output.WriteLine("    <option value=\"categories\" selected=\"selected\">Categories</option>");
            }
            else
            {
                Output.WriteLine("    <option value=\"categories\">Categories</option>");
            }

            if (menu_preference == "classic")
            {
                Output.WriteLine("    <option value=\"classic\" selected=\"selected\">Classic</option>");
            }
            else
            {
                Output.WriteLine("    <option value=\"classic\">Classic</option>");
            }

            Output.WriteLine("  </select>");
            Output.WriteLine("</div>");
            Output.WriteLine();


            Output.WriteLine("<div class=\"sbkHav_MainText\" >");
            Output.WriteLine("  <h1>What would you like to manage today?</h1>");

            switch (menu_preference)
            {
            case "categories":
                write_categorized(Output);
                break;

            case "alphabetical":
                write_alphabetical(Output);
                break;

            case "classic":
                write_classic(Output);
                break;

            default:
                write_brief(Output);
                break;
            }


            Output.WriteLine("  <p>For clarification on any of these options, <a href=\"" + UI_ApplicationCache_Gateway.Settings.System.Help_URL(RequestSpecificValues.Current_Mode.Base_URL) + "adminhelp/tasks\" target=\"ADMIN_USER_HELP\" >click here to view the help page</a>.</p>");
            Output.WriteLine("  <p>You are currently running version " + UI_ApplicationCache_Gateway.Settings.Static.Current_Web_Version + ". ( <a href=\"http://sobekrepository.org/sobekcm/development/history\">see release notes</a> )</p>");
            Output.WriteLine("</div>");
        }
示例#47
0
        /// <summary> This is an opportunity to write HTML directly into the main form, without
        /// using the pop-up html form architecture </summary>
        /// <param name="Output"> Textwriter to write the pop-up form HTML for this viewer </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> This text will appear within the ItemNavForm form tags </remarks>
        public override void Write_ItemNavForm_Closing(TextWriter Output, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Thematic_Headings_AdminViewer.Write_ItemNavForm_Closing", "Add any popup divisions for form elements");

            Output.WriteLine("<!-- Thematic_Headings_AdminViewer.Write_ItemNavForm_Closing -->");
            Output.WriteLine("<script type=\"text/javascript\" src=\"" + Static_Resources_Gateway.Jquery_Ui_1_10_3_Custom_Js + "\"></script>");

            // Add the hidden field
            Output.WriteLine("<!-- Hidden field is used for postbacks to indicate what to save and reset -->");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_heading_action\" name=\"admin_heading_action\" value=\"\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_heading_tosave\" name=\"admin_heading_tosave\" value=\"\" />");
            Output.WriteLine();

            Output.WriteLine("<!-- Thematic Heading Edit Form -->");
            Output.WriteLine("<div class=\"sbkThav_PopupDiv\" id=\"form_heading\" style=\"display:none;\">");
            Output.WriteLine("  <div class=\"sbkAdm_PopupTitle\"><table style=\"width:100%;\"><tr><td style=\"text-align: left;\">EDIT THEMATIC HEADING</td><td style=\"text-align:right;\"> <a href=\"#template\" alt=\"CLOSE\" onclick=\"heading_form_close()\">X</a> &nbsp; </td></tr></table></div>");
            Output.WriteLine("  <br />");
            Output.WriteLine("  <table class=\"sbkAdm_PopupTable\">");

            // Add line for heading
            Output.WriteLine("    <tr><td style=\"width: 80px;\"><label for=\"form_heading_name\">Heading:</label></td><td colspan=\"2\"><input class=\"sbkThav_input sbkAdmin_Focusable\" name=\"form_heading_name\" id=\"form_heading_name\" type=\"text\" value=\"\" /></td></tr>");

            // Add the buttons
            Output.WriteLine("    <tr style=\"height:35px; text-align: center; vertical-align: bottom;\">");
            Output.WriteLine("      <td colspan=\"2\">");
            Output.WriteLine("        <button title=\"Do not apply changes\" class=\"sbkAdm_RoundButton\" onclick=\"return heading_form_close();\"><img src=\"" + Static_Resources_Gateway.Button_Previous_Arrow_Png + "\" class=\"sbkAdm_RoundButton_LeftImg\" alt=\"\" /> CANCEL</button> &nbsp; &nbsp; ");
            Output.WriteLine("        <button title=\"Save changes to this existing thematic heading\" class=\"sbkAdm_RoundButton\" type=\"submit\">SAVE <img src=\"" + Static_Resources_Gateway.Button_Next_Arrow_Png + "\" class=\"sbkAdm_RoundButton_RightImg\" alt=\"\" /></button> &nbsp; &nbsp; ");
            Output.WriteLine("      </td>");
            Output.WriteLine("    </tr>");
            Output.WriteLine("  </table>");
            Output.WriteLine("</div>");
            Output.WriteLine();


            Tracer.Add_Trace("Thematic_Headings_AdminViewer.Write_ItemNavForm_Closing", "Write the rest of the form ");

            Output.WriteLine("<script src=\"" + Static_Resources_Gateway.Sobekcm_Admin_Js + "\" type=\"text/javascript\"></script>");
            Output.WriteLine("<div class=\"sbkAdm_HomeText\">");

            if (actionMessage.Length > 0)
            {
                Output.WriteLine("  <br />");
                Output.WriteLine("  <div id=\"sbkAdm_ActionMessage\">" + actionMessage + "</div>");
            }

            Output.WriteLine("  <p>Thematic headings are the headings on the main library home page, under which all the item aggregation icons appear.</p>");
            Output.WriteLine("  <p>For more information about thematic headings, <a href=\"" + UI_ApplicationCache_Gateway.Settings.System.Help_URL(RequestSpecificValues.Current_Mode.Base_URL) + "adminhelp/headings\" target=\"ADMIN_USER_HELP\" >click here to view the help page</a>.</p>");
            Output.WriteLine();

            Output.WriteLine("  <h2>New Thematic Heading</h2>");
            Output.WriteLine("  <div class=\"sbkThav_NewDiv\">");
            Output.WriteLine("    <table class=\"sbkAdm_PopupTable\">");
            Output.WriteLine("      <tr>");
            Output.WriteLine("        <td><label for=\"admin_heading_name\">Heading:</label></td>");
            Output.WriteLine("        <td><input class=\"sbkThav_input sbkAdmin_Focusable\" name=\"admin_heading_name\" id=\"admin_heading_name\" type=\"text\" value=\"\" /></td>");
            Output.WriteLine("        <td><button title=\"Save new thematic heading\" class=\"sbkAdm_RoundButton\" onclick=\"return save_new_heading();\">SAVE <img src=\"" + Static_Resources_Gateway.Button_Next_Arrow_Png + "\" class=\"sbkAdm_RoundButton_RightImg\" alt=\"\" /></button></td>");
            Output.WriteLine("      </tr>");
            Output.WriteLine("    </table>");
            Output.WriteLine("  </div>");
            Output.WriteLine("  <br />");

            Output.WriteLine("  <h2>Existing Thematic Headings</h2>");
            Output.WriteLine("  <table class=\"sbkThav_Table sbkAdm_Table\">");
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <th class=\"sbkThav_TableHeader1\">ACTIONS</th>");
            Output.WriteLine("      <th class=\"sbkThav_TableHeader2\">REORDER</th>");
            Output.WriteLine("      <th class=\"sbkThav_TableHeader3\">THEMATIC HEADING</th>");
            Output.WriteLine("     </tr>");
            Output.WriteLine("     <tr><td class=\"sbkAdm_TableRule\" colspan=\"3\"></td></tr>");

            // Write the data for each interface
            int current_order = 1;

            foreach (Thematic_Heading thisTheme in UI_ApplicationCache_Gateway.Thematic_Headings)
            {
                // Build the action links
                Output.WriteLine("    <tr style=\"text-align:left;\" >");
                Output.Write("      <td class=\"sbkAdm_ActionLink\" >( ");
                Output.Write("<a title=\"Click to edit\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return heading_form_popup('" + thisTheme.Text + "','" + thisTheme.ID + "');\">edit</a> | ");
                Output.WriteLine("<a title=\"Delete this thematic heading\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return delete_heading('" + thisTheme.ID + "', '" + thisTheme.Text.Replace("\'", "") + "');\">delete</a> )</td>");

                Output.Write("      <td class=\"sbkAdm_ActionLink\">( ");
                Output.Write("<a title=\"Move this heading up in the order\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return move_heading_up('" + thisTheme.ID + "', '" + current_order + "');\">up</a> | ");
                Output.WriteLine("<a title=\"Move this heading down in the order\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return move_heading_down('" + thisTheme.ID + "', '" + current_order + "');\">down</a> )</td>");

                // Add the rest of the row with data
                Output.WriteLine("      <td>" + thisTheme.Text + "</td>");
                Output.WriteLine("    </tr>");
                Output.WriteLine("    <tr><td class=\"sbkAdm_TableRule\" colspan=\"3\"></td></tr>");

                current_order++;
            }

            Output.WriteLine("  </table>");
            Output.WriteLine("  <br />");
            Output.WriteLine("</div>");
            Output.WriteLine();
        }
        /// <summary> This is an opportunity to write HTML directly into the main form, without
        /// using the pop-up html form architecture </summary>
        /// <param name="Output"> Textwriter to write the pop-up form HTML for this viewer </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> This text will appear within the ItemNavForm form tags </remarks>
        public override void Write_ItemNavForm_Closing(TextWriter Output, Custom_Tracer Tracer)
        {
            Output.WriteLine("<!-- IP_Restrictions_AdminViewer.Write_ItemNavForm_Closing -->");

            // Add the stylesheet(s)and javascript  needed
            Output.WriteLine("<script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/sobekcm_admin.js\" ></script>");
            Output.WriteLine();

            // Add the hidden field
            Output.WriteLine("<!-- Hidden field is used for postbacks to indicate what to save and reset -->");
            if (thisRange != null)
            {
                Output.WriteLine("<input type=\"hidden\" id=\"rangeid\" name=\"rangeid\" value=\"" + thisRange.RangeID + "\" />");
            }
            Output.WriteLine("<input type=\"hidden\" id=\"action\" name=\"action\" value=\"\" />");
            Output.WriteLine();

            Output.WriteLine("<div class=\"sbkAdm_HomeText\">");

            if (!String.IsNullOrEmpty(actionMessage))
            {
                Output.WriteLine("  <br />");
                Output.WriteLine("  <div id=\"sbkAdm_ActionMessage\">" + actionMessage + "</div>");
            }

            if ((details != null) && (thisRange != null) && (details.Tables[0].Rows.Count > 0))
            {
                Tracer.Add_Trace("IP_Restrictions_AdminViewer.Write_ItemNavForm_Closing", "Display details regarding one IP restrictive range");

                // Assign some of the values from the details to the range
                thisRange.Title = details.Tables[0].Rows[0]["Title"].ToString();
                thisRange.Notes = details.Tables[0].Rows[0]["Notes"].ToString();

                // Add the save and cancel button and link to help
                currentMode.My_Sobek_SubMode = String.Empty;
                Output.WriteLine("  <br />");
                Output.WriteLine("  <table style=\"width:750px;\">");
                Output.WriteLine("    <tr>");
                Output.WriteLine("      <td> &nbsp; &nbsp; &nbsp; For clarification of any terms on this form, <a href=\"" + SobekCM_Library_Settings.Help_URL(currentMode.Base_URL) + "adminhelp/restrictions\" target=\"ADMIN_USER_HELP\" >click here to view the help page</a>.</td>");
                Output.WriteLine("      <td style=\"text-align:right\">");
                if (user.Is_System_Admin)
                {
                    Output.WriteLine("        <button title=\"Do not apply changes\" class=\"sbkAdm_RoundButton\" onclick=\"parent.location='" + currentMode.Redirect_URL() + "';return false;\"><img src=\"" + currentMode.Base_URL + "default/images/button_previous_arrow.png\" class=\"sbkAdm_RoundButton_LeftImg\" alt=\"\" /> CANCEL</button> &nbsp; &nbsp; ");
                    Output.WriteLine("        <button title=\"Save changes to this IP restriction range\" class=\"sbkAdm_RoundButton\" type=\"submit\">SAVE <img src=\"" + currentMode.Base_URL + "default/images/button_next_arrow.png\" class=\"sbkAdm_RoundButton_RightImg\" alt=\"\" /></button>");
                }
                else
                {
                    Output.WriteLine("        <button title=\"Do not apply changes\" class=\"sbkAdm_RoundButton\" onclick=\"parent.location='" + currentMode.Redirect_URL() + "';return false;\"><img src=\"" + currentMode.Base_URL + "default/images/button_previous_arrow.png\" class=\"sbkAdm_RoundButton_LeftImg\" alt=\"\" /> BACK</button> &nbsp; &nbsp; ");
                }
                Output.WriteLine("      </td>");
                Output.WriteLine("    </tr>");
                Output.WriteLine("  </table>");
                Output.WriteLine();

                // Add portal admin message
                string readonly_tag = String.Empty;
                int    columns      = 4;
                if (!user.Is_System_Admin)
                {
                    Output.WriteLine("<p>Portal Admins have rights to see these settings. System Admins can change these settings.</p>");
                    readonly_tag = " readonly=\"readonly\"";
                    columns      = 3;
                }

                // Add all the basic information
                Output.WriteLine("  <h2>Basic Information</h2>");
                Output.WriteLine("  <div class=\"sbkIpav_NewDiv\">");
                Output.WriteLine("    <table class=\"sbkAdm_PopupTable\">");

                // Add line for range title
                Output.WriteLine("      <tr>");
                Output.WriteLine("        <td style=\"width:120px;\"><label for=\"admin_title\">Title:</label></td>");
                Output.WriteLine("        <td><input class=\"sbkIpav_large_input sbkAdmin_Focusable\" name=\"admin_title\" id=\"admin_title\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(thisRange.Title) + "\" " + readonly_tag + " /></td>");
                Output.WriteLine("      </tr>");

                // Add the notes text area box
                Output.WriteLine("      <tr style=\"vertical-align:top\"><td><label for=\"admin_notes\">Notes:</label></td><td colspan=\"2\"><textarea rows=\"5\" name=\"admin_notes\" id=\"admin_notes\" class=\"sbkIpav_input sbkAdmin_Focusable\"" + readonly_tag + ">" + HttpUtility.HtmlEncode(thisRange.Notes) + "</textarea></td></tr>");

                // Add the message text area box
                Output.WriteLine("      <tr style=\"vertical-align:top\"><td><label for=\"admin_message\">Message:</label></td><td colspan=\"2\"><textarea rows=\"10\" name=\"admin_message\" id=\"admin_message\" class=\"sbkIpav_input sbkAdmin_Focusable\"" + readonly_tag + " >" + HttpUtility.HtmlEncode(thisRange.Item_Restricted_Statement) + "</textarea></td></tr>");

                Output.WriteLine("    </table>");
                Output.WriteLine("  </div>");
                Output.WriteLine();

                Output.WriteLine("  <h2>IP Addresses</h2>");

                Output.WriteLine("  <table class=\"sbkIpav_Table sbkAdm_Table\">");
                Output.WriteLine("    <tr>");
                if (user.Is_System_Admin)
                {
                    Output.WriteLine("      <th class=\"sbkIpav_TableHeader1\">ACTIONS</th>");
                }
                Output.WriteLine("      <th class=\"sbkIpav_TableHeader2\">START IP</th>");
                Output.WriteLine("      <th class=\"sbkIpav_TableHeader3\">END IP</th>");
                Output.WriteLine("      <th class=\"sbkIpav_TableHeader4\">LABEL</th>");
                Output.WriteLine("    </tr>");

                foreach (DataRow thisRow in details.Tables[1].Rows)
                {
                    // Get the primary key for this IP address
                    string ip_primary = thisRow["IP_SingleID"].ToString();

                    // Build the action links
                    Output.WriteLine("    <tr>");

                    if (user.Is_System_Admin)
                    {
                        Output.WriteLine("      <td class=\"sbkAdm_ActionLink\" >( <a title=\"Click to clear this ip address\" href=\"" + currentMode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return clear_ip_address('" + ip_primary + "');\">clear</a> )</td>");
                    }

                    // Add the rest of the row with data
                    Output.WriteLine("      <td><input class=\"sbkIpav_small_input sbkAdmin_Focusable\" name=\"admin_ipstart_" + ip_primary + "\" id=\"admin_ipstart_" + ip_primary + "\" type=\"text\" value=\"" + thisRow["StartIP"].ToString().Trim() + "\" /></td>");
                    Output.WriteLine("      <td><input class=\"sbkIpav_small_input sbkAdmin_Focusable\" name=\"admin_ipend_" + ip_primary + "\" id=\"admin_ipend_" + ip_primary + "\" type=\"text\" value=\"" + thisRow["EndIP"].ToString().Trim() + "\" /></td>");
                    Output.WriteLine("      <td><input class=\"sbkIpav_medium_input sbkAdmin_Focusable\" name=\"admin_iplabel_" + ip_primary + "\" id=\"admin_iplabel_" + ip_primary + "\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(thisRow["Notes"].ToString().Trim()) + "\" /></td>");
                    Output.WriteLine("     </tr>");
                    Output.WriteLine("    <tr><td class=\"sbkAdm_TableRule\" colspan=\"" + columns + "\"></td></tr>");
                }


                // Now, always add ten empty IP rows here, for system administrators
                if (user.Is_System_Admin)
                {
                    for (int i = 1; i < 10; i++)
                    {
                        Output.WriteLine("    <tr>");
                        Output.WriteLine("      <td class=\"sbkAdm_ActionLink\" >( <a title=\"Click to clear this ip address\" href=\"" + currentMode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return clear_ip_address('new" + i + "');\">clear</a> )</td>");

                        // Add the rest of the row with data
                        Output.WriteLine("      <td><input class=\"sbkIpav_small_input sbkAdmin_Focusable\" name=\"admin_ipstart_new" + i + "\" id=\"admin_ipstart_new" + i + "\" type=\"text\" value=\"\" /></td>");
                        Output.WriteLine("      <td><input class=\"sbkIpav_small_input sbkAdmin_Focusable\" name=\"admin_ipend_new" + i + "\" id=\"admin_ipend_new" + i + "\" type=\"text\" value=\"\" /></td>");
                        Output.WriteLine("      <td><input class=\"sbkIpav_medium_input sbkAdmin_Focusable\" name=\"admin_iplabel_new" + i + "\" id=\"admin_iplabel_new" + i + "\" type=\"text\" value=\"\" /></td>");
                        Output.WriteLine("    </tr>");
                        Output.WriteLine("    <tr><td class=\"sbkAdm_TableRule\" colspan=\"4\"></td></tr>");
                    }
                }

                Output.WriteLine("  </table>");
                Output.WriteLine("</div>");

                return;
            }

            Tracer.Add_Trace("IP_Restrictions_AdminViewer.Write_ItemNavForm_Closing", "Display main IP restrictive range admin form");


            Output.WriteLine("  <p>Restrictive ranges of IP addresses may be used to restrict access to digital resources.  This form allows system administrators to edit the individual IP addresses and contiguous IP addresses associated with an existing restrictive range.</p>");
            Output.WriteLine("  <p>For more information about IP restriction ranges and this form, <a href=\"" + SobekCM_Library_Settings.Help_URL(currentMode.Base_URL) + "adminhelp/restrictions\" target=\"ADMIN_USER_HELP\" >click here to view the help page</a>.</p>");
            Output.WriteLine();

            if (user.Is_System_Admin)
            {
                // Add all the basic information
                Output.WriteLine("  <h2>New IP Restrictive Range</h2>");
                Output.WriteLine("  <div class=\"sbkIpav_NewDiv\">");
                Output.WriteLine("    <table class=\"sbkAdm_PopupTable\">");

                // Add line for range title
                Output.WriteLine("      <tr>");
                Output.WriteLine("        <td style=\"width:120px;\"><label for=\"admin_title\">Title:</label></td>");
                Output.WriteLine("        <td><input class=\"sbkIpav_large_input sbkAdmin_Focusable\" name=\"new_admin_title\" id=\"new_admin_title\" type=\"text\" value=\"\" /></td>");
                Output.WriteLine("      </tr>");

                // Add the notes text area box
                Output.WriteLine("      <tr style=\"vertical-align:top\"><td><label for=\"admin_notes\">Notes:</label></td><td colspan=\"2\"><textarea rows=\"5\" name=\"new_admin_notes\" id=\"new_admin_notes\" class=\"sbkIpav_input sbkAdmin_Focusable\" ></textarea></td></tr>");

                // Add the message text area box
                Output.WriteLine("      <tr style=\"vertical-align:top\"><td><label for=\"admin_message\">Message:</label></td><td colspan=\"2\"><textarea rows=\"10\" name=\"new_admin_message\" id=\"new_admin_message\" class=\"sbkIpav_input sbkAdmin_Focusable\" ></textarea></td></tr>");
                // Add the SAVE button
                Output.WriteLine("      <tr style=\"height:30px; text-align: center;\"><td></td><td><button title=\"Save new IP restrictive range\" class=\"sbkAdm_RoundButton\" onclick=\"return save_new_ip_range();\">SAVE <img src=\"" + currentMode.Base_URL + "default/images/button_next_arrow.png\" class=\"sbkAdm_RoundButton_RightImg\" alt=\"\" /></button></td></tr>");
                Output.WriteLine("    </table>");
                Output.WriteLine("  </div>");
                Output.WriteLine();
            }
            else
            {
                // Add portal admin message
                Output.WriteLine("<p>Portal Admins have rights to see these settings. System Admins can change these settings.</p>");
            }

            Output.WriteLine("  <h2>Existing Ranges</h2>");
            if (ipRestrictionInfo.Count == 0)
            {
                Output.WriteLine("  <p>No existing IP restrictive ranges exist.</p>");
                if (user.Is_System_Admin)
                {
                    Output.WriteLine("<p>To add one, enter the information above and press SAVE.</p>");
                }
            }
            else
            {
                Output.WriteLine("  <p>Select an IP restrictive range below to view or edit:</p>");
                Output.WriteLine("  <ul id=\"sbkIpav_RangeList\">");

                for (int i = 0; i < ipRestrictionInfo.Count; i++)
                {
                    currentMode.My_Sobek_SubMode = ipRestrictionInfo[i].RangeID.ToString();
                    Output.WriteLine("<li><a href=\"" + currentMode.Redirect_URL() + "\">" + ipRestrictionInfo[i].Title + "</a></li>");
                }

                Output.WriteLine("  </ul>");
            }

            Output.WriteLine("</div>");
        }
示例#49
0
        /// <summary> Adds any viewer_specific information to the item viewer above the standard pagination buttons </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 void Write_Top_Additional_Navigation_Row(TextWriter Output, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("Related_Images_ItemViewer.Write_Top_Additional_Navigation_Row", "");
            }

            string       numOfThumbnails   = "thumbnails per page";
            string       goToThumbnail     = "Go to thumbnail";
            const string SMALL_THUMBNAILS  = "Switch to small thumbnails";
            const string MEDIUM_THUMBNAILS = "Switch to medium thumbnails";
            const string LARGE_THUMBNAILS  = "Switch to large thumbnails";

            if (currentRequest.Language == Web_Language_Enum.French)
            {
                numOfThumbnails = "vignettes par page";
                //Size_Of_Thumbnail = "la taille des vignettes";
                goToThumbnail = "Aller à l'Vignette";
            }

            if (currentRequest.Language == Web_Language_Enum.Spanish)
            {
                numOfThumbnails = "miniaturas por página";
                //Size_Of_Thumbnail = "Miniatura de tamaño";
                goToThumbnail = "Ir a la miniatura";
            }

            //Start building the top nav bar
            Output.WriteLine("<tr>");
            Output.WriteLine("<td>");
            Output.WriteLine("\t\t<!-- RELATED IMAGES VIEWER TOP NAV ROW -->");

            //Include the js files
            Output.WriteLine("<script type=\"text/javascript\" src=\"" + Static_Resources_Gateway.Jquery_Ui_1_10_3_Custom_Js + "\"></script>");
            Output.WriteLine("<script type=\"text/javascript\" src=\"" + Static_Resources_Gateway.Jquery_Color_2_1_1_Js + "\"></script>");
            Output.WriteLine("<table style=\"width: 100%\">");
            Output.WriteLine("\t<tr>");

            //Add the dropdown for the number of thumbnails per page, only if there are >25 thumbnails
            if (pageCount > 25)
            {
                //Redirect to the first page of results when the number of thumbnails option is changed by the user
                string current_viewercode = currentRequest.ViewerCode;
                UrlWriterHelper.Redirect_URL(currentRequest, "thumbs");

                //   currentRequest.Thumbnails_Per_Page = -1;
                //  string current_Page_url = UrlWriterHelper.Redirect_URL(currentRequest, "1thumbs");

                // Collect the list of options to display
                List <int> thumbsOptions = new List <int> {
                    25
                };
                if (pageCount > 50)
                {
                    thumbsOptions.Add(50);
                }
                if (pageCount > 100)
                {
                    thumbsOptions.Add(100);
                }
                if (pageCount > 250)
                {
                    thumbsOptions.Add(250);
                }
                if (pageCount > 500)
                {
                    thumbsOptions.Add(500);
                }

                // Start the drop down select list
                Output.WriteLine("\t\t<td style=\"valign:top;text-align:left;padding-left: 20px;\">");
                Output.WriteLine("\t\t\t<select id=\"selectNumOfThumbnails\" onchange=\"location=this.options[this.selectedIndex].value;\">");

                // Step through all the options
                foreach (int thumbOption in thumbsOptions)
                {
                    currentRequest.Thumbnails_Per_Page = (short)thumbOption;
                    if (thumbnailsPerPage == thumbOption)
                    {
                        Output.WriteLine("\t\t\t\t<option value=\"" + UrlWriterHelper.Redirect_URL(currentRequest) + "\" selected=\"selected\">" + thumbOption + " " + numOfThumbnails + "</option>");
                    }
                    else
                    {
                        Output.WriteLine("\t\t\t\t<option value=\"" + UrlWriterHelper.Redirect_URL(currentRequest) + "\">" + thumbOption + " " + numOfThumbnails + "</option>");
                    }
                }

                currentRequest.Thumbnails_Per_Page = -1;
                if (thumbnailsPerPage == int.MaxValue)
                {
                    Output.WriteLine("\t\t\t\t<option value=\"" + UrlWriterHelper.Redirect_URL(currentRequest) + "\" selected=\"selected\">All thumbnails</option>");
                }
                else
                {
                    Output.WriteLine("\t\t\t\t<option value=\"" + UrlWriterHelper.Redirect_URL(currentRequest) + "\">All thumbnails</option>");
                }

                //Reset the Current Mode Thumbnails_Per_Page

                currentRequest.ViewerCode = current_viewercode;
                Output.WriteLine("\t\t\t</select>");
                Output.WriteLine("\t\t</td>");
            }
            currentRequest.Thumbnails_Per_Page = -100;


            //Add the control for the thumbnail size

            //Get the icons for the thumbnail sizes
            Output.WriteLine("\t\t<td id=\"sbkRi_Thumbnailsizeselect\">");
            if (thumbnailSize == 1)
            {
                Output.Write("\t\t\t<img src=\"" + Static_Resources_Gateway.Thumbs3_Selected_Gif + "\" alt=\"Small\" />");
            }
            else
            {
                currentRequest.Size_Of_Thumbnails = 1;
                Output.Write("\t\t\t<a href=\"" + UrlWriterHelper.Redirect_URL(currentRequest, "thumbs") + "\" title=\"" + SMALL_THUMBNAILS + "\"><img src=\"" + Static_Resources_Gateway.Thumbs3_Gif + "\" alt=\"Small\" /></a>");
            }

            if (thumbnailSize == 2)
            {
                Output.Write("<img src=\"" + Static_Resources_Gateway.Thumbs2_Selected_Gif + "\" alt=\"Medium\" />");
            }
            else
            {
                currentRequest.Size_Of_Thumbnails = 2;
                Output.Write("<a href=\"" + UrlWriterHelper.Redirect_URL(currentRequest, "thumbs") + "\" title=\"" + MEDIUM_THUMBNAILS + "\"><img src=\"" + Static_Resources_Gateway.Thumbs2_Gif + "\" alt=\"Medium\" /></a>");
            }
            if (thumbnailSize == 3)
            {
                Output.Write("<img src=\"" + Static_Resources_Gateway.Thumbs2_Selected_Gif + "\" alt=\"Large\" />");
            }
            else
            {
                currentRequest.Size_Of_Thumbnails = 3;
                Output.Write("<a href=\"" + UrlWriterHelper.Redirect_URL(currentRequest, "thumbs") + "\" title=\"" + LARGE_THUMBNAILS + "\"><img src=\"" + Static_Resources_Gateway.Thumbs1_Gif + "\" alt=\"Large\" /></a>");
            }
            //Reset the current mode
            currentRequest.Size_Of_Thumbnails = -1;
            Output.WriteLine("\t\t</td>");


            //Add the dropdown for the thumbnail anchor within the page to directly navigate to
            Output.WriteLine("\t\t<td style=\"valign:top;text-align:right;font-weight:bold;padding-right: 20px;\">");
            Output.WriteLine(goToThumbnail + ":");
            Output.WriteLine("\t\t\t<select onchange=\"location=this.options[this.selectedIndex].value; AddAnchorDivEffect(this.options[this.selectedIndex].value);\" >");

            //iterate through the page items and add each label?
            if (pageCount > 0)
            {
                int thumbnail_count = 0;
                foreach (BriefItem_FileGrouping thisFile in briefItem.Images)
                {
                    string currentPageURL1 = UrlWriterHelper.Redirect_URL(currentRequest, (thumbnail_count / thumbnailsPerPage + (thumbnail_count % thumbnailsPerPage == 0 ? 0 : 1)).ToString() + "thumbs");

                    //  Output.WriteLine("<option value=\"" + current_Page_url1 + "#" + thisFile.Label + "\">" + thisFile.Label + "</option>");
                    if (String.IsNullOrEmpty(thisFile.Label))
                    {
                        Output.WriteLine("\t\t\t\t<option value=\"" + currentPageURL1 + "#" + thumbnail_count + "\">" + "(page " + thumbnail_count + ")" + "</option>");
                    }
                    else
                    {
                        if (thisFile.Label.Length > 50)
                        {
                            Output.WriteLine("\t\t\t\t<option value=\"" + currentPageURL1 + "#" + thumbnail_count + "\">" + thisFile.Label.Substring(0, 50) + "...</option>");
                        }
                        else
                        {
                            Output.WriteLine("\t\t\t\t<option value=\"" + currentPageURL1 + "#" + thumbnail_count + "\">" + thisFile.Label + "</option>");
                        }
                    }

                    thumbnail_count++;
                }
            }
            Output.WriteLine("\t\t\t</select>");

            Output.WriteLine("\t\t</td>");
            Output.WriteLine("\t</tr>");
            Output.WriteLine("</table>");

            // Finish the nav row controls
            Output.WriteLine("\t\t<!-- END RELATED IMAGES VIEWER NAV ROW -->");
            Output.WriteLine("\t\t</td>");
            Output.WriteLine("\t</tr>");
        }
示例#50
0
        /// <summary> Adds the controls for this result viewer to the place holder on the main form </summary>
        /// <param name="placeHolder"> Main place holder ( &quot;mainPlaceHolder&quot; ) in the itemNavForm form into which the the bulk of the result viewer's output is displayed</param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        /// <returns> Sorted tree with the results in hierarchical structure with volumes and issues under the titles and sorted by serial hierarchy </returns>
        public override void Add_HTML(PlaceHolder placeHolder, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("Export_File_ResultsViewer.Add_HTML", "Rendering results in text view");
            }

            //// Sort this by BIbID
            //resultTable.Sort("BibID");

            //// Determine which rows to display
            //int lastRow = base.LastRow;
            //int startRow = base.StartRow(lastRow);

            //// prepare to step through each title to display
            //List<SobekCM_Item_Collection.SobekCM_Item_Row> itemRows = new List<SobekCM_Item_Collection.SobekCM_Item_Row>();

            // Prepare to build an output
            StringBuilder resultsBldr = new StringBuilder(5000);

            int currentPage = CurrentMode.Page;

            if (currentPage < 2)
            {
                resultsBldr.Append("<br />" + Environment.NewLine + "<div class=\"SobekHomeText\">" + Environment.NewLine + "<blockquote>" + Environment.NewLine);
                resultsBldr.Append("This option allows you to export the list of results which match your search or browse to an excel document or CSV file for download.<br /><br />");
                resultsBldr.Append("Select the file type below to create the report:");
                resultsBldr.Append("<blockquote>");

                //currentMode.Page = 2;
                //resultsBldr.Append("<a href=\"" + currentMode.Redirect_URL() + "\">Excel Spreadsheet file (XLSX)</a><br /><br />");

                CurrentMode.Page = 3;
                resultsBldr.Append("<a href=\"" + CurrentMode.Redirect_URL() + "\">Excel Spreadsheet file (XLS)</a><br /><br />");

                CurrentMode.Page = 4;
                resultsBldr.Append("<a href=\"" + CurrentMode.Redirect_URL() + "\">Comma-seperated value text file (CSV)</a><br /><br />");

                //currentMode.Page = 5;
                //resultsBldr.Append("<a href=\"" + currentMode.Redirect_URL() + "\">HTML Table (HTML)</a><br /><br />");


                resultsBldr.Append("</blockquote>");
                resultsBldr.Append("</blockquote>");
                resultsBldr.Append("<br /><br />");
                resultsBldr.Append("</div>");

                // Add this to the page
                Literal mainLiteral = new Literal {
                    Text = resultsBldr.ToString()
                };
                placeHolder.Controls.Add(mainLiteral);
            }
            else
            {
                string filename = CurrentMode.SobekCM_Instance_Name;

                // Set the Gembox spreadsheet license key
                SpreadsheetInfo.SetLicense("EDWF-ZKV9-D793-1D2A");

                // Create the excel file and worksheet
                ExcelFile      excelFile  = new ExcelFile();
                ExcelWorksheet excelSheet = excelFile.Worksheets.Add(CurrentMode.SobekCM_Instance_Name);
                excelFile.Worksheets.ActiveWorksheet = excelSheet;

                // Create the header cell style
                CellStyle headerStyle = new CellStyle
                {
                    HorizontalAlignment = HorizontalAlignmentStyle.Left, Font = { Weight = ExcelFont.BoldWeight }
                };
                headerStyle.FillPattern.SetSolid(Color.Yellow);
                headerStyle.Borders.SetBorders(MultipleBorders.Outside, Color.Black, LineStyle.Thin);

                // Create the title cell style
                CellStyle titleStyle = new CellStyle
                {
                    HorizontalAlignment = HorizontalAlignmentStyle.Left, Font = { Weight = ExcelFont.BoldWeight, Size = 12 * 20 }
                };

                // Set the default style
                CellStyle defaultStyle = new CellStyle();
                defaultStyle.Borders.SetBorders(MultipleBorders.Outside, Color.Black, LineStyle.Thin);

                const int columnSelector = 0;
                int       row            = 0;

                if (CurrentMode.Page != 4)
                {
                    // Add the title
                    excelSheet.Cells[1, columnSelector].Value = "Search or browse result list";
                    excelSheet.Cells[1, columnSelector].Style = titleStyle;
                    row = 3;
                }

                // Add the column headers
                excelSheet.Cells[row, columnSelector].Value      = "System ID";
                excelSheet.Cells[row, columnSelector].Style      = headerStyle;
                excelSheet.Cells[row, columnSelector + 1].Value  = "Link";
                excelSheet.Cells[row, columnSelector + 1].Style  = headerStyle;
                excelSheet.Cells[row, columnSelector + 2].Value  = "Group Title";
                excelSheet.Cells[row, columnSelector + 2].Style  = headerStyle;
                excelSheet.Cells[row, columnSelector + 3].Value  = "Item Title";
                excelSheet.Cells[row, columnSelector + 3].Style  = headerStyle;
                excelSheet.Cells[row, columnSelector + 4].Value  = "Date";
                excelSheet.Cells[row, columnSelector + 4].Style  = headerStyle;
                excelSheet.Cells[row, columnSelector + 5].Value  = "Author";
                excelSheet.Cells[row, columnSelector + 5].Style  = headerStyle;
                excelSheet.Cells[row, columnSelector + 6].Value  = "Publisher";
                excelSheet.Cells[row, columnSelector + 6].Style  = headerStyle;
                excelSheet.Cells[row, columnSelector + 7].Value  = "Format";
                excelSheet.Cells[row, columnSelector + 7].Style  = headerStyle;
                excelSheet.Cells[row, columnSelector + 8].Value  = "Edition";
                excelSheet.Cells[row, columnSelector + 8].Style  = headerStyle;
                excelSheet.Cells[row, columnSelector + 9].Value  = "Subjects";
                excelSheet.Cells[row, columnSelector + 9].Style  = headerStyle;
                excelSheet.Cells[row, columnSelector + 10].Value = "Measurement";
                excelSheet.Cells[row, columnSelector + 10].Style = headerStyle;
                excelSheet.Cells[row, columnSelector + 11].Value = "Style / Period";
                excelSheet.Cells[row, columnSelector + 11].Style = headerStyle;
                excelSheet.Cells[row, columnSelector + 12].Value = "Technique";
                excelSheet.Cells[row, columnSelector + 12].Style = headerStyle;
                excelSheet.Cells[row, columnSelector + 13].Value = "Institution";
                excelSheet.Cells[row, columnSelector + 13].Style = headerStyle;
                excelSheet.Cells[row, columnSelector + 14].Value = "Donor";
                excelSheet.Cells[row, columnSelector + 14].Style = headerStyle;
                excelSheet.Cells[row, columnSelector + 15].Value = "OCLC";
                excelSheet.Cells[row, columnSelector + 15].Style = headerStyle;
                excelSheet.Cells[row, columnSelector + 16].Value = "ALEPH";
                excelSheet.Cells[row, columnSelector + 16].Style = headerStyle;
                excelSheet.Cells[row, columnSelector + 17].Value = "Serial1";
                excelSheet.Cells[row, columnSelector + 17].Style = headerStyle;
                excelSheet.Cells[row, columnSelector + 18].Value = "Serial2";
                excelSheet.Cells[row, columnSelector + 18].Style = headerStyle;
                excelSheet.Cells[row, columnSelector + 19].Value = "Serial3";
                excelSheet.Cells[row, columnSelector + 19].Style = headerStyle;

                // Set the correct widths
                excelSheet.Columns[columnSelector].Width      = 12 * 256;
                excelSheet.Columns[columnSelector + 1].Width  = 8 * 256;
                excelSheet.Columns[columnSelector + 2].Width  = 40 * 256;
                excelSheet.Columns[columnSelector + 3].Width  = 40 * 256;
                excelSheet.Columns[columnSelector + 4].Width  = 20 * 256;
                excelSheet.Columns[columnSelector + 5].Width  = 14 * 256;
                excelSheet.Columns[columnSelector + 6].Width  = 14 * 256;
                excelSheet.Columns[columnSelector + 7].Width  = 20 * 256;
                excelSheet.Columns[columnSelector + 8].Width  = 20 * 256;
                excelSheet.Columns[columnSelector + 9].Width  = 20 * 256;
                excelSheet.Columns[columnSelector + 10].Width = 20 * 256;
                excelSheet.Columns[columnSelector + 11].Width = 20 * 256;
                excelSheet.Columns[columnSelector + 12].Width = 20 * 256;
                excelSheet.Columns[columnSelector + 13].Width = 20 * 256;
                excelSheet.Columns[columnSelector + 14].Width = 20 * 256;
                excelSheet.Columns[columnSelector + 15].Width = 20 * 256;
                excelSheet.Columns[columnSelector + 16].Width = 20 * 256;
                excelSheet.Columns[columnSelector + 17].Width = 20 * 256;
                excelSheet.Columns[columnSelector + 18].Width = 20 * 256;
                excelSheet.Columns[columnSelector + 19].Width = 20 * 256;
                row++;

                // Add each row
                foreach (iSearch_Title_Result titleResult in Paged_Results)
                {
                    for (int item_count = 0; item_count < titleResult.Item_Count; item_count++)
                    {
                        iSearch_Item_Result itemResult = titleResult.Get_Item(item_count);

                        excelSheet.Cells[row, columnSelector].Value      = titleResult.BibID + "_" + itemResult.VID;
                        excelSheet.Cells[row, columnSelector + 1].Value  = CurrentMode.Base_URL + titleResult.BibID + "/" + itemResult.VID;
                        excelSheet.Cells[row, columnSelector + 2].Value  = titleResult.GroupTitle.Replace("<i>", "").Replace("</i>", "").Replace("&amp;", "&");
                        excelSheet.Cells[row, columnSelector + 3].Value  = itemResult.Title.Replace("<i>", "").Replace("</i>", "").Replace("&amp;", "&");
                        excelSheet.Cells[row, columnSelector + 4].Value  = itemResult.PubDate.Replace("<i>", "").Replace("</i>", "").Replace("&amp;", "&");
                        excelSheet.Cells[row, columnSelector + 5].Value  = titleResult.Author.Replace("<i>", "").Replace("</i>", "").Replace("&amp;", "&");
                        excelSheet.Cells[row, columnSelector + 6].Value  = titleResult.Publisher.Replace("<i>", "").Replace("</i>", "").Replace("&amp;", "&");
                        excelSheet.Cells[row, columnSelector + 7].Value  = titleResult.Format.Replace("<i>", "").Replace("</i>", "").Replace("&amp;", "&");
                        excelSheet.Cells[row, columnSelector + 8].Value  = titleResult.Edition.Replace("<i>", "").Replace("</i>", "").Replace("&amp;", "&");
                        excelSheet.Cells[row, columnSelector + 9].Value  = titleResult.Subjects.Replace("<i>", "").Replace("</i>", "").Replace("&amp;", "&");
                        excelSheet.Cells[row, columnSelector + 10].Value = titleResult.Measurement.Replace("<i>", "").Replace("</i>", "").Replace("&amp;", "&");
                        excelSheet.Cells[row, columnSelector + 11].Value = titleResult.Style_Period.Replace("<i>", "").Replace("</i>", "").Replace("&amp;", "&");
                        excelSheet.Cells[row, columnSelector + 12].Value = titleResult.Technique.Replace("<i>", "").Replace("</i>", "").Replace("&amp;", "&");
                        excelSheet.Cells[row, columnSelector + 13].Value = titleResult.Institution.Replace("<i>", "").Replace("</i>", "").Replace("&amp;", "&");
                        excelSheet.Cells[row, columnSelector + 14].Value = titleResult.Donor.Replace("<i>", "").Replace("</i>", "").Replace("&amp;", "&");
                        if (titleResult.OCLC_Number > 1)
                        {
                            excelSheet.Cells[row, columnSelector + 15].Value = titleResult.OCLC_Number.ToString();
                        }
                        if (titleResult.ALEPH_Number > 1)
                        {
                            excelSheet.Cells[row, columnSelector + 16].Value = titleResult.ALEPH_Number.ToString();
                        }
                        excelSheet.Cells[row, columnSelector + 17].Value = itemResult.Level1_Text.Replace("<i>", "").Replace("</i>", "").Replace("&amp;", "&");
                        excelSheet.Cells[row, columnSelector + 18].Value = itemResult.Level2_Text.Replace("<i>", "").Replace("</i>", "").Replace("&amp;", "&");
                        excelSheet.Cells[row, columnSelector + 19].Value = itemResult.Level3_Text.Replace("<i>", "").Replace("</i>", "").Replace("&amp;", "&");

                        row++;
                    }
                }

                // Set the border
                excelSheet.Cells.GetSubrange("A4", "T" + row).SetBorders(MultipleBorders.Outside, Color.Black, LineStyle.Medium);
                excelSheet.Cells.GetSubrange("A4", "t4").SetBorders(MultipleBorders.Outside, Color.Black, LineStyle.Medium);

                if (Tracer != null)
                {
                    Tracer.Add_Trace("Export_File_ResultsViewer.Add_HTML", "Clearing response");
                }

                // Clear any response until now
                HttpContext.Current.Response.Clear();


                // Output in proper format to the user
                switch (CurrentMode.Page)
                {
                //case 2:
                //    System.Web.HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats";
                //    System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + filename + ".xlsx");
                //    // With XLSX it is a bit more complicated as MS Packaging API can't write
                //    // directly to Response.OutputStream. Therefore we use temporary MemoryStream.
                //    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                //    excelFile.SaveXlsx(ms);
                //    ms.WriteTo(System.Web.HttpContext.Current.Response.OutputStream);
                //    break;


                case 3:
                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
                    HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + filename + ".xls");
                    excelFile.SaveXls(HttpContext.Current.Response.OutputStream);
                    break;

                case 4:
                    HttpContext.Current.Response.ContentType = "text/csv";
                    HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + filename + ".csv");
                    excelFile.SaveCsv(HttpContext.Current.Response.OutputStream, CsvType.CommaDelimited);
                    break;

                    //case 5:
                    //    System.Web.HttpContext.Current.Response.ContentType = "text/html";
                    //    System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + "Report18.html");
                    //    System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(System.Web.HttpContext.Current.Response.OutputStream, new UTF8Encoding(false));
                    //    excelFile.SaveHtml(writer, null, true);
                    //    writer.Close();
                    //    break;
                }

                if (Tracer != null)
                {
                    Tracer.Add_Trace("Export_File_ResultsViewer.Add_HTML", "Ending response");
                }

                HttpContext.Current.Response.End();
            }
        }
        private void add_usage_definitions(TextWriter Output, Custom_Tracer Tracer)
        {
            // See if the FAQ is present for this collection
            string directory        = SobekCM_Library_Settings.Base_Design_Location + "\\extra\\stats";
            string usageDefinitions = String.Empty;

            if (Directory.Exists(directory))
            {
                if (File.Exists(directory + "\\stats_usage_definitions.txt"))
                {
                    if (Tracer != null)
                    {
                        Tracer.Add_Trace("Usage_Statistics_AggregationViewer.add_usage_definitions", "Loading usage definitions");
                    }

                    try
                    {
                        StreamReader faqReader = new StreamReader(directory + "\\stats_usage_definitions.txt");
                        usageDefinitions = faqReader.ReadToEnd();
                        faqReader.Close();
                    }
                    catch (Exception)
                    {
                        // If there is an error here, no problem.. just uses the default
                    }
                }
            }

            if (usageDefinitions.Length > 0)
            {
                string urloptions = currentMode.URL_Options();
                if (urloptions.Length > 0)
                {
                    urloptions = "?" + urloptions;
                }

                if (Tracer != null)
                {
                    Tracer.Add_Trace("Usage_Statistics_AggregationViewer.add_usage_definitions", "Rendering HTML read from source file");
                }
                Output.WriteLine("<div class=\"SobekText\">");
                Output.WriteLine(usageDefinitions.Replace("<%BASEURL%>", currentMode.Base_URL).Replace("<%?URLOPTS%>", urloptions));
                Output.WriteLine("</div>");
            }
            else
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("Usage_Statistics_AggregationViewer.add_usage_definitions", "Rendering Default HTML");
                }
                Output.WriteLine("<div class=\"SobekText\">");
                Output.WriteLine("<p>The following terms are defined below:</p>");

                Output.WriteLine("<table width=\"600px\" border=\"0\" align=\"center\">");
                Output.WriteLine("  <tr>");
                Output.WriteLine("    <td><a href=\"#Collection_Hierarchy\">Collection Hierarchy</a></td>");
                Output.WriteLine("    <td><a href=\"#Collection_Groups\">Collection Groups</a></td>");
                Output.WriteLine("    <td><a href=\"#Collections\">Collections</a></td>");
                Output.WriteLine("  </tr>");
                Output.WriteLine("  <tr>");
                Output.WriteLine("    <td><a href=\"#SubCollections\">SubCollections</a></td>");
                Output.WriteLine("    <td><a href=\"#Views\">Views</a></td>");
                Output.WriteLine("    <td><a href=\"#Visits\">Visits</a></td>");
                Output.WriteLine("  </tr>");
                Output.WriteLine("  <tr>");
                Output.WriteLine("    <td><a href=\"#Main_Pages\">Main Pages</a></td>");
                Output.WriteLine("    <td><a href=\"#Browses\">Browses</a></td>");
                Output.WriteLine("    <td><a href=\"#Titles_Items\">Titles and Items</a></td>");
                Output.WriteLine("  </tr>");
                Output.WriteLine("  <tr>");
                Output.WriteLine("    <td><a href=\"#Title_Views\">Title Views</a></td>");
                Output.WriteLine("    <td><a href=\"#Item_Views\">Item Views</a></td>");
                Output.WriteLine("    <td><a href=\"#Citation_Views\">Citation Views</a></td>");
                Output.WriteLine("  </tr>");
                Output.WriteLine("  <tr>");
                Output.WriteLine("    <td><a href=\"#Text_Searches\">Text Searches</a></td>");
                Output.WriteLine("    <td><a href=\"#Static_Views\">Static Views</a></td>");
                Output.WriteLine("    <td>&nbsp;</td>");
                Output.WriteLine("  </tr>");
                Output.WriteLine("</table>");

                Output.WriteLine("<h2>Defined Terms</h2>");
                Output.WriteLine();

                Output.WriteLine("<a name=\"Collection_Hierarchy\" ></a>");
                Output.WriteLine("<h3>COLLECTION HIERARCHY</h3>");
                Output.WriteLine("<p>Collections are organized by Collection Groups, which contain Collections and Collections contain Subcollections. This hierarchical organization allows for general searches and browses at the Collection Group level and for granular searches at the Collection level for optimum usability for multiple user needs. <br /><br />");
                Output.WriteLine("In reading the statistics by Collection, views and searches done from the main page and the Collection Group pages are not within collections and so are not included in the Collection statistics.</p>");

                Output.WriteLine("<a name=\"Collection_Groups\" ></a>");
                Output.WriteLine("<h3>COLLECTION GROUPS</h3>");
                Output.WriteLine("<p>Collection groups are aggregations of collections in this library. The Collection Groups simplify searching across multiple Collections simultaneously. Collection Groups also connect less tightly related materials to increase the likelihood for serendipity, where users may be searching for one topic and may easily stumble across something related and critically useful that they had not considered. Thus, Collection Groups are usually constructed topically. <br /><br />");
                Output.WriteLine("As an aggregate, views at the Collection Group level do not count toward any particular Collection and are not included in the Collection based statistics.</p>");

                Output.WriteLine("<a name=\"Collections\" ></a>");
                Output.WriteLine("<h3>COLLECTIONS</h3>");
                Output.WriteLine("<p>Collections are the main method for defining and collecting related materials and are the most familiar hierarchical structures for subject specialists, partners, and other internal users. A single Collection can exist in several Collection Groups, and a single Collection can have many subcollections.  <br /><br />");
                Output.WriteLine("A single item may be in several Collections, but one Collection is always selected as primary so all item views will be within a single Collection. </p>");

                Output.WriteLine("<a name=\"SubCollections\" ></a>");
                Output.WriteLine("<h3>SUBCOLLECTIONS</h3>");
                Output.WriteLine("<p>The smallest collected unit is the Subcollection. A single item can belong to several Subcollections under the same collection, or to multiple Collections and to Subcollections within each Collection. <br /><br />");
                Output.WriteLine("Because all Subcollection items will have a primary Collection, the usage statistics for Subcollections are also included in the Collection usage statistics. </p>");

                Output.WriteLine("<a name=\"Views\" ></a>");
                Output.WriteLine("<h3>VIEWS</h3>");
                Output.WriteLine("<p>Views are the actual page hits. Each time a person goes to " + currentMode.SobekCM_Instance_Abbreviation + " it counts as a view. The " + currentMode.SobekCM_Instance_Abbreviation + " statistics are cleaned so that views from robots, which search engines use to index websites, are removed. If they were not removed, the views on all collections and items would be much higher. Web usage statistics are always somewhat fallible, and this is one of the means for ensuring better quality usage statistics. <br /><br />");
                Output.WriteLine("Some web statistics count &quot;page item downloads&quot; as views, which is highly inaccurate because each page has multiple items on it. For instance, the digital library main page, " + currentMode.SobekCM_Instance_Abbreviation + ", includes the page HTML and all of the images. If the statistics counted each “page item download” as a hit, each single view to the main page would be counted as over 30 “page item downloads.” To make matters more confusing, some digital repositories only offer PDF downloads for users to view items. Those digital repositories track &quot;item downloads&quot; and those are most equivalent to our statistics for usage by &quot;item.&quot; </p>");

                Output.WriteLine("<a name=\"Visits\" ></a>");
                Output.WriteLine("<h3>VISITS</h3>");
                Output.WriteLine("<p>Each time a person goes to this digital library it counts as a view, but that means a single user going to the site repeatedly can log a large number of views. Visits provide a better statistic for how many different “unique” users are using the site. Visits include all views from a particular IP address (the user’s computer web address when connected) as recorded in the web log file within an hour.  <br /><br />");
                Output.WriteLine("This is also a fallible statistic since users’ IP addresses are frequently reused on networks.  Connecting to free wireless means that network gives your computer an IP address, and then when you disconnect that IP address will be given to the next user who needs it. For a campus based resource with so many on campus users connecting through the VPN or from on campus, the margin for error increases for visit-based statistics. </p>");

                Output.WriteLine("<a name=\"Main_Pages\" ></a>");
                Output.WriteLine("<h3>MAIN PAGES</h3>");
                Output.WriteLine("<p>For each of the elements in the Collection Hierarchy, the main pages are the home or landing pages, the search pages, the contact pages, and any other supplemental pages.  <br /><br />");
                Output.WriteLine("When users conduct a search through the Collection pages and view the results, those search result pages are also included in the main pages. Once a user clicks on one of the items in the search results, that item is not one of the main pages. The views for search results by thumbnail, table, and brief modes are all included in the main pages for the Collection.</p>");

                Output.WriteLine("<a name=\"Browses\" ></a>");
                Output.WriteLine("<h3>BROWSES</h3>");
                Output.WriteLine("<p>Browses include views against standard browses, such as <i>All Items</i> and <i>New Items</i> (when available).  It also includes all views of non-standard browses.</p>");

                Output.WriteLine("<a name=\"Search_Results\" ></a>");
                Output.WriteLine("<h3>SEARCH RESULTS</h3>");
                Output.WriteLine("<p>Search result views includes every view of a section of search results, and includes searches which returned zero results.</p>");

                Output.WriteLine("<a name=\"Titles_Items\" ></a>");
                Output.WriteLine("<h3>TITLES & ITEMS</h3>");
                Output.WriteLine("<p>Titles are for single bibliographic units, like a book or a newspaper. Items are the volumes within titles. Thus, one book may have one title and one item where one newspaper may have one title and thousands of items.  <br /><br />");
                Output.WriteLine("Titles with only one item (or volume) appear functionally equivalent to users. However for items like newspapers, a single title may correspond to thousands of items. <br /><br />");
                Output.WriteLine("Readers of the technical documentation and internal users know titles by their bibliographic identifier (BIBID) and items within each title by the BIBID plus the volume identifier (VID).</p>");

                Output.WriteLine("<a name=\"Title_Views\" ></a>");
                Output.WriteLine("<h3>TITLE VIEWS</h3>");
                Output.WriteLine("<p>Title views include all views at the title level.</p>");

                Output.WriteLine("<a name=\"Item_Views\" ></a>");
                Output.WriteLine("<h3>ITEM VIEWS</h3>");
                Output.WriteLine("<p>Item views include views at the item level only.</p>");

                Output.WriteLine("<a name=\"Citation_Views\" ></a>");
                Output.WriteLine("<h3>CITATION VIEWS</h3>");
                Output.WriteLine("<p>For each item, the default view is set to the page item (zoomable or static based on user selection and the availability of each of the views for that item). All items also include a “Citation View” that is not selected by default. The “Citation Views” counts the number of times a user chooses the “Citation View” for an item.</p>");

                Output.WriteLine("<a name=\"Text_Searches\" ></a>");
                Output.WriteLine("<h3>TEXT SEARCHES</h3>");
                Output.WriteLine("<p>Text searches are item-level searches within the text of a single document.  This returns the pages upon which the term or terms appear.</p>");

                Output.WriteLine("<a name=\"Static_Views\" ></a>");
                Output.WriteLine("<h3>STATIC VIEWS</h3>");
                Output.WriteLine("<p>For each item in this library, a static page is generated for search engines to index.  When an item appears in the search results in a standard search engine, the link forwards the user to the static page.  Any additional navigation moves the user into the dynamically generated pages within this library.  Attempts have been made to remove all the search engine indexing views from these numbers.  These numbers represent the number of users that entered this library from a search engine.</p>");
                Output.WriteLine("</div>");
            }
        }
        /// <summary> Adds the controls for this result viewer to the place holder on the main form </summary>
        /// <param name="placeHolder"> Main place holder ( &quot;mainPlaceHolder&quot; ) in the itemNavForm form into which the the bulk of the result viewer's output is displayed</param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        /// <returns> Sorted tree with the results in hierarchical structure with volumes and issues under the titles and sorted by serial hierarchy </returns>
        public override void Add_HTML(PlaceHolder placeHolder, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("No_Results_ResultsWriter.Add_HTML", "Adding no result text");
            }

            Literal thisLiteral = new Literal();

            StringBuilder noResultsTextBuilder = new StringBuilder();

            //   noResultsTextBuilder.Append("<div class=\"SobekHomeText\">");
            noResultsTextBuilder.AppendLine("<span class=\"SobekNoResultsText\"><br />Your search returned no results.<br /><br /></span>");

            // Get the list of search terms
            string terms = CurrentMode.Search_String.Replace(",", " ").Trim();

            // Try to search out into the Union catalog
            int union_catalog_matches = 0;

            try
            {
                // the html retrieved from the page
                String     strResult;
                WebRequest objRequest = WebRequest.Create(SobekCM_Library_Settings.Mango_Union_Search_Base_URL + "&term=" + terms);
                objRequest.Timeout = 2000;
                WebResponse objResponse = objRequest.GetResponse();

                // the using keyword will automatically dispose the object once complete
                using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
                {
                    strResult = sr.ReadToEnd().Trim();
                    // Close and clean up the StreamReader
                    sr.Close();
                }
                if (strResult.Length > 0)
                {
                    bool isNumber = strResult.All(Char.IsNumber);
                    if (isNumber)
                    {
                        union_catalog_matches = Convert.ToInt32(strResult);
                    }
                }
            }
            catch (Exception)
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("No_Results_ResultsWriter.Add_HTML", "Exception caught while querying Mango state union catalog", Custom_Trace_Type_Enum.Error);
                }
            }

            string union_library_link = "http://uf.catalog.fcla.edu/uf.jsp";

            if ((union_catalog_matches > 0) || ((CurrentMode.Aggregation.Length > 0) && (CurrentMode.Aggregation.ToUpper() != "ALL") && (Results_Statistics.All_Collections_Items > 0) && (CurrentMode.Default_Aggregation == "all")))
            {
                noResultsTextBuilder.AppendLine("The following matches were found:<br /><br />");

                if ((CurrentMode.Aggregation.Length > 0) && (CurrentMode.Aggregation.ToUpper() != "ALL") && (Results_Statistics.All_Collections_Items > 0) && (CurrentMode.Default_Aggregation == "all"))
                {
                    string aggregation = CurrentMode.Aggregation;
                    CurrentMode.Aggregation = String.Empty;
                    if (Results_Statistics.All_Collections_Items > 1)
                    {
                        noResultsTextBuilder.AppendLine("<a href=\"" + CurrentMode.Redirect_URL() + "\">" + number_to_string(Results_Statistics.All_Collections_Items) + " found in the " + CurrentMode.SobekCM_Instance_Name + "</a><br /><br />");
                    }
                    else
                    {
                        noResultsTextBuilder.AppendLine("<a href=\"" + CurrentMode.Redirect_URL() + "\">" + Results_Statistics.All_Collections_Items + " found in the " + CurrentMode.SobekCM_Instance_Name + "</a><br /><br />");
                    }

                    CurrentMode.Aggregation = aggregation;
                }

                if (union_catalog_matches > 0)
                {
                    union_library_link = union_library_link + "?st=" + HttpUtility.HtmlEncode(terms) + "&ix=kw";
                    if (union_catalog_matches > 1)
                    {
                        noResultsTextBuilder.AppendLine("<a href=\"" + union_library_link + "\" target=\"_BLANK\">" + number_to_string(union_catalog_matches) + " found in the University of Florida Library Catalog</a><br /><br />");
                    }
                    else
                    {
                        noResultsTextBuilder.AppendLine("<a href=\"" + union_library_link + "\" target=\"_BLANK\">One found in the University of Florida Library Catalog</a><br /><br />");
                    }
                }

                noResultsTextBuilder.AppendLine("<br />");
            }

            noResultsTextBuilder.AppendLine("Consider searching one of the following:<br /><br />");

            noResultsTextBuilder.AppendLine("Online Resource: <a href=\"http://scholar.google.com\" target=\"_BLANK\">Google Scholar</a> or <a href=\"http://books.google.com\" target=\"_BLANK\">Google Books</a><br />");
            noResultsTextBuilder.AppendLine("Physical Holdings: the <a href=\"" + union_library_link + "\" target=\"_BLANK\">Library Catalog</a> or <a href=\"http://www.worldcat.org\" target=\"_BLANK\">Worldcat</a><br />");
            noResultsTextBuilder.AppendLine("  <br /><br /><br /><br />");
            noResultsTextBuilder.AppendLine("</td></tr></table>");
            //   noResultsTextBuilder.Append("</div>");

            noResultsTextBuilder.AppendLine();
            noResultsTextBuilder.AppendLine("<!-- place holder for the load() event in the body -->");
            noResultsTextBuilder.AppendLine("<script type=\"text/javascript\"> ");
            noResultsTextBuilder.AppendLine("  //<![CDATA[");
            noResultsTextBuilder.AppendLine("    function load() { } ");
            noResultsTextBuilder.AppendLine("  //]]>");
            noResultsTextBuilder.AppendLine("</script>");
            noResultsTextBuilder.AppendLine();

            thisLiteral.Text = noResultsTextBuilder.ToString();
            placeHolder.Controls.Add(thisLiteral);
        }
        /// <summary> This is an opportunity to write HTML directly into the main form, without
        /// using the pop-up html form architecture </summary>
        /// <param name="Output"> Textwriter to write the pop-up form HTML for this viewer </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> This text will appear within the ItemNavForm form tags </remarks>
        public override void Add_HTML_In_Main_Form(TextWriter Output, Custom_Tracer Tracer)
        {
            if ((details != null) && (details.Tables[0].Rows.Count > 0))
            {
                Tracer.Add_Trace("IP_Restrictions_AdminViewer.Add_HTML_In_Main_Form", "Display details regarding one IP restrictive range");

                // Assign some of the values from the details to the range
                thisRange.Title = details.Tables[0].Rows[0]["Title"].ToString();
                thisRange.Notes = details.Tables[0].Rows[0]["Notes"].ToString();

                // Add the stylesheet(s)and javascript  needed
                Output.WriteLine("<script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/sobekcm_form.js\" ></script>");
                Output.WriteLine("<script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/sobekcm_admin.js\" ></script>");

                // Add the hidden field
                Output.WriteLine("<!-- Hidden field is used for postbacks to indicate what to save and reset -->");
                Output.WriteLine("<input type=\"hidden\" id=\"rangeid\" name=\"rangeid\" value=\"" + thisRange.RangeID + "\" />");
                Output.WriteLine("<input type=\"hidden\" id=\"action\" name=\"action\" value=\"\" />");
                Output.WriteLine();

                // Start the HTML rendering
                Output.WriteLine("<div class=\"SobekHomeText\">");

                // Add the save and cancel button and link to help
                currentMode.My_Sobek_SubMode = String.Empty;
                Output.WriteLine("  <br />");
                Output.WriteLine("  <table width=\"750px\"><tr><td align=\"left\"> &nbsp; &nbsp; &nbsp; For clarification of any terms on this form, <a href=\"" + SobekCM_Library_Settings.Help_URL(currentMode.Base_URL) + "admin/restrictions\" target=\"ADMIN_USER_HELP\" >click here to view the help page</a>.</td><td align=\"right\"><a href=\"" + currentMode.Redirect_URL() + "\"><img border=\"0\" src=\"" + currentMode.Base_URL + "design/skins/" + currentMode.Base_Skin + "/buttons/cancel_button_22.gif\" alt=\"CLOSE\" /></a> &nbsp; <input type=\"image\" src=\"" + currentMode.Base_URL + "design/skins/" + currentMode.Base_Skin + "/buttons/save_button.gif\" value=\"Submit\" alt=\"Submit\"></td></tr></table>");

                // Add all the basic information
                Output.WriteLine("  <span class=\"SobekAdminTitle\">Basic Information</span>");
                Output.WriteLine("  <blockquote>");
                Output.WriteLine("    <div class=\"admin_aggr_new_div\">");
                Output.WriteLine("      <table class=\"popup_table\">");

                // Add line for range title
                Output.WriteLine("        <tr>");
                Output.WriteLine("          <td width=\"120px\"><label for=\"admin_title\">Title:</label></td>");
                Output.WriteLine("          <td><input class=\"admin_ip_large_input\" name=\"admin_title\" id=\"admin_title\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(thisRange.Title) + "\"  onfocus=\"javascript:textbox_enter('admin_title', 'admin_ip_large_input_focused')\" onblur=\"javascript:textbox_leave('admin_title', 'admin_ip_large_input')\" /></td>");
                Output.WriteLine("        </tr>");

                // Compute the size of the text boxes
                int actual_cols = 75;
                if (currentMode.Browser_Type.ToUpper().IndexOf("FIREFOX") >= 0)
                {
                    actual_cols = 70;
                }

                // Add the notes text area box
                Output.WriteLine("        <tr valign=\"top\"><td valign=\"top\"><label for=\"admin_notes\">Notes:</label></td><td colspan=\"2\"><textarea rows=\"5\" cols=\"" + actual_cols + "\" name=\"admin_notes\" id=\"admin_notes\" class=\"admin_ip_input\" onfocus=\"javascript:textbox_enter('admin_notes','admin_ip_focused')\" onblur=\"javascript:textbox_leave('admin_notes','admin_ip_input')\">" + HttpUtility.HtmlEncode(thisRange.Notes) + "</textarea></td></tr>");

                // Add the message text area box
                Output.WriteLine("        <tr valign=\"top\"><td valign=\"top\"><label for=\"admin_message\">Message:</label></td><td colspan=\"2\"><textarea rows=\"10\" cols=\"" + actual_cols + "\" name=\"admin_message\" id=\"admin_message\" class=\"admin_ip_input\" onfocus=\"javascript:textbox_enter('admin_message','admin_ip_focused')\" onblur=\"javascript:textbox_leave('admin_message','admin_ip_input')\">" + HttpUtility.HtmlEncode(thisRange.Item_Restricted_Statement) + "</textarea></td></tr>");

                Output.WriteLine("      </table>");
                Output.WriteLine("    </div>");
                Output.WriteLine("  </blockquote>");
                Output.WriteLine("  <br />");



                Output.WriteLine("  <span class=\"SobekAdminTitle\">IP Addresses</span>");
                Output.WriteLine("  <br /><br />");
                Output.WriteLine("    <blockquote>");

                Output.WriteLine("<table border=\"0px\" cellspacing=\"0px\" class=\"statsTable\">");
                Output.WriteLine("  <tr align=\"left\" bgcolor=\"#0022a7\" >");
                Output.WriteLine("    <th width=\"90px\" align=\"left\"><span style=\"color: White\"> &nbsp; ACTIONS</span></th>");
                Output.WriteLine("    <th width=\"135px\" align=\"left\"><span style=\"color: White\">START IP</span></th>");
                Output.WriteLine("    <th width=\"135px\" align=\"left\"><span style=\"color: White\">END IP</span></th>");
                Output.WriteLine("    <th width=\"250px\" align=\"left\"><span style=\"color: White\">LABEL</span></th>");
                Output.WriteLine("  </tr>");

                foreach (DataRow thisRow in details.Tables[1].Rows)
                {
                    // Get the primary key for this IP address
                    string ip_primary = thisRow["IP_SingleID"].ToString();

                    // Build the action links
                    Output.WriteLine("  <tr align=\"left\" >");
                    Output.Write("    <td class=\"SobekAdminActionLink\" >( ");
                    Output.WriteLine("<a title=\"Click to clear this ip address\" id=\"CLEAR_" + ip_primary + "\" href=\"" + currentMode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return clear_ip_address('" + ip_primary + "');\">clear</a> )</td>");

                    // Add the rest of the row with data
                    Output.WriteLine("    <td><input class=\"admin_ip_small_input\" name=\"admin_ipstart_" + ip_primary + "\" id=\"admin_ipstart_" + ip_primary + "\" type=\"text\" value=\"" + thisRow["StartIP"].ToString().Trim() + "\"  onfocus=\"javascript:textbox_enter('admin_ipstart_" + ip_primary + "', 'admin_ip_small_input_focused')\" onblur=\"javascript:textbox_leave('admin_ipstart_" + ip_primary + "', 'admin_ip_small_input')\" /></td>");
                    Output.WriteLine("    <td><input class=\"admin_ip_small_input\" name=\"admin_ipend_" + ip_primary + "\" id=\"admin_ipend_" + ip_primary + "\" type=\"text\" value=\"" + thisRow["EndIP"].ToString().Trim() + "\"  onfocus=\"javascript:textbox_enter('admin_ipend_" + ip_primary + "', 'admin_ip_small_input_focused')\" onblur=\"javascript:textbox_leave('admin_ipend_" + ip_primary + "', 'admin_ip_small_input')\" /></td>");
                    Output.WriteLine("    <td><input class=\"admin_ip_medium_input\" name=\"admin_iplabel_" + ip_primary + "\" id=\"admin_iplabel_" + ip_primary + "\" type=\"text\" value=\"" + HttpUtility.HtmlEncode(thisRow["Notes"].ToString().Trim()) + "\"  onfocus=\"javascript:textbox_enter('admin_iplabel_" + ip_primary + "', 'admin_ip_medium_input_focused')\" onblur=\"javascript:textbox_leave('admin_iplabel_" + ip_primary + "', 'admin_ip_medium_input')\" /></td>");
                    Output.WriteLine("   </tr>");
                    Output.WriteLine("  <tr><td bgcolor=\"#e7e7e7\" colspan=\"4\"></td></tr>");
                }

                // Now, always add ten empty IP rows here
                for (int i = 1; i < 10; i++)
                {
                    Output.WriteLine("  <tr align=\"left\" >");
                    Output.Write("    <td class=\"SobekAdminActionLink\" >( ");
                    Output.WriteLine("<a title=\"Click to clear this ip address\" id=\"CLEAR_new" + i + "\" href=\"" + currentMode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return clear_ip_address('new" + i + "');\">clear</a> )</td>");

                    // Add the rest of the row with data
                    Output.WriteLine("    <td><input class=\"admin_ip_small_input\" name=\"admin_ipstart_new" + i + "\" id=\"admin_ipstart_new" + i + "\" type=\"text\" value=\"\"  onfocus=\"javascript:textbox_enter('admin_ipstart_new" + i + "', 'admin_ip_small_input_focused')\" onblur=\"javascript:textbox_leave('admin_ipstart_new" + i + "', 'admin_ip_small_input')\" /></td>");
                    Output.WriteLine("    <td><input class=\"admin_ip_small_input\" name=\"admin_ipend_new" + i + "\" id=\"admin_ipend_new" + i + "\" type=\"text\" value=\"\"  onfocus=\"javascript:textbox_enter('admin_ipend_new" + i + "', 'admin_ip_small_input_focused')\" onblur=\"javascript:textbox_leave('admin_ipend_new" + i + "', 'admin_ip_small_input')\" /></td>");
                    Output.WriteLine("    <td><input class=\"admin_ip_medium_input\" name=\"admin_iplabel_new" + i + "\" id=\"admin_iplabel_new" + i + "\" type=\"text\" value=\"\"  onfocus=\"javascript:textbox_enter('admin_iplabel_new" + i + "', 'admin_ip_medium_input_focused')\" onblur=\"javascript:textbox_leave('admin_iplabel_new" + i + "', 'admin_ip_medium_input')\" /></td>");
                    Output.WriteLine("   </tr>");
                    Output.WriteLine("  <tr><td bgcolor=\"#e7e7e7\" colspan=\"4\"></td></tr>");
                }

                Output.WriteLine("</table>");
                Output.WriteLine("    </blockquote>");

                Output.WriteLine("</div>");

                return;
            }

            Tracer.Add_Trace("IP_Restrictions_AdminViewer.Add_HTML_In_Main_Form", "Display main IP restrictive range admin form");
            Output.WriteLine("<div class=\"SobekHomeText\">");
            Output.WriteLine("  <blockquote>");
            Output.WriteLine("    Restrictive ranges of IP addresses may be used to restrict access to digital resources.  This form allows system administrators to edit the individual IP addresses and contiguous IP addresses associated with an existing restrictive range.<br /><br />");
            Output.WriteLine("    For more information about IP restriction ranges and this form, <a href=\"" + SobekCM_Library_Settings.Help_URL(currentMode.Base_URL) + "admin/restrictions\" target=\"ADMIN_USER_HELP\" >click here to view the help page</a>.");
            Output.WriteLine("  </blockquote>");
            Output.WriteLine("  <span class=\"SobekAdminTitle\">Existing Ranges</span>");
            Output.WriteLine("  <blockquote>");
            Output.WriteLine("    Select an IP restrictive range below to view or edit:<br />");
            Output.WriteLine("    <blockquote>");

            for (int i = 0; i < ipRestrictionInfo.Count; i++)
            {
                currentMode.My_Sobek_SubMode = ipRestrictionInfo[i].RangeID.ToString();
                Output.WriteLine("<a href=\"" + currentMode.Redirect_URL() + "\">" + ipRestrictionInfo[i].Title + "</a><br /><br />");
            }

            Output.WriteLine("    </blockquote>");
            Output.WriteLine("  </blockquote>");
            Output.WriteLine("  <br />");
            Output.WriteLine("</div>");
        }
示例#54
0
        /// <summary> Returns the string which contains the item and title level statistics </summary>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        /// <returns> Sttring with the statistical usage information for this item and title</returns>
        protected string Statistics_String(Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("Citation_ItemViewer.Statistics_String", "Create the statistics html");
            }

            int hits     = 0;
            int sessions = 0;

            // Pull the item statistics
            List <Item_Monthly_Usage> stats = SobekEngineClient.Items.Get_Item_Statistics_History(BriefItem.BibID, BriefItem.VID, Tracer);

            StringBuilder builder = new StringBuilder(2000);

            builder.AppendLine("  <p>This item was has been viewed <%HITS%> times within <%SESSIONS%> visits.  Below are the details for overall usage for this item within this library.<br /><br />For definitions of these terms, see the <a href=\"" + CurrentRequest.Base_URL + "stats/usage/definitions\" target=\"_BLANK\">definitions on the main statistics page</a>.</p>");

            builder.AppendLine("  <table class=\"sbkCiv_StatsTable\">");
            builder.AppendLine("    <tr class=\"sbkCiv_StatsTableHeaderRow\">");
            builder.AppendLine("      <th style=\"width:120px\">Date</th>");
            builder.AppendLine("      <th style=\"width:90px\">Views</th>");
            builder.AppendLine("      <th style=\"width:90px\">Visits</th>");
            builder.AppendLine("    </tr>");

            const int COLUMNS   = 3;
            int       last_year = -1;

            if (stats != null)
            {
                foreach (Item_Monthly_Usage thisRow in stats)
                {
                    if (thisRow.Year != last_year)
                    {
                        builder.AppendLine("    <tr><td class=\"sbkCiv_StatsTableYearRow\" colspan=\"" + COLUMNS + "\">" + thisRow.Year + " STATISTICS</td></tr>");
                        last_year = thisRow.Year;
                    }
                    else
                    {
                        builder.AppendLine("    <tr><td class=\"sbkCiv_StatsTableRowSeperator\" colspan=\"" + COLUMNS + "\"></td></tr>");
                    }
                    builder.AppendLine("    <tr>");
                    builder.AppendLine("      <td style=\"text-align: left\">" + Month_From_Int(thisRow.Month) + " " + thisRow.Year + "</td>");

                    if ((!BriefItem.Web.Siblings.HasValue) || (BriefItem.Web.Siblings.Value <= 1))
                    {
                        // Show the views
                        int total_hits = thisRow.Views + thisRow.Title_Views;
                        hits += total_hits;
                        builder.AppendLine("      <td>" + total_hits + "</td>");

                        // Show the visits
                        int total_sessions = thisRow.Title_Visitors + thisRow.Visitors;
                        sessions += total_sessions;
                        builder.AppendLine("      <td>" + total_sessions + "</td>");
                    }
                    else
                    {
                        // Show the views
                        hits += thisRow.Views;
                        builder.AppendLine("      <td>" + thisRow.Views + "</td>");

                        // Show the visits
                        sessions += thisRow.Visitors;
                        builder.AppendLine("      <td>" + thisRow.Visitors + "</td>");
                    }
                    builder.AppendLine("    </tr>");
                }

                builder.AppendLine("    <tr><td class=\"sbkCiv_StatsTableFinalSeperator\" colspan=\"" + COLUMNS + "\"></td></tr>");
                builder.AppendLine("    <tr id=\"sbkCiv_StatsTableTotalRow\" >");
                builder.AppendLine("      <td style=\"text-align:left\">TOTAL</td>");
                builder.AppendLine("      <td>" + hits + "</td>");
                builder.AppendLine("      <td>" + sessions + "</td>");
                builder.AppendLine("    </tr>");
                builder.AppendLine("  </table>");
                builder.AppendLine("  <br />");
            }

            builder.AppendLine("</div>");
            return(builder.ToString().Replace("<%HITS%>", hits.ToString()).Replace("<%SESSIONS%>", sessions.ToString()));
        }
示例#55
0
 /// <summary> Add the HTML to be displayed in the main SobekCM viewer area </summary>
 /// <param name="Output"> Textwriter to write the HTML for this viewer</param>
 /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
 /// <remarks> This class does nothing, since the skin list is added as controls, not HTML </remarks>
 public override void Write_HTML(TextWriter Output, Custom_Tracer Tracer)
 {
     Tracer.Add_Trace("Skins_AdminViewer.Write_HTML", "Do nothing");
 }
示例#56
0
        /// <summary> Constructor for a new instance of the Home_MySobekViewer class </summary>
        /// <param name="currentMode"> Mode / navigation information for the current request (including interface code) </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Logon_MySobekViewer(SobekCM_Navigation_Object currentMode, Custom_Tracer Tracer)
            : base(null)
        {
            Tracer.Add_Trace("Logon_MySobekViewer.Constructor", String.Empty);

            CurrentMode = currentMode;

            errorMessage = String.Empty;

            // If this is a postback, check to see if the user is valid
            if (currentMode.isPostBack)
            {
                string possible_username = String.Empty;
                string possible_password = String.Empty;
                bool   remember_me       = false;

                string[] getKeys = HttpContext.Current.Request.Form.AllKeys;
                foreach (string thisKey in getKeys)
                {
                    switch (thisKey)
                    {
                    case "logon_username":
                        possible_username = HttpContext.Current.Request.Form[thisKey].Trim();
                        break;

                    case "logon_password":
                        possible_password = HttpContext.Current.Request.Form[thisKey].Trim();
                        break;

                    case "rememberme":
                        if (HttpContext.Current.Request.Form[thisKey].Trim() == "rememberme")
                        {
                            remember_me = true;
                        }
                        break;
                    }
                }

                if ((!String.IsNullOrEmpty(possible_password)) && (!String.IsNullOrEmpty(possible_username)))
                {
                    user = SobekCM_Database.Get_User(possible_username, possible_password, Tracer);
                    if (user != null)
                    {
                        // The user was valid here, so save this user information
                        HttpContext.Current.Session["user"] = user;

                        // Should we remember this user via cookies?
                        if (remember_me)
                        {
                            HttpCookie userCookie = new HttpCookie("SobekUser");
                            userCookie.Values["userid"]        = user.UserID.ToString();
                            userCookie.Values["security_hash"] = user.Security_Hash(HttpContext.Current.Request.UserHostAddress);
                            userCookie.Expires = DateTime.Now.AddDays(14);
                            HttpContext.Current.Response.Cookies.Add(userCookie);
                        }

                        // Forward back to their original URL (unless the original URL was this logon page)
                        string raw_url = HttpContext.Current.Items["Original_URL"].ToString();
                        if (raw_url.ToLower().IndexOf("my/logon") > 0)
                        {
                            currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                            HttpContext.Current.Response.Redirect(currentMode.Redirect_URL());
                        }
                        else
                        {
                            HttpContext.Current.Response.Redirect(raw_url);
                        }
                    }
                }
            }
        }
示例#57
0
        /// <summary> This is an opportunity to write HTML directly into the main form, without
        /// using the pop-up html form architecture </summary>
        /// <param name="Output"> Textwriter to write the pop-up form HTML for this viewer </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> This text will appear within the ItemNavForm form tags </remarks>
        public override void Write_ItemNavForm_Closing(TextWriter Output, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Skins_AdminViewer.Write_ItemNavForm_Closing", "Add any popup divisions for form elements");

            Output.WriteLine("<!-- Skins_AdminViewer.Write_ItemNavForm_Closing -->");
            Output.WriteLine("<script type=\"text/javascript\" src=\"" + Static_Resources_Gateway.Jquery_Ui_1_10_3_Custom_Js + "\"></script>");

            // Add the hidden field
            Output.WriteLine("<!-- Hidden field is used for postbacks to indicate what to save and reset -->");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_interface_tosave\" name=\"admin_interface_tosave\" value=\"\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_interface_reset\" name=\"admin_interface_reset\" value=\"\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_interface_delete\" name=\"admin_interface_delete\" value=\"\" />");
            Output.WriteLine();

            Output.WriteLine("<script src=\"" + Static_Resources_Gateway.Sobekcm_Admin_Js + "\" type=\"text/javascript\"></script>");
            Output.WriteLine("<div class=\"sbkAdm_HomeText\">");

            if (!String.IsNullOrEmpty(actionMessage))
            {
                Output.WriteLine("  <br />");
                if (actionMessage.IndexOf("error", StringComparison.InvariantCultureIgnoreCase) >= 0)
                {
                    Output.WriteLine("  <div id=\"sbkAdm_ActionMessageError\">" + actionMessage + "</div>");
                }
                else
                {
                    Output.WriteLine("  <div id=\"sbkAdm_ActionMessageSuccess\">" + actionMessage + "</div>");
                }
            }

            Output.WriteLine("  <p>For clarification of any terms on this form, <a href=\"" + UI_ApplicationCache_Gateway.Settings.System.Help_URL(RequestSpecificValues.Current_Mode.Base_URL) + "adminhelp/webskins\" target=\"ADMIN_INTERFACE_HELP\" >click here to view the help page</a>.</p>");

            Output.WriteLine("  <h2>New Web Skin</h2>");
            Output.WriteLine("  <div class=\"sbkSav_NewDiv\">");
            Output.WriteLine("    <table class=\"sbkAdm_PopupTable\">");

            // Add line for interface code and base interface code
            Output.WriteLine("      <tr style=\"height:25px;\">");
            Output.WriteLine("        <td style=\"width:112px;\"><label for=\"admin_interface_code\">Web Skin Code:</label></td>");
            Output.WriteLine("        <td style=\"width:220px;\"><input class=\"sbkSav_small_input sbkAdmin_Focusable\" name=\"admin_interface_code\" id=\"admin_interface_code\" type=\"text\" value=\"\" /></td>");
            Output.WriteLine("        <td style=\"text-align:right;\">");
            Output.WriteLine("          <label for=\"admin_interface_basecode\">Base Skin Code:</label> &nbsp; ");
            Output.WriteLine("          <select class=\"sbkSav_small_input2 sbkAdmin_Focusable\" name=\"admin_interface_basecode\" id=\"admin_interface_basecode\">");
            Output.WriteLine("            <option value=\"\"></option>");

            foreach (string thisSkinCode in UI_ApplicationCache_Gateway.Web_Skin_Collection.Ordered_Skin_Codes)
            {
                Output.WriteLine("            <option value=\"" + thisSkinCode.ToUpper() + "\">" + thisSkinCode + "</option>");
            }

            Output.WriteLine("          </select>");
            Output.WriteLine("        </td>");
            Output.WriteLine("      </tr>");

            // Add line for banner link
            Output.WriteLine("      <tr id=\"banner_link_row\" style=\"height:25px; display:none;\"><td><label for=\"admin_interface_link\">Banner Link:</label></td><td colspan=\"2\"><input class=\"sbkSav_large_input sbkAdmin_Focusable\" name=\"admin_interface_link\" id=\"admin_interface_link\" type=\"text\" value=\"\" /></td></tr>");

            // Add line for notes
            Output.WriteLine("      <tr style=\"height:25px;\"><td><label for=\"admin_interface_notes\">Notes:</label></td><td colspan=\"2\"><input class=\"sbkSav_large_input sbkAdmin_Focusable\" name=\"admin_interface_notes\" id=\"admin_interface_notes\" type=\"text\" value=\"\" /></td></tr>");

            // Add checkboxes for overriding the header/footer and overriding banner
            Output.WriteLine("      <tr style=\"height:15px;\"><td>Flags:</td><td><input class=\"sbkSav_checkbox\" type=\"checkbox\" name=\"admin_interface_banner_override\" id=\"admin_interface_banner_override\" onchange=\"return skins_display_banner_link(this);\" /> <label for=\"admin_interface_banner_override\" >Override banner?</label></td><td></td></tr>");
            Output.WriteLine("      <tr style=\"height:15px;\"><td>&nbsp;</td><td><input class=\"sbkSav_checkbox\" type=\"checkbox\" name=\"admin_interface_top_nav\" id=\"admin_interface_top_nav\" /> <label for=\"admin_interface_top_nav\">Suppress main menu?</label></td><td></td></tr>");
            Output.WriteLine("      <tr style=\"height:15px;\"><td>&nbsp;</td><td colspan=\"2\"><input class=\"sbkSav_checkbox\" type=\"checkbox\" name=\"admin_interface_copycurrent\" id=\"admin_interface_copycurrent\" checked=\"checked\" /> <label for=\"admin_interface_copycurrent\">Copy current files for this new web skin if folder does not exist?</label></td></tr>");

            // Add the SAVE button
            Output.WriteLine("      <tr style=\"height:30px; text-align: center;\"><td colspan=\"3\"><button title=\"Save new web skin\" class=\"sbkAdm_RoundButton\" onclick=\"return save_new_interface();\">SAVE <img src=\"" + Static_Resources_Gateway.Button_Next_Arrow_Png + "\" class=\"sbkAdm_RoundButton_RightImg\" alt=\"\" /></button></td></tr>");
            Output.WriteLine("    </table>");
            Output.WriteLine("  </div>");
            Output.WriteLine();
            Output.WriteLine("  <h2>Existing Web Skins</h2>");

            // Get the list of all aggregationPermissions
            Output.WriteLine("  <table class=\"sbkSav_Table sbkAdm_Table\">");
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <th class=\"sbkSav_TableHeader1\">ACTIONS</th>");
            Output.WriteLine("      <th class=\"sbkSav_TableHeader2\">CODE</th>");
            Output.WriteLine("      <th class=\"sbkSav_TableHeader3\">BASE</th>");
            Output.WriteLine("      <th class=\"sbkSav_TableHeader4\">NOTES</th>");
            Output.WriteLine("    </tr>");
            Output.WriteLine("    <tr><td class=\"sbkAdm_TableRule\" colspan=\"4\"></td></tr>");

            // Get the view URL
            string current_skin = RequestSpecificValues.Current_Mode.Skin;

            RequestSpecificValues.Current_Mode.Skin = "TESTSKINCODE";
            string view_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            RequestSpecificValues.Current_Mode.Skin = current_skin;

            // Write the data for each interface
            RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Skins_Single;
            foreach (DataRow thisRow in UI_ApplicationCache_Gateway.Web_Skin_Collection.Skin_Table.Rows)
            {
                // Pull all these values
                string code      = thisRow["WebSkinCode"].ToString();
                string base_code = thisRow["BaseInterface"].ToString();
                string notes     = thisRow["Notes"].ToString();
                //bool overrideHeader = Convert.ToBoolean(thisRow["OverrideHeaderFooter"]);
                //bool overrideBanner = Convert.ToBoolean(thisRow["OverrideBanner"]);
                //bool buildOnLaunch = Convert.ToBoolean(thisRow["Build_On_Launch"]);
                //bool suppressTopNav = Convert.ToBoolean(thisRow["SuppressTopNavigation"]);
                //string bannerLink = thisRow["BannerLink"].ToString();

                // Build the action links
                Output.WriteLine("    <tr>");
                Output.Write("      <td class=\"sbkAdm_ActionLink\" >( ");

                RequestSpecificValues.Current_Mode.My_Sobek_SubMode = code;

                Output.Write("<a title=\"Click to edit\" href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "\" >edit</a> | ");
                Output.Write("<a title=\"Click to view\" href=\"" + view_url.Replace("testskincode", code) + "\" >view</a> | ");
                Output.Write("<a title=\"Click to reset\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\" onclick=\"reset_interface('" + code + "');\">reset</a> | ");

                if (RequestSpecificValues.Current_User.Is_System_Admin)
                {
                    Output.WriteLine("<a title=\"Click to delete this web skin\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\"  onclick=\"return delete_interface('" + code + "');\">delete</a> )</td>");
                }
                else
                {
                    Output.WriteLine("<a title=\"Only SYSTEM administrators can delete web skins\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\"  onclick=\"alert('Only SYSTEM administrators can delete web skins'); return false;\">delete</a> )</td>");
                }


                // Add the rest of the row with data
                if (String.Compare(code, current_skin, StringComparison.InvariantCultureIgnoreCase) == 0)
                {
                    Output.WriteLine("      <td>" + code + "*</span></td>");
                }
                else
                {
                    Output.WriteLine("      <td>" + code + "</span></td>");
                }
                Output.WriteLine("      <td>" + base_code + "</span></td>");
                Output.WriteLine("      <td>" + notes + "</span></td>");
                Output.WriteLine("    </tr>");
                Output.WriteLine("    <tr><td class=\"sbkAdm_TableRule\" colspan=\"4\"></td></tr>");
            }
            RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Skins_Mgmt;

            Output.WriteLine("  </table>");
            Output.WriteLine("  <p>* indicates the current web skin in the table above</p>");
            Output.WriteLine("  <br />");
            Output.WriteLine("</div>");
            Output.WriteLine();
        }
示例#58
0
        /// <summary> This is an opportunity to write HTML directly into the main form, without
        /// using the pop-up html form architecture </summary>
        /// <param name="Output"> Textwriter to write the pop-up form HTML for this viewer </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> This text will appear within the ItemNavForm form tags </remarks>
        public override void Write_ItemNavForm_Closing(TextWriter Output, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Default_Metadata_AdminViewer.Write_ItemNavForm_Closing", "Add any popup divisions for form elements");

            Output.WriteLine("<!-- Default_Metadata_AdminViewer.Write_ItemNavForm_Closing -->");

            // Add the scripts needed
            Output.WriteLine("<script type=\"text/javascript\" src=\"" + Static_Resources_Gateway.Jquery_Ui_1_10_3_Custom_Js + "\"></script>");

            // Add the hidden field
            Output.WriteLine("<!-- Hidden field is used for postbacks to indicate what to save -->");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_project_tosave\" name=\"admin_project_tosave\" value=\"\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_project_delete\" name=\"admin_project_delete\" value=\"\" />");
            Output.WriteLine();

            Output.WriteLine("<!-- Default_Metadata Rename Form -->");
            Output.WriteLine("<div class=\"sbkPav_PopupDiv\" id=\"form_project\" style=\"display:none;\">");
            Output.WriteLine("  <div class=\"sbkAdm_PopupTitle\"><table style=\"width:100%\"><tr><td style=\"text-align:left;\">RENAME DEFAULT METADATA</td><td style=\"text-align:right;\"> <a href=\"#template\" alt=\"CLOSE\" onclick=\"project_form_close()\">X</a> &nbsp; </td></tr></table></div>");
            Output.WriteLine("  <br />");
            Output.WriteLine("  <table class=\"sbkAdm_PopupTable\">");

            // Add line for code
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <td style=\"width:120px;\"><label for=\"form_project_code\">Code:</label></td>");
            Output.WriteLine("      <td><span class=\"form_linkline admin_existing_code_line\" id=\"form_project_code\"></span></td>");
            Output.WriteLine("    </tr>");

            // Add line for name
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <td><label for=\"form_project_name\">Name:</label></td>");
            Output.WriteLine("      <td><input class=\"sbkPav_large_input sbkAdmin_Focusable\" name=\"form_project_name\" id=\"form_project_name\" type=\"text\" value=\"\" /></td>");
            Output.WriteLine("    </tr>");

            // Add line for description
            Output.WriteLine("    <tr class=\"sbkPav_descriptionRow\">");
            Output.WriteLine("      <td><label for=\"form_project_desc\">Description:</label></td>");
            Output.WriteLine("      <td><textarea class=\"sbkPav_textarea sbkAdmin_Focusable\" name=\"form_project_desc\" id=\"form_project_desc\" type=\"text\" ></textarea></td>");
            Output.WriteLine("    </tr>");

            // Add the buttons and close the table
            Output.WriteLine("    <tr style=\"height:35px; text-align: center; vertical-align: bottom;\">");
            Output.WriteLine("      <td colspan=\"2\"> &nbsp; &nbsp; ");
            Output.WriteLine("        <button title=\"Do not apply changes\" class=\"sbkAdm_RoundButton\" onclick=\"return project_form_close();\"><img src=\"" + Static_Resources_Gateway.Button_Previous_Arrow_Png + "\" class=\"sbkAdm_RoundButton_LeftImg\" alt=\"\" /> CANCEL</button> &nbsp; &nbsp; ");
            Output.WriteLine("        <button title=\"Save changes to this default metadata\" class=\"sbkAdm_RoundButton\" type=\"submit\">SAVE <img src=\"" + Static_Resources_Gateway.Button_Next_Arrow_Png + "\" class=\"sbkAdm_RoundButton_RightImg\" alt=\"\" /></button>");
            Output.WriteLine("      </td>");
            Output.WriteLine("    </tr>");
            Output.WriteLine("  </table>");
            Output.WriteLine("</div>");
            Output.WriteLine();

            Tracer.Add_Trace("Default_Metadata_AdminViewer.Write_ItemNavForm_Closing", "Write the rest of the form html");


            Output.WriteLine("<script src=\"" + Static_Resources_Gateway.Sobekcm_Admin_Js + "\" type=\"text/javascript\"></script>");
            Output.WriteLine("<div class=\"sbkAdm_HomeText\">");

            if (actionMessage.Length > 0)
            {
                Output.WriteLine("  <br />");
                Output.WriteLine("  <div id=\"sbkAdm_ActionMessage\">" + actionMessage + "</div>");
            }

            Output.WriteLine("  <p>For clarification of any terms on this form, <a href=\"" + UI_ApplicationCache_Gateway.Settings.System.Help_URL(RequestSpecificValues.Current_Mode.Base_URL) + "adminhelp/projects\" target=\"PROJECTS_INTERFACE_HELP\" >click here to view the help page</a>.</p>");

            Output.WriteLine("  <h2>New Default Metadata</h2>");
            Output.WriteLine("  <div class=\"sbkPav_NewDiv\">");
            Output.WriteLine("    <table class=\"sbkAdm_PopupTable\">");

            // Add line for code
            Output.WriteLine("      <tr>");
            Output.WriteLine("        <td style=\"width:120px;\"><label for=\"admin_project_code\">Metadata Code:</label></td>");
            Output.WriteLine("        <td><input class=\"sbkPav_small_input sbkAdmin_Focusable\" name=\"admin_project_code\" id=\"admin_project_code\" type=\"text\" value=\"" + entered_code + "\" /></td>");
            Output.WriteLine("      </tr>");

            // Add line for basecode
            Output.WriteLine("      <tr>");
            Output.WriteLine("        <td style=\"width:120px;\"><label for=\"admin_project_code\">Base Metadata:</label></td>");
            Output.WriteLine("        <td><select class=\"sbkPav_select\" name=\"admin_project_base\" id=\"admin_project_base\">");
            Output.WriteLine("            <option value=\"\" selected=\"selected\">(none)</option>");
            foreach (Default_Metadata thisSet in UI_ApplicationCache_Gateway.Global_Default_Metadata)
            {
                if (String.Compare(thisSet.Code, "NONE", true) != 0)
                {
                    if (entered_base == thisSet.Code)
                    {
                        Output.Write("            <option value=\"" + thisSet.Code + "\" selected=\"selected\" >" + thisSet.Code + " - " + thisSet.Name + "</option>");
                    }
                    else
                    {
                        Output.Write("            <option value=\"" + thisSet.Code + "\" >" + thisSet.Code + " - " + thisSet.Name + "</option>");
                    }
                }
            }
            Output.WriteLine("          </select>");
            Output.WriteLine("        </td>");
            Output.WriteLine("      </tr>");

            // Add line for name
            Output.WriteLine("      <tr>");
            Output.WriteLine("        <td><label for=\"admin_project_name\">Name:</label></td>");
            Output.WriteLine("        <td><input class=\"sbkPav_large_input sbkAdmin_Focusable\" name=\"admin_project_name\" id=\"admin_project_name\" type=\"text\" value=\"" + entered_name + "\" /></td>");
            Output.WriteLine("      <tr>");

            // Add line for description
            Output.WriteLine("      <tr class=\"sbkPav_descriptionRow\">");
            Output.WriteLine("        <td><label for=\"admin_project_desc\">Description:</label></td>");
            Output.WriteLine("        <td><textarea class=\"sbkPav_textarea sbkAdmin_Focusable\" name=\"admin_project_desc\" id=\"admin_project_desc\"/>" + entered_desc + "</textarea></td>");
            Output.WriteLine("      <tr>");

            // Add the SAVE button
            Output.WriteLine("      <tr style=\"height:30px; text-align: center;\"><td colspan=\"2\"><button title=\"Save new default metadata\" class=\"sbkAdm_RoundButton\" onclick=\"return save_new_project();\">SAVE <img src=\"" + Static_Resources_Gateway.Button_Next_Arrow_Png + "\" class=\"sbkAdm_RoundButton_RightImg\" alt=\"\" /></button></td></tr>");
            Output.WriteLine("    </table>");
            Output.WriteLine("  </div>");
            Output.WriteLine("  <br />");
            Output.WriteLine();

            if (UI_ApplicationCache_Gateway.Global_Default_Metadata.Count > 0)
            {
                // Add all the existing proejcts
                Output.WriteLine("  <h2>Existing Global Default Metadata Sets</h2>");
                Output.WriteLine("  <p>The following global default metadata sets can be edited, renamed, or deleted below:</p>");
                Output.WriteLine("  <table class=\"sbkPav_Table sbkAdm_Table\">");
                Output.WriteLine("    <tr>");
                Output.WriteLine("      <th class=\"sbkPav_TableHeader1\">ACTIONS</th>");
                Output.WriteLine("      <th class=\"sbkPav_TableHeader2\">CODE</th>");
                Output.WriteLine("      <th class=\"sbkPav_TableHeader3\">NAME</th>");
                Output.WriteLine("    </tr>");
                Output.WriteLine("    <tr><td class=\"sbkAdm_TableRule\" colspan=\"3\"></td></tr>");

                RequestSpecificValues.Current_Mode.My_Sobek_SubMode = "XXXXXXX";
                string redirect = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

                // Write the data for each interface
                foreach (Default_Metadata thisSet in UI_ApplicationCache_Gateway.Global_Default_Metadata)
                {
                    // Build the action links
                    Output.WriteLine("    <tr>");
                    Output.Write("      <td class=\"sbkAdm_ActionLink\" >( ");
                    Output.Write("<a title=\"Click to edit this default metadata\" href=\"" + redirect.Replace("XXXXXXX", "1" + thisSet.Code) + "\" >edit</a> | ");
                    Output.Write("<a title=\"Click to change the name of this default metadata\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return project_form_popup('" + thisSet.Code + "','" + thisSet.Name.Replace("'", "&quot;") + "', '" + thisSet.Description.Replace("'", "&quot;") + "');\">rename</a> ");
                    if (String.Compare(thisSet.Code, "none", StringComparison.OrdinalIgnoreCase) != 0)
                    {
                        if (RequestSpecificValues.Current_User.Is_System_Admin)
                        {
                            Output.WriteLine("| <a title=\"Click to delete this default metadata\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\"  onclick=\"return delete_project('" + thisSet.Code + "');\">delete</a> )</td>");
                        }
                        else
                        {
                            Output.WriteLine("| <a title=\"Only SYSTEM administrators can delete default metadata\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\"  onclick=\"alert('Only SYSTEM administrators can delete default metadata'); return false;\">delete</a> )</td>");
                        }
                    }
                    else
                    {
                        Output.WriteLine(")</td>");
                    }


                    // Add the rest of the row with data
                    Output.WriteLine("      <td>" + thisSet.Code + "</td>");
                    Output.WriteLine("      <td>" + thisSet.Name + "</td>");
                    Output.WriteLine("    </tr>");
                    Output.WriteLine("    <tr><td></td><td colspan=\"2\" class=\"sbkPav_DescriptionCell\">" + HttpUtility.HtmlEncode(thisSet.Description) + "</td></tr>");
                    Output.WriteLine("    <tr><td class=\"sbkAdm_TableRule\" colspan=\"3\"></td></tr>");
                }

                Output.WriteLine("  </table>");
                Output.WriteLine("  <br />");
            }

            Output.WriteLine("</div>");
            Output.WriteLine();
        }
示例#59
0
        /// <summary> Add the HTML to be displayed in the main SobekCM viewer area </summary>
        /// <param name="Output"> Textwriter to write the HTML for this viewer</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public override void Write_HTML(TextWriter Output, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Home_AdminViewer.Write_HTML", String.Empty);

            Output.WriteLine("<div class=\"SobekHomeText\" >");
            Output.WriteLine("<table width=\"700\"><tr><td width=\"200px\">&nbsp;</td>");
            Output.WriteLine("<td><div style=\"font-size:larger\">");
            Output.WriteLine("<br />");
            Output.WriteLine("<br />");
            Output.WriteLine("What would you like to edit today?");
            Output.WriteLine("<blockquote>");

            Output.WriteLine("<table>");

            // Edit item aggregations
            currentMode.Admin_Type = Admin_Type_Enum.Aggregations_Mgmt;
            Output.WriteLine("<tr valign=\"middle\" height=\"40px\"><td width=\"35px\"><a href=\"" + currentMode.Redirect_URL() + "\"><img src=\"" + currentMode.Default_Images_URL + "building.gif\" /></a></td><td><a href=\"" + currentMode.Redirect_URL() + "\">Item Aggregations</a></td></tr>");

            // Edit interfaces
            currentMode.Admin_Type = Admin_Type_Enum.Interfaces;
            Output.WriteLine("<tr valign=\"middle\" height=\"40px\"><td width=\"35px\"><a href=\"" + currentMode.Redirect_URL() + "\"><img src=\"" + currentMode.Default_Images_URL + "skins.gif\" /></a></td><td><a href=\"" + currentMode.Redirect_URL() + "\">Web Skins</a></td></tr>");

            // Edit wordmarks
            currentMode.Admin_Type = Admin_Type_Enum.Wordmarks;
            Output.WriteLine("<tr valign=\"middle\" height=\"40px\"><td width=\"35px\"><a href=\"" + currentMode.Redirect_URL() + "\"><img src=\"" + currentMode.Default_Images_URL + "wordmarks.gif\" /></a></td><td><a href=\"" + currentMode.Redirect_URL() + "\">Wordmarks / Icons</a></td></tr>");

            // Edit forwarding
            currentMode.Admin_Type = Admin_Type_Enum.Forwarding;
            Output.WriteLine("<tr valign=\"middle\" height=\"40px\"><td width=\"35px\"><a href=\"" + currentMode.Redirect_URL() + "\"><img src=\"" + currentMode.Default_Images_URL + "forwarding.gif\" /></a></td><td><a href=\"" + currentMode.Redirect_URL() + "\">Aggregation Aliases</a></td></tr>");

            // Edit Projects
            currentMode.Admin_Type = Admin_Type_Enum.Projects;
            Output.WriteLine("<tr valign=\"middle\" height=\"40px\"><td width=\"35px\"><a href=\"" + currentMode.Redirect_URL() + "\"><img src=\"" + currentMode.Default_Images_URL + "pmets.gif\" /></a></td><td><a href=\"" + currentMode.Redirect_URL() + "\">Projects</a></td></tr>");

            // Edit Thematic Headings
            currentMode.Admin_Type = Admin_Type_Enum.Thematic_Headings;
            Output.WriteLine("<tr valign=\"middle\" height=\"40px\"><td width=\"35px\"></td><td><a href=\"" + currentMode.Redirect_URL() + "\">Thematic Headings</a></td></tr>");

            if (user.Is_System_Admin)
            {
                // Edit users
                currentMode.Admin_Type = Admin_Type_Enum.Users;
                Output.WriteLine("<tr valign=\"middle\" height=\"40px\"><td width=\"35px\"><a href=\"" + currentMode.Redirect_URL() + "\"><img src=\"" + currentMode.Default_Images_URL + "users.gif\" /></a></td><td><a href=\"" + currentMode.Redirect_URL() + "\">Registered Users and Groups</a></td></tr>");

                // Edit IP Restrictions
                currentMode.Admin_Type = Admin_Type_Enum.IP_Restrictions;
                Output.WriteLine("<tr valign=\"middle\" height=\"40px\"><td width=\"35px\"><a href=\"" + currentMode.Redirect_URL() + "\"><img src=\"" + currentMode.Default_Images_URL + "firewall.gif\" /></a></td><td><a href=\"" + currentMode.Redirect_URL() + "\">IP Restriction Ranges</a></td></tr>");

                // Edit URL Portals
                currentMode.Admin_Type = Admin_Type_Enum.URL_Portals;
                Output.WriteLine("<tr valign=\"middle\" height=\"40px\"><td width=\"35px\"><a href=\"" + currentMode.Redirect_URL() + "\"><img src=\"" + currentMode.Default_Images_URL + "portals.gif\" /></a></td><td><a href=\"" + currentMode.Redirect_URL() + "\">URL Portals</a></td></tr>");

                // Edit Settings
                currentMode.Admin_Type = Admin_Type_Enum.Settings;
                Output.WriteLine("<tr valign=\"middle\" height=\"40px\"><td width=\"35px\"><a href=\"" + currentMode.Redirect_URL() + "\"><img src=\"" + currentMode.Default_Images_URL + "wrench.png\" /></a></td><td><a href=\"" + currentMode.Redirect_URL() + "\">System-Wide Settings</a></td></tr>");

                // View and set SobekCM Builder Status
                currentMode.Admin_Type = Admin_Type_Enum.Builder_Status;
                Output.WriteLine("<tr valign=\"middle\" height=\"40px\"><td width=\"35px\"><a href=\"" + currentMode.Redirect_URL() + "\"><img src=\"" + currentMode.Default_Images_URL + "gears.png\" /></a></td><td><a href=\"" + currentMode.Redirect_URL() + "\">SobekCM Builder Status</a></td></tr>");
            }

            // Reset cache
            currentMode.Admin_Type = Admin_Type_Enum.Reset;
            Output.WriteLine("<tr valign=\"middle\" height=\"40px\"><td width=\"35px\"><a href=\"" + currentMode.Redirect_URL() + "\"><img src=\"" + currentMode.Default_Images_URL + "refresh.gif\" /></a></td><td><a href=\"" + currentMode.Redirect_URL() + "\">Reset Cache</a></td></tr>");

            currentMode.Admin_Type = Admin_Type_Enum.Home;

            Output.WriteLine("</table>");
            Output.WriteLine("</blockquote>");
            Output.WriteLine("<br />");
            Output.WriteLine("</div>");
            Output.WriteLine("</td></tr></table>");
            Output.WriteLine(" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; For clarification on any of these options, <a href=\"" + SobekCM_Library_Settings.Help_URL(currentMode.Base_URL) + "admin/tasks\" target=\"ADMIN_USER_HELP\" >click here to view the help page</a>.<br /><br />");
            Output.WriteLine(" &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; You are currently running version " + SobekCM_Library_Settings.CURRENT_WEB_VERSION + ". ( <a href=\"http://ufdc.ufl.edu/sobekcm/development/history\">see release notes</a> )<br /><br />");
            Output.WriteLine("</div>");
        }
        /// <summary> Gets a fully built item aggregation object for a particular aggregation code and language code.  </summary>
        /// <param name="AggregationCode">Code for this aggregation object</param>
        /// <param name="Language_Code">Code for the language for this aggregation object</param>
        /// <param name="CacheInstance">Instance of this item aggregation pulled from cache (or NULL)</param>
        /// <param name="IsRobot">Flag tells if this request is from a robot (which will vary cacheing time)</param>
        /// <param name="StoreInCache"> Flag indicates if this should be stored in the cache once built </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <returns>Fully built item aggregation object for the particular aggregation code and language code</returns>
        /// <remarks>Item aggregation object is also placed in the cache.<br /><br />
        /// Building of an item aggregation always starts by pulling the item from the database ( either <see cref="SobekCM_Database.Get_Item_Aggregation"/> or <see cref="SobekCM_Database.Get_Main_Aggregation"/> ).<br /><br />
        /// Then, either the Item Aggregation XML file is read (if present) or the entire folder hierarchy is analyzed to find the browses, infos, banners, etc..</remarks>
        public static Item_Aggregation Get_Item_Aggregation(string AggregationCode, string Language_Code, Item_Aggregation CacheInstance, bool IsRobot, bool StoreInCache, Custom_Tracer Tracer)
        {
            // Does this exist in the cache?
            if (CacheInstance == null)
            {
                if (Tracer != null)
                {
                    Tracer.Add_Trace("Item_Aggregation_Builder.Get_Item_Aggregation", "Creating '" + AggregationCode + "' item aggregation");
                }

                // Get the information about this collection and this entry point
                Item_Aggregation hierarchyObject;
                if ((AggregationCode.Length > 0) && (AggregationCode != "all"))
                {
                    hierarchyObject = SobekCM_Database.Get_Item_Aggregation(AggregationCode, false, IsRobot, Tracer);
                }
                else
                {
                    hierarchyObject = SobekCM_Database.Get_Main_Aggregation(Tracer);
                }

                // If no value was returned, don't do anything else here
                if (hierarchyObject != null)
                {
                    // Add all the values to this object
                    string xmlDataFile = SobekCM_Library_Settings.Base_Design_Location + hierarchyObject.ObjDirectory + "\\" + hierarchyObject.Code + ".xml";
                    if (File.Exists(xmlDataFile))
                    {
                        if (Tracer != null)
                        {
                            Tracer.Add_Trace("Item_Aggregation_Builder.Get_Item_Aggregation", "Reading XML Configuration File");
                        }

                        // Add the ALL and NEW browses
                        Add_All_New_Browses(hierarchyObject);

                        // Add all the other data from the XML file
                        Item_Aggregation_XML_Reader reader = new Item_Aggregation_XML_Reader();
                        reader.Add_Info_From_XML_File(hierarchyObject, xmlDataFile);
                    }
                    else
                    {
                        if (Tracer != null)
                        {
                            Tracer.Add_Trace("Item_Aggregation_Builder.Get_Item_Aggregation", "Adding banner, home, and all/new browse information");
                        }

                        Add_HTML(hierarchyObject);
                        Add_All_New_Browses(hierarchyObject);
                        if (!IsRobot)
                        {
                            if (Tracer != null)
                            {
                                Tracer.Add_Trace("Item_Aggregation_Builder.Get_Item_Aggregation", "Scanning Design Directory for browse and info files");
                            }
                            Add_Browse_Files(hierarchyObject, Tracer);
                        }

                        // Since there was no configuration file, save one
                        hierarchyObject.Write_Configuration_File(SobekCM_Library_Settings.Base_Design_Location + hierarchyObject.ObjDirectory);
                    }

                    // Now, save this to the cache
                    if ((!IsRobot) && (StoreInCache))
                    {
                        Cached_Data_Manager.Store_Item_Aggregation(AggregationCode, Language_Code, hierarchyObject, Tracer);
                    }
                    else
                    {
                        if (Tracer != null)
                        {
                            Tracer.Add_Trace("Item_Aggregation_Builder.Get_Item_Aggregation", "Skipping storing item aggregation on cache due to robot flag");
                        }
                    }

                    // Return this built hierarchy object
                    return(hierarchyObject);
                }

                if (Tracer != null)
                {
                    Tracer.Add_Trace("Item_Aggregation_Builder.Get_Item_Aggregation", "NULL value returned from database");
                }
                return(null);
            }

            if (Tracer != null)
            {
                Tracer.Add_Trace("Item_Aggregation_Builder.Get_Item_Aggregation", "Found '" + AggregationCode + "' item aggregation in cache");
            }

            // Get the HTML element and search fields and return all this
            return(CacheInstance);
        }