Example #1
0
        /// <summary> Constructor for a new instance of the Map_Search_AggregationViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <param name="ViewBag"> Aggregation-specific request information, such as aggregation object and any browse object requested </param>
        public Map_Search_AggregationViewer(RequestCache RequestSpecificValues, AggregationViewBag ViewBag)
            : base(RequestSpecificValues, ViewBag)
        {
            // Compute the redirect stem to use
            string fields        = RequestSpecificValues.Current_Mode.Search_Fields;
            string search_string = RequestSpecificValues.Current_Mode.Search_String;

            RequestSpecificValues.Current_Mode.Search_String    = String.Empty;
            RequestSpecificValues.Current_Mode.Search_Fields    = String.Empty;
            RequestSpecificValues.Current_Mode.Mode             = Display_Mode_Enum.Results;
            RequestSpecificValues.Current_Mode.Search_Type      = Search_Type_Enum.Map;
            RequestSpecificValues.Current_Mode.Search_Precision = Search_Precision_Type_Enum.Inflectional_Form;
            string redirect_stem = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.Search;
            RequestSpecificValues.Current_Mode.Search_String = search_string;
            RequestSpecificValues.Current_Mode.Search_Fields = fields;
            // Now, populate the search terms, if there was one or some
            text1 = String.Empty;
            text2 = String.Empty;
            text3 = String.Empty;
            text4 = String.Empty;
            if (RequestSpecificValues.Current_Mode.Search_String.Length > 0)
            {
                string[] splitter = RequestSpecificValues.Current_Mode.Search_String.Split(",".ToCharArray());
                bool     isNumber = true;
                foreach (char thisChar in splitter[0])
                {
                    if ((!Char.IsDigit(thisChar)) && (thisChar != '.') && (thisChar != '-'))
                    {
                        isNumber = false;
                    }
                }
                if (isNumber)
                {
                    text1 = splitter[0].Replace(" =", " or ");


                    if (splitter.Length > 1)
                    {
                        foreach (char thisChar in splitter[1])
                        {
                            if ((!Char.IsDigit(thisChar)) && (thisChar != '.') && (thisChar != '-'))
                            {
                                isNumber = false;
                            }
                        }
                        if (isNumber)
                        {
                            text2 = splitter[1].Replace(" =", " or ");

                            if (splitter.Length > 2)
                            {
                                foreach (char thisChar in splitter[2])
                                {
                                    if ((!Char.IsDigit(thisChar)) && (thisChar != '.') && (thisChar != '-'))
                                    {
                                        isNumber = false;
                                    }
                                }

                                if (isNumber)
                                {
                                    text3 = splitter[2].Replace(" =", " or ");

                                    foreach (char thisChar in splitter[3])
                                    {
                                        if ((!Char.IsDigit(thisChar)) && (thisChar != '.') && (thisChar != '-'))
                                        {
                                            isNumber = false;
                                        }
                                    }

                                    if (isNumber)
                                    {
                                        text4 = splitter[3].Replace(" =", " or ");
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // Add the google script information
            mapHeight = 500;
            StringBuilder scriptBuilder = new StringBuilder();

            // Only continue if there actually IS a map key
            if (!String.IsNullOrWhiteSpace(UI_ApplicationCache_Gateway.Settings.System.Google_Map_API_Key))
            {
                scriptBuilder.AppendLine("<script src=\"https://maps.googleapis.com/maps/api/js?key=" + UI_ApplicationCache_Gateway.Settings.System.Google_Map_API_Key + "\" type=\"text/javascript\"></script>");
                scriptBuilder.AppendLine("<script type=\"text/javascript\" src=\"" + Static_Resources_Gateway.Sobekcm_Map_Search_Js + "\"></script>");
                scriptBuilder.AppendLine("<script type=\"text/javascript\" src=\"" + Static_Resources_Gateway.Sobekcm_Map_Tool_Js + "\"></script>");

                scriptBuilder.AppendLine("<script type=\"text/javascript\">");
                scriptBuilder.AppendLine("  //<![CDATA[");
                scriptBuilder.AppendLine("  function load() { ");

                // Set the latitude and longitude
                int     zoom      = 1;
                decimal latitude  = 0;
                decimal longitude = 0;
                if (ViewBag.Hierarchy_Object.Map_Search_Display != null)
                {
                    if ((ViewBag.Hierarchy_Object.Map_Search_Display.ZoomLevel.HasValue) && (ViewBag.Hierarchy_Object.Map_Search_Display.Latitude.HasValue) && (ViewBag.Hierarchy_Object.Map_Search_Display.Longitude.HasValue))
                    {
                        latitude  = ViewBag.Hierarchy_Object.Map_Search_Display.Latitude.Value;
                        longitude = ViewBag.Hierarchy_Object.Map_Search_Display.Longitude.Value;
                        zoom      = ViewBag.Hierarchy_Object.Map_Search_Display.ZoomLevel.Value;
                    }
                }
                scriptBuilder.AppendLine("    load_search_map(" + latitude + ", " + longitude + ", " + zoom + ", \"map1\");");

                //// If no point searching is allowed, disable it
                //if (ViewBag.Hierarchy_Object.Map_Search >= 100)
                //{
                //    pointSearchingDisabled = true;
                //    scriptBuilder.AppendLine("    disable_point_searching();");
                //}

                if ((text1.Length > 0) && (text2.Length > 0) && (text3.Length > 0) && (text4.Length > 0))
                {
                    scriptBuilder.AppendLine("    add_selection_rectangle( " + text1 + ", " + text2 + ", " + text3 + ", " + text4 + " );");
                    scriptBuilder.AppendLine("    zoom_to_bounds();");
                }
                else if ((text1.Length > 0) && (text2.Length > 0))
                {
                    scriptBuilder.AppendLine("    add_selection_point( " + text1 + ", " + text2 + ", 8 );");
                }

                scriptBuilder.AppendLine("  }");
                scriptBuilder.AppendLine("  //]]>");
                scriptBuilder.AppendLine("</script>");
            }
            else
            {
                // No Google Map API Key
                scriptBuilder.AppendLine("<script type=\"text/javascript\">");
                scriptBuilder.AppendLine("  //<![CDATA[ ");
                scriptBuilder.AppendLine("  function load() {  }");
                scriptBuilder.AppendLine("  //]]>");
                scriptBuilder.AppendLine("</script>");
            }
            Search_Script_Reference = scriptBuilder.ToString();

            // Get the action name for the button
            Search_Script_Action = "map_search_sobekcm('" + redirect_stem + "');";
        }
Example #2
0
        /// <summary> Add controls directly to the form in the main control area placeholder </summary>
        /// <param name="MainPlaceHolder"> Main place holder to which all main controls are added </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> The bulk of this page is added here, as controls </remarks>
        public override void Add_Controls(PlaceHolder MainPlaceHolder, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("NewPassword_MySobekViewer.Add_Controls", "");

            User_Object user = RequestSpecificValues.Current_User;

            // Is this for registration?
            bool registration = (HttpContext.Current.Session["user"] == null);

            if (registration)
            {
                user = new User_Object();
            }

            string current_password = String.Empty;
            string new_password     = String.Empty;
            string new_password2    = String.Empty;

            if (RequestSpecificValues.Current_Mode.isPostBack)
            {
                // Loop through and get the dataa
                string[] getKeys = HttpContext.Current.Request.Form.AllKeys;
                foreach (string thisKey in getKeys)
                {
                    switch (thisKey)
                    {
                    case "current_password_enter":
                        current_password = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "new_password_enter":
                        new_password = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "new_password_confirm":
                        new_password2 = HttpContext.Current.Request.Form[thisKey];
                        break;
                    }
                }

                if ((new_password.Trim().Length == 0) || (new_password2.Trim().Length == 0))
                {
                    validationErrors.Add("Select and confirm a new password");
                }
                if (new_password != new_password2)
                {
                    validationErrors.Add("New passwords do not match");
                }
                else if ((new_password.Length < 8) && (new_password.Length > 0))
                {
                    validationErrors.Add("Password must be at least eight digits");
                }
                if (validationErrors.Count == 0)
                {
                    if (new_password == current_password)
                    {
                        validationErrors.Add("The new password cannot match the old password");
                    }
                }

                if (validationErrors.Count == 0)
                {
                    bool success = SobekCM_Database.Change_Password(user.UserName, current_password, new_password, false, Tracer);
                    if (success)
                    {
                        user.Is_Temporary_Password = false;
                        // Forward back to their original URL (unless the original URL was this logon page)
                        string raw_url = (HttpContext.Current.Request.RawUrl);
                        if (raw_url.ToUpper().IndexOf("M=HML") > 0)
                        {
                            RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                            UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                            return;
                        }
                        else
                        {
                            HttpContext.Current.Response.Redirect(HttpContext.Current.Request.RawUrl, false);
                            HttpContext.Current.ApplicationInstance.CompleteRequest();
                            RequestSpecificValues.Current_Mode.Request_Completed = true;
                            return;
                        }
                    }
                    else
                    {
                        validationErrors.Add("Unable to change password.  Verify current password.");
                    }
                }
            }

            StringBuilder literalBuilder = new StringBuilder(1000);

            literalBuilder.AppendLine("<script src=\"" + Static_Resources_Gateway.Sobekcm_Metadata_Js + "\" type=\"text/javascript\"></script>");
            literalBuilder.AppendLine("<div class=\"SobekHomeText\" >");
            literalBuilder.AppendLine("<br />");
            literalBuilder.AppendLine("<blockquote>");
            literalBuilder.AppendLine(user.Is_Temporary_Password
                                          ? "You are required to change your password to continue."
                                          : "Please enter your existing password and your new password.");
            if (validationErrors.Count > 0)
            {
                literalBuilder.AppendLine("<br /><br /><strong><span style=\"color: Red\">The following errors were detected:");
                literalBuilder.AppendLine("<blockquote>");
                foreach (string thisError in validationErrors)
                {
                    literalBuilder.AppendLine(thisError + "<br />");
                }
                literalBuilder.AppendLine("</blockquote>");
                literalBuilder.AppendLine("</span></strong>");
            }
            literalBuilder.AppendLine("</blockquote>");
            literalBuilder.AppendLine("<table width=\"700px\"><tr><td width=\"180px\">&nbsp;</td>");
            literalBuilder.AppendLine("<td width=\"200px\"><label for=\"current_password_enter\">Existing Password:</label></td>");
            literalBuilder.AppendLine("<td width=\"180px\">");
            LiteralControl literal1 = new LiteralControl(literalBuilder.ToString());

            literalBuilder.Remove(0, literalBuilder.Length);
            MainPlaceHolder.Controls.Add(literal1);

            existingPasswordBox = new TextBox
            {
                CssClass = "preferences_small_input",
                ID       = "current_password_enter",
                TextMode = TextBoxMode.Password
            };
            existingPasswordBox.Attributes.Add("onfocus", "textbox_enter('current_password_enter', 'preferences_small_input_focused')");
            existingPasswordBox.Attributes.Add("onblur", "textbox_leave('current_password_enter', 'preferences_small_input')");
            MainPlaceHolder.Controls.Add(existingPasswordBox);

            LiteralControl literal2 = new LiteralControl("</td><td width=\"140px\">&nbsp;</td></tr>" + Environment.NewLine + "<tr><td>&nbsp;</td><td><label for=\"new_password_enter\">New Password:</label></td><td>");

            MainPlaceHolder.Controls.Add(literal2);

            passwordBox = new TextBox
            {
                CssClass = "preferences_small_input",
                ID       = "new_password_enter",
                TextMode = TextBoxMode.Password
            };
            passwordBox.Attributes.Add("onfocus", "textbox_enter('new_password_enter', 'preferences_small_input_focused')");
            passwordBox.Attributes.Add("onblur", "textbox_leave('new_password_enter', 'preferences_small_input')");
            MainPlaceHolder.Controls.Add(passwordBox);

            LiteralControl literal3 = new LiteralControl("</td><td>&nbsp;</td></tr>" + Environment.NewLine + "<tr><td>&nbsp;</td><td><label for=\"new_password_confirm\">Confirm New Password:</label></td><td>");

            MainPlaceHolder.Controls.Add(literal3);

            confirmPasswordBox = new TextBox
            {
                CssClass = "preferences_small_input",
                ID       = "new_password_confirm",
                TextMode = TextBoxMode.Password
            };
            confirmPasswordBox.Attributes.Add("onfocus", "textbox_enter('new_password_confirm', 'preferences_small_input_focused')");
            confirmPasswordBox.Attributes.Add("onblur", "textbox_leave('new_password_confirm', 'preferences_small_input')");
            MainPlaceHolder.Controls.Add(confirmPasswordBox);

            literalBuilder.AppendLine("   </td><td>&nbsp;</td></tr>");
            literalBuilder.AppendLine("  <tr align=\"right\" valign=\"bottom\" height=\"50px\" ><td colspan=\"3\">");
            RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Log_Out;
            literalBuilder.AppendLine("    <a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "\"><img src=\"" + RequestSpecificValues.Current_Mode.Base_URL + "design/skins/" + RequestSpecificValues.Current_Mode.Base_Skin_Or_Skin + "/buttons/cancel_button.gif\" border=\"0\" alt=\"CANCEL\" /></a> &nbsp; ");
            RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.New_Password;

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

            MainPlaceHolder.Controls.Add(literal4);

            // Add the submit button
            ImageButton submitButton = new ImageButton
            {
                ImageUrl      = RequestSpecificValues.Current_Mode.Base_URL + "design/skins/" + RequestSpecificValues.Current_Mode.Base_Skin_Or_Skin + "/buttons/save_button.gif",
                AlternateText = "SAVE"
            };

            submitButton.Click += submitButton_Click;
            MainPlaceHolder.Controls.Add(submitButton);

            LiteralControl literal5 = new LiteralControl("</td></tr></table></blockquote></div>\n\n<!-- Focus on current password text box -->\n<script type=\"text/javascript\">focus_element('current_password_enter');</script>\n\n");

            MainPlaceHolder.Controls.Add(literal5);
        }
Example #3
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 override void Write_Main_Viewer_Section(TextWriter Output, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("HTML_ItemViewer.Write_Main_Viewer_Section", "");
            }

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

            // Start the citation table
            Output.WriteLine("\t\t<!-- HTML VIEWER OUTPUT -->");
            Output.WriteLine("\t\t<td style=\"align:left;\">");

            // Determine some replacement strings here
            string itemURL  = SobekFileSystem.Resource_Web_Uri(BriefItem);
            string itemLink = CurrentRequest.Base_URL + "/" + BriefItem.BibID + "/" + BriefItem.VID;

            // Determine the source string
            string sourceString = SobekFileSystem.Resource_Web_Uri(BriefItem) + htmlFile;

            if ((htmlFile.IndexOf("http://") == 0) || (htmlFile.IndexOf("https://") == 0) || (htmlFile.IndexOf("[%BASEURL%]") == 0) || (htmlFile.IndexOf("<%BASEURL%>") == 0))
            {
                sourceString = htmlFile.Replace("[%BASEURL%]", CurrentRequest.Base_URL).Replace("<%BASEURL%>", CurrentRequest.Base_URL);
            }

            // Try to get the HTML for this
            if (Tracer != null)
            {
                Tracer.Add_Trace("HTML_ItemViewer.Write_Main_Viewer_Section", "Reading html for this view from static page");
            }
            string map;

            try
            {
                map = SobekFileSystem.ReadToEnd(BriefItem, sourceString);
            }
            catch
            {
                StringBuilder builder = new StringBuilder();
                builder.AppendLine("<div style=\"background-color: White; color: black;text-align:center; width:630px;\">");
                builder.AppendLine("  <br /><br />");
                builder.AppendLine("  <span style=\"font-weight:bold;font-size:1.4em\">Unable to pull html view for item ( <a href=\"" + sourceString + "\">source</a> )</span><br /><br />");
                builder.AppendLine("  <span style=\"font-size:1.2em\">We apologize for the inconvenience.</span><br /><br />");

                string returnurl = CurrentRequest.Base_URL + "/contact";
                builder.AppendLine("  <span style=\"font-size:1.2em\">Click <a href=\"" + returnurl + "\">here</a> to report the problem.</span>");
                builder.AppendLine("  <br /><br />");
                builder.AppendLine("</div>");
                map = builder.ToString();
            }

            // Write the HTML
            string url_options = UrlWriterHelper.URL_Options(CurrentRequest);
            string urlOptions1 = String.Empty;
            string urlOptions2 = String.Empty;

            if (url_options.Length > 0)
            {
                urlOptions1 = "?" + url_options;
                urlOptions2 = "&" + url_options;
            }
            Output.WriteLine(map.Replace("<%URLOPTS%>", url_options).Replace("<%?URLOPTS%>", urlOptions1).Replace("<%&URLOPTS%>", urlOptions2).Replace("<%ITEMURL%>", itemURL).Replace("<%ITEM_LINK%>", itemLink));

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

            // Restore the mode
            CurrentRequest.ViewerCode = current_view_code;
        }
        /// <summary> Constructor for a new instance of the Contact_HtmlSubwriter class </summary>
        /// <param name="Last_Mode"> URL for the last mode this user was in before selecting contact us</param>
        /// <param name="UserHistoryRequestInfo"> Some history and user information to include in the final email </param>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public Contact_HtmlSubwriter(string Last_Mode, string UserHistoryRequestInfo, RequestCache RequestSpecificValues) : base(RequestSpecificValues)
        {
            // Save the parameters
            lastMode = Last_Mode;

            // Set the error message to an empty string to start with
            errorMsg = String.Empty;

            // We need the aggregation here
            Item_Aggregation aggregation;

            if (!Get_Collection(RequestSpecificValues.Current_Mode, RequestSpecificValues.Tracer, out aggregation))
            {
                aggregation = RequestSpecificValues.Top_Collection;
            }

            // Determine the configuration to use for this contact us form
            configuration = UI_ApplicationCache_Gateway.Configuration.ContactForm;
            if ((aggregation != null) && (aggregation.ContactForm != null))
            {
                configuration = aggregation.ContactForm;
            }

            postBackValues = new Dictionary <string, string>();
            foreach (string thisKey in HttpContext.Current.Request.Form.AllKeys)
            {
                if (thisKey != "item_action")
                {
                    string value = HttpContext.Current.Request.Form[thisKey];
                    if (!String.IsNullOrEmpty(value))
                    {
                        postBackValues[thisKey] = value;
                    }
                }
            }

            // If this is a post back, send email
            if (HttpContext.Current.Request.Form["item_action"] == null)
            {
                return;
            }

            string action = HttpContext.Current.Request.Form["item_action"];

            if (action == "email")
            {
                // Some values to collect information
                string subject      = "Contact [" + RequestSpecificValues.Current_Mode.Instance_Abbreviation + " Submission]";
                string message_from = RequestSpecificValues.Current_Mode.Instance_Abbreviation + "<" + UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromAddress + ">";
                if (!String.IsNullOrEmpty(UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromDisplay))
                {
                    message_from = UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromDisplay + "<" + UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromAddress + ">";
                }
                int           text_area_count = configuration.TextAreaElementCount;
                StringBuilder emailBuilder    = new StringBuilder();

                // Make sure all the required fields are completed and build the emails
                StringBuilder errorBuilder  = new StringBuilder();
                int           control_count = 1;
                foreach (ContactForm_Configuration_Element thisElement in configuration.FormElements)
                {
                    if ((thisElement.Element_Type != ContactForm_Configuration_Element_Type_Enum.HiddenValue) && (thisElement.Element_Type != ContactForm_Configuration_Element_Type_Enum.ExplanationText))
                    {
                        // Determine the name of this control
                        string control_name = String.Empty;
                        if (!String.IsNullOrEmpty(thisElement.Name))
                        {
                            control_name = thisElement.Name.Replace(" ", "_");
                        }
                        if (thisElement.Element_Type == ContactForm_Configuration_Element_Type_Enum.Subject)
                        {
                            control_name = "subject";
                        }
                        if (thisElement.Element_Type == ContactForm_Configuration_Element_Type_Enum.Email)
                        {
                            control_name = "email";
                        }
                        if (String.IsNullOrEmpty(control_name))
                        {
                            control_name = "Control" + control_count;
                        }

                        if (!postBackValues.ContainsKey(control_name))
                        {
                            if (thisElement.Required)
                            {
                                errorBuilder.Append(thisElement.QueryText.Get_Value(RequestSpecificValues.Current_Mode.Language).Replace(":", "") + "<br />");
                            }
                        }
                        else
                        {
                            if (thisElement.Element_Type == ContactForm_Configuration_Element_Type_Enum.Subject)
                            {
                                subject = postBackValues[control_name] + " [" + RequestSpecificValues.Current_Mode.Instance_Abbreviation + " Submission]";
                            }
                            else if (thisElement.Element_Type == ContactForm_Configuration_Element_Type_Enum.Email)
                            {
                                string entered_message_from = postBackValues[control_name];

                                if (!IsValidEmail(entered_message_from))
                                {
                                    errorBuilder.Append(thisElement.QueryText.Get_Value(RequestSpecificValues.Current_Mode.Language).Replace(":", "") + " (INVALID) <br />");
                                }

                                message_from = RequestSpecificValues.Current_Mode.Instance_Abbreviation + "<" + entered_message_from + ">";
                                if (!String.IsNullOrEmpty(UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromDisplay))
                                {
                                    message_from = UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromDisplay + "<" + entered_message_from + ">";
                                }

                                emailBuilder.Append("Email:\t\t" + entered_message_from + "\n");
                            }
                            else if (thisElement.Element_Type == ContactForm_Configuration_Element_Type_Enum.TextArea)
                            {
                                if (text_area_count == 1)
                                {
                                    emailBuilder.Insert(0, postBackValues[control_name] + "\n\n");
                                }
                                else
                                {
                                    if (emailBuilder.Length > 0)
                                    {
                                        emailBuilder.Append("\n");
                                    }
                                    emailBuilder.Append(thisElement.QueryText.Get_Value(RequestSpecificValues.Current_Mode.Language) + "\n");
                                    emailBuilder.Append(postBackValues[control_name] + "\n\n");
                                }
                            }
                            else
                            {
                                emailBuilder.Append(control_name.Replace("_", " ") + ":\t\t" + postBackValues[control_name] + "\n");
                            }
                        }

                        control_count++;
                    }
                }

                if (errorBuilder.Length > 0)
                {
                    errorMsg = errorBuilder.ToString();
                    return;
                }

                // Create the final body
                string email_body = emailBuilder + "\n\n" + UserHistoryRequestInfo;

                // Determine the sendee
                string sendTo = UI_ApplicationCache_Gateway.Settings.Email.System_Email;
                if ((aggregation != null) && (!String.IsNullOrEmpty(aggregation.Contact_Email)))
                {
                    sendTo = aggregation.Contact_Email.Replace(";", ",");
                }

                int userid = -1;
                if (RequestSpecificValues.Current_User != null)
                {
                    userid = RequestSpecificValues.Current_User.UserID;
                }

                EmailInfo newEmail = new EmailInfo
                {
                    Body           = email_body,
                    isContactUs    = true,
                    isHTML         = false,
                    RecipientsList = sendTo,
                    Subject        = subject,
                    UserID         = userid,
                    FromAddress    = message_from
                };

                string error_msg;
                bool   email_error = !Email_Helper.SendEmail(newEmail, out error_msg);


                // Send back to the home for this collection, sub, or group
                if (email_error)
                {
                    HttpContext.Current.Response.Redirect(UI_ApplicationCache_Gateway.Settings.Servers.System_Error_URL, false);
                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                }
                else
                {
                    // Send back to the home for this collection, sub, or group
                    RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Contact_Sent;
                    UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                }
            }
        }
Example #5
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 override void Write_Main_Viewer_Section(TextWriter Output, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("Text_Search_ItemViewer.Write_Main_Viewer_Section", "");
            }

            string search_this_document = "Search this document";

            if (CurrentRequest.Language == Web_Language_Enum.French)
            {
                search_this_document = "Rechercher sur ce Document";
            }

            if (CurrentRequest.Language == Web_Language_Enum.Spanish)
            {
                search_this_document = "Buscar en este Objeto";
            }

            // Save the original search string
            string originalSearchString = CurrentRequest.Text_Search;

            Output.WriteLine("       <!-- TEXT SEARCH ITEM VIEWER OUTPUT -->");

            // Determine the value without any search
            string currentSearch = CurrentRequest.Text_Search;

            CurrentRequest.Text_Search = String.Empty;
            string redirect_url = UrlWriterHelper.Redirect_URL(CurrentRequest);

            CurrentRequest.Text_Search = currentSearch;
            string button_text = String.Empty;

            // Makee sure the search is not null
            if (String.IsNullOrWhiteSpace(currentSearch))
            {
                currentSearch = String.Empty;
            }

            // Add the search this document portion
            Output.WriteLine("    <td style=\"text-align:center;\">");
            Output.WriteLine("      <div style=\"padding:10px 0 10px 0;\" >");
            Output.WriteLine("        <label for=\"searchTextBox\">" + search_this_document + ":</label> &nbsp;");
            Output.WriteLine("        <input class=\"sbkTsv_SearchBox sbkIsw_Focusable\" id=\"searchTextBox\" name=\"searchTextBox\" type=\"text\" value=\"" + currentSearch.Replace(" =", " or ") + "\" onkeydown=\"item_search_keytrap(event, '" + redirect_url + "');\" /> &nbsp; ");
            Output.WriteLine("        <button title=\"" + search_this_document + "\" class=\"sbkIsw_RoundButton\" onclick=\"item_search_sobekcm('" + redirect_url + "'); return false;\">GO<img src=\"" + Static_Resources_Gateway.Button_Next_Arrow_Png + "\" class=\"roundbutton_img_right\" alt=\"\" /></button>");
            Output.WriteLine("      </div>");
            if (results != null)
            {
                // Display the explanation string, and possibly paging options if there are more results
                Output.WriteLine("      <hr id=\"sbkTsv_HorizontalLine\">");
                Output.WriteLine("    </td>");
                Output.WriteLine("  </tr>");
                Output.WriteLine("  <tr>");
                Output.WriteLine("    <td style=\"text-align:center;\">");
                Output.WriteLine("      <div id=\"sbkTsv_CurrentSearch\">");
                Output.WriteLine(Compute_Search_Explanation());
                Output.WriteLine("</div>");

                if (results.TotalResults > 20)
                {
                    int current_page = CurrentRequest.SubPage.HasValue ? Math.Max(CurrentRequest.SubPage.Value, ((ushort)1)) : 1;

                    string first_page         = "First Page";
                    string previous_page      = "Previous Page";
                    string next_page          = "Next Page";
                    string last_page          = "Last Page";
                    string first_page_text    = "First";
                    string previous_page_text = "Previous";
                    string next_page_text     = "Next";
                    string last_page_text     = "Last";

                    if (CurrentRequest.Language == Web_Language_Enum.Spanish)
                    {
                        first_page         = "Primera Página";
                        previous_page      = "Página Anterior";
                        next_page          = "Página Siguiente";
                        last_page          = "Última Página";
                        first_page_text    = "Primero";
                        previous_page_text = "Anterior";
                        next_page_text     = "Proximo";
                        last_page_text     = "Último";
                    }

                    if (CurrentRequest.Language == Web_Language_Enum.French)
                    {
                        first_page         = "Première Page";
                        previous_page      = "Page Précédente";
                        next_page          = "Page Suivante";
                        last_page          = "Dernière Page";
                        first_page_text    = "Première";
                        previous_page_text = "Précédente";
                        next_page_text     = "Suivante";
                        last_page_text     = "Derniere";
                    }

                    // Use a stringbuilder here
                    StringBuilder buttonWriter = new StringBuilder(2000);

                    buttonWriter.AppendLine("            <div class=\"sbkIsw_PageNavBar\">");

                    // Should the first and previous buttons be shown?
                    if (current_page > 1)
                    {
                        // Get the URL for the first and previous buttons
                        CurrentRequest.SubPage = 1;
                        string firstButtonURL = UrlWriterHelper.Redirect_URL(CurrentRequest);
                        CurrentRequest.SubPage = (ushort)(current_page - 1);
                        string prevButtonURL = UrlWriterHelper.Redirect_URL(CurrentRequest);

                        buttonWriter.AppendLine("              <span class=\"sbkIsw_LeftPaginationButtons\">");
                        buttonWriter.AppendLine("                <button title=\"" + first_page + "\" class=\"sbkIsw_RoundButton\" onclick=\"window.location='" + firstButtonURL + "'; return false;\"><img src=\"" + Static_Resources_Gateway.Button_First_Arrow_Png + "\" class=\"roundbutton_img_left\" alt=\"\" />" + first_page_text + "</button>&nbsp;");
                        buttonWriter.AppendLine("                <button title=\"" + previous_page + "\" class=\"sbkIsw_RoundButton\" onclick=\"window.location='" + prevButtonURL + "'; return false;\"><img src=\"" + Static_Resources_Gateway.Button_Previous_Arrow_Png + "\" class=\"roundbutton_img_left\" alt=\"\" />" + previous_page_text + "</button>");
                        buttonWriter.AppendLine("              </span>");
                    }



                    // Only continue if there is an item and mode, and there is previous pages to go to
                    int total_pages = (int)Math.Ceiling((((decimal)results.TotalResults) / 20));
                    if (current_page < total_pages)
                    {
                        // Get the URL for the first and previous buttons
                        CurrentRequest.SubPage = (ushort)total_pages;
                        string lastButtonURL = UrlWriterHelper.Redirect_URL(CurrentRequest);
                        CurrentRequest.SubPage = (ushort)(current_page + 1);
                        string nextButtonURL = UrlWriterHelper.Redirect_URL(CurrentRequest);

                        buttonWriter.AppendLine("              <span class=\"sbkIsw_RightPaginationButtons\">");
                        buttonWriter.AppendLine("                <button title=\"" + next_page + "\" class=\"sbkIsw_RoundButton\" onclick=\"window.location='" + nextButtonURL + "'; return false;\">" + next_page_text + "<img src=\"" + Static_Resources_Gateway.Button_Next_Arrow_Png + "\" class=\"roundbutton_img_right\" alt=\"\" /></button>&nbsp;");
                        buttonWriter.AppendLine("                <button title=\"" + last_page + "\" class=\"sbkIsw_RoundButton\" onclick=\"window.location='" + lastButtonURL + "'; return false;\">" + last_page_text + "<img src=\"" + Static_Resources_Gateway.Button_Last_Arrow_Png + "\" class=\"roundbutton_img_right\" alt=\"\" /></button>");
                        buttonWriter.AppendLine("              </span>");
                    }

                    buttonWriter.AppendLine("            </div>");

                    button_text = buttonWriter.ToString();
                    Output.WriteLine(button_text);
                    CurrentRequest.SubPage = (ushort)current_page;
                }
            }
            Output.WriteLine("    </td>");
            Output.WriteLine("  </tr>");

            if ((results != null) && (results.TotalResults > 0))
            {
                // Look that some of these have thumbnails
                char columns   = '2';
                bool hasThumbs = false;
                if (results.Results.Any(Result => Result.Thumbnail.Length > 0))
                {
                    columns   = '3';
                    hasThumbs = true;
                }

                Output.WriteLine("  <tr>");
                Output.WriteLine("    <td id=\"sbkTsv_ResultsArea\">");
                Output.WriteLine("        <table id=\"sbkTsv_ResultsTable\">");

                string thumbnail_root = BriefItem.Web.Source_URL;
                string url_options    = UrlWriterHelper.URL_Options(CurrentRequest);
                if (url_options.Length > 0)
                {
                    url_options = url_options + "&search=" + HttpUtility.UrlEncode(originalSearchString);
                }
                else
                {
                    url_options = "?search=" + HttpUtility.UrlEncode(originalSearchString);
                }
                int  current_displayed_result = ((results.Page_Number - 1) * 20) + 1;
                bool first = true;
                foreach (Legacy_Solr_Page_Result result in results.Results)
                {
                    // If this is not the first results drawn, add a seperating line
                    if (!first)
                    {
                        Output.WriteLine("          <tr><td colspan=\"" + columns + "\"></td></tr>");
                    }
                    else
                    {
                        first = false;
                    }

                    Output.WriteLine("          <tr style=\"vertical-align:middle;\">");
                    Output.WriteLine("            <td class=\"sbkTsv_ResultNumber\">" + current_displayed_result + "</td>");

                    // Only include the thumbnail column if some exist
                    if (hasThumbs)
                    {
                        if (result.Thumbnail.Length > 0)
                        {
                            Output.WriteLine("            <td style=\"text-align:left; width: 150px;\"><a href=\"" + CurrentRequest.Base_URL + BriefItem.BibID + "/" + BriefItem.VID + "/" + result.PageOrder + url_options + "\"><img src=\"" + thumbnail_root + "/" + result.Thumbnail + "\" class=\"sbkTsv_Thumbnail\" /></a></td>");
                        }
                        else
                        {
                            Output.WriteLine("            <td style=\"text-align:left; width: 150px;\"><a href=\"" + CurrentRequest.Base_URL + BriefItem.BibID + "/" + BriefItem.VID + "/" + result.PageOrder + url_options + "\"><img src=\"" + Static_Resources_Gateway.Nothumb_Jpg + "\" class=\"sbkTsv_Thumbnail\" /></a></td>");
                        }
                    }

                    Output.WriteLine("            <td style=\"text-align:left;\">");
                    Output.WriteLine("              <a class=\"sbkTsv_ResultsLink\" href=\"" + CurrentRequest.Base_URL + BriefItem.BibID + "/" + BriefItem.VID + "/" + result.PageOrder + url_options + "\">" + result.PageName + "</a>");
                    if (result.Snippet.Length > 0)
                    {
                        Output.WriteLine("              <br /><br />");
                        Output.WriteLine("              &ldquo;..." + result.Snippet.Replace("<em>", "<span class=\"sbkTsv_HighlightText\">").Replace("</em>", "</span>") + "...&rdquo;");
                    }
                    Output.WriteLine("            </td>");
                    Output.WriteLine("          </tr>");

                    current_displayed_result++;
                }

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

                Output.WriteLine(button_text);
                Output.WriteLine("    </td>");
            }
            else
            {
                Output.WriteLine("  <tr>");
                Output.WriteLine("    <td class=\"sbkTsv_ResultsArea\">");
                Output.WriteLine("        <br />");
                Output.WriteLine("        <h2>Quick Tips</h2>");
                Output.WriteLine("        <div id=\"sbkTsv_QuickTips\">");
                Output.WriteLine("          <ul>");
                Output.WriteLine("            <li><h3>Document Searching</h3>");
                Output.WriteLine("              <p> This option searches the full-text of the document and returns any pages which match<br />");
                Output.WriteLine("              the conditions of your search.</p>");
                Output.WriteLine("            </li>");
                Output.WriteLine("            <li><h3>Boolean Searches</h3>");
                Output.WriteLine("              <p> Use <span class=\"sbkTsv_Bold\">+</span> or <span class=\"sbkTsv_BoldItalic\">and</span> between terms to find records with <span class=\"sbkTsv_Bold\">all</span> the terms.<br />");
                Output.WriteLine("              Use <span class=\"sbkTsv_Bold\">-</span> or <span class=\"sbkTsv_BoldItalic\">or</span> between terms to find records with <span class=\"sbkTsv_Bold\">any</span> of the terms.<br />");
                Output.WriteLine("              Use <span class=\"sbkTsv_Bold\">!</span> or <span class=\"sbkTsv_BoldItalic\">and not</span> between terms to exclude records with terms.<br />");
                Output.WriteLine("              If nothing is indicated, <span class=\"sbkTsv_BoldItalic\">and</span> is the default.<br />");
                Output.WriteLine("              EXAMPLE: natural and not history");
                Output.WriteLine("              </p>");
                Output.WriteLine("            </li>");
                Output.WriteLine("            <li><h3>Phrase Searching</h3>");
                Output.WriteLine("              <p> Placing quotes around a phrase will search for the exact phrase.<br />");
                Output.WriteLine("              EXAMPLE: &quot;natural history&quot;</p>");
                Output.WriteLine("            </li>");
                Output.WriteLine("            <li><h3>Capitalization</h3>");
                Output.WriteLine("              <p> Searches are not capitalization sensitive.<br />");
                Output.WriteLine("              EXAMPLE: Searching for <span class=\"sbkTsv_Italic\">NATURAL</span> will return the same results as searching for <span class=\"sbkTsv_Italic\">natural</span></p>");
                Output.WriteLine("            </li>");
                Output.WriteLine("            <li><h3>Diacritics</h3>");
                Output.WriteLine("              <p> To search for words with diacritics, the character must be entered into the search box.<br />");
                Output.WriteLine("              EXAMPLE: Searching <span class=\"sbkTsv_Italic\">Précédent</span> is a different search than <span class=\"sbkTsv_Italic\">Precedent</span></p>");
                Output.WriteLine("            </li>");
                Output.WriteLine("          </ul>");
                Output.WriteLine("        </div>");
                Output.WriteLine("        <br />");
                Output.WriteLine("    </td>");
            }
        }
        /// <summary> Constructor for a new instance of the WebContent_Usage_AdminViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <remarks> Postback from handling an edit or new aggregation is handled here in the constructor </remarks>
        public WebContent_Usage_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues)
        {
            RequestSpecificValues.Tracer.Add_Trace("WebContent_Usage_AdminViewer.Constructor", String.Empty);
            actionMessage = String.Empty;


            // Ensure the user is the system admin or portal admin
            if ((RequestSpecificValues.Current_User == null) || ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin)))
            {
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.My_Sobek;
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            //// If this is posted back, look for the reset
            //if (RequestSpecificValues.Current_Mode.isPostBack)
            //{
            //    string reset_value = HttpContext.Current.Request.Form[""];
            //    if ((!String.IsNullOrEmpty(reset_value)) && (reset_value == "reset"))
            //    {
            //        // Just ensure everything is emptied out
            //        HttpContext.Current.Cache.Remove("GlobalPermissionsReport");
            //        HttpContext.Current.Cache.Remove("GlobalPermissionsUsersLinked");
            //        HttpContext.Current.Cache.Remove("GlobalPermissionsLinkedAggr");
            //        HttpContext.Current.Cache.Remove("GlobalPermissionsReportSubmit");
            //    }
            //}

            // Set filters initially to empty strings
            level1 = String.Empty;
            level2 = String.Empty;
            level3 = String.Empty;
            level4 = String.Empty;
            level5 = String.Empty;
            month1 = -1;
            year1  = -1;
            month2 = -1;
            year2  = -1;

            // Get any level filter information from the query string
            if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l1"]))
            {
                level1 = HttpContext.Current.Request.QueryString["l1"];

                if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l2"]))
                {
                    level2 = HttpContext.Current.Request.QueryString["l2"];

                    if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l3"]))
                    {
                        level3 = HttpContext.Current.Request.QueryString["l3"];

                        if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l4"]))
                        {
                            level4 = HttpContext.Current.Request.QueryString["l4"];

                            if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l5"]))
                            {
                                level5 = HttpContext.Current.Request.QueryString["l5"];
                            }
                        }
                    }
                }
            }

            // Get the year and month filters
            if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["d1"]))
            {
                string date1 = HttpContext.Current.Request.QueryString["d1"];
                if (date1.Length == 6)
                {
                    int year1possible;
                    int month1possible;
                    if ((Int32.TryParse(date1.Substring(0, 4), out year1possible)) && (Int32.TryParse(date1.Substring(4), out month1possible)))
                    {
                        year1  = year1possible;
                        month1 = month1possible;
                    }
                }
            }
            if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["d2"]))
            {
                string date2 = HttpContext.Current.Request.QueryString["d2"];
                if (date2.Length == 6)
                {
                    int year2possible;
                    int month2possible;
                    if ((Int32.TryParse(date2.Substring(0, 4), out year2possible)) && (Int32.TryParse(date2.Substring(4), out month2possible)))
                    {
                        year2  = year2possible;
                        month2 = month2possible;
                    }
                }
            }

            // If the end year is filled out, but not the month, set to the end of that year
            if ((year2 > 1900) && (month2 < 1) || (month2 > 12))
            {
                month2 = (year2 == DateTime.Now.Year) ? DateTime.Now.Month : 12;
            }

            // If no final year/month, set it to now as well
            if (year2 < 1900)
            {
                year2  = UI_ApplicationCache_Gateway.Stats_Date_Range.Latest_Year;
                month2 = UI_ApplicationCache_Gateway.Stats_Date_Range.Latest_Month;
            }

            // If no initial year/month, use the first stats date
            if ((year1 < 1900) || (year1 < UI_ApplicationCache_Gateway.Stats_Date_Range.Earliest_Year))
            {
                year1  = UI_ApplicationCache_Gateway.Stats_Date_Range.Earliest_Year;
                month1 = UI_ApplicationCache_Gateway.Stats_Date_Range.Earliest_Month;
            }

            if ((month1 < 1) || (month1 > 12))
            {
                month1 = 1;
                if (year1 == UI_ApplicationCache_Gateway.Stats_Date_Range.Earliest_Year)
                {
                    month1 = UI_ApplicationCache_Gateway.Stats_Date_Range.Earliest_Month;
                }
            }
        }
        ///// <summary> Gets the collection of special behaviors which this item viewer
        ///// requests from the main HTML subwriter. </summary>
        //public override List<HtmlSubwriter_Behaviors_Enum> ItemViewer_Behaviors
        //{
        //	get
        //	{
        //		return new List<HtmlSubwriter_Behaviors_Enum>
        //			{
        //				HtmlSubwriter_Behaviors_Enum.Item_Subwriter_Suppress_Left_Navigation_Bar
        //			};
        //	}
        //}

        /// <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("Dataset_CodeBook_ItemViewer.Write_Main_Viewer_Section", "");
            }

            Output.WriteLine("          <td><div id=\"sbkDcv_ViewerTitle\">Data Structure / Codebook</div></td>");
            Output.WriteLine("        </tr>");
            Output.WriteLine("        <tr>");


            // Was there an error?
            if ((itemDataset == null) || (error_message.Length > 0))
            {
                Output.WriteLine("          <td id=\"sbkDcv_MainAreaError\">");
                if (error_message.Length > 0)
                {
                    Output.WriteLine("            " + error_message);
                }
                else
                {
                    Output.WriteLine("            No XML dataset found in the digital resource");
                }
                Output.WriteLine("          </td>");
                return;
            }

            // Start the main area
            const string INDENT = "          ";

            // If only one datatable set the subpage
            if (itemDataset.Tables.Count == 1)
            {
                CurrentMode.SubPage = 2;
            }

            if ((CurrentMode.SubPage < 2) || (CurrentMode.SubPage > (1 + itemDataset.Tables.Count)))
            {
                Output.WriteLine("          <td id=\"sbkDcv_MainArea\">");

                // Add the information about all the datatables
                int table_number = 1;
                foreach (DataTable thisTable in itemDataset.Tables)
                {
                    Output.WriteLine(INDENT + "<div id=\"CodeBookTable" + table_number + "\" class=\"sbkDcv_TableDiv\">");
                    Output.WriteLine(INDENT + "  <table class=\"sbkDcv_Table\">");

                    // Add the header row
                    Output.WriteLine(INDENT + "    <tr>");
                    Output.WriteLine(INDENT + "      <td>&nbsp;</td>");
                    CurrentMode.SubPage = (ushort)(table_number + 1);
                    Output.WriteLine(INDENT + "      <td colspan=\"3\" class=\"sbkDcv_TableHeader\"><a href=\"" + UrlWriterHelper.Redirect_URL(CurrentMode) + "\" title=\"View additional details for this table\">" + thisTable.TableName.Replace("_", " ") + "</a></td>");
                    Output.WriteLine(INDENT + "    </tr>");

                    // Add each table's column information
                    foreach (DataColumn thisColumn in thisTable.Columns)
                    {
                        string column_definition = String.Empty;
                        string column_reference  = "&nbsp;";
                        if (thisColumn.Unique)
                        {
                            column_definition = thisColumn.AutoIncrement ? "PK" : "U";
                        }
                        foreach (Constraint constraint in thisTable.Constraints)
                        {
                            ForeignKeyConstraint fkConstraint = constraint as ForeignKeyConstraint;
                            if (fkConstraint != null)
                            {
                                if (fkConstraint.Columns[0] == thisColumn)
                                {
                                    column_definition = "FK";
                                    column_reference  = fkConstraint.RelatedColumns[0].Table.TableName + "." + fkConstraint.RelatedColumns[0].ColumnName + " <img src=\"" + Static_Resources.Leftarrow_Png + "\" alt=\"<--\" />";
                                }
                            }
                        }



                        if (thisColumn.AllowDBNull)
                        {
                            Output.WriteLine(INDENT + "    <tr>");
                        }
                        else
                        {
                            Output.WriteLine(INDENT + "    <tr class=\"sbkDcv_TableRequiredField\">");
                        }

                        Output.WriteLine(INDENT + "      <td class=\"sbkDcv_TableColumn0\">" + column_reference + "</td>");



                        Output.WriteLine(INDENT + "      <td class=\"sbkDcv_TableColumn1\">" + column_definition + "</td>");
                        Output.WriteLine(INDENT + "      <td class=\"sbkDcv_TableColumn2\">" + thisColumn.ColumnName.Replace("_", " ") + "</td>");

                        string colunmType = thisColumn.DataType.ToString().Replace("System.", "").ToLower().Replace("int32", "integer");
                        if ((colunmType == "string") && (thisColumn.MaxLength == 1))
                        {
                            colunmType = "char";
                        }
                        Output.WriteLine(INDENT + "      <td class=\"sbkDcv_TableColumn3\">" + colunmType + "</td>");
                        Output.WriteLine(INDENT + "    </tr>");

                        if (column_definition == "PK")
                        {
                            Output.WriteLine(INDENT + "    <tr><td></td><td colspan=\"3\" class=\"sbkDcv_TablePkRule\"></td></tr>");
                        }
                    }

                    // Close the table out
                    Output.WriteLine(INDENT + "    <tr>");
                    Output.WriteLine(INDENT + "      <td>&nbsp;</td>");
                    Output.WriteLine(INDENT + "      <td colspan=\"3\" class=\"sbkDcv_TableFooter\">");

                    CurrentMode.SubPage = (ushort)(table_number + 1);
                    Output.WriteLine(INDENT + "        <a href=\"" + UrlWriterHelper.Redirect_URL(CurrentMode) + "\" title=\"View additional details for this table\">view details</a> &nbsp; &nbsp; &nbsp;");

                    CurrentMode.ViewerCode = "dsview";
                    Output.WriteLine(INDENT + "        <a href=\"" + UrlWriterHelper.Redirect_URL(CurrentMode) + "\" title=\"View the rows of data within this table\">view contents</a>");

                    CurrentMode.ViewerCode = "dscodebook";

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

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

                    table_number++;
                }
            }
            else
            {
                Output.WriteLine("          <td id=\"sbkDcv_DetailsArea\">");
                int       subpage_index = CurrentMode.SubPage.HasValue ? CurrentMode.SubPage.Value : 0;
                DataTable thisTable     = itemDataset.Tables[subpage_index - 2];

                if (itemDataset.Tables.Count > 1)
                {
                    ushort?subpage = CurrentMode.SubPage;
                    CurrentMode.SubPage = 1;
                    Output.WriteLine("<a href=\"" + UrlWriterHelper.Redirect_URL(CurrentMode) + "\" title=\"Back to full data structure\">&larr; Back</a><br /><br />");
                    CurrentMode.SubPage = subpage;
                }
                else
                {
                    Output.WriteLine("<br /><br />");
                }

                // Add the basic table information (if the word table is in the table name, don't include the
                // word table in the title)
                if (thisTable.TableName.IndexOf("table", StringComparison.OrdinalIgnoreCase) < 0)
                {
                    Output.WriteLine(INDENT + "<div id=\"sbkDcv_DetailsTableName\"><span style=\"font-style:italic\">" + thisTable.TableName.Replace("_", " ") + "</span> Table Details</div>");
                }
                else
                {
                    Output.WriteLine(INDENT + "<div id=\"sbkDcv_DetailsTableName\"><span style=\"font-style:italic\">" + thisTable.TableName.Replace("_", " ") + "</span> Details</div>");
                }


                if (thisTable.ExtendedProperties.ContainsKey("Description"))
                {
                    Output.WriteLine(INDENT + "<div id=\"sbkDcv_DetailsTableDescription\">" + thisTable.ExtendedProperties["Description"] + "</div>");
                }

                Output.WriteLine(INDENT + "  <table id=\"sbkDcv_TableDetails2\">");

                // Add the header row
                Output.WriteLine(INDENT + "    <tr>");
                Output.WriteLine(INDENT + "      <td>&nbsp;</td>");
                Output.WriteLine(INDENT + "      <td colspan=\"4\" class=\"sbkDcv_TableHeader\">" + thisTable.TableName.Replace("_", " ") + "</td>");
                Output.WriteLine(INDENT + "    </tr>");

                // Add each table's column information
                foreach (DataColumn thisColumn in thisTable.Columns)
                {
                    string column_definition = String.Empty;
                    string column_reference  = "&nbsp;";
                    if (thisColumn.Unique)
                    {
                        column_definition = thisColumn.AutoIncrement ? "PK" : "U";
                    }
                    foreach (Constraint constraint in thisTable.Constraints)
                    {
                        ForeignKeyConstraint fkConstraint = constraint as ForeignKeyConstraint;
                        if (fkConstraint != null)
                        {
                            if (fkConstraint.Columns[0] == thisColumn)
                            {
                                column_definition   = "FK";
                                CurrentMode.SubPage = (ushort)(itemDataset.Tables.IndexOf(fkConstraint.RelatedColumns[0].Table) + 2);
                                column_reference    = "<a href=\"" + UrlWriterHelper.Redirect_URL(CurrentMode) + "\" title=\"View details of linked table\">" + fkConstraint.RelatedColumns[0].Table.TableName + "</a>." + fkConstraint.RelatedColumns[0].ColumnName + " <img src=\"" + Static_Resources.Leftarrow_Png + "\" alt=\"<--\" />";
                            }
                        }
                    }

                    if (thisColumn.AllowDBNull)
                    {
                        Output.WriteLine(INDENT + "    <tr>");
                    }
                    else
                    {
                        Output.WriteLine(INDENT + "    <tr class=\"sbkDcv_TableRequiredField\">");
                    }


                    Output.WriteLine(INDENT + "      <td class=\"sbkDcv_TableColumn0\">" + column_reference + "</td>");



                    Output.WriteLine(INDENT + "      <td class=\"sbkDcv_TableDetailsColumn1\">" + column_definition + "</td>");
                    Output.WriteLine(INDENT + "      <td class=\"sbkDcv_TableDetailsColumn2\">" + thisColumn.ColumnName.Replace("_", " ") + " &nbsp; </td>");

                    string colunmType = thisColumn.DataType.ToString().Replace("System.", "").ToLower().Replace("int32", "integer");
                    if ((colunmType == "string") && (thisColumn.MaxLength == 1))
                    {
                        colunmType = "char";
                    }
                    Output.WriteLine(INDENT + "      <td class=\"sbkDcv_TableDetailsColumn3\">" + colunmType + "</td>");
                    Output.WriteLine(INDENT + "      <td class=\"sbkDcv_TableDetailsColumn4\">" + thisColumn.Caption.Replace("_", " ") + "</td>");
                    Output.WriteLine(INDENT + "    </tr>");

                    if (column_definition == "PK")
                    {
                        Output.WriteLine(INDENT + "    <tr><td></td><td colspan=\"4\" class=\"sbkDcv_TablePkRule\"></td></tr>");
                    }
                }

                // Close the table out
                Output.WriteLine(INDENT + "    <tr>");
                Output.WriteLine(INDENT + "      <td>&nbsp;</td>");
                Output.WriteLine(INDENT + "      <td colspan=\"4\" class=\"sbkDcv_TableFooter\">");

                CurrentMode.ViewerCode = "dsview";
                Output.WriteLine(INDENT + "        <a href=\"" + UrlWriterHelper.Redirect_URL(CurrentMode) + "\" title=\"View the rows of data within this table\">view contents</a>");

                CurrentMode.ViewerCode = "dscodebook";

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

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

            Output.WriteLine("          </td>");
        }
        /// <summary> Add the HTML to be displayed below 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 writes the HTML from the static browse or info page here  </remarks>
        public override void Add_Secondary_HTML(TextWriter Output, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("Usage_Statistics_AggregationViewer.Add_Secondary_HTML", "Adding HTML");
            }

            const string COLLECTION_VIEWS = "COLLECTION VIEWS";
            const string ITEM_VIEWS       = "ITEM VIEWS";
            const string TOP_TITLES       = "TOP TITLES";
            const string TOP_ITEMS        = "TOP ITEMS";
            const string DEFINITIONS      = "DEFINITIONS";

            Output.WriteLine("<div class=\"ShowSelectRow\">");
            Output.WriteLine("  <ul class=\"sbk_FauxDownwardTabsList\">");

            // Save and normalize the submode
            string submode = "views";

            if (!String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.Info_Browse_Mode))
            {
                submode = RequestSpecificValues.Current_Mode.Info_Browse_Mode.ToLower();
            }
            if ((submode != "views") && (submode != "itemviews") && (submode != "titles") && (submode != "items") && (submode != "definitions"))
            {
                submode = "views";
            }


            if (submode == "views")
            {
                Output.WriteLine("    <li class=\"current\">" + COLLECTION_VIEWS + "</li>");
            }
            else
            {
                RequestSpecificValues.Current_Mode.Info_Browse_Mode = "views";
                Output.WriteLine("    <li><a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "\">" + COLLECTION_VIEWS + "</a></li>");
            }

            if (submode == "itemviews")
            {
                Output.WriteLine("    <li class=\"current\">" + ITEM_VIEWS + "</li>");
            }
            else
            {
                RequestSpecificValues.Current_Mode.Info_Browse_Mode = "itemviews";
                Output.WriteLine("    <li><a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "\">" + ITEM_VIEWS + "</a></li>");
            }

            if (submode == "titles")
            {
                Output.WriteLine("    <li class=\"current\">" + TOP_TITLES + "</li>");
            }
            else
            {
                RequestSpecificValues.Current_Mode.Info_Browse_Mode = "titles";
                Output.WriteLine("    <li><a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "\">" + TOP_TITLES + "</a></li>");
            }

            if (submode == "items")
            {
                Output.WriteLine("    <li class=\"current\">" + TOP_ITEMS + "</li>");
            }
            else
            {
                RequestSpecificValues.Current_Mode.Info_Browse_Mode = "items";
                Output.WriteLine("    <li><a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "\">" + TOP_ITEMS + "</a></li>");
            }

            if (submode == "definitions")
            {
                Output.WriteLine("    <li class=\"current\">" + DEFINITIONS + "</li>");
            }
            else
            {
                RequestSpecificValues.Current_Mode.Info_Browse_Mode = "definitions";
                Output.WriteLine("    <li><a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "\">" + DEFINITIONS + "</a></li>");
            }
            RequestSpecificValues.Current_Mode.Info_Browse_Mode = submode;
            Output.WriteLine("  </ul>");
            Output.WriteLine("</div>");
            Output.WriteLine("<br />");

            // Show the next data, depending on type
            switch (submode)
            {
            case "views":
                add_collection_usage_history(Output, SobekCM_Database.Get_Aggregation_Statistics_History(ViewBag.Hierarchy_Object.Code, Tracer), Tracer);
                break;

            case "itemviews":
                add_item_usage_history(Output, SobekCM_Database.Get_Aggregation_Statistics_History(ViewBag.Hierarchy_Object.Code, Tracer), Tracer);
                break;

            case "titles":
                add_titles_by_collection(Output, ViewBag.Hierarchy_Object.Code, Tracer);
                break;

            case "items":
                add_items_by_collection(Output, ViewBag.Hierarchy_Object.Code, Tracer);
                break;

            case "definitions":
                add_usage_definitions(Output, Tracer);
                break;
            }
        }
        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>");

            RequestSpecificValues.Current_Mode.Info_Browse_Mode = "definitions";
            Output.WriteLine("<p>The <a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "\">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>");
        }
Example #10
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 override void Write_Main_Viewer_Section(TextWriter Output, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("ManageMenu_ItemViewer.Write_Main_Viewer_Section", "");
            }

            string currentViewerCode = CurrentRequest.ViewerCode;

            // Add the HTML for the image
            Output.WriteLine("<!-- MANAGE MENU ITEM VIEWER OUTPUT -->");

            bool is_bib_level = (String.Compare(BriefItem.Type, "BIB_LEVEL", StringComparison.OrdinalIgnoreCase) == 0);

            if (!is_bib_level)
            {
                // Look for TEI-type item
                bool is_tei = false;
                if ((UI_ApplicationCache_Gateway.Configuration.Extensions != null) &&
                    (UI_ApplicationCache_Gateway.Configuration.Extensions.Get_Extension("TEI") != null) &&
                    (UI_ApplicationCache_Gateway.Configuration.Extensions.Get_Extension("TEI").Enabled))
                {
                    string tei_file  = BriefItem.Behaviors.Get_Setting("TEI.Source_File");
                    string xslt_file = BriefItem.Behaviors.Get_Setting("TEI.XSLT");
                    if ((tei_file != null) && (xslt_file != null))
                    {
                        is_tei = true;
                    }
                }


                // Start the citation table
                Output.WriteLine("  <td align=\"left\"><div class=\"sbkMmiv_ViewerTitle\">Manage this Item</div></td>");
                Output.WriteLine("</tr>");
                Output.WriteLine("<tr>");
                Output.WriteLine("  <td class=\"sbkMmiv_MainArea\">");


                Output.WriteLine("\t\t\t<table id=\"sbkMmiv_MainTable\">");
                Output.WriteLine("\t\t\t\t<tr class=\"sbkMmiv_HeaderRow\"><td colspan=\"3\">How would you like to manage this item today?</td></tr>");

                string url;
                if (!is_tei)
                {
                    // Add ability to edit metadata for this item
                    CurrentRequest.Mode             = Display_Mode_Enum.My_Sobek;
                    CurrentRequest.My_Sobek_Type    = My_Sobek_Type_Enum.Edit_Item_Metadata;
                    CurrentRequest.My_Sobek_SubMode = "1";
                    url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                    Output.WriteLine("\t\t\t\t<tr>");
                    Output.WriteLine("\t\t\t\t\t<td style=\"width:50px\">&nbsp;</td>");
                    Output.WriteLine("\t\t\t\t\t<td style=\"width:60px\"><a href=\"" + url + "\"><img src=\"" + Static_Resources_Gateway.Edit_Metadata_Icon_Png + "\" /></a></td>");
                    Output.WriteLine("\t\t\t\t\t<td>");
                    Output.WriteLine("\t\t\t\t\t\t<a href=\"" + url + "\">Edit Item Metadata</a>");
                    Output.WriteLine("\t\t\t\t\t\t<div class=\"sbkMmiv_Desc\">Edit the information about this item which appears in the citation/description.  This is basic information about the original item and this digital manifestation.</div>");
                    Output.WriteLine("\t\t\t\t\t</td>");
                    Output.WriteLine("\t\t\t\t</tr>");
                    Output.WriteLine("\t\t\t\t<tr class=\"sbkMmiv_SpacerRow\"><td colspan=\"3\"></td></tr>");
                }
                else
                {
                    // Add ability to edit metadata for this item
                    CurrentRequest.Mode             = Display_Mode_Enum.My_Sobek;
                    CurrentRequest.My_Sobek_Type    = My_Sobek_Type_Enum.Edit_TEI_Item;
                    CurrentRequest.My_Sobek_SubMode = "1";
                    url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                    Output.WriteLine("\t\t\t\t<tr>");
                    Output.WriteLine("\t\t\t\t\t<td style=\"width:50px\">&nbsp;</td>");
                    Output.WriteLine("\t\t\t\t\t<td style=\"width:60px\"><a href=\"" + url + "\"><img src=\"http://cdn.sobekrepository.org/images/misc/add_tei.png\" /></a></td>");
                    Output.WriteLine("\t\t\t\t\t<td>");
                    Output.WriteLine("\t\t\t\t\t\t<a href=\"" + url + "\">Edit TEI</a>");
                    Output.WriteLine("\t\t\t\t\t\t<div class=\"sbkMmiv_Desc\">Edit this TEI object, including the XSLT and CSS file used as well as uploading a new TEI file or editing the existing TEI file online.</div>");
                    Output.WriteLine("\t\t\t\t\t</td>");
                    Output.WriteLine("\t\t\t\t</tr>");
                    Output.WriteLine("\t\t\t\t<tr class=\"sbkMmiv_SpacerRow\"><td colspan=\"3\"></td></tr>");
                }

                // Add ability to edit behaviors for this item
                CurrentRequest.Mode             = Display_Mode_Enum.My_Sobek;
                CurrentRequest.My_Sobek_Type    = My_Sobek_Type_Enum.Edit_Item_Behaviors;
                CurrentRequest.My_Sobek_SubMode = "1";
                url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                Output.WriteLine("\t\t\t\t<tr>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:50px\">&nbsp;</td>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:60px\"><a href=\"" + url + "\"><img src=\"" + Static_Resources_Gateway.Edit_Behaviors_Icon_Png + "\" /></a></td>");
                Output.WriteLine("\t\t\t\t\t<td>");
                Output.WriteLine("\t\t\t\t\t\t<a href=\"" + url + "\">Edit Item Behaviors</a>");
                Output.WriteLine("\t\t\t\t\t\t<div class=\"sbkMmiv_Desc\">Change the way this item behaves in this library, including which aggregations it appears under, the wordmarks to the left, and which viewer types are publicly accessible.</div>");
                Output.WriteLine("\t\t\t\t\t</td>");
                Output.WriteLine("\t\t\t\t</tr>");
                Output.WriteLine("\t\t\t\t<tr class=\"sbkMmiv_SpacerRow\"><td colspan=\"3\"></td></tr>");

                // Add ability to perform QC ( manage pages and divisions) for this item
                CurrentRequest.Mode       = Display_Mode_Enum.Item_Display;
                CurrentRequest.ViewerCode = "qc";
                url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                Output.WriteLine("\t\t\t\t<tr>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:50px\">&nbsp;</td>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:60px\"><a href=\"" + url + "\"><img src=\"" + Static_Resources_Gateway.Qc_Button_Img_Large + "\" /></a></td>");
                Output.WriteLine("\t\t\t\t\t<td>");
                Output.WriteLine("\t\t\t\t\t\t<a href=\"" + url + "\">Manage Pages and Divisions (Quality Control)</a>");
                Output.WriteLine("\t\t\t\t\t\t<div class=\"sbkMmiv_Desc\">Reorder page images, name pages, assign divisions, and delete and add new page images to this item.</div>");
                Output.WriteLine("\t\t\t\t\t</td>");
                Output.WriteLine("\t\t\t\t</tr>");
                Output.WriteLine("\t\t\t\t<tr class=\"sbkMmiv_SpacerRow\"><td colspan=\"3\"></td></tr>");


                // Add ability to view work history for this item
                CurrentRequest.Mode       = Display_Mode_Enum.Item_Display;
                CurrentRequest.ViewerCode = "tracking";
                url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                Output.WriteLine("\t\t\t\t<tr>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:50px\">&nbsp;</td>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:60px\"><a href=\"" + url + "\"><img src=\"" + Static_Resources_Gateway.View_Work_Log_Img_Large + "\" /></a></td>");
                Output.WriteLine("\t\t\t\t\t<td>");
                Output.WriteLine("\t\t\t\t\t\t<a href=\"" + url + "\">View Work History</a>");
                Output.WriteLine("\t\t\t\t\t\t<div class=\"sbkMmiv_Desc\">View the history of all work performed on this item.  From this view, you can also see any digitization milestones and digital resource file information.</div>");
                Output.WriteLine("\t\t\t\t\t</td>");
                Output.WriteLine("\t\t\t\t</tr>");
                Output.WriteLine("\t\t\t\t<tr class=\"sbkMmiv_SpacerRow\"><td colspan=\"3\"></td></tr>");


                // Add ability to upload new download files for this item
                CurrentRequest.Mode          = Display_Mode_Enum.My_Sobek;
                CurrentRequest.My_Sobek_Type = My_Sobek_Type_Enum.File_Management;
                url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                Output.WriteLine("\t\t\t\t<tr>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:50px\">&nbsp;</td>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:60px\"><a href=\"" + url + "\"><img src=\"" + Static_Resources_Gateway.File_Management_Icon_Png + "\" /></a></td>");
                Output.WriteLine("\t\t\t\t\t<td>");
                Output.WriteLine("\t\t\t\t\t\t<a href=\"" + url + "\">Manage Download Files</a>");
                Output.WriteLine("\t\t\t\t\t\t<div class=\"sbkMmiv_Desc\">Upload new files for download or remove existing files that are attached to this item for download.  This generally includes everything except for the page images.</div>");
                Output.WriteLine("\t\t\t\t\t</td>");
                Output.WriteLine("\t\t\t\t</tr>");
                Output.WriteLine("\t\t\t\t<tr class=\"sbkMmiv_SpacerRow\"><td colspan=\"3\"></td></tr>");

                // Add ability to edit geo-spatial information for this item
                CurrentRequest.Mode       = Display_Mode_Enum.Item_Display;
                CurrentRequest.ViewerCode = "mapedit";
                url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                Output.WriteLine("\t\t\t\t<tr>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:50px\">&nbsp;</td>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:60px\"><a href=\"" + url + "\"><img src=\"" + Static_Resources_Gateway.Add_Geospatial_Img + "\" /></a></td>");
                Output.WriteLine("\t\t\t\t\t<td>");
                Output.WriteLine("\t\t\t\t\t\t<a href=\"" + url + "\">Manage Geo-Spatial Data (beta)</a>");
                Output.WriteLine("\t\t\t\t\t\t<div class=\"sbkMmiv_Desc\">Add geo-spatial information for this item.  This can be as simple as a location for a photograph or can be an overlay for a map.  Points, lines, and polygons of interest can also be drawn.</div>");
                Output.WriteLine("\t\t\t\t\t</td>");
                Output.WriteLine("\t\t\t\t</tr>");
                Output.WriteLine("\t\t\t\t<tr class=\"sbkMmiv_SpacerRow\"><td colspan=\"3\"></td></tr>");


                // Add ability to edit geo-spatial information for this item
                CurrentRequest.Mode       = Display_Mode_Enum.Item_Display;
                CurrentRequest.ViewerCode = "ts";
                url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                Output.WriteLine("\t\t\t\t<tr>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:50px\">&nbsp;</td>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:60px\"><a href=\"" + url + "\"><img src=\"" + Static_Resources_Gateway.Track2_Gif + "\" /></a></td>");
                Output.WriteLine("\t\t\t\t\t<td>");
                Output.WriteLine("\t\t\t\t\t\t<a href=\"" + url + "\">View Tracking Sheet</a>");
                Output.WriteLine("\t\t\t\t\t\t<div class=\"sbkMmiv_Desc\">This can be used for printing the tracking sheet for this item, which can be used as part of the built-in digitization workflow.</div>");
                Output.WriteLine("\t\t\t\t\t</td>");
                Output.WriteLine("\t\t\t\t</tr>");
                Output.WriteLine("\t\t\t\t<tr class=\"sbkMmiv_SpacerRow\"><td colspan=\"3\"></td></tr>");


                Output.WriteLine("\t\t\t\t<tr class=\"sbkMmiv_HeaderRow\"><td colspan=\"3\">In addition, the following changes can be made at the item group level:</td></tr>");

                // Add ability to edit GROUP behaviors for this group
                CurrentRequest.Mode             = Display_Mode_Enum.My_Sobek;
                CurrentRequest.My_Sobek_Type    = My_Sobek_Type_Enum.Edit_Group_Behaviors;
                CurrentRequest.My_Sobek_SubMode = "1";
                url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                Output.WriteLine("\t\t\t\t<tr>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:50px\">&nbsp;</td>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:60px\"><a href=\"" + url + "\"><img src=\"" + Static_Resources_Gateway.Edit_Behaviors_Icon_Png + "\" /></a></td>");
                Output.WriteLine("\t\t\t\t\t<td>");
                Output.WriteLine("\t\t\t\t\t\t<a href=\"" + url + "\">Edit Item Group Behaviors</a>");
                Output.WriteLine("\t\t\t\t\t\t<div class=\"sbkMmiv_Desc\">Set the title under which all of these items appear in search results and set the web skins under which all these items should appear.</div>");
                Output.WriteLine("\t\t\t\t\t</td>");
                Output.WriteLine("\t\t\t\t</tr>");
                Output.WriteLine("\t\t\t\t<tr class=\"sbkMmiv_SpacerRow\"><td colspan=\"3\"></td></tr>");

                // Add ability to add new volume for this group
                CurrentRequest.Mode             = Display_Mode_Enum.My_Sobek;
                CurrentRequest.My_Sobek_Type    = My_Sobek_Type_Enum.Group_Add_Volume;
                CurrentRequest.My_Sobek_SubMode = "1";
                url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                Output.WriteLine("\t\t\t\t<tr>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:50px\">&nbsp;</td>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:60px\"><a href=\"" + url + "\"><img src=\"" + Static_Resources_Gateway.Add_Volume_Img + "\" /></a></td>");
                Output.WriteLine("\t\t\t\t\t<td>");
                Output.WriteLine("\t\t\t\t\t\t<a href=\"" + url + "\">Add New Volume</a>");
                Output.WriteLine("\t\t\t\t\t\t<div class=\"sbkMmiv_Desc\">Add a new, related volume to this item group.<br /><br /></div>");
                Output.WriteLine("\t\t\t\t\t</td>");
                Output.WriteLine("\t\t\t\t</tr>");
                Output.WriteLine("\t\t\t\t<tr class=\"sbkMmiv_SpacerRow\"><td colspan=\"3\"></td></tr>");

                if ((BriefItem.Web != null) && (BriefItem.Web.Siblings.HasValue) && (BriefItem.Web.Siblings > 1))
                {
                    // Add ability to mass update all items for this group
                    CurrentRequest.Mode             = Display_Mode_Enum.My_Sobek;
                    CurrentRequest.My_Sobek_Type    = My_Sobek_Type_Enum.Group_Mass_Update_Items;
                    CurrentRequest.My_Sobek_SubMode = "1";
                    url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                    Output.WriteLine("\t\t\t\t<tr>");
                    Output.WriteLine("\t\t\t\t\t<td style=\"width:50px\">&nbsp;</td>");
                    Output.WriteLine("\t\t\t\t\t<td style=\"width:60px\"><a href=\"" + url + "\"><img src=\"" + Static_Resources_Gateway.Mass_Update_Icon_Png + "\" /></a></td>");
                    Output.WriteLine("\t\t\t\t\t<td>");
                    Output.WriteLine("\t\t\t\t\t\t<a href=\"" + url + "\">Mass Update Item Behaviors</a>");
                    Output.WriteLine("\t\t\t\t\t\t<div class=\"sbkMmiv_Desc\">This allows item-level behaviors to be set for all items within this item group, including which aggregations it appears under, the wordmarks to the left, and which viewer types are publicly accessible.</div>");
                    Output.WriteLine("\t\t\t\t\t</td>");
                    Output.WriteLine("\t\t\t\t</tr>");
                    Output.WriteLine("\t\t\t\t<tr class=\"sbkMmiv_SpacerRow\"><td colspan=\"3\"></td></tr>");
                }

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

                Output.WriteLine("\t\t</td>");
            }
            else
            {
                // Start the citation table
                Output.WriteLine("  <td align=\"left\"><div class=\"sbkMmiv_ViewerTitle\">Manage this Item Group</div></td>");
                Output.WriteLine("</tr>");
                Output.WriteLine("<tr>");
                Output.WriteLine("  <td class=\"sbkMmiv_MainArea\">");


                Output.WriteLine("\t\t\t<table id=\"sbkMmiv_MainTable\">");
                Output.WriteLine("\t\t\t\t<tr class=\"sbkMmiv_HeaderRow\"><td colspan=\"3\">How would you like to manage this item group today?</td></tr>");


                // Add ability to edit GROUP behaviors for this group
                CurrentRequest.Mode             = Display_Mode_Enum.My_Sobek;
                CurrentRequest.My_Sobek_Type    = My_Sobek_Type_Enum.Edit_Group_Behaviors;
                CurrentRequest.My_Sobek_SubMode = "1";
                string url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                Output.WriteLine("\t\t\t\t<tr>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:50px\">&nbsp;</td>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:60px\"><a href=\"" + url + "\"><img src=\"" + Static_Resources_Gateway.Edit_Behaviors_Icon_Png + "\" /></a></td>");
                Output.WriteLine("\t\t\t\t\t<td>");
                Output.WriteLine("\t\t\t\t\t\t<a href=\"" + url + "\">Edit Item Group Behaviors</a>");
                Output.WriteLine("\t\t\t\t\t\t<div class=\"sbkMmiv_Desc\">Set the title under which all of these items appear in search results and set the web skins under which all these items should appear.</div>");
                Output.WriteLine("\t\t\t\t\t</td>");
                Output.WriteLine("\t\t\t\t</tr>");
                Output.WriteLine("\t\t\t\t<tr class=\"sbkMmiv_SpacerRow\"><td colspan=\"3\"></td></tr>");

                // Add ability to add new volume for this group
                CurrentRequest.Mode             = Display_Mode_Enum.My_Sobek;
                CurrentRequest.My_Sobek_Type    = My_Sobek_Type_Enum.Group_Add_Volume;
                CurrentRequest.My_Sobek_SubMode = "1";
                url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                Output.WriteLine("\t\t\t\t<tr>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:50px\">&nbsp;</td>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:60px\"><a href=\"" + url + "\"><img src=\"" + Static_Resources_Gateway.Add_Volume_Img + "\" /></a></td>");
                Output.WriteLine("\t\t\t\t\t<td>");
                Output.WriteLine("\t\t\t\t\t\t<a href=\"" + url + "\">Add New Volume</a>");
                Output.WriteLine("\t\t\t\t\t\t<div class=\"sbkMmiv_Desc\">Add a new, related volume to this item group.<br /><br /></div>");
                Output.WriteLine("\t\t\t\t\t</td>");
                Output.WriteLine("\t\t\t\t</tr>");
                Output.WriteLine("\t\t\t\t<tr class=\"sbkMmiv_SpacerRow\"><td colspan=\"3\"></td></tr>");

                // Add ability to mass update all items for this group
                CurrentRequest.Mode             = Display_Mode_Enum.My_Sobek;
                CurrentRequest.My_Sobek_Type    = My_Sobek_Type_Enum.Group_Mass_Update_Items;
                CurrentRequest.My_Sobek_SubMode = "1";
                url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                Output.WriteLine("\t\t\t\t<tr>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:50px\">&nbsp;</td>");
                Output.WriteLine("\t\t\t\t\t<td style=\"width:60px\"><a href=\"" + url + "\"><img src=\"" + Static_Resources_Gateway.Mass_Update_Icon_Png + "\" /></a></td>");
                Output.WriteLine("\t\t\t\t\t<td>");
                Output.WriteLine("\t\t\t\t\t\t<a href=\"" + url + "\">Mass Update Item Behaviors</a>");
                Output.WriteLine("\t\t\t\t\t\t<div class=\"sbkMmiv_Desc\">This allows item-level behaviors to be set for all items within this item group, including which aggregations it appears under, the wordmarks to the left, and which viewer types are publicly accessible.</div>");
                Output.WriteLine("\t\t\t\t\t</td>");
                Output.WriteLine("\t\t\t\t</tr>");
                Output.WriteLine("\t\t\t\t<tr class=\"sbkMmiv_SpacerRow\"><td colspan=\"3\"></td></tr>");

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

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

            // Reset the value
            CurrentRequest.Mode       = Display_Mode_Enum.Item_Display;
            CurrentRequest.ViewerCode = currentViewerCode;
        }
Example #11
0
        /// <summary> Gets the menu items related to this viewer that should be included on the main item (digital resource) menu </summary>
        /// <param name="CurrentItem"> Digital resource object, which can be used to ensure if and how this viewer should appear
        /// in the main item (digital resource) menu </param>
        /// <param name="CurrentUser"> Current user, who may or may not be logged on </param>
        /// <param name="CurrentRequest"> Information about the current request </param>
        /// <param name="MenuItems"> List of menu items, to which this method may add one or more menu items </param>
        /// <param name="IpRestricted"> Flag indicates if this item is IP restricted AND if the current user is outside the ranges </param>
        public void Add_Menu_items(BriefItemInfo CurrentItem, User_Object CurrentUser, Navigation_Object CurrentRequest, List <Item_MenuItem> MenuItems, bool IpRestricted)
        {
            // Again, ensure access
            if (!Has_Access(CurrentItem, CurrentUser, false))
            {
                return;
            }

            // Get the URL for this
            string previous_code = CurrentRequest.ViewerCode;

            CurrentRequest.ViewerCode = ViewerCode;
            string url = UrlWriterHelper.Redirect_URL(CurrentRequest);

            CurrentRequest.ViewerCode = previous_code;
            MenuItems.Add(new Item_MenuItem("Manage", "Management Menu", null, url, "manage"));

            bool is_bib_level = (String.Compare(CurrentItem.Type, "BIB_LEVEL", StringComparison.OrdinalIgnoreCase) == 0);

            if (!is_bib_level)
            {
                // Look for TEI-type item
                bool is_tei = false;
                if ((UI_ApplicationCache_Gateway.Configuration.Extensions != null) &&
                    (UI_ApplicationCache_Gateway.Configuration.Extensions.Get_Extension("TEI") != null) &&
                    (UI_ApplicationCache_Gateway.Configuration.Extensions.Get_Extension("TEI").Enabled))
                {
                    string tei_file  = CurrentItem.Behaviors.Get_Setting("TEI.Source_File");
                    string xslt_file = CurrentItem.Behaviors.Get_Setting("TEI.XSLT");
                    if ((tei_file != null) && (xslt_file != null))
                    {
                        is_tei = true;
                    }
                }

                if (!is_tei)
                {
                    // Add the menu item for editing metadatga
                    CurrentRequest.Mode          = Display_Mode_Enum.My_Sobek;
                    CurrentRequest.My_Sobek_Type = My_Sobek_Type_Enum.Edit_Item_Metadata;
                    string edit_metadata_url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                    MenuItems.Add(new Item_MenuItem("Manage", "Edit Metadata", null, edit_metadata_url, "nevermatchthis"));
                }
                else
                {
                    // Add the menu item for editing metadatga
                    CurrentRequest.Mode          = Display_Mode_Enum.My_Sobek;
                    CurrentRequest.My_Sobek_Type = My_Sobek_Type_Enum.Edit_TEI_Item;
                    string edit_tei_url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                    MenuItems.Add(new Item_MenuItem("Manage", "Edit TEI", null, edit_tei_url, "nevermatchthis"));
                }

                // Add the menu item for editing item behaviors
                CurrentRequest.My_Sobek_Type = My_Sobek_Type_Enum.Edit_Item_Behaviors;
                string edit_behaviors_url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                MenuItems.Add(new Item_MenuItem("Manage", "Edit Item Behaviors", null, edit_behaviors_url, "nevermatchthis"));

                // Add the menu item for managing download files
                CurrentRequest.My_Sobek_Type = My_Sobek_Type_Enum.File_Management;
                string manage_downloads = UrlWriterHelper.Redirect_URL(CurrentRequest);
                MenuItems.Add(new Item_MenuItem("Manage", "Manage Download Files", null, manage_downloads, "nevermatchthis"));

                // Add the menu item for managing pages and divisions
                if ((CurrentItem.Images == null) || (CurrentItem.Images.Count == 0))
                {
                    CurrentRequest.My_Sobek_Type = My_Sobek_Type_Enum.Page_Images_Management;
                    string page_images_url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                    MenuItems.Add(new Item_MenuItem("Manage", "Manage Pages and Divisions", null, page_images_url, "nevermatchthis"));
                }
                else
                {
                    CurrentRequest.Mode       = Display_Mode_Enum.Item_Display;
                    CurrentRequest.ViewerCode = "qc";
                    string qc_url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                    MenuItems.Add(new Item_MenuItem("Manage", "Manage Pages and Divisions", null, qc_url, "nevermatchthis"));
                }

                // Add the manage geo-spatial data option
                CurrentRequest.Mode       = Display_Mode_Enum.Item_Display;
                CurrentRequest.ViewerCode = "mapedit";
                string mapedit_url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                MenuItems.Add(new Item_MenuItem("Manage", "Manage Geo-Spatial Data (beta)", null, mapedit_url, "mapedit"));

                // Add the tracking sheet menu option
                CurrentRequest.ViewerCode = "ts";
                string tracking_url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                MenuItems.Add(new Item_MenuItem("Manage", "View Tracking Sheet", null, tracking_url, "ts"));
            }
            else
            {
                // Get all the mySObek URLs
                CurrentRequest.Mode = Display_Mode_Enum.My_Sobek;

                // Add the group behavior edit
                CurrentRequest.My_Sobek_Type = My_Sobek_Type_Enum.Edit_Group_Behaviors;
                string edit_behaviors_url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                MenuItems.Add(new Item_MenuItem("Manage", "Edit Item Group Behaviors", null, edit_behaviors_url, "nevermatchthis"));

                // Add the option to add a new volume
                CurrentRequest.My_Sobek_Type = My_Sobek_Type_Enum.Group_Add_Volume;
                string add_volume_url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                MenuItems.Add(new Item_MenuItem("Manage", "Add New Volume", null, add_volume_url, "nevermatchthis"));

                // Add the option for group mass update
                CurrentRequest.My_Sobek_Type = My_Sobek_Type_Enum.Group_Mass_Update_Items;
                string mass_update_url = UrlWriterHelper.Redirect_URL(CurrentRequest);
                MenuItems.Add(new Item_MenuItem("Manage", "Mass Update Item Behaviors", null, mass_update_url, "nevermatchthis"));
            }

            CurrentRequest.Mode       = Display_Mode_Enum.Item_Display;
            CurrentRequest.ViewerCode = previous_code;
        }
        /// <summary> Constructor for a new instance of the IP_Restrictions_AdminViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <remarks> Postback from handling an edit or new item aggregation alias is handled here in the constructor </remarks>
        public IP_Restrictions_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues)
        {
            RequestSpecificValues.Tracer.Add_Trace("IP_Restrictions_AdminViewer.Constructor", String.Empty);

            // Set some defaults
            entered_title   = String.Empty;
            entered_notes   = String.Empty;
            entered_message = String.Empty;

            // Ensure the RequestSpecificValues.Current_User is the system admin
            if ((RequestSpecificValues.Current_User == null) || ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin)))
            {
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.My_Sobek;
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // Determine if there is an specific IP address range for editing
            int index = -1;

            if (!String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.My_Sobek_SubMode))
            {
                if (!Int32.TryParse(RequestSpecificValues.Current_Mode.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)
            {
                thisRange = UI_ApplicationCache_Gateway.IP_Restrictions[index];
                if (thisRange != null)
                {
                    details = SobekCM_Database.Get_IP_Restriction_Range_Details(thisRange.RangeID, RequestSpecificValues.Tracer);
                }
            }

            readOnlyMode = true;
            if (((RequestSpecificValues.Current_User.Is_System_Admin) && (!UI_ApplicationCache_Gateway.Settings.Servers.isHosted)) ||
                (RequestSpecificValues.Current_User.Is_Host_Admin))
            {
                readOnlyMode = false;
            }

            if ((RequestSpecificValues.Current_Mode.isPostBack) && (RequestSpecificValues.Current_User.Is_System_Admin))
            {
                if (readOnlyMode)
                {
                    return;
                }

                // Get a reference to this form
                NameValueCollection form = HttpContext.Current.Request.Form;

                string action = form["action"].Trim();

                if (action == "new")
                {
                    // Pull the main values
                    entered_title   = form["new_admin_title"].Trim();
                    entered_notes   = form["new_admin_notes"].Trim();
                    entered_message = form["new_admin_message"].Trim();

                    if ((entered_title.Length == 0) || (entered_message.Length == 0))
                    {
                        actionMessage = "Both title and message are required fields";
                    }
                    else
                    {
                        if (SobekCM_Database.Edit_IP_Range(-1, entered_title, entered_notes, entered_message, RequestSpecificValues.Tracer))
                        {
                            actionMessage = "Saved new IP range '" + entered_title + "'";

                            entered_title   = String.Empty;
                            entered_notes   = String.Empty;
                            entered_message = String.Empty;

                            // Need to recalcualte the IP range membership for the current user
                            HttpContext.Current.Session["IP_Range_Membership"] = null;
                        }
                        else
                        {
                            actionMessage = "Error saving new IP range '" + entered_title + "'";
                        }
                    }
                }
                else if (action == "delete")
                {
                    int id_to_delete = Int32.Parse(form["admin_ip_delete"]);

                    string delete_title = UI_ApplicationCache_Gateway.IP_Restrictions[id_to_delete].Title;

                    if (SobekCM_Database.Delete_IP_Range(id_to_delete, RequestSpecificValues.Tracer))
                    {
                        actionMessage = "Deleted IP range '" + delete_title + "'";

                        // Need to recalcualte the IP range membership for the current user
                        HttpContext.Current.Session["IP_Range_Membership"] = null;
                    }
                    else
                    {
                        actionMessage = "Error deleting new IP range '" + delete_title + "'";
                    }
                }
                else if ((details != null) && (thisRange != null))
                {
                    try
                    {
                        // 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, RequestSpecificValues.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, RequestSpecificValues.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, RequestSpecificValues.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, RequestSpecificValues.Tracer);
                                        }
                                    }
                                }
                            }
                        }

                        // Need to recalcualte the IP range membership for the current user
                        HttpContext.Current.Session["IP_Range_Membership"] = null;
                    }
                    catch (Exception)
                    {
                        actionMessage = "Error saving IP range";
                    }
                }


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

                // Forward back to the main form
                if (String.IsNullOrEmpty(actionMessage))
                {
                    RequestSpecificValues.Current_Mode.My_Sobek_SubMode = String.Empty;
                    UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                }
            }
        }
        /// <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=\"" + Static_Resources_Gateway.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("<input type=\"hidden\" id=\"admin_ip_delete\" name=\"admin_ip_delete\" 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
                RequestSpecificValues.Current_Mode.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=\"" + UI_ApplicationCache_Gateway.Settings.System.Help_URL(RequestSpecificValues.Current_Mode.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 (!readOnlyMode)
                {
                    Output.WriteLine("        <button title=\"Do not apply changes\" class=\"sbkAdm_RoundButton\" onclick=\"parent.location='" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "';return false;\"><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 IP restriction range\" class=\"sbkAdm_RoundButton\" type=\"submit\">SAVE <img src=\"" + Static_Resources_Gateway.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='" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "';return false;\"><img src=\"" + Static_Resources_Gateway.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 (readOnlyMode)
                {
                    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 (!readOnlyMode)
                {
                    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 (!readOnlyMode)
                    {
                        Output.WriteLine("      <td class=\"sbkAdm_ActionLink\" >( <a title=\"Click to clear this ip address\" href=\"" + RequestSpecificValues.Current_Mode.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 (!readOnlyMode)
                {
                    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=\"" + RequestSpecificValues.Current_Mode.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=\"" + UI_ApplicationCache_Gateway.Settings.System.Help_URL(RequestSpecificValues.Current_Mode.Base_URL) + "adminhelp/restrictions\" target=\"ADMIN_USER_HELP\" >click here to view the help page</a>.</p>");
            Output.WriteLine();

            if (!readOnlyMode)
            {
                // 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=\"" + HttpUtility.HtmlEncode(entered_title) + "\" /></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\" >" + HttpUtility.HtmlEncode(entered_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=\"new_admin_message\" id=\"new_admin_message\" class=\"sbkIpav_input sbkAdmin_Focusable\" >" + HttpUtility.HtmlEncode(entered_message) + "</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=\"" + Static_Resources_Gateway.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 (UI_ApplicationCache_Gateway.IP_Restrictions.Count == 0)
            {
                Output.WriteLine("  <p>No existing IP restrictive ranges exist.</p>");
                if (!readOnlyMode)
                {
                    Output.WriteLine("<p>To add one, enter the information above and press SAVE.</p>");
                }
            }
            else
            {
                Output.WriteLine("  <p>The following IP restrictive ranges are active:</p>");
                Output.WriteLine("  <table class=\"sbkIpav_MainTable sbkAdm_Table\">");
                Output.WriteLine("    <tr>");
                Output.WriteLine("      <th class=\"sbkIpav_MainTableHeader1\">ACTIONS</th>");
                Output.WriteLine("      <th class=\"sbkIpav_MainTableHeader2\">TITLE</th>");
                Output.WriteLine("      <th class=\"sbkIpav_MainTableHeader3\">NOTES</th>");
                Output.WriteLine("    </tr>");
                Output.WriteLine("    <tr><td class=\"sbkAdm_TableRule\" colspan=\"3\"></td></tr>");

                string action_verb = "view";
                if (!readOnlyMode)
                {
                    action_verb = "edit";
                }

                foreach (IP_Restriction_Range existingRange in UI_ApplicationCache_Gateway.IP_Restrictions.IpRanges)
                {
                    Output.WriteLine("    <tr>");
                    Output.Write("      <td class=\"sbkAdm_ActionLink\" >( ");

                    RequestSpecificValues.Current_Mode.My_Sobek_SubMode = existingRange.RangeID.ToString();
                    Output.WriteLine("<a title=\"Click to " + action_verb + " this group of IP addresses\" href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "\">" + action_verb + "</a>");

                    if (!readOnlyMode)
                    {
                        Output.WriteLine("| <a title=\"Click to delete this group of IP addresses\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\"  onclick=\"return delete_ip_group(" + existingRange.RangeID + ", '" + HttpUtility.HtmlEncode(existingRange.Title) + "');\">delete</a>");
                    }
                    else
                    {
                        Output.WriteLine("| <a title=\"Only SYSTEM administrators can delete a group of IP addresses\" href=\"" + RequestSpecificValues.Current_Mode.Base_URL + "l/technical/javascriptrequired\"  onclick=\"alert('Only SYSTEM administrators can delete a group of IP addresses'); return false;\">delete</a>");
                    }


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

                    Output.WriteLine("      <td>" + HttpUtility.HtmlEncode(existingRange.Title) + "</td>");
                    Output.WriteLine("      <td>" + HttpUtility.HtmlEncode(existingRange.Notes) + "</td>");
                    Output.WriteLine("    </tr>");
                    Output.WriteLine("    <tr><td class=\"sbkAdm_TableRule\" colspan=\"3\"></td></tr>");
                }

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

            Output.WriteLine("</div>");
        }
Example #14
0
        /// <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 = UrlWriterHelper.URL_Options(RequestSpecificValues.Current_Mode);

            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=\"" + RequestSpecificValues.Current_Mode.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 ((RequestSpecificValues.Current_Mode != null) && (!String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.Error_Message)))
                {
                    error_message = RequestSpecificValues.Current_Mode.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=\"" + RequestSpecificValues.Current_Mode.Base_URL + url_options + "\">here</a> to return to the library.</h5>");
                string returnurl = RequestSpecificValues.Current_Mode.Base_URL + "contact?em=" + error_message.Replace(" ", "%20") + UrlWriterHelper.URL_Options(RequestSpecificValues.Current_Mode);
                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> 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("Manage_Menu_WebContentViewer.Add_HTML", "Start to add the html content");
            }

            Output.WriteLine("  <table id=\"sbkMmav_MainTable\">");

            string type1 = "web content page";
            string type2 = "Web Content Page";

            if (!String.IsNullOrEmpty(StaticPage.Redirect))
            {
                type1 = "global redirect";
                type2 = "Global Redirect";
            }

            Output.WriteLine("    <tr class=\"sbkMmav_HeaderRow\"><td colspan=\"3\">How would you like to manage this " + type1 + " today?</td></tr>");


            // Collect all the URLs
            RequestSpecificValues.Current_Mode.Mode            = Display_Mode_Enum.Simple_HTML_CMS;
            RequestSpecificValues.Current_Mode.WebContent_Type = WebContent_Type_Enum.Display;
            string view_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            RequestSpecificValues.Current_Mode.WebContent_Type = WebContent_Type_Enum.Edit;
            string edit_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            RequestSpecificValues.Current_Mode.WebContent_Type = WebContent_Type_Enum.Usage;
            string usage_stats_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            RequestSpecificValues.Current_Mode.WebContent_Type = WebContent_Type_Enum.Milestones;
            string history_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            RequestSpecificValues.Current_Mode.WebContent_Type = WebContent_Type_Enum.Permissions;
            string permissions_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            RequestSpecificValues.Current_Mode.WebContent_Type = WebContent_Type_Enum.Delete_Verify;
            string delete_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);


            // Add admin view is system administrator
            RequestSpecificValues.Current_Mode.Mode       = Display_Mode_Enum.Administrative;
            RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.WebContent_Single;
            string admin_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Simple_HTML_CMS;

            // Add the link for viewing this
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <td style=\"width:50px\">&nbsp;</td>");
            Output.WriteLine("      <td style=\"width:60px\"><a href=\"" + view_url + "\"><img src=\"" + Static_Resources_Gateway.WebContent_Img_Large + "\" /></a></td>");
            Output.WriteLine("      <td>");
            Output.WriteLine("        <a href=\"" + view_url + "\">View " + type2 + "</a>");
            Output.WriteLine("        <div class=\"sbkMmav_Desc\">View this web content page or global redirect, as it will be viewed by public, non-authenticated users.</div>");
            Output.WriteLine("      </td>");
            Output.WriteLine("    </tr>");
            Output.WriteLine("    <tr class=\"sbkMmav_SpacerRow\"><td colspan=\"3\"></td></tr>");

            // Add the link for editing this
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <td style=\"width:50px\">&nbsp;</td>");
            Output.WriteLine("      <td style=\"width:60px\"><a href=\"" + edit_url + "\"><img src=\"" + Static_Resources_Gateway.Edit_Metadata_Icon_Png + "\" /></a></td>");
            Output.WriteLine("      <td>");
            Output.WriteLine("        <a href=\"" + edit_url + "\">Edit " + type2 + "</a>");
            Output.WriteLine("        <div class=\"sbkMmav_Desc\">Edit the information including the redirect URL, title, subjects, and keywords, and control the general appearance of the page and bulk upload images and documents.</div>");
            Output.WriteLine("      </td>");
            Output.WriteLine("    </tr>");
            Output.WriteLine("    <tr class=\"sbkMmav_SpacerRow\"><td colspan=\"3\"></td></tr>");


            // Add the link for the usage stats
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <td style=\"width:50px\">&nbsp;</td>");
            Output.WriteLine("      <td style=\"width:60px\"><a href=\"" + usage_stats_url + "\"><img src=\"" + Static_Resources_Gateway.Usage_Img_Large + "\" /></a></td>");
            Output.WriteLine("      <td>");
            Output.WriteLine("        <a href=\"" + usage_stats_url + "\">View History of Use</a>");
            Output.WriteLine("        <div class=\"sbkMmav_Desc\">View ths usage statistics for this web content page or global redirect.</div>");
            Output.WriteLine("      </td>");
            Output.WriteLine("    </tr>");
            Output.WriteLine("    <tr class=\"sbkMmav_SpacerRow\"><td colspan=\"3\"></td></tr>");

            // Add the link for aggregation management
            if ((RequestSpecificValues.Current_User.Is_System_Admin) || (RequestSpecificValues.Current_User.Is_Portal_Admin))
            {
                // Add the link for the work log history
                Output.WriteLine("    <tr>");
                Output.WriteLine("      <td style=\"width:50px\">&nbsp;</td>");
                Output.WriteLine("      <td style=\"width:60px\"><a href=\"" + history_url + "\"><img src=\"" + Static_Resources_Gateway.View_Work_Log_Img_Large + "\" /></a></td>");
                Output.WriteLine("      <td>");
                Output.WriteLine("        <a href=\"" + history_url + "\">View Change Log</a>");
                Output.WriteLine("        <div class=\"sbkMmav_Desc\">View the change log for this web content page or global redirect and the design files under this collection.</div>");
                Output.WriteLine("      </td>");
                Output.WriteLine("    </tr>");
                Output.WriteLine("    <tr class=\"sbkMmav_SpacerRow\"><td colspan=\"3\"></td></tr>");

                // Add the link for the user permissions
                Output.WriteLine("    <tr>");
                Output.WriteLine("      <td style=\"width:50px\">&nbsp;</td>");
                Output.WriteLine("      <td style=\"width:60px\"><a href=\"" + permissions_url + "\"><img src=\"" + Static_Resources_Gateway.User_Permission_Img_Large + "\" /></a></td>");
                Output.WriteLine("      <td>");
                Output.WriteLine("        <a href=\"" + permissions_url + "\">View User Permissions</a>");
                Output.WriteLine("        <div class=\"sbkMmav_Desc\">View special user permissions granted to users over this web content page or global redirect.  This includes permissions assigned individually, as well as permissions assigned through user groups.</div>");
                Output.WriteLine("      </td>");
                Output.WriteLine("    </tr>");
                Output.WriteLine("    <tr class=\"sbkMmav_SpacerRow\"><td colspan=\"3\"></td></tr>");

                // Add the link to delete this web page
                Output.WriteLine("    <tr>");
                Output.WriteLine("      <td style=\"width:50px\">&nbsp;</td>");
                Output.WriteLine("      <td style=\"width:60px\"><a href=\"" + delete_url + "\"><img src=\"" + Static_Resources_Gateway.Delete_Item_Icon_Png + "\" /></a></td>");
                Output.WriteLine("      <td>");
                Output.WriteLine("        <a href=\"" + delete_url + "\">Delete " + type2 + "</a>");
                Output.WriteLine("        <div class=\"sbkMmav_Desc\">Delete this web content page or global redirect from the system entirely.</div>");
                Output.WriteLine("      </td>");
                Output.WriteLine("    </tr>");
                Output.WriteLine("    <tr class=\"sbkMmav_SpacerRow\"><td colspan=\"3\"></td></tr>");

                // Add the link to administer
                Output.WriteLine("    <tr>");
                Output.WriteLine("      <td style=\"width:50px\">&nbsp;</td>");
                Output.WriteLine("      <td style=\"width:60px\"><a href=\"" + admin_url + "\"><img src=\"" + Static_Resources_Gateway.Admin_View_Img_Large + "\" /></a></td>");
                Output.WriteLine("      <td>");
                Output.WriteLine("        <a href=\"" + admin_url + "\">Web Content Administration</a>");
                Output.WriteLine("        <div class=\"sbkMmav_Desc\">Perform administrative duties against this web content page or global redirect, changing the appearance, viewing the child list, and managing files related to this page.</div>");
                Output.WriteLine("      </td>");
                Output.WriteLine("    </tr>");
                Output.WriteLine("    <tr class=\"sbkMmav_SpacerRow\"><td colspan=\"3\"></td></tr>");
            }

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

            if (Tracer != null)
            {
                Tracer.Add_Trace("Manage_Menu_WebContentViewer.Add_HTML", "Done adding the html content");
            }
        }
        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>");

            RequestSpecificValues.Current_Mode.Info_Browse_Mode = "definitions";
            Output.WriteLine("<p>The <a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "\">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> 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("WebContent_Usage_AdminViewer.Write_ItemNavForm_Closing", "");

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

            string last_mode = RequestSpecificValues.Current_Mode.My_Sobek_SubMode;



            if (actionMessage.Length > 0)
            {
                Output.WriteLine("  <div class=\"sbkAdm_HomeText\">");
                Output.WriteLine("  <br />");
                if (actionMessage.IndexOf("Error", StringComparison.InvariantCultureIgnoreCase) >= 0)
                {
                    Output.WriteLine("  <br />");
                    Output.WriteLine("  <div id=\"sbkAdm_ActionMessageError\">" + actionMessage + "</div>");
                }
                else
                {
                    Output.WriteLine("  <div id=\"sbkAdm_ActionMessageSuccess\">" + actionMessage + "</div>");
                }
                Output.WriteLine("  <br />");
                Output.WriteLine("  </div>");
            }



            // Start the outer tab containe
            Output.WriteLine("  <div id=\"tabContainer\" class=\"fulltabs sbkAdm_HomeTabs\">");
            Output.WriteLine("  <div class=\"tabs\">");
            Output.WriteLine("    <ul>");

            string tab1_title = "USAGE";

            Output.WriteLine("      <li class=\"tabActiveHeader\"> " + tab1_title + " </li>");

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

            Output.WriteLine("    <div class=\"tabscontent\">");
            Output.WriteLine("    	<div class=\"sbkUgav_TabPage\" id=\"tabpage_1\">");

            //// Add the buttons
            //Output.WriteLine("  <div class=\"sbkSeav_ButtonsDiv\">");
            //Output.WriteLine("    <button title=\"Do not apply changes\" class=\"sbkAdm_RoundButton\" onclick=\"return cancel_user_edits();return false;\"><img src=\"" + Static_Resources.Button_Previous_Arrow_Png + "\" class=\"sbkAdm_RoundButton_LeftImg\" alt=\"\" /> CANCEL</button> &nbsp; &nbsp; ");
            //Output.WriteLine("    <button title=\"Save changes to this user group\" class=\"sbkAdm_RoundButton\" onclick=\"return save_user_edits();return false;\">SAVE <img src=\"" + Static_Resources.Button_Next_Arrow_Png + "\" class=\"sbkAdm_RoundButton_RightImg\" alt=\"\" /></button>");
            //Output.WriteLine("  </div>");
            //Output.WriteLine();


            Output.WriteLine();

            // Determine the two URLS needed (one for the GO button, and another for the jQuery datatable results)
            StringBuilder script_builder  = new StringBuilder(UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode));
            StringBuilder results_builder = new StringBuilder(SobekEngineClient.WebContent.Get_Global_Usage_Report_JDataTable_URL);

            // Get the base URL without any filtering
            string filterUrl = script_builder + "?d1=" + year1 + month1.ToString().PadLeft(2, '0') + "&d2=" + year2 + month2.ToString().PadLeft(2, '0');

            // Add the month/year query stuff to the results
            results_builder.Append("?year1=" + year1 + "&month1=" + month1.ToString().PadLeft(2, '0') + "&year2=" + year2 + "&month2=" + month2.ToString().PadLeft(2, '0'));

            // Add any query string related to the filter levels
            if (!String.IsNullOrEmpty(level1))
            {
                script_builder.Append("?l1=" + level1);
                results_builder.Append("&l1=" + level1);
                if (!String.IsNullOrEmpty(level2))
                {
                    script_builder.Append("&l2=" + level2);
                    results_builder.Append("&l2=" + level2);
                    if (!String.IsNullOrEmpty(level3))
                    {
                        script_builder.Append("&l3=" + level3);
                        results_builder.Append("&l3=" + level3);
                        if (!String.IsNullOrEmpty(level4))
                        {
                            script_builder.Append("&l4=" + level4);
                            results_builder.Append("&l4=" + level4);
                            if (!String.IsNullOrEmpty(level5))
                            {
                                script_builder.Append("&l5=" + level5);
                                results_builder.Append("&l5=" + level5);
                            }
                        }
                    }
                }
            }

            // Get the URLS from the string builders
            string goUrl   = script_builder.ToString();
            string dataUrl = results_builder.ToString();



            // If there are none whatsoever, show  a special message and don't bother with the table
            if (!SobekEngineClient.WebContent.Has_Global_Usage(Tracer))
            {
                Output.WriteLine("<div id=\"sbkWchs_NoDataMsg\">No usage statistics collected</div>");
            }
            else
            {
                Output.WriteLine("  <p>Usage statistics for the web content pages over time appears below.");
                Output.WriteLine("     Views are the number of times this page was requested.  Hierarchical views includes the hits on this page, as well as all the child pages.");
                Output.WriteLine("     Usage statistics are collected from the web logs by the SobekCM builder in a regular, monthly automated process.</p>");


                Output.WriteLine("  <p>The usage for the web content pages appears below for the following data range:</p>");

                Output.WriteLine("  <div id=\"sbkWcuav_DatePanel\">");
                Output.WriteLine("    From: <select id=\"date1_selector\" class=\"SobekStatsDateSelector\" >");

                int select_month = UI_ApplicationCache_Gateway.Stats_Date_Range.Earliest_Month;
                int select_year  = UI_ApplicationCache_Gateway.Stats_Date_Range.Earliest_Year;
                while ((select_month != UI_ApplicationCache_Gateway.Stats_Date_Range.Latest_Month) || (select_year != UI_ApplicationCache_Gateway.Stats_Date_Range.Latest_Year))
                {
                    if ((month1 == select_month) && (year1 == select_year))
                    {
                        Output.WriteLine("      <option value=\"" + select_year + select_month.ToString().PadLeft(2, '0') + "\" selected=\"selected\" >" + Month_From_Int(select_month) + " " + select_year + "</option>");
                    }
                    else
                    {
                        Output.WriteLine("      <option value=\"" + select_year + select_month.ToString().PadLeft(2, '0') + "\">" + Month_From_Int(select_month) + " " + select_year + "</option>");
                    }

                    select_month++;
                    if (select_month > 12)
                    {
                        select_month = 1;
                        select_year++;
                    }
                }
                if ((month1 == select_month) && (year1 == select_year))
                {
                    Output.WriteLine("      <option value=\"" + select_year + select_month.ToString().PadLeft(2, '0') + "\" selected=\"selected\" >" + Month_From_Int(select_month) + " " + select_year + "</option>");
                }
                else
                {
                    Output.WriteLine("      <option value=\"" + select_year + select_month.ToString().PadLeft(2, '0') + "\">" + Month_From_Int(select_month) + " " + select_year + "</option>");
                }
                Output.WriteLine("    </select>");
                Output.WriteLine("    &nbsp; &nbsp;");
                Output.WriteLine("    To: <select id=\"date2_selector\" class=\"SobekStatsDateSelector\" >");

                select_month = UI_ApplicationCache_Gateway.Stats_Date_Range.Earliest_Month;
                select_year  = UI_ApplicationCache_Gateway.Stats_Date_Range.Earliest_Year;
                while ((select_month != UI_ApplicationCache_Gateway.Stats_Date_Range.Latest_Month) || (select_year != UI_ApplicationCache_Gateway.Stats_Date_Range.Latest_Year))
                {
                    if ((month2 == select_month) && (year2 == select_year))
                    {
                        Output.WriteLine("      <option value=\"" + select_year + select_month.ToString().PadLeft(2, '0') + "\" selected=\"selected\" >" + Month_From_Int(select_month) + " " + select_year + "</option>");
                    }
                    else
                    {
                        Output.WriteLine("      <option value=\"" + select_year + select_month.ToString().PadLeft(2, '0') + "\">" + Month_From_Int(select_month) + " " + select_year + "</option>");
                    }

                    select_month++;
                    if (select_month > 12)
                    {
                        select_month = 1;
                        select_year++;
                    }
                }
                if ((month2 == select_month) && (year2 == select_year))
                {
                    Output.WriteLine("      <option value=\"" + select_year + select_month.ToString().PadLeft(2, '0') + "\" selected=\"selected\" >" + Month_From_Int(select_month) + " " + select_year + "</option>");
                }
                else
                {
                    Output.WriteLine("      <option value=\"" + select_year + select_month.ToString().PadLeft(2, '0') + "\">" + Month_From_Int(select_month) + " " + select_year + "</option>");
                }

                Output.WriteLine("    </select>");
                Output.WriteLine("    &nbsp; &nbsp;");
                Output.WriteLine("    <button title=\"Select Range\" class=\"roundbutton\" onclick=\"date_jump_sobekcm('" + goUrl + "'); return false;\">GO <img src=\"" + Static_Resources_Gateway.Button_Next_Arrow_Png + "\" class\"roundbutton_img_right\" alt=\"\" /></button>");
                Output.WriteLine("  </div>");


                // Add the filter boxes
                Output.WriteLine("  <p>Use the boxes below to filter the results to only show a subset.</p>");
                Output.WriteLine("  <div id=\"sbkWcuav_FilterPanel\">");

                Output.WriteLine("    Filter by URL: ");
                Output.WriteLine("    <select id=\"lvl1Filter\" name=\"lvl1Filter\" class=\"sbkWcav_FilterBox\" onchange=\"new_webcontent_filter('" + filterUrl + "',1);\">");
                if (String.IsNullOrEmpty(level1))
                {
                    Output.WriteLine("      <option value=\"\" selected=\"selected\"></option>");
                }
                else
                {
                    Output.WriteLine("      <option value=\"\"></option>");
                }

                List <string> level1Options = SobekEngineClient.WebContent.Get_Global_Recent_Updates_NextLevel(Tracer);
                foreach (string thisOption in level1Options)
                {
                    if (String.Compare(level1, thisOption, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        Output.WriteLine("      <option value=\"" + thisOption + "\" selected=\"selected\">" + thisOption + "</option>");
                    }
                    else
                    {
                        Output.WriteLine("      <option value=\"" + thisOption + "\">" + thisOption + "</option>");
                    }
                }
                Output.WriteLine("    </select>");

                // Should the second level be shown?
                if (!String.IsNullOrEmpty(level1))
                {
                    List <string> level2Options = SobekEngineClient.WebContent.Get_Global_Recent_Updates_NextLevel(Tracer, level1);
                    if (level2Options.Count > 0)
                    {
                        Output.WriteLine("    /");
                        Output.WriteLine("    <select id=\"lvl2Filter\" name=\"lvl2Filter\" class=\"sbkWcav_FilterBox\" onchange=\"new_webcontent_filter('" + filterUrl + "',2);\">");
                        if (String.IsNullOrEmpty(level2))
                        {
                            Output.WriteLine("      <option value=\"\" selected=\"selected\"></option>");
                        }
                        else
                        {
                            Output.WriteLine("      <option value=\"\"></option>");
                        }


                        foreach (string thisOption in level2Options)
                        {
                            if (String.Compare(level2, thisOption, StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                Output.WriteLine("      <option value=\"" + thisOption + "\" selected=\"selected\">" + thisOption + "</option>");
                            }
                            else
                            {
                                Output.WriteLine("      <option value=\"" + thisOption + "\">" + thisOption + "</option>");
                            }
                        }
                        Output.WriteLine("    </select>");

                        // Should the third level be shown?
                        if (!String.IsNullOrEmpty(level2))
                        {
                            List <string> level3Options = SobekEngineClient.WebContent.Get_Global_Recent_Updates_NextLevel(Tracer, level1, level2);
                            if (level3Options.Count > 0)
                            {
                                Output.WriteLine("    /");
                                Output.WriteLine("    <select id=\"lvl3Filter\" name=\"lvl3Filter\" class=\"sbkWcav_FilterBox\" onchange=\"new_webcontent_filter('" + filterUrl + "',3);\">");
                                if (String.IsNullOrEmpty(level3))
                                {
                                    Output.WriteLine("      <option value=\"\" selected=\"selected\"></option>");
                                }
                                else
                                {
                                    Output.WriteLine("      <option value=\"\"></option>");
                                }


                                foreach (string thisOption in level3Options)
                                {
                                    if (String.Compare(level3, thisOption, StringComparison.OrdinalIgnoreCase) == 0)
                                    {
                                        Output.WriteLine("      <option value=\"" + thisOption + "\" selected=\"selected\">" + thisOption + "</option>");
                                    }
                                    else
                                    {
                                        Output.WriteLine("      <option value=\"" + thisOption + "\">" + thisOption + "</option>");
                                    }
                                }
                                Output.WriteLine("    </select>");

                                // Should the fourth level be shown?
                                if (!String.IsNullOrEmpty(level3))
                                {
                                    List <string> level4Options = SobekEngineClient.WebContent.Get_Global_Recent_Updates_NextLevel(Tracer, level1, level2, level3);
                                    if (level4Options.Count > 0)
                                    {
                                        Output.WriteLine("    /");
                                        Output.WriteLine("    <select id=\"lvl4Filter\" name=\"lvl4Filter\" class=\"sbkWcav_FilterBox\" onchange=\"new_webcontent_filter('" + filterUrl + "',4);\">");
                                        if (String.IsNullOrEmpty(level4))
                                        {
                                            Output.WriteLine("      <option value=\"\" selected=\"selected\"></option>");
                                        }
                                        else
                                        {
                                            Output.WriteLine("      <option value=\"\"></option>");
                                        }


                                        foreach (string thisOption in level4Options)
                                        {
                                            if (String.Compare(level4, thisOption, StringComparison.OrdinalIgnoreCase) == 0)
                                            {
                                                Output.WriteLine("      <option value=\"" + thisOption + "\" selected=\"selected\">" + thisOption + "</option>");
                                            }
                                            else
                                            {
                                                Output.WriteLine("      <option value=\"" + thisOption + "\">" + thisOption + "</option>");
                                            }
                                        }
                                        Output.WriteLine("    </select>");


                                        // Should the fifth level be shown?
                                        if (!String.IsNullOrEmpty(level4))
                                        {
                                            List <string> level5Options = SobekEngineClient.WebContent.Get_Global_Recent_Updates_NextLevel(Tracer, level1, level2, level3, level4);
                                            if (level5Options.Count > 0)
                                            {
                                                Output.WriteLine("    /");
                                                Output.WriteLine("    <select id=\"lvl5Filter\" name=\"lvl5Filter\" class=\"sbkWcav_FilterBox\" onchange=\"new_webcontent_filter('" + filterUrl + "',5);\">");
                                                if (String.IsNullOrEmpty(level5))
                                                {
                                                    Output.WriteLine("      <option value=\"\" selected=\"selected\"></option>");
                                                }
                                                else
                                                {
                                                    Output.WriteLine("      <option value=\"\"></option>");
                                                }


                                                foreach (string thisOption in level5Options)
                                                {
                                                    if (String.Compare(level5, thisOption, StringComparison.OrdinalIgnoreCase) == 0)
                                                    {
                                                        Output.WriteLine("      <option value=\"" + thisOption + "\" selected=\"selected\">" + thisOption + "</option>");
                                                    }
                                                    else
                                                    {
                                                        Output.WriteLine("      <option value=\"" + thisOption + "\">" + thisOption + "</option>");
                                                    }
                                                }
                                                Output.WriteLine("    </select>");
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                Output.WriteLine("  </div>");
                Output.WriteLine();

                Output.WriteLine("  <table id=\"sbkWcav_MainTable\" class=\"sbkWcuav_Table display\">");
                Output.WriteLine("    <thead>");
                Output.WriteLine("      <tr>");
                Output.WriteLine("        <th>URL</th>");
                Output.WriteLine("        <th>Title</th>");
                Output.WriteLine("        <th>Hits</th>");
                Output.WriteLine("        <th>HitsHierarchical</th>");
                Output.WriteLine("      </tr>");
                Output.WriteLine("    </thead>");
                Output.WriteLine("    <tbody>");
                Output.WriteLine("      <tr><td colspan=\"5\" class=\"dataTables_empty\">Loading data from server</td></tr>");
                Output.WriteLine("    </tbody>");
                Output.WriteLine("  </table>");

                Output.WriteLine();
                Output.WriteLine("<script type=\"text/javascript\">");
                Output.WriteLine("  $(document).ready(function() {");
                Output.WriteLine("     var shifted=false;");
                Output.WriteLine("     $(document).on('keydown', function(e){shifted = e.shiftKey;} );");
                Output.WriteLine("     $(document).on('keyup', function(e){shifted = false;} );");

                Output.WriteLine();
                Output.WriteLine("      var oTable = $('#sbkWcav_MainTable').dataTable({");
                Output.WriteLine("           \"lengthMenu\": [ [50, 100, 500, 1000, -1], [50, 100, 500, 1000, \"All\"] ],");
                Output.WriteLine("           \"pageLength\": 50,");
                //Output.WriteLine("           \"bFilter\": false,");
                Output.WriteLine("           \"processing\": true,");
                Output.WriteLine("           \"serverSide\": true,");
                Output.WriteLine("           \"sDom\": \"lprtip\",");



                Output.WriteLine("           \"sAjaxSource\": \"" + dataUrl + "\",");
                Output.WriteLine("           \"aoColumns\": [ null, null, null, null ]  });");
                Output.WriteLine();

                Output.WriteLine("     $('#sbkWcav_MainTable tbody').on( 'click', 'tr', function () {");
                Output.WriteLine("          var aData = oTable.fnGetData( this );");
                Output.WriteLine("          var iId = aData[1];");
                Output.WriteLine("          if ( shifted == true )");
                Output.WriteLine("          {");
                Output.WriteLine("             window.open('" + RequestSpecificValues.Current_Mode.Base_URL + "' + iId);");
                Output.WriteLine("             shifted=false;");
                Output.WriteLine("          }");
                Output.WriteLine("          else");
                Output.WriteLine("             window.location.href='" + RequestSpecificValues.Current_Mode.Base_URL + "' + iId;");
                Output.WriteLine("     });");
                Output.WriteLine("  });");
                Output.WriteLine("</script>");
                Output.WriteLine();
                //// Add the buttons
                //RequestSpecificValues.Current_Mode.My_Sobek_SubMode = String.Empty;
                //Output.WriteLine("  <div class=\"sbkSeav_ButtonsDiv\">");
                //Output.WriteLine("    <button title=\"Do not apply changes\" class=\"sbkAdm_RoundButton\" onclick=\"return cancel_user_edits();return false;\"><img src=\"" + Static_Resources.Button_Previous_Arrow_Png + "\" class=\"sbkAdm_RoundButton_LeftImg\" alt=\"\" /> CANCEL</button> &nbsp; &nbsp; ");
                //Output.WriteLine("    <button title=\"Save changes to this user\" class=\"sbkAdm_RoundButton\" onclick=\"return save_user_edits();return false;\">SAVE <img src=\"" + Static_Resources.Button_Next_Arrow_Png + "\" class=\"sbkAdm_RoundButton_RightImg\" alt=\"\" /></button>");
                //Output.WriteLine("  </div>");

                Output.WriteLine();
            }

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

            Output.WriteLine("<br />");
            Output.WriteLine("<br />");
        }
        private void add_usage_definitions(TextWriter Output, Custom_Tracer Tracer)
        {
            // See if the FAQ is present for this collection
            string directory        = UI_ApplicationCache_Gateway.Settings.Servers.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 = UrlWriterHelper.URL_Options(RequestSpecificValues.Current_Mode);
                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%>", RequestSpecificValues.Current_Mode.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 " + RequestSpecificValues.Current_Mode.Instance_Abbreviation + " it counts as a view. The " + RequestSpecificValues.Current_Mode.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, " + RequestSpecificValues.Current_Mode.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>");
            }
        }
Example #19
0
        /// <summary> Writes the HTML generated by this my sobek 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> 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("Admin_HtmlSubwriter.Write_HTML", "Rendering HTML");

            // if (CurrentMode.Admin_Type == Admin_Type_Enum.Wordmarks)
            //     return false;

            if ((!adminViewer.Contains_Popup_Forms) && (!RequestSpecificValues.Current_Mode.Logon_Required))
            {
                if ((RequestSpecificValues.Current_Mode.Admin_Type != Admin_Type_Enum.Aggregation_Single) && (RequestSpecificValues.Current_Mode.Admin_Type != Admin_Type_Enum.Skins_Single) && (RequestSpecificValues.Current_Mode.Admin_Type != Admin_Type_Enum.Add_Collection_Wizard))
                {
                    // Add the banner
                    if (!adminViewer.Viewer_Behaviors.Contains(HtmlSubwriter_Behaviors_Enum.Suppress_Banner))
                    {
                        Add_Banner(Output, "sbkAhs_BannerDiv", WebPage_Title.Replace("{0} ", ""), RequestSpecificValues.Current_Mode, RequestSpecificValues.HTML_Skin, RequestSpecificValues.Top_Collection);
                    }

                    // Add the RequestSpecificValues.Current_User-specific main menu
                    MainMenus_Helper_HtmlSubWriter.Add_UserSpecific_Main_Menu(Output, RequestSpecificValues);

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

                    // Add the box with the title
                    if (((RequestSpecificValues.Current_Mode.My_Sobek_Type != My_Sobek_Type_Enum.Folder_Management) || (RequestSpecificValues.Current_Mode.My_Sobek_SubMode != "submitted items")) && (RequestSpecificValues.Current_Mode.Admin_Type != Admin_Type_Enum.WebContent_Single))
                    {
                        // Add the title
                        Output.WriteLine("<div class=\"sbkAdm_TitleDiv sbkAdm_TitleDivBorder\">");
                        if (adminViewer != null)
                        {
                            if (adminViewer.Viewer_Icon.Length > 0)
                            {
                                Output.WriteLine("  <img id=\"sbkAdm_TitleDivImg\" src=\"" + adminViewer.Viewer_Icon + "\" alt=\"\" />");
                            }
                            Output.WriteLine("  <h1>" + adminViewer.Web_Title + "</h1>");
                        }
                        else if (RequestSpecificValues.Current_User != null)
                        {
                            Output.WriteLine("  <h1>Welcome back, " + RequestSpecificValues.Current_User.Nickname + "</h1>");
                        }
                        Output.WriteLine("</div>");
                        Output.WriteLine();

                        // Add some administrative breadcrumbs here
                        if (adminViewer != null)
                        {
                            // Keep the current values
                            Admin_Type_Enum adminType   = RequestSpecificValues.Current_Mode.Admin_Type;
                            ushort          page        = RequestSpecificValues.Current_Mode.Page.HasValue ? RequestSpecificValues.Current_Mode.Page.Value : ((ushort)1);
                            string          browse_code = RequestSpecificValues.Current_Mode.Info_Browse_Mode;
                            //string aggregation = RequestSpecificValues.Current_Mode.Aggregation;
                            //string mySobekMode = RequestSpecificValues.Current_Mode.My_Sobek_SubMode;

                            // Get the URL for the home page
                            RequestSpecificValues.Current_Mode.Mode             = Display_Mode_Enum.Aggregation;
                            RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home;
                            RequestSpecificValues.Current_Mode.Home_Type        = Home_Type_Enum.List;
                            string home_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

                            if (adminViewer is Home_AdminViewer)
                            {
                                // Render the breadcrumbns
                                Output.WriteLine("<div class=\"sbkAdm_Breadcrumbs\">");
                                Output.WriteLine("  <a href=\"" + home_url + "\">" + RequestSpecificValues.Current_Mode.Instance_Abbreviation + " Home</a> > ");
                                Output.WriteLine("  System Administrative Tasks");
                                Output.WriteLine("</div>");
                            }
                            else
                            {
                                // Get the URL for the system admin menu
                                RequestSpecificValues.Current_Mode.Mode       = Display_Mode_Enum.Administrative;
                                RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Home;
                                string menu_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

                                // Restor everything
                                RequestSpecificValues.Current_Mode.Admin_Type = adminType;

                                // Render the breadcrumbns
                                Output.WriteLine("<div class=\"sbkAdm_Breadcrumbs\">");
                                Output.WriteLine("  <a href=\"" + home_url + "\">" + RequestSpecificValues.Current_Mode.Instance_Abbreviation + " Home</a> > ");
                                Output.WriteLine("  <a href=\"" + menu_url + "\">System Administrative Tasks</a> > ");
                                Output.WriteLine("  " + adminViewer.Web_Title);
                                Output.WriteLine("</div>");
                            }

                            RequestSpecificValues.Current_Mode.Page             = page;
                            RequestSpecificValues.Current_Mode.Info_Browse_Mode = browse_code;
                        }
                    }
                }
            }

            // Add the text here
            adminViewer.Write_HTML(Output, Tracer);
            return(false);
        }
Example #20
0
        /// <summary> Add the main HTML to be added to the page </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 writes the HTML from the static browse or info page here  </remarks>
        public override void Add_Secondary_HTML(TextWriter Output, Custom_Tracer Tracer)
        {
            DataTable permissionsTbl = SobekCM_Database.Get_Aggregation_User_Permissions(ViewBag.Hierarchy_Object.Code, RequestSpecificValues.Tracer);


            // Is this a system administrator?
            bool   isSysAdmin        = ((RequestSpecificValues.Current_User.Is_System_Admin) || (RequestSpecificValues.Current_User.Is_Host_Admin));
            string userAdminUrl      = String.Empty;
            string userGroupAdminUrl = String.Empty;

            // If no permissions received, just show a message
            if ((permissionsTbl == null) || (permissionsTbl.Rows.Count == 0))
            {
                Output.WriteLine("<p>No special user permissions found for this collection.</p>");

                if (isSysAdmin)
                {
                    RequestSpecificValues.Current_Mode.Mode       = Display_Mode_Enum.Administrative;
                    RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Users;

                    Output.WriteLine("<p>Use the <a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "\">administrative Users &amp; Groups</a> to assign collection-specific user permissions.");

                    RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
                }

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

                return;
            }

            Output.WriteLine("<p style=\"text-align: left; padding:0 20px 0 20px;\">Below is the list of all users that have specialized user permissions for this collection.  These permissions may be assigned individually, or through a user group.</p>");



            // Show a message about selecting the user below to edit them
            if (isSysAdmin)
            {
                Output.WriteLine("<p style=\"text-align: left; padding:0 20px 0 20px;\">Select a user from the list below to edit that user's permissions.</p>");

                RequestSpecificValues.Current_Mode.Mode             = Display_Mode_Enum.Administrative;
                RequestSpecificValues.Current_Mode.Admin_Type       = Admin_Type_Enum.Users;
                RequestSpecificValues.Current_Mode.My_Sobek_SubMode = "Xyzzy";
                userAdminUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

                RequestSpecificValues.Current_Mode.Admin_Type       = Admin_Type_Enum.User_Groups;
                RequestSpecificValues.Current_Mode.My_Sobek_SubMode = "Xyzzy";
                userGroupAdminUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
            }

            // Is this using detailed permissions?
            bool detailedPermissions = UI_ApplicationCache_Gateway.Settings.System.Detailed_User_Aggregation_Permissions;

            Output.WriteLine("  <table id=\"sbkPrav_DetailedUsers\">");
            Output.WriteLine("  <thead>");
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <th style=\"width:180px;\">User</th>");
            Output.WriteLine("      <th style=\"width:90px;\"><acronym title=\"Can select this aggregation when editing or submitting an item\">Can<br />Select</acronym></th>");

            if (detailedPermissions)
            {
                Output.WriteLine("      <th style=\"width:85px;\"><acronym title=\"Can edit anything about an item in this aggregation ( i.e., behaviors, metadata, visibility, etc.. )\">Item<br />Edit<br />Metadata</acronym></th>");
                Output.WriteLine("      <th style=\"width:85px;\"><acronym title=\"Can edit anything about an item in this aggregation ( i.e., behaviors, metadata, visibility, etc.. )\">Item<br />Edit<br />Behaviors</acronym></th>");
                Output.WriteLine("      <th style=\"width:85px;\"><acronym title=\"Can edit anything about an item in this aggregation ( i.e., behaviors, metadata, visibility, etc.. )\">Item<br />Perform<br />QC</acronym></th>");
                Output.WriteLine("      <th style=\"width:85px;\"><acronym title=\"Can edit anything about an item in this aggregation ( i.e., behaviors, metadata, visibility, etc.. )\">Item<br />Upload<br />Files</acronym></th>");
                Output.WriteLine("      <th style=\"width:85px;\"><acronym title=\"Can edit anything about an item in this aggregation ( i.e., behaviors, metadata, visibility, etc.. )\">Item<br />Change<br />Visibility</acronym></th>");
                Output.WriteLine("      <th style=\"width:85px;\"><acronym title=\"Can edit anything about an item in this aggregation ( i.e., behaviors, metadata, visibility, etc.. )\">Item<br />Can<br />Delete</acronym></th>");
            }
            else
            {
                Output.WriteLine("      <th style=\"width:85px;\"><acronym title=\"Can edit any item in this aggregation\">Can<br />Edit</acronym></th>");
            }

            Output.WriteLine("      <th style=\"width:85px;\"><acronym title=\"Can perform curatorial or collection manager tasks on this aggregation\">Is<br />Curator</acronym></th>");
            Output.WriteLine("      <th style=\"width:85px;\"><acronym title=\"Can perform curatorial or collection manager tasks on this aggregation\">Is<br />Admin</acronym></th>");
            Output.WriteLine("    </tr>");
            Output.WriteLine("  </thead>");
            Output.WriteLine("  <tbody>");

            // Collect the relevant user group rows, if some permissions were assined by user group
            SortedDictionary <string, DataRow> userGroupRows = new SortedDictionary <string, DataRow>();

            // Users that are attached to user groups may have multiple rows with their name, so collect
            // all the user information from all rows before displaying
            int    last_userid         = -1;
            string username            = String.Empty;
            bool   canSelect           = false;
            bool   canEditMetadata     = false;
            bool   canEditBehaviors    = false;
            bool   canPerformQc        = false;
            bool   canUploadFiles      = false;
            bool   canChangeVisibility = false;
            bool   canDelete           = false;
            bool   isCurator           = false;
            bool   isAdmin             = false;

            foreach (DataRow thisUser in permissionsTbl.Rows)
            {
                // Get the user id for this user row
                int thisUserId = Convert.ToInt32(thisUser["UserID"].ToString());

                // See if this is a new user, to be displayed
                if ((last_userid > 0) && (last_userid != thisUserId))
                {
                    // Show the information for this user
                    if (isSysAdmin)
                    {
                        Output.WriteLine("    <tr class=\"sbkUpav_SelectableRow\" onclick=\"window.open('" + userAdminUrl.Replace("Xyzzy", thisUserId.ToString()) + "', '_UserEdit+ " + thisUserId + "');\">");
                    }
                    else
                    {
                        Output.WriteLine("    <tr>");
                    }

                    Output.WriteLine("      <td>" + username + "</td>");
                    Output.WriteLine("      <td>" + flag_to_display(canSelect) + "</td>");
                    if (detailedPermissions)
                    {
                        Output.WriteLine("      <td>" + flag_to_display(canEditMetadata) + "</td>");
                        Output.WriteLine("      <td>" + flag_to_display(canEditBehaviors) + "</td>");
                        Output.WriteLine("      <td>" + flag_to_display(canPerformQc) + "</td>");
                        Output.WriteLine("      <td>" + flag_to_display(canUploadFiles) + "</td>");
                        Output.WriteLine("      <td>" + flag_to_display(canChangeVisibility) + "</td>");
                        Output.WriteLine("      <td>" + flag_to_display(canDelete) + "</td>");
                    }
                    else
                    {
                        Output.WriteLine("      <td>" + flag_to_display(canEditMetadata) + "</td>");
                    }


                    Output.WriteLine("      <td>" + flag_to_display(isCurator) + "</td>");
                    Output.WriteLine("      <td>" + flag_to_display(isAdmin) + "</td>");

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


                    // Prepare to collect the information about this user
                    canSelect           = false;
                    canEditMetadata     = false;
                    canEditBehaviors    = false;
                    canPerformQc        = false;
                    canUploadFiles      = false;
                    canChangeVisibility = false;
                    canDelete           = false;
                    isCurator           = false;
                    isAdmin             = false;
                }
                last_userid = thisUserId;

                // Collect the flags from this row
                username = thisUser["LastName"] + "," + thisUser["FirstName"];
                if ((thisUser["CanSelect"] != DBNull.Value) && (Convert.ToBoolean(thisUser["CanSelect"])))
                {
                    canSelect = true;
                }
                if ((thisUser["CanEditMetadata"] != DBNull.Value) && (Convert.ToBoolean(thisUser["CanEditMetadata"])))
                {
                    canEditMetadata = true;
                }
                if ((thisUser["CanEditBehaviors"] != DBNull.Value) && (Convert.ToBoolean(thisUser["CanEditBehaviors"])))
                {
                    canEditBehaviors = true;
                }
                if ((thisUser["CanPerformQc"] != DBNull.Value) && (Convert.ToBoolean(thisUser["CanPerformQc"])))
                {
                    canPerformQc = true;
                }
                if ((thisUser["CanUploadFiles"] != DBNull.Value) && (Convert.ToBoolean(thisUser["CanUploadFiles"])))
                {
                    canUploadFiles = true;
                }
                if ((thisUser["CanChangeVisibility"] != DBNull.Value) && (Convert.ToBoolean(thisUser["CanChangeVisibility"])))
                {
                    canChangeVisibility = true;
                }
                if ((thisUser["CanDelete"] != DBNull.Value) && (Convert.ToBoolean(thisUser["CanDelete"])))
                {
                    canDelete = true;
                }
                if ((thisUser["IsCollectionManager"] != DBNull.Value) && (Convert.ToBoolean(thisUser["IsCollectionManager"])))
                {
                    isCurator = true;
                }
                if ((thisUser["IsAggregationAdmin"] != DBNull.Value) && (Convert.ToBoolean(thisUser["IsAggregationAdmin"])))
                {
                    isAdmin = true;
                }

                // If this is from a user group, save that row as well
                if ((thisUser["GroupName"] != DBNull.Value) && (thisUser["GroupName"].ToString().Length > 0))
                {
                    string groupName = thisUser["GroupName"].ToString();
                    if (!userGroupRows.ContainsKey(groupName))
                    {
                        userGroupRows[groupName] = thisUser;
                    }
                }
            }

            // Show the information for the last user
            if (isSysAdmin)
            {
                Output.WriteLine("    <tr class=\"sbkUpav_SelectableRow\" onclick=\"window.open('" + userAdminUrl.Replace("Xyzzy", last_userid.ToString()) + "', '_UserEdit+ " + last_userid + "');\">");
            }
            else
            {
                Output.WriteLine("    <tr>");
            }
            Output.WriteLine("      <td>" + username + "</td>");
            Output.WriteLine("      <td>" + flag_to_display(canSelect) + "</td>");
            if (detailedPermissions)
            {
                Output.WriteLine("      <td>" + flag_to_display(canEditMetadata) + "</td>");
                Output.WriteLine("      <td>" + flag_to_display(canEditBehaviors) + "</td>");
                Output.WriteLine("      <td>" + flag_to_display(canPerformQc) + "</td>");
                Output.WriteLine("      <td>" + flag_to_display(canUploadFiles) + "</td>");
                Output.WriteLine("      <td>" + flag_to_display(canChangeVisibility) + "</td>");
                Output.WriteLine("      <td>" + flag_to_display(canDelete) + "</td>");
            }
            else
            {
                Output.WriteLine("      <td>" + flag_to_display(canEditMetadata) + "</td>");
            }


            Output.WriteLine("      <td>" + flag_to_display(isCurator) + "</td>");
            Output.WriteLine("      <td>" + flag_to_display(isAdmin) + "</td>");

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

            Output.WriteLine("<script type=\"text/javascript\">");
            Output.WriteLine("    $(document).ready(function() { ");
            Output.WriteLine("        var table = $('#sbkPrav_DetailedUsers').DataTable({ ");
            Output.WriteLine("            \"paging\":   false, ");
            Output.WriteLine("            \"filter\":   false, ");
            Output.WriteLine("            \"info\":   false });");
            Output.WriteLine("    } );");
            Output.WriteLine("</script>");


            // If there were user groups, add them now also.
            if (userGroupRows.Count > 0)
            {
                Output.WriteLine("<p style=\"text-align: left; padding:0 20px 0 20px;\">Some of the permissions above are assigned to the users through user groups.  These user groups and their permissions appear below:</p>");


                Output.WriteLine("  <table id=\"sbkPrav_DetailedUserGroups\">");
                Output.WriteLine("  <thead>");
                Output.WriteLine("    <tr>");
                Output.WriteLine("      <th style=\"width:180px;\">User Group</th>");
                Output.WriteLine("      <th style=\"width:90px;\"><acronym title=\"Can select this aggregation when editing or submitting an item\">Can<br />Select</acronym></th>");

                if (detailedPermissions)
                {
                    Output.WriteLine("      <th style=\"width:85px;\"><acronym title=\"Can edit anything about an item in this aggregation ( i.e., behaviors, metadata, visibility, etc.. )\">Item<br />Edit<br />Metadata</acronym></th>");
                    Output.WriteLine("      <th style=\"width:85px;\"><acronym title=\"Can edit anything about an item in this aggregation ( i.e., behaviors, metadata, visibility, etc.. )\">Item<br />Edit<br />Behaviors</acronym></th>");
                    Output.WriteLine("      <th style=\"width:85px;\"><acronym title=\"Can edit anything about an item in this aggregation ( i.e., behaviors, metadata, visibility, etc.. )\">Item<br />Perform<br />QC</acronym></th>");
                    Output.WriteLine("      <th style=\"width:85px;\"><acronym title=\"Can edit anything about an item in this aggregation ( i.e., behaviors, metadata, visibility, etc.. )\">Item<br />Upload<br />Files</acronym></th>");
                    Output.WriteLine("      <th style=\"width:85px;\"><acronym title=\"Can edit anything about an item in this aggregation ( i.e., behaviors, metadata, visibility, etc.. )\">Item<br />Change<br />Visibility</acronym></th>");
                    Output.WriteLine("      <th style=\"width:85px;\"><acronym title=\"Can edit anything about an item in this aggregation ( i.e., behaviors, metadata, visibility, etc.. )\">Item<br />Can<br />Delete</acronym></th>");
                }
                else
                {
                    Output.WriteLine("      <th style=\"width:85px;\"><acronym title=\"Can edit any item in this aggregation\">Can<br />Edit</acronym></th>");
                }

                Output.WriteLine("      <th style=\"width:85px;\"><acronym title=\"Can perform curatorial or collection manager tasks on this aggregation\">Is<br />Curator</acronym></th>");
                Output.WriteLine("      <th style=\"width:85px;\"><acronym title=\"Can perform curatorial or collection manager tasks on this aggregation\">Is<br />Admin</acronym></th>");
                Output.WriteLine("    </tr>");
                Output.WriteLine("  </thead>");
                Output.WriteLine("  <tbody>");


                foreach (KeyValuePair <string, DataRow> userGroupRow in userGroupRows)
                {
                    DataRow thisUser    = userGroupRow.Value;
                    int     userGroupId = Convert.ToInt32(thisUser["UserGroupID"]);

                    if (isSysAdmin)
                    {
                        Output.WriteLine("    <tr class=\"sbkUpav_SelectableRow\" onclick=\"window.open('" + userGroupAdminUrl.Replace("Xyzzy", userGroupId.ToString()) + "', '_UserGroupEdit+ " + userGroupId + "');\">");
                    }
                    else
                    {
                        Output.WriteLine("    <tr>");
                    }
                    Output.WriteLine("      <td>" + userGroupRow.Key + "</td>");
                    Output.WriteLine("      <td>" + flag_to_display(thisUser["CanSelect"]) + "</td>");
                    if (detailedPermissions)
                    {
                        Output.WriteLine("      <td>" + flag_to_display(thisUser["CanEditMetadata"]) + "</td>");
                        Output.WriteLine("      <td>" + flag_to_display(thisUser["CanEditBehaviors"]) + "</td>");
                        Output.WriteLine("      <td>" + flag_to_display(thisUser["CanPerformQc"]) + "</td>");
                        Output.WriteLine("      <td>" + flag_to_display(thisUser["CanUploadFiles"]) + "</td>");
                        Output.WriteLine("      <td>" + flag_to_display(thisUser["CanChangeVisibility"]) + "</td>");
                        Output.WriteLine("      <td>" + flag_to_display(thisUser["CanDelete"]) + "</td>");
                    }
                    else
                    {
                        Output.WriteLine("      <td>" + flag_to_display(thisUser["CanEditMetadata"]) + "</td>");
                    }


                    Output.WriteLine("      <td>" + flag_to_display(thisUser["IsCollectionManager"]) + "</td>");
                    Output.WriteLine("      <td>" + flag_to_display(thisUser["IsAggregationAdmin"]) + "</td>");

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

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

                Output.WriteLine("<script type=\"text/javascript\">");
                Output.WriteLine("    $(document).ready(function() { ");
                Output.WriteLine("        var table2 = $('#sbkPrav_DetailedUserGroups').DataTable({ ");
                Output.WriteLine("            \"paging\":   false, ");
                Output.WriteLine("            \"filter\":   false, ");
                Output.WriteLine("            \"info\":   false });");
                Output.WriteLine("    } );");
                Output.WriteLine("</script>");
            }

            if (isSysAdmin)
            {
                RequestSpecificValues.Current_Mode.Mode             = Display_Mode_Enum.Administrative;
                RequestSpecificValues.Current_Mode.Admin_Type       = Admin_Type_Enum.Users;
                RequestSpecificValues.Current_Mode.My_Sobek_SubMode = String.Empty;

                Output.WriteLine("  <p style=\"text-align: left; padding:0 20px 0 20px;\">Use the <a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "\">administrative Users &amp; Groups</a> to assign any new collection-specific user permissions.");
                Output.WriteLine("  <br /><br />");
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
            }
        }
        /// <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");

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

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

            if (RequestSpecificValues.Current_Mode.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=\"" + RequestSpecificValues.Current_Mode.Base_URL + "\">Click here to return to the digital collection home</a>");
                Output.WriteLine("      <br /><br />");
                if ((!String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.Browser_Type)) && (RequestSpecificValues.Current_Mode.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 submit           = "Submit";
                string cancel           = "Cancel";

                if (RequestSpecificValues.Current_Mode.Language == Web_Language_Enum.French)
                {
                    contact_us_title = "Contactez Nous";
                    please_complete  = "Veuillez remplir les champs obligatoires indiqués:";
                    submit           = "Soumettre";
                    cancel           = "Annuler";
                }

                if (RequestSpecificValues.Current_Mode.Language == Web_Language_Enum.Spanish)
                {
                    contact_us_title = "Contáctenos";
                    please_complete  = "Por Favor llene la información Requerida:";
                    submit           = "Mandar";
                    cancel           = "Cancelar";
                }

                // 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=\"sbkChsw_Panel\">");
                Output.WriteLine("  <h1>" + contact_us_title + "</h1>");

                if (errorMsg.Length > 0)
                {
                    Output.WriteLine("  <div class=\"sbkChsw_Errors\">" + please_complete + "<blockquote>" + errorMsg + "</blockquote></div>");
                }

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

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

                string firstControl   = String.Empty;
                bool   inElementBlock = false;
                int    control_count  = 1;
                foreach (ContactForm_Configuration_Element thisElement in configuration.FormElements)
                {
                    if (thisElement.Element_Type == ContactForm_Configuration_Element_Type_Enum.HiddenValue)
                    {
                        if ((thisElement.UserAttribute != User_Object_Attribute_Mapping_Enum.NONE) && (RequestSpecificValues.Current_User != null))
                        {
                            string userAttrValue = RequestSpecificValues.Current_User.Get_Value_By_Mapping(thisElement.UserAttribute);
                            Output.WriteLine("    <input type=\"hidden\" id=\"" + thisElement.Name + "\" name=\"" + thisElement.Name + "\" value=\"" + HttpContext.Current.Server.HtmlEncode(userAttrValue) + "\" />");
                        }
                        else
                        {
                            Output.WriteLine("    <input type=\"hidden\" id=\"" + thisElement.Name + "\" name=\"" + thisElement.Name + "\" value=\"\" />");
                        }
                    }
                    else if (thisElement.Element_Type == ContactForm_Configuration_Element_Type_Enum.ExplanationText)
                    {
                        // If this is in an element block, close that now
                        if (inElementBlock)
                        {
                            Output.WriteLine("    </div>");
                            inElementBlock = false;
                        }

                        // This is an explanation text, or prompt for the user
                        string cssClass = "sbkChsw_ExplanationText";
                        if (!String.IsNullOrEmpty(thisElement.CssClass))
                        {
                            cssClass = thisElement.CssClass;
                        }
                        Output.WriteLine("    <div class=\"" + cssClass + "\">" + thisElement.QueryText.Get_Value(RequestSpecificValues.Current_Mode.Language) + "</div>");
                    }
                    else
                    {
                        // This is a user input element

                        // If this is NOT in an element block, close that now
                        if (!inElementBlock)
                        {
                            Output.WriteLine("    <div class=\"sbkChsw_ElementBlock\">");
                            inElementBlock = true;
                        }

                        // Determine the name of this control
                        string control_name = String.Empty;
                        if (!String.IsNullOrEmpty(thisElement.Name))
                        {
                            control_name = thisElement.Name.Replace(" ", "_");
                        }
                        if (thisElement.Element_Type == ContactForm_Configuration_Element_Type_Enum.Subject)
                        {
                            control_name = "subject";
                        }
                        if (thisElement.Element_Type == ContactForm_Configuration_Element_Type_Enum.Email)
                        {
                            control_name = "email";
                        }
                        if (String.IsNullOrEmpty(control_name))
                        {
                            control_name = "Control" + control_count;
                        }

                        // If this maps from a user value, get that now
                        string initialValue = String.Empty;
                        if ((thisElement.UserAttribute != User_Object_Attribute_Mapping_Enum.NONE) && (RequestSpecificValues.Current_User != null))
                        {
                            initialValue = RequestSpecificValues.Current_User.Get_Value_By_Mapping(thisElement.UserAttribute);
                        }

                        // But, if this was already posted back, get that value
                        if (postBackValues.ContainsKey(control_name))
                        {
                            initialValue = postBackValues[control_name];
                        }

                        // Get the css
                        string cssClass = "sbkChsw_Element";
                        if (!String.IsNullOrEmpty(thisElement.CssClass))
                        {
                            cssClass = thisElement.CssClass;
                        }



                        // If this is the firest element of this type, then get th ename
                        if (firstControl.Length == 0)
                        {
                            firstControl = control_name;
                        }

                        // Start this element
                        Output.WriteLine("      <div class=\"" + cssClass + "\">");
                        switch (thisElement.Element_Type)
                        {
                        case ContactForm_Configuration_Element_Type_Enum.TextBox:
                            Output.WriteLine("        <label for=\"" + control_name + "\">" + thisElement.QueryText.Get_Value(RequestSpecificValues.Current_Mode.Language) + "</label> ");
                            Output.WriteLine("        <input name=\"" + control_name + "\" id=\"" + control_name + "\" type=\"text\" value=\"" + initialValue + "\" class=\"sbk_Focusable\" />");
                            break;

                        case ContactForm_Configuration_Element_Type_Enum.Subject:
                            Output.WriteLine("        <label for=\"subject\">" + thisElement.QueryText.Get_Value(RequestSpecificValues.Current_Mode.Language) + "</label> ");
                            Output.WriteLine("        <input name=\"subject\" id=\"subject\" type=\"text\" value=\"" + initialValue + "\" class=\"sbk_Focusable\" />");
                            break;

                        case ContactForm_Configuration_Element_Type_Enum.Email:
                            Output.WriteLine("        <label for=\"email\">" + thisElement.QueryText.Get_Value(RequestSpecificValues.Current_Mode.Language) + "</label> ");
                            Output.WriteLine("        <input name=\"email\" id=\"email\" type=\"text\" value=\"" + initialValue + "\" class=\"sbk_Focusable\" />");
                            break;

                        case ContactForm_Configuration_Element_Type_Enum.TextArea:
                            Output.WriteLine("        <label for=\"" + control_name + "\">" + thisElement.QueryText.Get_Value(RequestSpecificValues.Current_Mode.Language) + "</label>  <br />");
                            Output.WriteLine("        <textarea name=\"" + control_name + "\" id=\"" + control_name + "\" class=\"sbk_Focusable\" >" + initialValue + "</textarea>");
                            break;

                        case ContactForm_Configuration_Element_Type_Enum.CheckBoxSet:
                            Output.WriteLine("        " + thisElement.QueryText.Get_Value(RequestSpecificValues.Current_Mode.Language) + " ( " + initialValue + ")<br />");
                            initialValue = initialValue + ",";
                            foreach (string thisOption in thisElement.Options)
                            {
                                if (initialValue.IndexOf(thisOption + ",") >= 0)
                                {
                                    Output.WriteLine("          <input type=\"checkbox\" name=\"" + control_name + "\" value=\"" + thisOption + "\" checked=\"checked\" />" + thisOption + "<br />");
                                }
                                else
                                {
                                    Output.WriteLine("          <input type=\"checkbox\" name=\"" + control_name + "\" value=\"" + thisOption + "\" />" + thisOption + "<br />");
                                }
                            }
                            break;

                        case ContactForm_Configuration_Element_Type_Enum.RadioSet:
                            Output.WriteLine("        " + thisElement.QueryText.Get_Value(RequestSpecificValues.Current_Mode.Language) + "<br />");
                            foreach (string thisOption in thisElement.Options)
                            {
                                if (thisOption == initialValue)
                                {
                                    Output.WriteLine("          <input type=\"radio\" name=\"" + control_name + "\" value=\"" + thisOption + "\" checked=\"checked\" />" + thisOption + "<br />");
                                }
                                else
                                {
                                    Output.WriteLine("          <input type=\"radio\" name=\"" + control_name + "\" value=\"" + thisOption + "\" />" + thisOption + "<br />");
                                }
                            }
                            break;


                        case ContactForm_Configuration_Element_Type_Enum.SelectBox:
                            Output.WriteLine("        " + thisElement.QueryText.Get_Value(RequestSpecificValues.Current_Mode.Language));
                            // Output.WriteLine("        <fieldset>");
                            Output.WriteLine("      <select name=\"" + control_name + "\" id=\"" + control_name + "\" >");
                            Output.WriteLine("          <option></option>");

                            foreach (string thisOption in thisElement.Options)
                            {
                                if (thisOption == initialValue)
                                {
                                    Output.WriteLine("          <option selected=\"selected\">" + thisOption + "</option>");
                                }
                                else
                                {
                                    Output.WriteLine("          <option>" + thisOption + "</option>");
                                }
                            }
                            Output.WriteLine("      </select>");
                            // Output.WriteLine("        </fieldset>");
                            break;
                        }
                        Output.WriteLine("      </div>");

                        control_count++;
                    }
                }

                // If this is in an element block, close that now
                if (inElementBlock)
                {
                    Output.WriteLine("    </div>");
                }

                Output.WriteLine("    <div id=\"sbkChsw_ButtonDiv\">");

                RequestSpecificValues.Current_Mode.Mode             = Display_Mode_Enum.Aggregation;
                RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home;
                string return_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Contact;

                if ((lastMode.Length > 0) && (lastMode.IndexOf("contact", StringComparison.InvariantCultureIgnoreCase) < 0))
                {
                    if (lastMode.IndexOf("http", StringComparison.InvariantCultureIgnoreCase) == 0)
                    {
                        return_url = lastMode;
                    }
                    else
                    {
                        return_url = "?" + lastMode;
                    }
                }

                Output.WriteLine("      <button title=\"" + cancel + "\" class=\"sbkChsw_Button\" onclick=\"window.location.href='" + return_url + "'; return false;\" type=\"button\"><img src=\"" + Static_Resources_Gateway.Button_Previous_Arrow_Png + "\" class=\"sbkAdm_RoundButton_LeftImg\" alt=\"\" /> " + cancel + "</button> &nbsp; &nbsp; ");
                Output.WriteLine("      <button title=\"" + submit + "\" class=\"sbkChsw_Button\" onclick=\"return send_contact_email();\" type=\"submit\">" + submit + " <img src=\"" + Static_Resources_Gateway.Button_Next_Arrow_Png + "\" class=\"sbkAdm_RoundButton_RightImg\" alt=\"\" /></button>");


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

                Output.WriteLine("  </div>");
                Output.WriteLine("</div>");
                Output.WriteLine("");
                if (firstControl.Length > 0)
                {
                    Output.WriteLine("<!-- Focus on the first control -->");
                    Output.WriteLine("<script type=\"text/javascript\">focus_element('" + firstControl + "');</script>");
                    Output.WriteLine("");
                }
                Output.WriteLine("<br />");
                Output.WriteLine("");
                Output.WriteLine("</form>");
            }

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

            return(true);
        }
Example #22
0
        /// <summary> Constructor for a new instance of the Google_Map_ItemViewer class, used to display the geographic
        /// information associated with a digital resource within a Google map context</summary>
        /// <param name="BriefItem"> Digital resource object </param>
        /// <param name="CurrentUser"> Current user, who may or may not be logged on </param>
        /// <param name="CurrentRequest"> Information about the current request </param>
        public Google_Map_ItemViewer(BriefItemInfo BriefItem, User_Object CurrentUser, Navigation_Object CurrentRequest)
        {
            // Save the arguments for use later
            this.BriefItem      = BriefItem;
            this.CurrentUser    = CurrentUser;
            this.CurrentRequest = CurrentRequest;

            // Set the behavior properties to the empy behaviors ( in the base class )
            Behaviors        = EmptyBehaviors;
            googleItemSearch = false;


            if (CurrentRequest.ViewerCode == "mapsearch")
            {
                googleItemSearch = true;
            }

            // If coordinates were passed in, pull the actual coordinates out of the URL
            bool validCoordinateSearchFound = false;

            if (!String.IsNullOrEmpty(CurrentRequest.Coordinates))
            {
                string[] splitter = CurrentRequest.Coordinates.Split(",".ToCharArray());
                if (((splitter.Length > 1) && (splitter.Length < 4)) || ((splitter.Length == 4) && (splitter[2].Length == 0) && (splitter[3].Length == 0)))
                {
                    if ((Double.TryParse(splitter[0], out providedMaxLat)) && (Double.TryParse(splitter[1], out providedMaxLong)))
                    {
                        validCoordinateSearchFound = true;
                    }
                    providedMinLat  = providedMaxLat;
                    providedMinLong = providedMaxLong;
                }
                else if (splitter.Length >= 4)
                {
                    if ((Double.TryParse(splitter[0], out providedMaxLat)) && (Double.TryParse(splitter[1], out providedMaxLong)) &&
                        (Double.TryParse(splitter[2], out providedMinLat)) && (Double.TryParse(splitter[3], out providedMinLong)))
                    {
                        validCoordinateSearchFound = true;
                    }
                }
            }

            mapBuilder = new StringBuilder();

            allPolygons = new List <BriefItem_Coordinate_Polygon>();
            allPoints   = new List <BriefItem_Coordinate_Point>();
            allLines    = new List <BriefItem_Coordinate_Line>();

            // Only continue if there actually IS a map key
            if (!String.IsNullOrWhiteSpace(UI_ApplicationCache_Gateway.Settings.System.Google_Map_API_Key))
            {
                mapBuilder.AppendLine("<script src=\"https://maps.googleapis.com/maps/api/js?key=" + UI_ApplicationCache_Gateway.Settings.System.Google_Map_API_Key + "\" type=\"text/javascript\"></script>");

                //mapBuilder.AppendLine("<script type=\"text/javascript\" src=\"http://maps.google.com/maps/api/js?sensor=false\"></script>");
                mapBuilder.AppendLine("<script type=\"text/javascript\" src=\"" + Static_Resources_Gateway.Sobekcm_Map_Search_Js + "\"></script>");
                mapBuilder.AppendLine("<script type=\"text/javascript\" src=\"" + Static_Resources_Gateway.Sobekcm_Map_Tool_Js + "\"></script>");

                // Set some values for the map key
                string search_type  = "geographic";
                bool   areas_shown  = false;
                bool   points_shown = false;
                string areas_name   = "Sheet";
                if (BriefItem.Type.IndexOf("aerial", StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    areas_name = "Tile";
                }

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

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

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

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

                    // Collect all the polygons, points, and lines
                    BriefItem_GeoSpatial geoInfo = BriefItem.GeoSpatial;
                    if ((geoInfo != null) && (geoInfo.hasData))
                    {
                        if (geoInfo.Polygon_Count > 0)
                        {
                            foreach (BriefItem_Coordinate_Polygon thisPolygon in geoInfo.Polygons)
                            {
                                allPolygons.Add(thisPolygon);
                            }
                        }
                        if (geoInfo.Line_Count > 0)
                        {
                            foreach (BriefItem_Coordinate_Line thisLine in geoInfo.Lines)
                            {
                                allLines.Add(thisLine);
                            }
                        }
                        if (geoInfo.Point_Count > 0)
                        {
                            foreach (BriefItem_Coordinate_Point thisPoint in geoInfo.Points)
                            {
                                allPoints.Add(thisPoint);
                            }
                        }
                    }

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

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

                        CurrentRequest.ViewerCode = currentViewerCode;

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

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

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

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

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

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

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

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

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

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

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

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

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


                mapBuilder.AppendLine("  }");
                mapBuilder.AppendLine("  //]]>");
                mapBuilder.AppendLine("</script>");
            }
            else
            {
                // No Google Map API Key
                mapBuilder.AppendLine("<script type=\"text/javascript\">");
                mapBuilder.AppendLine("  //<![CDATA[ ");
                mapBuilder.AppendLine("  function load() {  }");
                mapBuilder.AppendLine("  //]]>");
                mapBuilder.AppendLine("</script>");
            }
        }
        /// <summary> Constructor for a new instance of the Edit_Item_Behaviors_MySobekViewer class </summary>
        ///  <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public Edit_Item_Behaviors_MySobekViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues)
        {
            RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", String.Empty);

            // If no user then that is an error
            if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn))
            {
                RequestSpecificValues.Current_Mode.Mode        = Display_Mode_Enum.Aggregation;
                RequestSpecificValues.Current_Mode.Aggregation = String.Empty;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // Ensure BibID and VID provided
            RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "Validate provided bibid / vid");
            if ((String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.BibID)) || (String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.VID)))
            {
                RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "BibID or VID was not provided!");
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.Error;
                RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : BibID/VID missing in item behavior request";
                return;
            }

            RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "Try to pull this sobek complete item");
            currentItem = SobekEngineClient.Items.Get_Sobek_Item(RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Current_Mode.VID, RequestSpecificValues.Current_User.UserID, RequestSpecificValues.Tracer);
            if (currentItem == null)
            {
                RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "Unable to build complete item");
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.Error;
                RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : Unable to build complete item";
                return;
            }


            // If no item, then an error occurred
            if (currentItem == null)
            {
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.Error;
                RequestSpecificValues.Current_Mode.Error_Message = "Invalid item indicated";
                return;
            }

            // If the RequestSpecificValues.Current_User cannot edit this currentItem, go back
            if (!RequestSpecificValues.Current_User.Can_Edit_This_Item(currentItem.BibID, currentItem.Bib_Info.SobekCM_Type_String, currentItem.Bib_Info.Source.Code, currentItem.Bib_Info.HoldingCode, currentItem.Behaviors.Aggregation_Code_List))
            {
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            const string TEMPLATE_CODE = "itembehaviors";

            completeTemplate = Template_MemoryMgmt_Utility.Retrieve_Template(TEMPLATE_CODE, RequestSpecificValues.Tracer);
            if (completeTemplate != null)
            {
                RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "Found CompleteTemplate in cache");
            }
            else
            {
                RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "Reading CompleteTemplate file");

                // Look in the user-defined templates portion first
                string user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\user\\standard\\" + TEMPLATE_CODE + ".xml";
                if (!File.Exists(user_template))
                {
                    user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\default\\standard\\" + TEMPLATE_CODE + ".xml";
                }


                // Read this CompleteTemplate
                Template_XML_Reader reader = new Template_XML_Reader();
                completeTemplate = new CompleteTemplate();
                reader.Read_XML(user_template, completeTemplate, true);

                // Save this into the cache
                Template_MemoryMgmt_Utility.Store_Template(TEMPLATE_CODE, completeTemplate, RequestSpecificValues.Tracer);
            }

            // See if there was a hidden request
            string hidden_request = HttpContext.Current.Request.Form["behaviors_request"] ?? String.Empty;

            // If this was a cancel request do that
            if (hidden_request == "cancel")
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
            }
            else if (hidden_request == "save")
            {
                // Changes to the tracking box require the metadata search citation be rebuilt for this currentItem
                // so save the old tracking box information first
                string oldTrackingBox = currentItem.Tracking.Tracking_Box;

                // Save these changes to bib
                completeTemplate.Save_To_Bib(currentItem, RequestSpecificValues.Current_User, 1);

                // Save the behaviors
                SobekCM_Item_Database.Save_Behaviors(currentItem, currentItem.Behaviors.Text_Searchable, false, false);

                // Save the serial hierarchy as well (sort of a behavior)
                SobekCM_Item_Database.Save_Serial_Hierarchy_Information(currentItem, currentItem.Web.GroupID, currentItem.Web.ItemID);

                // Did the tracking box change?
                if (currentItem.Tracking.Tracking_Box != oldTrackingBox)
                {
                    SobekCM_Item_Database.Create_Full_Citation_Value(currentItem.Web.ItemID);
                }

                // Remoe from the caches (to replace the other)
                CachedDataManager.Items.Remove_Digital_Resource_Object(currentItem.BibID, currentItem.VID, RequestSpecificValues.Tracer);

                // Also remove the list of volumes, since this may have changed
                CachedDataManager.Items.Remove_Items_In_Title(currentItem.BibID, RequestSpecificValues.Tracer);
                CachedDataManager.Items.Remove_Items_List(currentItem.BibID, RequestSpecificValues.Tracer);

                // Also clear the engine
                SobekEngineClient.Items.Clear_Item_Group_Cache(currentItem.BibID, RequestSpecificValues.Tracer);

                // Also clear any searches or browses ( in the future could refine this to only remove those
                // that are impacted by this save... but this is good enough for now )
                CachedDataManager.Clear_Search_Results_Browses();

                // Forward
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
            }
        }
Example #24
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 override void Write_Main_Viewer_Section(TextWriter Output, Custom_Tracer Tracer)
        {
            if (CurrentRequest.ViewerCode == "mapsearch")
            {
                googleItemSearch = true;
            }

            if (Tracer != null)
            {
                Tracer.Add_Trace("Google_Map_ItemViewer.Write_Main_Viewer_Section", "");
            }

            Output.WriteLine("        <!-- GOOGLE MAP VIEWER OUTPUT -->" + Environment.NewLine);

            if ((allPolygons.Count > 0) || (allPoints.Count > 0) || (allLines.Count > 0))
            {
                // If there is a coordinate search here
                if ((allPolygons.Count > 1) &&
                    ((!String.IsNullOrEmpty(CurrentRequest.Coordinates)) && (matchingTilesList != null) || (googleItemSearch)))
                {
                    if (googleItemSearch)
                    {
                        // Compute the redirect stem to use
                        string redirect_stem = CurrentRequest.BibID + "/" + CurrentRequest.VID + "/map";
                        if (CurrentRequest.Writer_Type == Writer_Type_Enum.HTML_LoggedIn)
                        {
                            redirect_stem = "l/" + redirect_stem;
                        }

                        // Set some constants
                        const string SEARCH_BUTTON_TEXT = "Search";
                        const string FIND_BUTTON_TEXT   = "Find Address";
                        string       script_action_name = "map_item_search_sobekcm('" + redirect_stem + "');";

                        Output.WriteLine("    <td style=\"text-align:left\">");
                        Output.WriteLine("      <ol>");
                        Output.WriteLine(
                            "        <li>Use the <i>Select Area</i> button below to draw a search box on the map or enter an address and press <i>Find Address</i>.</li>");
                        Output.WriteLine("        <li>Press the <i>Search</i> button to see results</li>");
                        Output.WriteLine("      </ol>");
                        Output.WriteLine("        <div class=\"map_address_div\">");
                        Output.WriteLine("          <label for=\"AddressTextBox\">Address:</label> &nbsp; ");
                        Output.WriteLine(
                            "          <input name=\"AddressTextBox\" type=\"text\" id=\"AddressTextBox\" class=\"MapAddressBox_initial\" value=\"Enter address ( i.e., 12 Main Street, Gainesville Florida )\" onfocus=\"enter_address_box(this);\" onblur=\"leave_address_box(this);\" onkeypress=\"address_box_changed(this);\" onchange=\"address_box_changed(this);\" /> &nbsp; ");
                        Output.WriteLine("          <input type=\"button\" name=\"findButton\" value=\"" + FIND_BUTTON_TEXT +
                                         "\" id=\"findButton\" class=\"SobekSearchButton\" onclick=\"map_address_geocode();\" /> &nbsp; ");
                        Output.WriteLine("          <input type=\"button\" name=\"searchButton\" value=\"" +
                                         SEARCH_BUTTON_TEXT +
                                         "\" id=\"searchButton\" class=\"SobekSearchButton\" onclick=\"" +
                                         script_action_name + "\" />");
                        Output.WriteLine("        </div>");
                        Output.WriteLine("         <input name=\"Textbox1\" type=\"hidden\" id=\"Textbox1\" value=\"" +
                                         providedMaxLat.ToString() + "\" />");
                        Output.WriteLine("         <input name=\"Textbox2\" type=\"hidden\" id=\"Textbox2\" value=\"" +
                                         providedMaxLong.ToString() + "\" />");
                        Output.WriteLine("         <input name=\"Textbox3\" type=\"hidden\" id=\"Textbox3\" value=\"" +
                                         providedMinLat.ToString() + "\" />");
                        Output.WriteLine("         <input name=\"Textbox4\" type=\"hidden\" id=\"Textbox4\" value=\"" +
                                         providedMaxLong.ToString() + "\" />");
                        Output.WriteLine("    </td>");
                    }
                    else
                    {
                        if (matchingTilesList == null || matchingTilesList.Count == 0)
                        {
                            Output.WriteLine("          <td align=\"center\">");
                            Output.WriteLine(
                                "            There were no matches within this item for your geographic search. &nbsp; ");
                            string currentModeViewerCode = CurrentRequest.ViewerCode;
                            CurrentRequest.ViewerCode = "mapsearch";
                            Output.WriteLine("            ( <a href=\"" + UrlWriterHelper.Redirect_URL(CurrentRequest) +
                                             "\">Modify item search</a> )");
                            CurrentRequest.ViewerCode = currentModeViewerCode;

                            // If there was an aggregation included, we can assume that was the origin of the coordinate search,
                            // or at least that map searching is allowed for that collection
                            if (CurrentRequest.Aggregation.Length > 0)
                            {
                                Output.WriteLine("            <br /><br />");
                                CurrentRequest.Mode                = Display_Mode_Enum.Results;
                                CurrentRequest.Search_Type         = Search_Type_Enum.Map;
                                CurrentRequest.Result_Display_Type = "map";
                                if ((providedMinLat > 0) && (providedMinLong > 0) && (providedMaxLat != providedMinLat) &&
                                    (providedMaxLong != providedMinLong))
                                {
                                    CurrentRequest.Search_String = providedMaxLat.ToString() + "," + providedMaxLong + "," +
                                                                   providedMinLat + "," + providedMinLong;
                                }
                                else
                                {
                                    CurrentRequest.Search_String = providedMaxLat.ToString() + "," + providedMaxLong;
                                }
                                Output.WriteLine("            <a href=\"" + UrlWriterHelper.Redirect_URL(CurrentRequest) +
                                                 "\">Click here to search other items in the current collection</a><br />");
                                CurrentRequest.Mode = Display_Mode_Enum.Item_Display;
                            }
                            Output.WriteLine("          </td>" + Environment.NewLine + "        </tr>");
                        }
                        else
                        {
                            string       modify_item_search = "Modify item search";
                            const string ZOOM_EXTENT        = "Zoom to extent";
                            const string ZOOM_MATCHES       = "Zoom to matches";
                            if (BriefItem.Type.IndexOf("aerial", StringComparison.OrdinalIgnoreCase) >= 0)
                            {
                                modify_item_search = "Modify search within flight";
                            }

                            Output.WriteLine("          <td style=\"vertical-align: left\">");
                            Output.WriteLine("            <table id=\"sbkGmiv_ResultsTable\">");

                            Output.WriteLine("              <tr>");
                            Output.WriteLine("                <td style=\"width:50px\">&nbsp;</td>");
                            Output.WriteLine(
                                "                <td colspan=\"4\">The following results match your geographic search:</td>"); //  and also appear on the navigation bar to the left
                            Output.WriteLine("              </tr>");

                            int    column      = 0;
                            bool   first_row   = true;
                            string url_options = UrlWriterHelper.URL_Options(CurrentRequest);
                            string urlOptions1 = String.Empty;
                            string urlOptions2 = String.Empty;
                            if (url_options.Length > 0)
                            {
                                urlOptions1 = "?" + url_options;
                                urlOptions2 = "&" + url_options;
                            }
                            foreach (string thisResult in matchingTilesList)
                            {
                                // Start this row, as it is needed
                                if (column == 0)
                                {
                                    Output.WriteLine("              <tr>");
                                    if (first_row)
                                    {
                                        Output.WriteLine("                <td style=\"width:50px\">&nbsp;</td>");
                                        Output.WriteLine("                <td style=\"width:50px\">&nbsp;</td>");
                                        first_row = false;
                                    }
                                    else
                                    {
                                        Output.WriteLine("                <td colspan=\"2\">&nbsp;</td>");
                                    }
                                }

                                // Add the information for this tile
                                Output.WriteLine("                <td style=\"width:80px\">" +
                                                 thisResult.Replace("<%URLOPTS%>", url_options).Replace("<%?URLOPTS%>",
                                                                                                        urlOptions1).
                                                 Replace("<%&URLOPTS%>", urlOptions2) + "</td>");
                                column++;

                                // If this was the last column, end it
                                if (column >= 3)
                                {
                                    Output.WriteLine("              </tr>");
                                    column = 0;
                                }
                            }

                            // If a row was started, finish it
                            if (column > 0)
                            {
                                while (column < 3)
                                {
                                    Output.WriteLine("                <td style=\"width:80px\">&nbsp;</td>");
                                    column++;
                                }
                                Output.WriteLine("              </tr>");
                            }

                            // Add a horizontal line here
                            Output.WriteLine("              <tr><td></td><td style=\"background-color:#cccccc\" colspan=\"4\"></td></tr>");

                            // Also, add the navigation links
                            Output.WriteLine("              <tr>");
                            Output.WriteLine("                <td>&nbsp;</td>");
                            Output.WriteLine("                <td colspan=\"4\">");
                            Output.WriteLine("                  <a href=\"\" onclick=\"return zoom_to_bounds();\">" +
                                             ZOOM_EXTENT + "</a> &nbsp; &nbsp; &nbsp;  &nbsp; &nbsp; ");
                            if (matchingTilesList.Count > 0)
                            {
                                Output.WriteLine("                  <a href=\"\" onclick=\"return zoom_to_selected();\">" +
                                                 ZOOM_MATCHES + "</a> &nbsp; &nbsp; &nbsp;  &nbsp; &nbsp; ");
                            }



                            // Add link to modify this item search
                            string currentModeViewerCode = CurrentRequest.ViewerCode;
                            CurrentRequest.ViewerCode = "mapsearch";
                            Output.WriteLine("                  <a href=\"" + UrlWriterHelper.Redirect_URL(CurrentRequest) + "\">" +
                                             modify_item_search + "</a> &nbsp; &nbsp; &nbsp;  &nbsp; &nbsp; ");
                            CurrentRequest.ViewerCode = currentModeViewerCode;

                            // Add link to search entire collection
                            if (CurrentRequest.Aggregation.Length > 0)
                            {
                                CurrentRequest.Mode                = Display_Mode_Enum.Results;
                                CurrentRequest.Search_Type         = Search_Type_Enum.Map;
                                CurrentRequest.Result_Display_Type = "map";
                                if ((providedMinLat > 0) && (providedMinLong > 0) && (providedMaxLat != providedMinLat) && (providedMaxLong != providedMinLong))
                                {
                                    CurrentRequest.Search_String = providedMaxLat.ToString() + "," + providedMaxLong + "," + providedMinLat + "," + providedMinLong;
                                }
                                else
                                {
                                    CurrentRequest.Search_String = providedMaxLat.ToString() + "," + providedMaxLong;
                                }

                                if (CurrentRequest.Aggregation == "aerials")
                                {
                                    Output.WriteLine("                  <a href=\"" + UrlWriterHelper.Redirect_URL(CurrentRequest) + "\">Search all flights</a><br />");
                                }
                                else
                                {
                                    Output.WriteLine("                  <a href=\"" + UrlWriterHelper.Redirect_URL(CurrentRequest) + "\">Search entire collection</a><br />");
                                }

                                CurrentRequest.Mode = Display_Mode_Enum.Item_Display;
                            }

                            Output.WriteLine("                </td>");
                            Output.WriteLine("              </tr>");
                            Output.WriteLine("            </table>");
                            Output.WriteLine("          </td>");
                            Output.WriteLine("        </tr>");
                        }
                    }
                }
                else
                {
                    // Start the citation table
                    string title = "Map It!";
                    if (allPolygons.Count == 1)
                    {
                        title = allPolygons[0].Label;
                    }
                }
            }

            Output.WriteLine("        <tr>");
            Output.WriteLine("          <td class=\"SobekCitationDisplay\">");

            if (!String.IsNullOrWhiteSpace(UI_ApplicationCache_Gateway.Settings.System.Google_Map_API_Key))
            {
                Output.WriteLine("            <div id=\"sbkGmiv_MapDiv\"></div>");
                Output.WriteLine();
            }
            else
            {
                Output.WriteLine("            <div style=\"padding: 50px\">");
                Output.WriteLine("              <p style=\"font-weight:bold; text-size:1.1em\">ERROR: Google Maps are not enabled on this instance of SobekCM!</p>");
                Output.WriteLine("              <p>To enable them, please create a Google Map API key and enter it in the system-wide settings.</p>");
                Output.WriteLine("              <p>Information on this process can be found here: <a href=\"http://sobekrepository.org/software/config/googlemaps\" style=\"color:white;\">http://sobekrepository.org/software/config/googlemaps</a>.</p>");
                Output.WriteLine("            </div>");
            }


            Tracer.Add_Trace("goole_map_itemviewer.Write_HTML", "Adding google map instructions as script");
            Output.WriteLine(mapBuilder.ToString());
            Output.WriteLine();

            Output.WriteLine("          </td>");
            Output.WriteLine("        <!-- END GOOGLE MAP VIEWER OUTPUT -->");
        }
Example #25
0
        /// <summary> Returns the textual explanation of the item-level search </summary>
        protected string Compute_Search_Explanation()
        {
            StringBuilder output = new StringBuilder();

            // Split the parts
            List <string> terms  = new List <string>();
            List <string> fields = new List <string>();

            // If this is basic, do some other preparation
            string complete_search = CurrentRequest.Text_Search;
            ushort subpage         = CurrentRequest.SubPage.HasValue ? Math.Max(CurrentRequest.SubPage.Value, ((ushort)1)) : ((ushort)1);

            CurrentRequest.SubPage = 1;
            Legacy_Solr_Searcher.Split_Multi_Terms(CurrentRequest.Text_Search, "ZZ", terms, fields);

            string your_search_language    = "Your search within this document for ";
            string and_not_language        = " AND NOT ";
            string and_language            = " AND ";
            string or_language             = " OR ";
            string not_language            = "not ";
            string resulted_in_language    = " resulted in ";
            string matching_pages_language = " matching pages";
            string no_matches_language     = "no matching pages";
            string expand_language         = "You can expand your results by searching for";
            string restrict_language       = "You can restrict your results by searching for";


            if (CurrentRequest.Language == Web_Language_Enum.French)
            {
                your_search_language    = "Votre recherche dans les textes intégrals pour les pages contenant ";
                and_not_language        = " ET PAS ";
                and_language            = " ET ";
                or_language             = " OU ";
                not_language            = "pas ";
                resulted_in_language    = " corresponde a ";
                matching_pages_language = " pages de résultats";
                no_matches_language     = "pas pages de résultats";
                expand_language         = "Vous pouvez elaborer votre rechereche en cherchant par";
                restrict_language       = "Vous pouvez limiter votre rechereche en cherchant par";
            }

            if (CurrentRequest.Language == Web_Language_Enum.Spanish)
            {
                your_search_language    = "Su búsqueda dentro de el texto completo por paginas conteniendo ";
                and_not_language        = " Y NO ";
                and_language            = " Y ";
                or_language             = " O ";
                not_language            = "no ";
                resulted_in_language    = " resulto en ";
                matching_pages_language = " paginas correspondientes";
                no_matches_language     = "no paginas correspondientes";
                expand_language         = "Usted puede ampliar sus resultados buscando por";
                restrict_language       = "Usted puede disminuir sus resultados buscando por";
            }

            output.Append(your_search_language);
            bool          first      = true;
            bool          allOr      = true;
            bool          allAnd     = true;
            StringBuilder allAndBldr = new StringBuilder(1000);
            StringBuilder allOrBldr  = new StringBuilder(1000);
            StringBuilder allAndURL  = new StringBuilder(1000);
            StringBuilder allOrURL   = new StringBuilder(1000);

            for (int i = 0; i < terms.Count; i++)
            {
                string thisTerm = terms[i];
                if (!first)
                {
                    switch (fields[i][0])
                    {
                    case '-':
                        allOr  = false;
                        allAnd = false;
                        output.Append(and_not_language);
                        allAndBldr.Append(and_not_language);
                        allAndURL.Append("+-");
                        break;

                    case '=':
                        output.Append(or_language);
                        allAndBldr.Append(and_language);
                        allOrBldr.Append(or_language);
                        allAnd = false;
                        allAndURL.Append("+");
                        allOrURL.Append("+=");
                        break;

                    default:
                        output.Append(and_language);
                        allAndBldr.Append(and_language);
                        allOrBldr.Append(or_language);
                        allOr = false;
                        allAndURL.Append("+");
                        allOrURL.Append("+=");
                        break;
                    }
                }
                else
                {
                    first = false;
                    if (fields[i][0] == '-')
                    {
                        output.Append(not_language);
                        allAndURL.Append("-");
                    }
                }

                // Write the term
                if (thisTerm[0] == '"')
                {
                    CurrentRequest.Text_Search = thisTerm;
                    output.Append("<a href=\"" + UrlWriterHelper.Redirect_URL(CurrentRequest) + "\">" + thisTerm.Replace("+", " ") + "</a>");

                    if (fields[i][0] == '-')
                    {
                        allAndBldr.Append(thisTerm.Replace("+", " "));
                        allAndURL.Append(thisTerm.Replace("\"", "%22"));
                    }
                    else
                    {
                        allAndBldr.Append(thisTerm.Replace("+", " "));
                        allAndURL.Append(thisTerm.Replace("\"", "%22"));
                        allOrBldr.Append(thisTerm.Replace("+", " "));
                        allOrURL.Append(thisTerm.Replace("\"", "%22"));
                    }
                }
                else
                {
                    CurrentRequest.Text_Search = thisTerm;
                    output.Append("<a href=\"" + UrlWriterHelper.Redirect_URL(CurrentRequest) + "\">'" + thisTerm + "'</a>");

                    if (fields[i][0] == '-')
                    {
                        allAndBldr.Append(thisTerm.Replace("+", " "));
                        allAndURL.Append(thisTerm.Replace("\"", "%22"));
                    }
                    else
                    {
                        allAndBldr.Append(thisTerm.Replace("+", " "));
                        allAndURL.Append(thisTerm.Replace("\"", "%22"));
                        allOrBldr.Append(thisTerm.Replace("+", " "));
                        allOrURL.Append(thisTerm.Replace("\"", "%22"));
                    }
                }
            }
            output.Append(resulted_in_language);

            if (results.TotalResults > 0)
            {
                output.AppendLine(number_to_string(results.TotalResults) + matching_pages_language + ".");
            }
            else
            {
                output.AppendLine("<b>" + no_matches_language + "</b>.");
            }

            if (!allOr)
            {
                CurrentRequest.Text_Search = allOrURL.ToString();
                output.AppendLine("<br /><br />" + expand_language + " <a href=\"" + UrlWriterHelper.Redirect_URL(CurrentRequest) + "\">" + allOrBldr + "</a>.");
            }

            if ((!allAnd) && (results.TotalResults > 0))
            {
                CurrentRequest.Text_Search = allAndURL.ToString();
                output.AppendLine("<br /><br />" + restrict_language + " <a href=\"" + UrlWriterHelper.Redirect_URL(CurrentRequest) + "\">" + allAndBldr + "</a>.");
            }

            // Restore the original values
            CurrentRequest.Text_Search = complete_search;
            CurrentRequest.SubPage     = subpage;

            return(output.ToString());
        }
Example #26
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_ItemNavForm_Closing(TextWriter Output, Custom_Tracer Tracer)
        {
            const string VISIBILITY = "VISIBILITY";

            RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display;
            string item_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);

            RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek;

            short selectIpMask = currentItem.Behaviors.IP_Restriction_Membership;

            if (selectIpMask == 0)
            {
                selectIpMask = 1;
            }

            Tracer.Add_Trace("Edit_Item_Permissions_MySobekViewer.Write_ItemNavForm_Closing", "");

            Output.WriteLine("<!-- Hidden field is used for postbacks to add new form elements (i.e., new name, new other titles, etc..) -->");
            Output.WriteLine("<input type=\"hidden\" id=\"permissions_action\" name=\"permissions_action\" value=\"\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"behaviors_request\" name=\"behaviors_request\" value=\"\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"restrictionMask\" name=\"restrictionMask\" value=\"" + ipRestrictionMask.ToString() + "\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"selectRestrictionMask\" name=\"selectRestrictionMask\" value=\"" + selectIpMask + "\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"isDark\" name=\"isDark\" value=\"" + isDark.ToString() + "\" />");

            // Write the top currentItem mimic html portion
            Write_Item_Type_Top(Output, currentItem);

            Output.WriteLine("<div id=\"container-inner1000\">");
            Output.WriteLine("<div id=\"pagecontainer\">");

            Output.WriteLine("<!-- Edit_Item_Permissions_MySobekViewer.Write_ItemNavForm_Closing -->");
            Output.WriteLine("<div class=\"sbkMySobek_HomeText\">");
            Output.WriteLine("  <br />");
            Output.WriteLine("  <h2>Edit item-level permissions for this item</h2>");
            Output.WriteLine("  <ul>");
            Output.WriteLine("    <li>Use this form to change visibility (and related embargo dates) on this item </li>");
            Output.WriteLine("    <li>This form also allows ip restriction and user group permissions to be set </li>");
            Output.WriteLine("    <li>Click <a href=\"" + UI_ApplicationCache_Gateway.Settings.System.Help_URL(RequestSpecificValues.Current_Mode.Base_URL) + "help/itempermissions\" target=\"_EDIT_INSTRUCTIONS\">here for detailed instructions</a> on editing permissions online.</li>");
            Output.WriteLine("  </ul>");
            Output.WriteLine("</div>");
            Output.WriteLine();

            Output.WriteLine("<a name=\"template\"> </a>");
            Output.WriteLine("<div id=\"tabContainer\" class=\"fulltabs\">");
            Output.WriteLine("  <div class=\"tabs\">");
            Output.WriteLine("    <ul>");
            Output.WriteLine("      <li id=\"tabHeader_1\" class=\"tabActiveHeader\">" + VISIBILITY + "</li>");
            Output.WriteLine("    </ul>");
            Output.WriteLine("  </div>");
            Output.WriteLine("  <div class=\"graytabscontent\">");
            Output.WriteLine("    <div class=\"tabpage\" id=\"tabpage_1\">");

            Output.WriteLine("      <!-- Add SAVE and CANCEL buttons to top of form -->");
            Output.WriteLine("      <script src=\"" + Static_Resources_Gateway.Sobekcm_Metadata_Js + "\" type=\"text/javascript\"></script>");
            Output.WriteLine();
            Output.WriteLine("      <div class=\"sbkMySobek_RightButtons\">");
            Output.WriteLine("        <button onclick=\"window.location.href='" + item_url + "';return false;\" class=\"sbkMySobek_BigButton\"><img src=\"" + Static_Resources_Gateway.Button_Previous_Arrow_Png + "\" class=\"sbkMySobek_RoundButton_LeftImg\" alt=\"\" /> CANCEL </button> &nbsp; &nbsp; ");
            Output.WriteLine("        <button onclick=\"behaviors_save_form(); return false;\" class=\"sbkMySobek_BigButton\"> SAVE <img src=\"" + Static_Resources_Gateway.Button_Next_Arrow_Png + "\" class=\"sbkMySobek_RoundButton_RightImg\" alt=\"\" /></button>");
            Output.WriteLine("      </div>");
            Output.WriteLine("      <br /><br />");
            Output.WriteLine();

            Output.WriteLine("        <div class=\"sbkMyEip_SetAccessText\">SET ACCESS RESTRICTIONS:</div>");

            if ((ipRestrictionMask == 0) && (!isDark) && (!restrictedSelected))
            {
                Output.WriteLine("              <button title=\"Make item public\" class=\"sbkMyEip_VisButton sbkMyEip_VisButtonPublic sbkMyEip_VisButtonCurrent\" onclick=\"set_item_access('public'); return false;\">PUBLIC ITEM</button>");
            }
            else
            {
                Output.WriteLine("              <button title=\"Make item public\" class=\"sbkMyEip_VisButton sbkMyEip_VisButtonPublic\" onclick=\"set_item_access('public'); return false;\">PUBLIC ITEM</button>");
            }

            if ((restrictedSelected) && (!isDark))
            {
                Output.WriteLine("              <button title=\"Add IP restriction to this item\" class=\"sbkMyEip_VisButton sbkMyEip_VisButtonRestricted sbkMyEip_VisButtonCurrent\" onclick=\"set_item_access('restricted'); return false;\">RESTRICT ITEM</button>");
            }
            else
            {
                if (UI_ApplicationCache_Gateway.IP_Restrictions.Count > 0)
                {
                    Output.WriteLine("              <button title=\"Add IP restriction to this item\" class=\"sbkMyEip_VisButton sbkMyEip_VisButtonRestricted\" onclick=\"set_item_access('restricted'); return false;\">RESTRICT ITEM</button>");
                }
                else
                {
                    Output.WriteLine("              <button title=\"Add IP restriction to this item\" class=\"sbkMyEip_VisButton sbkMyEip_VisButtonRestricted\" onclick=\"alert('You must have at least one IP range entered in the system to use this option.\\n\\nAt least create an administrative range before assigning RESTRICTED to items'); return false;\">RESTRICT ITEM</button>");
                }
            }

            if ((ipRestrictionMask < 0) && (!isDark) && (!restrictedSelected))
            {
                Output.WriteLine("              <button title=\"Make item private\" class=\"sbkMyEip_VisButton sbkMyEip_VisButtonPrivate sbkMyEip_VisButtonCurrent\" onclick=\"set_item_access('private'); return false;\">PRIVATE ITEM</button>");
            }
            else
            {
                Output.WriteLine("              <button title=\"Make item private\" class=\"sbkMyEip_VisButton sbkMyEip_VisButtonPrivate\" onclick=\"set_item_access('private'); return false;\">PRIVATE ITEM</button>");
            }

            if (isDark)
            {
                Output.WriteLine("              <button title=\"Make item dark\" class=\"sbkMyEip_VisButton sbkMyEip_VisButtonDark sbkMyEip_VisButtonCurrent\" onclick=\"set_item_access('dark'); return false;\">DARKEN ITEM</button>");
            }
            else
            {
                Output.WriteLine("              <button title=\"Make item dark\" class=\"sbkMyEip_VisButton sbkMyEip_VisButtonDark\" onclick=\"set_item_access('dark'); return false;\">DARKEN ITEM</button>");
            }


            // Should we add ability to delete this currentItem?
            if (RequestSpecificValues.Current_User.Can_Delete_This_Item(currentItem.BibID, currentItem.Bib_Info.Source.Code, currentItem.Bib_Info.HoldingCode, currentItem.Behaviors.Aggregation_Code_List))
            {
                // Determine the delete URL
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.My_Sobek;
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Delete_Item;
                string delete_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode);
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Edit_Item_Permissions;
                Output.WriteLine("              <button title=\"Delete this item\" class=\"sbkMyEip_VisButton sbkMyEip_VisButtonDelete\" onclick=\"if(confirm('Delete this item completely?')) window.location.href = '" + delete_url + "'; return false;\">DELETE ITEM</button>");
            }



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


            if ((isDark) || (ipRestrictionMask != 0) || (restrictedSelected))
            {
                Output.WriteLine("         <tr>");
                Output.WriteLine("           <th>Embargo Date:</th>");

                string embargoDateString = String.Empty;
                if (embargoDate.HasValue)
                {
                    embargoDateString = embargoDate.Value.ToShortDateString();
                }

                Output.WriteLine("           <td><input name=\'embargoDateBox' type='text' id='embargoDateBox' class='sbkMyEip_EmbargoDate sbk_Focusable' value='" + embargoDateString + "' /></td>");
                Output.WriteLine("         </tr>");
            }

            Output.WriteLine("         <tr><td colspan=\"2\">&nbsp;</td></tr>");

            if ((UI_ApplicationCache_Gateway.IP_Restrictions.Count > 0) && (restrictedSelected) && (!isDark))
            {
                Output.WriteLine("         <tr>");
                Output.WriteLine("           <th>Restriction Ranges:-</th>");
                Output.WriteLine("           <td>");

                // At least always select the FIRST ip range, if restricted is selected
                short forComparison = currentItem.Behaviors.IP_Restriction_Membership;
                if (forComparison == 0)
                {
                    forComparison = 1;
                }
                foreach (IP_Restriction_Range thisRange in UI_ApplicationCache_Gateway.IP_Restrictions.IpRanges)
                {
                    int comparison = forComparison & ((short)Math.Pow(2, thisRange.RangeID - 1));
                    if (comparison == 0)
                    {
                        Output.WriteLine("             <input type='checkbox' id='range" + thisRange.RangeID + "' name='range" + thisRange.RangeID + "' value='" + thisRange.RangeID + "' /> <label for=\"range" + thisRange.RangeID + "\"><span title=\"" + HttpUtility.HtmlEncode(thisRange.Notes) + "\">" + thisRange.Title + "</span></label><br />");
                    }
                    else
                    {
                        Output.WriteLine("             <input type='checkbox' checked='checked' id='range" + thisRange.RangeID + "' name='range" + thisRange.RangeID + "' value='" + thisRange.RangeID + "' /> <label for=\"range" + thisRange.RangeID + "\"><span title=\"" + HttpUtility.HtmlEncode(thisRange.Notes) + "\">" + thisRange.Title + "</span></label><br />");
                    }
                }

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


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


            // Add the second buttons at the bottom of the form
            Output.WriteLine();
            Output.WriteLine("      <!-- Add SAVE and CANCEL buttons to bottom of form -->");
            Output.WriteLine("      <div class=\"sbkMySobek_RightButtons\">");
            Output.WriteLine("        <button onclick=\"window.location.href='" + item_url + "';return false;\" class=\"sbkMySobek_BigButton\"><img src=\"" + Static_Resources_Gateway.Button_Previous_Arrow_Png + "\" class=\"sbkMySobek_RoundButton_LeftImg\" alt=\"\" /> CANCEL </button> &nbsp; &nbsp; ");
            Output.WriteLine("        <button onclick=\"behaviors_save_form(); return false;\" class=\"sbkMySobek_BigButton\"> SAVE <img src=\"" + Static_Resources_Gateway.Button_Next_Arrow_Png + "\" class=\"sbkMySobek_RoundButton_RightImg\" alt=\"\" /></button>");
            Output.WriteLine("      </div>");
            Output.WriteLine("      <br />");
            Output.WriteLine("    </div>");
            Output.WriteLine("  </div>");
            Output.WriteLine("</div>");
            Output.WriteLine("</div>");
            Output.WriteLine("</div>");
            Output.WriteLine("<br />");
        }
Example #27
0
        /// <summary> Writes the tracking tabs for all these related viewers </summary>
        /// <param name="Output"> Response stream for the item viewer to write directly to </param>
        /// <param name="CurrentRequest"> Information about the current request </param>
        /// <param name="BriefItem"> Digital resource object </param>
        public static void Write_Tracking_Tabs(TextWriter Output, Navigation_Object CurrentRequest, BriefItemInfo BriefItem)
        {
            // Set the text
            const string MILESTONES_VIEW = "MILESTONES";
            const string TRACKING_VIEW   = "HISTORY";
            const string MEDIA_VIEW      = "MEDIA";
            const string ARCHIVE_VIEW    = "ARCHIVES";
            const string DIRECTORY_VIEW  = "DIRECTORY";

            // Is this bib level?
            if (String.Compare(BriefItem.Type, "BIB_LEVEL", StringComparison.OrdinalIgnoreCase) == 0)
            {
                return;
            }

            // Add the tabs for the different citation information
            string viewer_code = CurrentRequest.ViewerCode;

            Output.WriteLine("    <div id=\"sbkTrk_ViewSelectRow\">");
            Output.WriteLine("      <ul class=\"sbk_FauxDownwardTabsList\">");

            // Get the current viewer code
            string viewerCode = CurrentRequest.ViewerCode;

            // Include milestones?
            if (BriefItem.UI.Includes_Viewer_Type("MILESTONES"))
            {
                string milestones_code = ItemViewer_Factory.ViewCode_From_ViewType("MILESTONES");
                if (String.Compare(viewerCode, milestones_code, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    Output.WriteLine("        <li class=\"current\">" + MILESTONES_VIEW + "</li>");
                }
                else
                {
                    Output.WriteLine("        <li><a href=\"" + UrlWriterHelper.Redirect_URL(CurrentRequest, milestones_code) + "\">" + MILESTONES_VIEW + "</a></li>");
                }
            }

            // Include tracking? (Okay, this is probably redundant since this is IN the tracking itemviewer)
            if (BriefItem.UI.Includes_Viewer_Type("TRACKING"))
            {
                string tracking_code = ItemViewer_Factory.ViewCode_From_ViewType("TRACKING");
                if (String.Compare(viewerCode, tracking_code, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    Output.WriteLine("        <li class=\"current\">" + TRACKING_VIEW + "</li>");
                }
                else
                {
                    Output.WriteLine("        <li><a href=\"" + UrlWriterHelper.Redirect_URL(CurrentRequest, tracking_code) + "\">" + TRACKING_VIEW + "</a></li>");
                }
            }

            // Include UF-specific media viewer?
            if (BriefItem.UI.Includes_Viewer_Type("MEDIA"))
            {
                string media_code = ItemViewer_Factory.ViewCode_From_ViewType("MEDIA");
                if (String.Compare(viewerCode, media_code, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    Output.WriteLine("        <li class=\"current\">" + MEDIA_VIEW + "</li>");
                }
                else
                {
                    Output.WriteLine("        <li><a href=\"" + UrlWriterHelper.Redirect_URL(CurrentRequest, media_code) + "\">" + MEDIA_VIEW + "</a></li>");
                }
            }

            // Include UF-specific archives viewer?
            if (BriefItem.UI.Includes_Viewer_Type("TIVOLI"))
            {
                string archives_code = ItemViewer_Factory.ViewCode_From_ViewType("TIVOLI");
                if (String.Compare(viewerCode, archives_code, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    Output.WriteLine("        <li class=\"current\">" + ARCHIVE_VIEW + "</li>");
                }
                else
                {
                    Output.WriteLine("        <li><a href=\"" + UrlWriterHelper.Redirect_URL(CurrentRequest, archives_code) + "\">" + ARCHIVE_VIEW + "</a></li>");
                }
            }

            // Include resource files viewer?
            if (BriefItem.UI.Includes_Viewer_Type("DIRECTORY"))
            {
                string directory_code = ItemViewer_Factory.ViewCode_From_ViewType("DIRECTORY");
                if (String.Compare(viewerCode, directory_code, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    Output.WriteLine("        <li class=\"current\">" + DIRECTORY_VIEW + "</li>");
                }
                else
                {
                    Output.WriteLine("        <li><a href=\"" + UrlWriterHelper.Redirect_URL(CurrentRequest, directory_code) + "\">" + DIRECTORY_VIEW + "</a></li>");
                }
            }

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

            CurrentRequest.ViewerCode = viewer_code;
        }
Example #28
0
        /// <summary> Constructor for a new instance of the Edit_Item_Permissions_MySobekViewer class  </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        public Edit_Item_Permissions_MySobekViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues)
        {
            // If no user then that is an error
            if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn))
            {
                RequestSpecificValues.Current_Mode.Mode        = Display_Mode_Enum.Aggregation;
                RequestSpecificValues.Current_Mode.Aggregation = String.Empty;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // Ensure BibID and VID provided
            RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "Validate provided bibid / vid");
            if ((String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.BibID)) || (String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.VID)))
            {
                RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "BibID or VID was not provided!");
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.Error;
                RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : BibID/VID missing in item file upload request";
                return;
            }

            RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "Try to pull this sobek complete item");
            currentItem = SobekEngineClient.Items.Get_Sobek_Item(RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Current_Mode.VID, RequestSpecificValues.Current_User.UserID, RequestSpecificValues.Tracer);
            if (currentItem == null)
            {
                RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "Unable to build complete item");
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.Error;
                RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : Unable to build complete item";
                return;
            }

            bool userCanEditItem = RequestSpecificValues.Current_User.Can_Edit_This_Item(currentItem.BibID, currentItem.Bib_Info.SobekCM_Type_String, currentItem.Bib_Info.Source.Code, currentItem.Bib_Info.HoldingCode, currentItem.Behaviors.Aggregation_Code_List);

            if (!userCanEditItem)
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
            }

            // Start by setting the values by the item (good the first time user comes here)
            ipRestrictionMask  = currentItem.Behaviors.IP_Restriction_Membership;
            isDark             = currentItem.Behaviors.Dark_Flag;
            restrictedSelected = (ipRestrictionMask > 0);


            // Is there already a RightsMD module in the item?
            // Ensure this metadata module extension exists
            RightsMD_Info rightsInfo = currentItem.Get_Metadata_Module(GlobalVar.PALMM_RIGHTSMD_METADATA_MODULE_KEY) as RightsMD_Info;

            if ((rightsInfo != null) && (rightsInfo.Has_Embargo_End))
            {
                embargoDate = rightsInfo.Embargo_End;
            }


            // Is this a postback?
            if (RequestSpecificValues.Current_Mode.isPostBack)
            {
                // Get the restriction mask and isDark flag
                if (HttpContext.Current.Request.Form["restrictionMask"] != null)
                {
                    ipRestrictionMask = short.Parse(HttpContext.Current.Request.Form["restrictionMask"]);
                    isDark            = bool.Parse(HttpContext.Current.Request.Form["isDark"]);
                }

                // Look for embargo date
                if (HttpContext.Current.Request.Form["embargoDateBox"] != null)
                {
                    string   embargoText = HttpContext.Current.Request.Form["embargoDateBox"];
                    DateTime embargoDateNew;
                    if (DateTime.TryParse(embargoText, out embargoDateNew))
                    {
                        embargoDate = embargoDateNew;
                    }
                }

                // If this was restrcted, there will be some checkboxes to determine ip restriction mask
                short checked_mask = 0;

                // Determine the IP restriction mask
                foreach (IP_Restriction_Range thisRange in UI_ApplicationCache_Gateway.IP_Restrictions.IpRanges)
                {
                    // Is this check box checked?
                    if (HttpContext.Current.Request.Form["range" + thisRange.RangeID] != null)
                    {
                        checked_mask += ((short)Math.Pow(2, (thisRange.RangeID - 1)));
                    }
                }


                // Handle any request from the internal header for the item
                if (HttpContext.Current.Request.Form["permissions_action"] != null)
                {
                    // Pull the action value
                    string action = HttpContext.Current.Request.Form["permissions_action"].Trim();

                    // Is this to change accessibility?
                    if ((action == "public") || (action == "private") || (action == "restricted") || (action == "dark"))
                    {
                        switch (action)
                        {
                        case "public":
                            ipRestrictionMask  = 0;
                            isDark             = false;
                            restrictedSelected = false;
                            break;

                        case "private":
                            ipRestrictionMask  = -1;
                            isDark             = false;
                            restrictedSelected = false;
                            break;

                        case "restricted":
                            ipRestrictionMask  = short.Parse(HttpContext.Current.Request.Form["selectRestrictionMask"]);
                            restrictedSelected = true;
                            isDark             = false;
                            break;

                        case "dark":
                            isDark             = true;
                            restrictedSelected = false;
                            break;
                        }
                    }
                }

                // Was the SAVE button pushed?
                if (HttpContext.Current.Request.Form["behaviors_request"] != null)
                {
                    string behaviorRequest = HttpContext.Current.Request.Form["behaviors_request"];
                    if (behaviorRequest == "save")
                    {
                        currentItem.Behaviors.IP_Restriction_Membership = ipRestrictionMask;
                        currentItem.Behaviors.Dark_Flag = isDark;

                        if (checked_mask > 0)
                        {
                            ipRestrictionMask = checked_mask;
                        }

                        // Save this to the database
                        if (SobekCM_Item_Database.Set_Item_Visibility(currentItem.Web.ItemID, ipRestrictionMask, isDark, embargoDate, RequestSpecificValues.Current_User.UserName))
                        {
                            // Update the web.config
                            Resource_Web_Config_Writer.Update_Web_Config(currentItem.Source_Directory, currentItem.Behaviors.Dark_Flag, ipRestrictionMask, currentItem.Behaviors.Main_Thumbnail);

                            // Remove the cached item
                            CachedDataManager.Items.Remove_Digital_Resource_Object(currentItem.BibID, currentItem.VID, RequestSpecificValues.Tracer);

                            // Also clear the engine
                            SobekEngineClient.Items.Clear_Item_Cache(currentItem.BibID, currentItem.VID, RequestSpecificValues.Tracer);

                            // Also clear any searches or browses ( in the future could refine this to only remove those
                            // that are impacted by this save... but this is good enough for now )
                            CachedDataManager.Clear_Search_Results_Browses();
                        }
                        RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display;
                        UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                    }
                }
            }
        }
Example #29
0
        /// <summary> Gets the menu items related to this viewer that should be included on the main item (digital resource) menu </summary>
        /// <param name="CurrentItem"> Digital resource object, which can be used to ensure if and how this viewer should appear
        /// in the main item (digital resource) menu </param>
        /// <param name="CurrentUser"> Current user, who may or may not be logged on </param>
        /// <param name="CurrentRequest"> Information about the current request </param>
        /// <param name="MenuItems"> List of menu items, to which this method may add one or more menu items </param>
        /// <param name="IpRestricted"> Flag indicates if this item is IP restricted AND if the current user is outside the ranges </param>
        public void Add_Menu_items(BriefItemInfo CurrentItem, User_Object CurrentUser, Navigation_Object CurrentRequest, List <Item_MenuItem> MenuItems, bool IpRestricted)
        {
            // Start with an empty label
            string first_label = String.Empty;

            // First, look at the viewer information from the database
            BriefItem_BehaviorViewer thisViewer = CurrentItem.Behaviors.Get_Viewer("HTML");

            if (!String.IsNullOrWhiteSpace(thisViewer.Label))
            {
                first_label = thisViewer.Label;
            }

            // Next, look for a page name in the METS
            if (String.IsNullOrEmpty(first_label))
            {
                foreach (BriefItem_FileGrouping thisPage in CurrentItem.Downloads)
                {
                    // Look for a HTML file on each page
                    foreach (BriefItem_File thisFile in thisPage.Files)
                    {
                        if (thisFile.File_Extension.IndexOf(".HTM", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            if (!String.IsNullOrWhiteSpace(thisPage.Label))
                            {
                                first_label = thisPage.Label;
                            }
                            break;
                        }
                    }
                }
            }

            // Finally, just default to HTML otherwise
            if (String.IsNullOrEmpty(first_label))
            {
                first_label = "HTML";
            }

            // Get the URL for this
            string previous_code = CurrentRequest.ViewerCode;

            CurrentRequest.ViewerCode = ViewerCode;
            string url = UrlWriterHelper.Redirect_URL(CurrentRequest);

            CurrentRequest.ViewerCode = previous_code;

            // Allow the label to be implemented for this viewer from the database as well
            BriefItem_BehaviorViewer thisViewerInfo = CurrentItem.Behaviors.Get_Viewer(ViewerCode);

            // If this is found, and has a custom label, use that
            if ((thisViewerInfo != null) && (!String.IsNullOrWhiteSpace(thisViewerInfo.Label)))
            {
                first_label = thisViewerInfo.Label;
            }

            // Add the item menu information
            Item_MenuItem menuItem = new Item_MenuItem(first_label, null, null, url, ViewerCode);

            MenuItems.Add(menuItem);
        }
Example #30
0
        /// <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 addes the map search panel which holds the google map, as well as the coordinate entry boxes </remarks>
        public override void Add_Search_Box_HTML(TextWriter Output, Custom_Tracer Tracer)
        {
            if (Tracer != null)
            {
                Tracer.Add_Trace("Map_Search_AggregationViewer.Add_Search_Box_HTML", "Adding html for search box");
            }

            string       search_button_text = "Search";
            string       find_button_text   = "Find Address";
            string       address_text       = "Address";
            const string LOCATE_TEXT        = "Locate";

            if (RequestSpecificValues.Current_Mode.Language == Web_Language_Enum.Spanish)
            {
                search_button_text = "Buscar";
                find_button_text   = "Localizar";
                address_text       = "Dirección";
            }


            bool show_coordinates = false;
            int  width            = 740;

            if (RequestSpecificValues.Current_Mode.Info_Browse_Mode == "1")
            {
                show_coordinates = true;
                width            = 550;
            }

            Output.WriteLine("  <table id=\"sbkMsav_SearchPanel\" >");
            Output.WriteLine("  <tr>");
            Output.WriteLine("    <td colspan=\"2\">");
            switch (RequestSpecificValues.Current_Mode.Language)
            {
            case Web_Language_Enum.Spanish:
                if (pointSearchingDisabled)
                {
                    Output.WriteLine("          <table>");
                    Output.WriteLine("            <tr><td><span style=\"line-height:160%\"> &nbsp; &nbsp; 1. Use the <i>Select Area</i> button and click to select opposite corners to draw a search box on the map &nbsp; &nbsp; <br /> &nbsp; &nbsp; 2. Press the <i>Search</i> button to see results &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ( <a href=\"#FAQ\">more help</a> )</span> </td>");
                    Output.WriteLine("                <td><button name=\"searchButton\" id=\"searchButton\" class=\"SobekSearchButton\" onclick=\"" + Search_Script_Action + "\">" + search_button_text + "<img id=\"sbkMsav_ButtonArrow\" src=\"" + Static_Resources_Gateway.Button_Next_Arrow2_Png + "\" alt=\"\" /></button></td></tr>");
                    Output.WriteLine("          </table>");
                }
                else
                {
                    Output.WriteLine("        <div class=\"sbkMsav_InstructionsLink\" id=\"MapInstructionsLink\" style=\"display:block\" >");
                    Output.WriteLine("          <a href=\"\" onclick=\"return show_map_instructions();\">Haga click aquí para ver las instrucciones para la interfase de esta búsqueda.</a>");
                    Output.WriteLine("        </div>");
                    Output.WriteLine("        <div class=\"sbkMsav_Instructions\" id=\"MapInstructions\" style=\"display:none\" >");
                    Output.WriteLine("          <table>");
                    Output.WriteLine("            <tr><td colspan=\"2\">1. Utilice uno de los siguientes métodos para definir su búsqueda geográfica:</td></tr>");
                    Output.WriteLine("            <tr><td style=\"width:50px;\">&nbsp;</td><td>a. Escriba una dirección y haga click en el botón <i>Localizar</a> para localizarla, <i>o</i></td></tr>");
                    Output.WriteLine("            <tr><td>&nbsp;</td><td>b. Haga click sobre el botón <i>Presione para Selecionar Area</i> para seleccionar dos esquinas opuestas, <i>o</i></td></tr>");
                    Output.WriteLine("            <tr><td>&nbsp;</td><td>c. Haga click sobre el botón <i>Presione para Seleccionar un Punto</i> para seleccionar un punto individual</td></tr>");
                    Output.WriteLine("            <tr><td colspan=\"2\">2. Presione el botón <i>Buscar</i> para ver los resultados. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ( <a href=\"#FAQ\">more help</a> )</td></tr>");
                    Output.WriteLine("          </table>");
                    Output.WriteLine("        </div>");
                }
                break;

            default:
                if (pointSearchingDisabled)
                {
                    Output.WriteLine("          <table>");
                    Output.WriteLine("            <tr><td><span style=\"line-height:160%\"> &nbsp; &nbsp; 1. Use the <i>Select Area</i> button and click to select opposite corners to draw a search box on the map &nbsp; &nbsp; <br /> &nbsp; &nbsp; 2. Press the <i>Search</i> button to see results &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ( <a href=\"#FAQ\">more help</a> )</span> </td>");
                    Output.WriteLine("                <td><button name=\"searchButton\" id=\"searchButton\" class=\"SobekSearchButton\" onclick=\"" + Search_Script_Action + "\">" + search_button_text + "<img id=\"sbkMsav_ButtonArrow\" src=\"" + Static_Resources_Gateway.Button_Next_Arrow2_Png + "\" alt=\"\" /></button></td></tr>");
                    Output.WriteLine("          </table>");
                }
                else
                {
                    Output.WriteLine("        <div class=\"sbkMsav_InstructionsLink\" id=\"MapInstructionsLink\" style=\"display:block\" >");
                    Output.WriteLine("          <a href=\"\" onclick=\"return show_map_instructions();\">Click here to view instructions for this search interface</a>");
                    Output.WriteLine("        </div>");
                    Output.WriteLine("        <div class=\"sbkMsav_Instructions\" id=\"MapInstructions\" style=\"display:none\" >");
                    Output.WriteLine("          <table>");
                    Output.WriteLine("            <tr><td colspan=\"2\">1. Use one of the methods below to define your geographic search:</td></tr>");
                    Output.WriteLine("            <tr><td style=\"width:50px;\">&nbsp;</td><td>a. Enter an address and press <i>Find Address</i> to locate, <i>or</i></td></tr>");
                    Output.WriteLine("            <tr><td>&nbsp;</td><td>b. Press the <i>Select Area</i> button and click to select two opposite corners, <i>or</i></td></tr>");
                    Output.WriteLine("            <tr><td>&nbsp;</td><td>c. Press the <i>Select Point</i> button and click to select a single point</td></tr>");
                    Output.WriteLine("            <tr><td colspan=\"2\">2. Press the <i>Search</i> button to see results &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ( <a href=\"#FAQ\">more help</a> )</td></tr>");
                    Output.WriteLine("          </table>");
                    Output.WriteLine("        </div>");
                }
                break;
            }

            if (!pointSearchingDisabled)
            {
                Output.WriteLine("        <div id=\"sbkMsav_AddressDiv\">");
                Output.WriteLine("          <label for=\"AddressTextBox\">" + address_text + ":</label> &nbsp; ");
                Output.WriteLine("          <input name=\"AddressTextBox\" type=\"text\" id=\"AddressTextBox\" class=\"sbkMsav_AddressBox sbk_Focusable\" value=\"\" placeholder=\"Enter address ( i.e., 12 Main Street, Gainesville Florida )\" data-placeholder-text=\"Enter address ( i.e., 12 Main Street, Gainesville Florida )\" onleave=\"address_box_changed(this);\" onchange=\"address_box_changed(this);\" onkeydown=\"address_keydown(event, this);\" /> &nbsp; ");
                Output.WriteLine("          <button name=\"findButton\" id=\"findButton\" class=\"sbk_SearchButton\" onclick=\"map_address_geocode();return false;\" >" + find_button_text + "</button> &nbsp; ");
                Output.WriteLine("          <button name=\"searchButton\" id=\"searchButton\" class=\"sbk_SearchButton\" onclick=\"" + Search_Script_Action + ";return false;\" >" + search_button_text + "<img id=\"sbkMsav_ButtonArrow\" src=\"" + Static_Resources_Gateway.Button_Next_Arrow2_Png + "\" alt=\"\" /></button>");
                Output.WriteLine("        </div>");
            }
            Output.WriteLine("    </td>");
            Output.WriteLine("  </tr>");

            Output.WriteLine("  <tr style=\"vertical-align:top\">");
            Output.WriteLine("    <td>");
            if (!show_coordinates)
            {
                Output.WriteLine("      <div id=\"sbkMsav_ShowCoordinateTab\">");
                RequestSpecificValues.Current_Mode.Info_Browse_Mode = "1";
                Output.WriteLine("        <span class=\"sbk_FauxUpwardTab\"><a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "\">SHOW COORDINATES</a></span>");
                RequestSpecificValues.Current_Mode.Info_Browse_Mode = "0";
                Output.WriteLine("      </div>");
            }
            else
            {
                Output.WriteLine("      <div id=\"sbkMsav_HideCoordinateTab\">");
                RequestSpecificValues.Current_Mode.Info_Browse_Mode = "0";
                Output.WriteLine("        <span class=\"sbk_FauxUpwardTab\"><a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "\">HIDE COORDINATES</a></span>");
                RequestSpecificValues.Current_Mode.Info_Browse_Mode = "1";
                Output.WriteLine("      </div>");
            }


            // Show error message if there is no Google Map API key
            if (String.IsNullOrWhiteSpace(UI_ApplicationCache_Gateway.Settings.System.Google_Map_API_Key))
            {
                Output.WriteLine("  <div style=\"width: " + width + "px; height: " + mapHeight + "px;padding: 25px\">");
                Output.WriteLine("              <p style=\"font-weight:bold; text-size:1.1em\">ERROR: Google Maps are not enabled on this instance of SobekCM!</p>");
                Output.WriteLine("              <p style=\"width: " + (width - 100) + "px;\">To enable them, please create a Google Map API key and enter it in the system-wide settings.</p>");
                Output.WriteLine("              <p style=\"width: " + (width - 100) + "px;\">Information on this process can be found here: <a href=\"http://sobekrepository.org/software/config/googlemaps\">http://sobekrepository.org/software/config/googlemaps</a>.</p>");
                Output.WriteLine("  </div>");
            }
            else
            {
                Output.WriteLine("      <div id=\"map1\" style=\"width: " + width + "px; height: " + mapHeight + "px\"></div>");
            }

            Output.WriteLine("    </td>");
            Output.WriteLine("    <td>");
            Output.WriteLine(show_coordinates ? "      <div id=\"map_coordinates_div\" >" : "      <div id=\"map_coordinates_div\" style=\"display: none;\" >");
            Output.WriteLine("        <table>");
            Output.WriteLine("          <tr><td colspan=\"2\"><br /><br /><br /><b>Search Coordinates</b><br /><br /></td></tr>");
            Output.WriteLine("          <tr><td colspan=\"2\">Point 1</td></tr>");
            Output.WriteLine("          <tr><td><label for=\"Textbox1\">Latitude:</label> </td><td><input name=\"Textbox1\" type=\"text\" id=\"Textbox1\" class=\"sbkMsav_SearchBox sbk_Focusable\" value=\"" + text1 + "\" /></td></tr>");
            Output.WriteLine("          <tr><td><label for=\"Textbox2\">Longitude:</label> </td><td><input name=\"Textbox2\" type=\"text\" id=\"Textbox2\" class=\"sbkMsav_SearchBox sbk_Focusable\" value=\"" + text2 + "\" /><br /><br /></td></tr>");
            Output.WriteLine("          <tr><td colspan=\"2\"><br />Point 2</td></tr>");
            Output.WriteLine("          <tr><td><label for=\"Textbox3\">Latitude:</label> </td><td><input name=\"Textbox3\" type=\"text\" id=\"Textbox3\" class=\"sbkMsav_SearchBox sbk_Focusable\" value=\"" + text3 + "\" /></td></tr>");
            Output.WriteLine("          <tr><td><label for=\"Textbox4\">Longitude:</label> </td><td><input name=\"Textbox4\" type=\"text\" id=\"Textbox4\" class=\"sbkMsav_SearchBox sbk_Focusable\" value=\"" + text4 + "\" ></td></tr>");
            Output.WriteLine("          <tr><td colspan=\"2\" align=\"right\"><br /></td></tr>");
            Output.WriteLine("          <tr><td colspan=\"2\" align=\"right\"><button name=\"locateButton\" id=\"locateButton\" class=\"sbk_SearchButton\" onclick=\"locate_by_coordinates();\">" + LOCATE_TEXT + "</button></td></tr>");
            Output.WriteLine("         </table>");
            Output.WriteLine("       </div>");
            Output.WriteLine("      </td>");
            Output.WriteLine("    </tr>");
            Output.WriteLine("  </table>");
            Output.WriteLine();
        }