Beispiel #1
0
            /// <summary> Constructor for a new instance of the Search object </summary>
            /// <param name="currentMode"> Current navigation object to save the modal information ( interface, etc..)</param>
            /// <param name="SessionIP"> IP address which performed this search</param>
            /// <param name="Search_Type"> Type of search </param>
            /// <param name="Aggregation"> Aggregation against which this search was performed</param>
            /// <param name="Search_Terms"> Terms used in the search </param>
            public Search(SobekCM_Navigation_Object currentMode, string SessionIP, Search_Type_Enum Search_Type, string Aggregation, string Search_Terms)
            {
                Time = DateTime.Now.ToShortDateString().Replace("/", "-") + " " + DateTime.Now.ToShortTimeString().Replace(" ", "");

                // Save some of the values
                this.SessionIP = SessionIP;
                switch (Search_Type)
                {
                case Search_Type_Enum.Advanced:
                    this.Search_Type = "Advanced";
                    break;

                case Search_Type_Enum.Basic:
                    this.Search_Type = "Basic";
                    break;

                case Search_Type_Enum.Newspaper:
                    this.Search_Type = "Newspaper";
                    break;

                case Search_Type_Enum.Map:
                    this.Search_Type = "Map";
                    break;

                default:
                    this.Search_Type = "Unknown";
                    break;
                }

                // Create the key
                Key = SessionIP + "_" + this.Search_Type + "_" + Aggregation + "_" + Search_Terms.Replace(" ", "_");

                // Save the collection as a link
                Display_Mode_Enum lastMode = currentMode.Mode;

                currentMode.Mode = Display_Mode_Enum.Aggregation_Home;
                this.Aggregation = "<a href=\"" + currentMode.Redirect_URL() + "\">" + Aggregation + "</a>";

                // Save the search terms as a link to the search
                currentMode.Mode  = lastMode;
                this.Search_Terms = "<a href=\"" + currentMode.Redirect_URL() + "\">" + Search_Terms + "</a>";
            }
        /// <summary> Constructor for a new instance of the Metadata_Browse_AggregationViewer class </summary>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Current_Aggregation"> Current item aggregation object to display </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Metadata_Browse_AggregationViewer(SobekCM_Navigation_Object Current_Mode, Item_Aggregation Current_Aggregation, Custom_Tracer Tracer) : base(Current_Aggregation, Current_Mode)
        {
            string defaultBrowseBy = Current_Aggregation.Default_BrowseBy;

            // If there is not info browse mode listed, use the default
            if (Current_Mode.Info_Browse_Mode.Length == 0)
            {
                Current_Mode.Info_Browse_Mode = defaultBrowseBy;
            }
            if ((Current_Mode.Info_Browse_Mode.Length == 0) && (Current_Aggregation.Has_Browse_By_Pages))
            {
                Current_Mode.Info_Browse_Mode = Current_Aggregation.Browse_By_Pages(Current_Mode.Language)[0].Code;
            }

            // Get this browse
            browseObject = Current_Aggregation.Get_Browse_Info_Object(Current_Mode.Info_Browse_Mode);

            // Was this a metadata browseby, or just a static html?
            if ((browseObject == null) || (browseObject.Source != Item_Aggregation_Child_Page.Source_Type.Static_HTML))
            {
                // Determine the correct metadata code
                string metadata_code = Current_Mode.Info_Browse_Mode.Trim().Replace("_", " ");
                Current_Mode.Info_Browse_Mode = metadata_code;

                // Only get values if there was a metadata code
                if (metadata_code.Length > 0)
                {
                    // Check the cache for this value
                    List <string> cacheInstance = Cached_Data_Manager.Retrieve_Aggregation_Metadata_Browse(Current_Mode.Aggregation, Current_Mode.Info_Browse_Mode, Tracer);

                    if (cacheInstance != null)
                    {
                        results = cacheInstance;
                    }
                    else
                    {
                        results = SobekCM_Database.Get_Item_Aggregation_Metadata_Browse(Current_Mode.Aggregation, Current_Mode.Info_Browse_Mode, Tracer);
                        Cached_Data_Manager.Store_Aggregation_Metadata_Browse(Current_Mode.Aggregation, Current_Mode.Info_Browse_Mode, results, Tracer);
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary> Constructor for a new instance of the dLOC_Search_AggregationViewer class </summary>
        /// <param name="Current_Aggregation"> Current item aggregation object </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        public dLOC_Search_AggregationViewer(Item_Aggregation Current_Aggregation, SobekCM_Navigation_Object Current_Mode) : base(Current_Aggregation, Current_Mode)
        {
            textBoxValue = String.Empty;
            if (currentMode.Search_String.Length > 0)
            {
                textBoxValue = currentMode.Search_String.Replace(",newspaper", "");
            }

            // Determine the complete script action name
            Display_Mode_Enum displayMode = currentMode.Mode;
            Search_Type_Enum  searchType  = currentMode.Search_Type;

            currentMode.Mode        = Display_Mode_Enum.Results;
            currentMode.Search_Type = Search_Type_Enum.Full_Text;
            string search_string = currentMode.Search_String;

            currentMode.Search_String = String.Empty;
            currentMode.Search_Fields = String.Empty;
            arg2 = String.Empty;
            currentMode.Search_Precision = Search_Precision_Type_Enum.Inflectional_Form;
            arg1                         = currentMode.Redirect_URL();
            currentMode.Mode             = Display_Mode_Enum.Aggregation_Browse_Info;
            currentMode.Info_Browse_Mode = "all";
            browse_url                   = currentMode.Redirect_URL();


            //if (( !currentMode.Show_Selection_Panel) || ( hierarchyObject.Codes.Length == 0 ))
            //{
            scriptActionName  = "dloc_search_sobekcm('" + arg1 + "', '" + browse_url + "');";
            scriptIncludeName = "<script src=\"" + currentMode.Base_URL + "default/scripts/sobekcm_search.js\" type=\"text/javascript\"></script>";
            //}
            //else
            //{
            //    script_action_name = "Javascript:dloc_select_search_sobekcm('" + currentMode.Redirect_URL() + "', '" + sub_code + "')";
            //    script_include_name = "<script src=\"" + currentMode.Base_URL + "default/scripts/dloc_select_search_sobekcm.js\" type=\"text/javascript\"></script>";
            //}
            currentMode.Mode             = displayMode;
            currentMode.Search_Type      = searchType;
            currentMode.Search_String    = search_string;
            currentMode.Info_Browse_Mode = String.Empty;
        }
        /// <summary> Constructor for a new instance of the Preferences_HtmlSubwriter class </summary>
        public Preferences_HtmlSubwriter(SobekCM_Navigation_Object Current_Mode)
        {
            currentMode = Current_Mode;

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

            if (hidden_request == "submit")
            {
                NameValueCollection form = HttpContext.Current.Request.Form;

                string language_option = form["languageDropDown"];
                switch (language_option)
                {
                case "en":
                    currentMode.Language = Web_Language_Enum.English;
                    break;

                case "fr":
                    currentMode.Language = Web_Language_Enum.French;
                    break;

                case "es":
                    currentMode.Language = Web_Language_Enum.Spanish;
                    break;
                }

                string defaultViewDropDown = form["defaultViewDropDown"];
                HttpContext.Current.Session["User_Default_View"] = defaultViewDropDown;

                int user_sort = Convert.ToInt32(form["defaultSortDropDown"]);
                HttpContext.Current.Session["User_Default_Sort"] = user_sort;

                currentMode.Mode             = Display_Mode_Enum.Aggregation;
                currentMode.Aggregation_Type = Aggregation_Type_Enum.Home;
                currentMode.Redirect();
            }
        }
        /// <summary> Constructor for a new instance of the dLOC_Search_AggregationViewer class </summary>
        /// <param name="Current_Aggregation"> Current item aggregation object </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        public dLOC_Search_AggregationViewer(Item_Aggregation Current_Aggregation, SobekCM_Navigation_Object Current_Mode) : base(Current_Aggregation, Current_Mode)
        {
            textBoxValue = String.Empty;
            if (currentMode.Search_String.Length > 0)
            {
                textBoxValue = currentMode.Search_String.Replace(",newspaper", "");
            }

            // Determine the complete script action name
            Display_Mode_Enum     displayMode = currentMode.Mode;
            Aggregation_Type_Enum aggrType    = currentMode.Aggregation_Type;
            Search_Type_Enum      searchType  = currentMode.Search_Type;

            currentMode.Mode        = Display_Mode_Enum.Results;
            currentMode.Search_Type = Search_Type_Enum.Full_Text;
            string search_string = currentMode.Search_String;

            currentMode.Search_String = String.Empty;
            currentMode.Search_Fields = String.Empty;
            arg2 = String.Empty;
            currentMode.Search_Precision = Search_Precision_Type_Enum.Inflectional_Form;
            arg1                         = currentMode.Redirect_URL();
            currentMode.Mode             = Display_Mode_Enum.Aggregation;
            currentMode.Aggregation_Type = Aggregation_Type_Enum.Browse_Info;
            currentMode.Info_Browse_Mode = "all";
            browse_url                   = currentMode.Redirect_URL();



            scriptActionName = "dloc_search_sobekcm('" + arg1 + "', '" + browse_url + "');";

            currentMode.Mode             = displayMode;
            currentMode.Aggregation_Type = aggrType;
            currentMode.Search_Type      = searchType;
            currentMode.Search_String    = search_string;
            currentMode.Info_Browse_Mode = String.Empty;
        }
        /// <summary> Constructor for a new instance of the Builder_AdminViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        public Builder_AdminViewer(User_Object User, SobekCM_Navigation_Object Current_Mode)
            : base(User)
        {
            currentMode = Current_Mode;

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

            // If this is a postback, handle any events first
            if (Current_Mode.isPostBack)
            {
                // Pull the hidden value
                string save_value = HttpContext.Current.Request.Form["admin_builder_tosave"].ToUpper().Trim();
                if (save_value.Length > 0)
                {
                    // Set this value
                    SobekCM_Database.Set_Setting("Builder Operation Flag", save_value);
                }
            }
        }
        /// <summary> Constructor for a new instance of the Full_ResultsViewer class </summary>
        /// <param name="CurrentMode"> Sobek object that holds useful information </param>
        /// <param name="All_Items_Lookup"> Lookup object used to pull basic information about any item loaded into this library </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        public Google_Map_ResultsViewer_Beta(SobekCM_Navigation_Object CurrentMode, Item_Lookup_Object All_Items_Lookup)
        {
            //create new tracer?
            Custom_Tracer Tracer = new Custom_Tracer();

            base.All_Items_Lookup = All_Items_Lookup;

            //holds actions from page
            string payload = HttpContext.Current.Request.Form["payload"] ?? String.Empty;

            // See if there were hidden requests
            if (!String.IsNullOrEmpty(payload))
            {
                //if (action == "action")
                Perform_Callback_Action(payload, Tracer);
            }
            else
            {
                //do a search for all the items in this agg
                string   temp_AggregationId   = CurrentMode.Aggregation;
                string[] temp_AggregationList = temp_AggregationId.Split(' ');
                Perform_Aggregation_Search(temp_AggregationList, Tracer);
            }
        }
        /// <summary> Constructor for a new instance of the User_Group_AdminViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="currentMode"> Mode / navigation information for the current request</param>
        /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> Postback from a user group edit is handled here in the constructor </remarks>
        public User_Group_AdminViewer(User_Object User, SobekCM_Navigation_Object currentMode, Aggregation_Code_Manager Code_Manager, Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("User_Group_AdminViewer.Constructor", String.Empty);

            // Set the action message to clear initially
            actionMessage = String.Empty;
            codeManager   = Code_Manager;

            // Get the user to edit, if there was a user id in the submode
            int edit_usergroupid = -100;

            editGroup = null;
            if (currentMode.My_Sobek_SubMode.Length > 0)
            {
                if (currentMode.My_Sobek_SubMode == "new")
                {
                    edit_usergroupid = -1;
                }
                else
                {
                    if (Int32.TryParse(currentMode.My_Sobek_SubMode.Replace("a", "").Replace("b", "").Replace("c", "").Replace("v", ""), out edit_usergroupid))
                    {
                        editGroup = SobekCM_Database.Get_User_Group(edit_usergroupid, Tracer);
                    }
                }
            }

            // Determine the mode
            mode = Users_Group_Admin_Mode_Enum.Error;
            if ((editGroup != null) || (edit_usergroupid == -1))
            {
                if ((currentMode.My_Sobek_SubMode.IndexOf("v") > 0) && (edit_usergroupid > 0))
                {
                    mode = Users_Group_Admin_Mode_Enum.View_User_Group;
                }
                else
                {
                    mode = Users_Group_Admin_Mode_Enum.Edit_User_Group;
                }
            }
            else
            {
                currentMode.My_Sobek_SubMode = String.Empty;
                currentMode.Admin_Type       = Admin_Type_Enum.Users;
                HttpContext.Current.Response.Redirect(currentMode.Redirect_URL());
            }

            // Set an empty user group object for a new item
            if (edit_usergroupid < 0)
            {
                editGroup = new User_Group(String.Empty, String.Empty, -1);
            }

            // Perform post back work
            if (currentMode.isPostBack)
            {
                if ((mode == Users_Group_Admin_Mode_Enum.Edit_User_Group) && (editGroup != null))
                {
                    // Get a reference to this form
                    NameValueCollection form    = HttpContext.Current.Request.Form;
                    string[]            getKeys = form.AllKeys;

                    bool successful_save = true;
                    bool can_editall     = editGroup.Editable_Regular_Expressions.Any(thisRegularExpression => thisRegularExpression == "[A-Z]{2}[A-Z|0-9]{4}[0-9]{4}");

                    bool   can_submit  = false;
                    bool   is_internal = false;
                    bool   is_admin    = false;
                    bool   is_portal   = false;
                    string name        = editGroup.Name;
                    string description = editGroup.Description;

                    List <string> projects  = new List <string>();
                    List <string> templates = new List <string>();

                    Dictionary <string, User_Editable_Aggregation> aggregations = new Dictionary <string, User_Editable_Aggregation>();

                    // Step through each key
                    foreach (string thisKey in getKeys)
                    {
                        switch (thisKey)
                        {
                        case "groupName":
                            name = form[thisKey].Trim();
                            break;

                        case "groupDescription":
                            description = form[thisKey].Trim();
                            break;

                        case "admin_user_submit":
                            can_submit = true;
                            break;

                        case "admin_user_internal":
                            is_internal = true;
                            break;

                        case "admin_user_editall":
                            can_editall = true;
                            break;

                        case "admin_user_admin":
                            is_admin = true;
                            break;

                        case "admin_user_portaladmin":
                            is_portal = true;
                            break;

                        default:
                            if (thisKey.IndexOf("admin_user_template_") == 0)
                            {
                                templates.Add(thisKey.Replace("admin_user_template_", ""));
                            }
                            if (thisKey.IndexOf("admin_user_project_") == 0)
                            {
                                projects.Add(thisKey.Replace("admin_user_project_", ""));
                            }
                            if (thisKey.IndexOf("admin_project_onhome_") == 0)
                            {
                                string select_project = thisKey.Replace("admin_project_onhome_", "");
                                if (aggregations.ContainsKey(select_project))
                                {
                                    aggregations[select_project].OnHomePage = true;
                                }
                                else
                                {
                                    aggregations.Add(select_project, new User_Editable_Aggregation(select_project, String.Empty, false, false, false, true));
                                }
                            }
                            if (thisKey.IndexOf("admin_project_select_") == 0)
                            {
                                string select_project = thisKey.Replace("admin_project_select_", "");
                                if (aggregations.ContainsKey(select_project))
                                {
                                    aggregations[select_project].CanSelect = true;
                                }
                                else
                                {
                                    aggregations.Add(select_project, new User_Editable_Aggregation(select_project, String.Empty, true, false, false, false));
                                }
                            }
                            if (thisKey.IndexOf("admin_project_edit_") == 0)
                            {
                                string edit_project = thisKey.Replace("admin_project_edit_", "");
                                if (aggregations.ContainsKey(edit_project))
                                {
                                    aggregations[edit_project].CanEditItems = true;
                                }
                                else
                                {
                                    aggregations.Add(edit_project, new User_Editable_Aggregation(edit_project, String.Empty, false, true, false, false));
                                }
                            }
                            if (thisKey.IndexOf("admin_project_admin_") == 0)
                            {
                                string admin_project = thisKey.Replace("admin_project_admin_", "");
                                if (aggregations.ContainsKey(admin_project))
                                {
                                    aggregations[admin_project].IsCurator = true;
                                }
                                else
                                {
                                    aggregations.Add(admin_project, new User_Editable_Aggregation(admin_project, String.Empty, false, false, true, false));
                                }
                            }
                            break;
                        }
                    }

                    // Determine if the projects and templates need to be updated
                    bool update_templates_projects = false;
                    if ((templates.Count != editGroup.Templates.Count) || (projects.Count != editGroup.Projects.Count))
                    {
                        update_templates_projects = true;
                    }
                    else
                    {
                        // Check all of the templates
                        if (templates.Any(template => !editGroup.Templates.Contains(template)))
                        {
                            update_templates_projects = true;
                        }

                        // Check all the projects
                        if (!update_templates_projects)
                        {
                            if (projects.Any(project => !editGroup.Projects.Contains(project)))
                            {
                                update_templates_projects = true;
                            }
                        }
                    }

                    // Determine if the aggregations need to be edited
                    bool update_aggregations = false;
                    if (aggregations.Count != editGroup.Aggregations.Count)
                    {
                        update_aggregations = true;
                    }
                    else
                    {
                        // Build a dictionary of the user aggregations as well
                        Dictionary <string, User_Editable_Aggregation> existingAggr = editGroup.Aggregations.ToDictionary(thisAggr => thisAggr.Code);

                        // Check all the aggregations
                        foreach (User_Editable_Aggregation adminAggr in aggregations.Values)
                        {
                            if (existingAggr.ContainsKey(adminAggr.Code))
                            {
                                if ((adminAggr.CanSelect != existingAggr[adminAggr.Code].CanSelect) || (adminAggr.CanEditItems != existingAggr[adminAggr.Code].CanEditItems) || (adminAggr.IsCurator != existingAggr[adminAggr.Code].IsCurator))
                                {
                                    update_aggregations = true;
                                    break;
                                }
                            }
                            else
                            {
                                update_aggregations = true;
                                break;
                            }
                        }
                    }

                    // Must have a name to continue
                    if (name.Length > 0)
                    {
                        // Update the basic user information
                        int newid = SobekCM_Database.Save_User_Group(editGroup.UserGroupID, name, description, can_submit, is_internal, can_editall, is_admin, is_portal, false, update_templates_projects, update_aggregations, false, Tracer);
                        if (editGroup.UserGroupID < 0)
                        {
                            editGroup.UserGroupID = newid;
                        }

                        if (editGroup.UserGroupID > 0)
                        {
                            // Update the templates and projects, if requested
                            if (update_templates_projects)
                            {
                                // Update projects, if necessary
                                if (projects.Count > 0)
                                {
                                    if (!SobekCM_Database.Update_SobekCM_User_Group_Projects(editGroup.UserGroupID, projects, Tracer))
                                    {
                                        successful_save = false;
                                    }
                                }

                                // Update templates, if necessary
                                if (templates.Count > 0)
                                {
                                    if (!SobekCM_Database.Update_SobekCM_User_Group_Templates(editGroup.UserGroupID, templates, Tracer))
                                    {
                                        successful_save = false;
                                    }
                                }
                            }

                            // Update the aggregations, if requested
                            if (update_aggregations)
                            {
                                if (aggregations.Count > 0)
                                {
                                    List <User_Editable_Aggregation> aggregationList = aggregations.Values.ToList();
                                    if (!SobekCM_Database.Update_SobekCM_User_Group_Aggregations(editGroup.UserGroupID, aggregationList, Tracer))
                                    {
                                        successful_save = false;
                                    }
                                }
                            }
                        }
                        else
                        {
                            successful_save = false;
                        }
                    }
                    else
                    {
                        actionMessage   = "User group's name must have a length greater than zero";
                        successful_save = false;
                    }

                    // Forward back to the list of users, if this was successful
                    if (successful_save)
                    {
                        currentMode.My_Sobek_SubMode = String.Empty;
                        HttpContext.Current.Response.Redirect(currentMode.Redirect_URL());
                    }
                }
            }
        }
Beispiel #9
0
        /// <summary> Constructor for a new instance of the Thematic_Headings_AdminViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request </param>
        /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the home page are organized </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> Postback from handling an edit or new thematic heading is handled here in the constructor </remarks>
        public Thematic_Headings_AdminViewer(User_Object User,
                                             SobekCM_Navigation_Object Current_Mode,
                                             List <Thematic_Heading> Thematic_Headings,
                                             Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("Thematic_Headings_AdminViewer.Constructor", String.Empty);

            // Get the current list of thematic headings
            thematicHeadings = Thematic_Headings;

            // Save the mode
            currentMode = Current_Mode;

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

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

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

                    // Switch, depending on the request
                    if (action_value != null)
                    {
                        switch (action_value.Trim().ToLower())
                        {
                        case "edit":
                            string new_name = form["form_heading_name"];
                            if (new_name != null)
                            {
                                int id    = Convert.ToInt32(save_value);
                                int order = 1 + Thematic_Headings.TakeWhile(thisHeading => thisHeading.ThematicHeadingID != id).Count();
                                if (SobekCM_Database.Edit_Thematic_Heading(id, order, new_name, Tracer) < 1)
                                {
                                    actionMessage = "Unable to edit existing thematic heading";
                                }
                                else
                                {
                                    // For thread safety, lock the thematic headings list
                                    lock (Thematic_Headings)
                                    {
                                        // Repopulate the thematic headings list
                                        SobekCM_Database.Populate_Thematic_Headings(Thematic_Headings, Tracer);
                                    }

                                    actionMessage = "Thematic heading edits saved";
                                }
                            }
                            break;

                        case "delete":
                            int thematicDeleteId = Convert.ToInt32(save_value);
                            if (!SobekCM_Database.Delete_Thematic_Heading(thematicDeleteId, Tracer))
                            {
                                // Set action message
                                actionMessage = "Unable to delete existing thematic heading";
                            }
                            else
                            {
                                // For thread safety, lock the thematic headings list
                                lock (Thematic_Headings)
                                {
                                    // Remove this thematic heading from the list
                                    int i = 0;
                                    while (i < Thematic_Headings.Count)
                                    {
                                        if (Thematic_Headings[i].ThematicHeadingID == thematicDeleteId)
                                        {
                                            Thematic_Headings.RemoveAt(i);
                                        }
                                        else
                                        {
                                            i++;
                                        }
                                    }
                                }

                                // Set action message
                                actionMessage = "Thematic heading deleted";
                            }
                            break;


                        case "new":
                            int new_order = Thematic_Headings.Count + 1;
                            if (SobekCM_Database.Edit_Thematic_Heading(-1, new_order, save_value, Tracer) < 1)
                            {
                                actionMessage = "Unable to save new thematic heading";
                            }
                            else
                            {
                                // For thread safety, lock the thematic headings list
                                lock (Thematic_Headings)
                                {
                                    // Repopulate the thematic headings list
                                    SobekCM_Database.Populate_Thematic_Headings(Thematic_Headings, Tracer);
                                }

                                actionMessage = "New thematic heading saved";
                            }
                            break;

                        case "moveup":
                            string[] moveup_split = save_value.Split(",".ToCharArray());
                            int      moveup_id    = Convert.ToInt32(moveup_split[0]);
                            int      moveup_order = Convert.ToInt32(moveup_split[1]);
                            if (moveup_order > 1)
                            {
                                Thematic_Heading themeHeading = Thematic_Headings[moveup_order - 1];
                                if (themeHeading.ThematicHeadingID == moveup_id)
                                {
                                    // For thread safety, lock the thematic headings list
                                    lock (Thematic_Headings)
                                    {
                                        // Move this thematic heading up
                                        Thematic_Headings.Remove(themeHeading);
                                        Thematic_Headings.Insert(moveup_order - 2, themeHeading);
                                        int current_order = 1;
                                        foreach (Thematic_Heading thisTheme in Thematic_Headings)
                                        {
                                            SobekCM_Database.Edit_Thematic_Heading(thisTheme.ThematicHeadingID, current_order, thisTheme.ThemeName, Tracer);
                                            current_order++;
                                        }

                                        // Repopulate the thematic headings list
                                        SobekCM_Database.Populate_Thematic_Headings(Thematic_Headings, Tracer);
                                    }
                                }
                            }
                            break;

                        case "movedown":
                            string[] movedown_split = save_value.Split(",".ToCharArray());
                            int      movedown_id    = Convert.ToInt32(movedown_split[0]);
                            int      movedown_order = Convert.ToInt32(movedown_split[1]);
                            if (movedown_order < Thematic_Headings.Count)
                            {
                                Thematic_Heading themeHeading = Thematic_Headings[movedown_order - 1];
                                if (themeHeading.ThematicHeadingID == movedown_id)
                                {
                                    // For thread safety, lock the thematic headings list
                                    lock (Thematic_Headings)
                                    {
                                        // Move this thematic heading down
                                        Thematic_Headings.Remove(themeHeading);
                                        Thematic_Headings.Insert(movedown_order, themeHeading);
                                        int current_order = 1;
                                        foreach (Thematic_Heading thisTheme in Thematic_Headings)
                                        {
                                            SobekCM_Database.Edit_Thematic_Heading(thisTheme.ThematicHeadingID, current_order, thisTheme.ThemeName, Tracer);
                                            current_order++;
                                        }

                                        // Repopulate the thematic headings list
                                        SobekCM_Database.Populate_Thematic_Headings(Thematic_Headings, Tracer);
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
                catch (Exception)
                {
                    actionMessage = "Unknown error caught while handling your reqeust";
                }
            }
        }
        /// <summary> Constructor for a new instance of the Edit_Group_Behaviors_MySobekViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Current_Item"> Individual digital resource to be edited by the user </param>
        /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Edit_Group_Behaviors_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager, Custom_Tracer Tracer) : base(User)
        {
            Tracer.Add_Trace("Edit_Group_Behaviors_MySobekViewer.Constructor", String.Empty);

            currentMode = Current_Mode;
            item        = Current_Item;


            // If the user cannot edit this item, go back
            if (!user.Can_Edit_This_Item(item))
            {
                currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                currentMode.Redirect();
                return;
            }

            const string TEMPLATE_CODE = "groupbehaviors";

            template = Cached_Data_Manager.Retrieve_Template(TEMPLATE_CODE, Tracer);
            if (template != null)
            {
                Tracer.Add_Trace("Edit_Group_Behaviors_MySobekViewer.Constructor", "Found template in cache");
            }
            else
            {
                Tracer.Add_Trace("Edit_Group_Behaviors_MySobekViewer.Constructor", "Reading template file");

                // Read this template
                Template_XML_Reader reader = new Template_XML_Reader();
                template = new Template();
                reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\defaults\\" + TEMPLATE_CODE + ".xml", template, true);

                // Add the current codes to this template
                template.Add_Codes(Code_Manager);

                // Save this into the cache
                Cached_Data_Manager.Store_Template(TEMPLATE_CODE, template, 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")
            {
                currentMode.Mode = Display_Mode_Enum.Item_Display;
                currentMode.Redirect();
            }
            else if (hidden_request == "save")
            {
                // Save these changes to bib
                template.Save_To_Bib(item, user, 1);

                // Save the group title
                SobekCM_Database.Update_Item_Group(item.BibID, item.Behaviors.GroupTitle, item.Bib_Info.SortSafeTitle(item.Behaviors.GroupTitle, true), String.Empty, item.Behaviors.Primary_Identifier.Type, item.Behaviors.Primary_Identifier.Identifier);

                // Save the interfaces to the group item as well
                SobekCM_Database.Save_Item_Group_Web_Skins(item.Web.GroupID, item);

                // Store on the caches (to replace the other)
                Cached_Data_Manager.Remove_Digital_Resource_Objects(item.BibID, Tracer);

                // Forward
                currentMode.Mode = Display_Mode_Enum.Item_Display;
                currentMode.Redirect();
            }
        }
Beispiel #11
0
        /// <summary> Constructor for a new instance of the Delete_Item_MySobekViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="All_Items_Lookup"> Allows individual items to be retrieved by various methods as <see cref="SobekCM.Library.Application_State.Single_Item"/> objects.</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Delete_Item_MySobekViewer(User_Object User,
                                         SobekCM_Navigation_Object Current_Mode,
                                         Item_Lookup_Object All_Items_Lookup,

                                         Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Delete this item");

            // Save mode and set defaults
            currentMode = Current_Mode;
            errorCode   = -1;

            // First, ensure this is a logged on user and system administrator before continuing
            Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Validate user permissions");
            if ((User == null) || ((!User.Is_System_Admin) && (User.UserName.ToLower() != "neldamaxs")))
            {
                Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "User does not have delete permissions", Custom_Trace_Type_Enum.Error);
                errorCode = 1;
            }

            // Second, ensure the item is valid
            if (errorCode == -1)
            {
                Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Validate item exists");
                if (!All_Items_Lookup.Contains_BibID_VID(Current_Mode.BibID, Current_Mode.VID))
                {
                    Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Item indicated is not valid", Custom_Trace_Type_Enum.Error);
                    errorCode = 2;
                }
            }

            // Get the current item details
            string bib_location = String.Empty;
            string vid_location = String.Empty;

            if (errorCode == -1)
            {
                // Get item details
                DataSet itemDetails = SobekCM_Database.Get_Item_Details(currentMode.BibID, currentMode.VID, Tracer);

                // If the itemdetails was null, this item is somehow invalid item then
                if (itemDetails == null)
                {
                    Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Item indicated is not valid", Custom_Trace_Type_Enum.Error);
                    errorCode = 2;
                }
                else
                {
                    // Get the location for this METS file from the returned value
                    DataRow mainItemRow = itemDetails.Tables[2].Rows[0];
                    bib_location = SobekCM_Library_Settings.Image_Server_Network + mainItemRow["File_Location"].ToString().Replace("/", "\\");
                    vid_location = bib_location + "\\" + currentMode.VID;
                }
            }

            // If this is a postback, handle any events first
            if ((currentMode.isPostBack) && (errorCode < 0))
            {
                Debug.Assert(User != null, "User != null");

                // Pull the standard values
                string save_value = HttpContext.Current.Request.Form["admin_delete_item"];
                string text_value = HttpContext.Current.Request.Form["admin_delete_confirm"];

                // Better say "DELETE", or just send back to the item
                if ((save_value == null) || (save_value.ToUpper() != "DELETE") || (text_value.ToUpper() != "DELETE"))
                {
                    HttpContext.Current.Response.Redirect(Current_Mode.Base_URL + currentMode.BibID + "/" + currentMode.VID);
                }
                else
                {
                    errorCode = 0;

                    // Perform the database delete
                    Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Perform database update");
                    bool database_result = SobekCM_Database.Delete_SobekCM_Item(currentMode.BibID, currentMode.VID, User.Is_System_Admin, String.Empty);

                    if (!database_result)
                    {
                        Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Error performing delete in the database", Custom_Trace_Type_Enum.Error);
                        errorCode = 3;
                    }
                    else
                    {
                        // Move the folder to deletes
                        try
                        {
                            Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Move resource files to DELETED folder");

                            // Make sure upper deleted folder exists, or create it
                            string delete_folder = SobekCM_Library_Settings.Image_Server_Network + "DELETED";
                            if (!Directory.Exists(delete_folder))
                            {
                                Directory.CreateDirectory(delete_folder);
                            }

                            // Create the bib level folder next
                            string bib_folder = SobekCM_Library_Settings.Image_Server_Network + "DELETED\\" + currentMode.BibID;
                            if (!Directory.Exists(bib_folder))
                            {
                                Directory.CreateDirectory(bib_folder);
                            }

                            // Ensure the VID folder does not exist
                            string vid_folder = SobekCM_Library_Settings.Image_Server_Network + "DELETED\\" + currentMode.BibID + "\\" + currentMode.VID;
                            if (Directory.Exists(vid_folder))
                            {
                                Directory.Move(vid_folder, vid_folder + "_OLD");
                            }

                            // Move the VID folder over now
                            Directory.Move(vid_location, vid_folder);

                            // Check if this was the last VID under this BIB
                            if (Directory.GetDirectories(bib_location).Length == 0)
                            {
                                // Move all files over to the bib folder then
                                string[] bib_files = Directory.GetFiles(bib_location);
                                foreach (string thisFile in bib_files)
                                {
                                    string fileName = (new FileInfo(thisFile)).Name;
                                    string new_file = bib_folder + "\\" + fileName;
                                    File.Move(thisFile, new_file);
                                }
                            }
                        }
                        catch (Exception ee)
                        {
                            Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Error moving the folder and files to the DELETED folder", Custom_Trace_Type_Enum.Error);
                            Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", ee.Message, Custom_Trace_Type_Enum.Error);
                            Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", ee.StackTrace, Custom_Trace_Type_Enum.Error);
                            errorCode = 4;
                        }

                        // Remove from the item list
                        All_Items_Lookup.Remove_Item(currentMode.BibID, currentMode.VID);

                        // Also remove from the cache
                        Cached_Data_Manager.Remove_Digital_Resource_Object(currentMode.BibID, currentMode.VID, Tracer);
                    }
                }
            }
        }
Beispiel #12
0
        /// <summary> Returns the HTML for one element within tab which appears over the search box in the collection view </summary>
        /// <param name="ThisView"> Collection view type for this tab </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request, to see if the tab is currently selected or not and determine current skin language </param>
        /// <param name="Translations"> Language support object for writing the name of the view in the appropriate interface language </param>
        /// <returns> HTML to display the tab, including the link if it is not currently selected </returns>
        public static string Menu_Get_Nav_Bar_HTML(Item_Aggregation.CollectionViewsAndSearchesEnum ThisView, SobekCM_Navigation_Object Current_Mode, Language_Support_Info Translations)
        {
            string skinCode = Current_Mode.Base_Skin;

            switch (ThisView)
            {
            case Item_Aggregation.CollectionViewsAndSearchesEnum.Advanced_Search:
            case Item_Aggregation.CollectionViewsAndSearchesEnum.Advanced_Search_YearRange:
                return(Menu_HTML_Helper(skinCode, Search_Type_Enum.Advanced, Translations.Get_Translation("ADVANCED SEARCH", Current_Mode.Language), Current_Mode));

            case Item_Aggregation.CollectionViewsAndSearchesEnum.Basic_Search:
            case Item_Aggregation.CollectionViewsAndSearchesEnum.Basic_Search_YearRange:
                return(Menu_HTML_Helper(skinCode, Search_Type_Enum.Basic, Translations.Get_Translation("BASIC SEARCH", Current_Mode.Language), Current_Mode));

            case Item_Aggregation.CollectionViewsAndSearchesEnum.Map_Search:
                return(Menu_HTML_Helper(skinCode, Search_Type_Enum.Map, Translations.Get_Translation("MAP SEARCH", Current_Mode.Language), Current_Mode));

            case Item_Aggregation.CollectionViewsAndSearchesEnum.Map_Search_Beta:
                return(Menu_HTML_Helper(skinCode, Search_Type_Enum.Map_Beta, Translations.Get_Translation("MAP SEARCH", Current_Mode.Language), Current_Mode));

            case Item_Aggregation.CollectionViewsAndSearchesEnum.Newspaper_Search:
                return(Menu_HTML_Helper(skinCode, Search_Type_Enum.Newspaper, Translations.Get_Translation("NEWSPAPER SEARCH", Current_Mode.Language), Current_Mode));

            case Item_Aggregation.CollectionViewsAndSearchesEnum.Admin_View:
                return(String.Empty);                        // HTML_Helper(Skin_Code, SobekCM.Library.Navigation.Search_Type_Enum.Admin_View, Translations.Get_Translation("ADMIN", Current_Mode.Language), Current_Mode, Downward_Tabs);

            case Item_Aggregation.CollectionViewsAndSearchesEnum.DLOC_FullText_Search:
                return(Menu_HTML_Helper(skinCode, Search_Type_Enum.dLOC_Full_Text, Translations.Get_Translation("TEXT SEARCH", Current_Mode.Language), Current_Mode));

            case Item_Aggregation.CollectionViewsAndSearchesEnum.FullText_Search:
                return(Menu_HTML_Helper(skinCode, Search_Type_Enum.Full_Text, Translations.Get_Translation("TEXT SEARCH", Current_Mode.Language), Current_Mode));
            }

            return(String.Empty);
        }
Beispiel #13
0
        /// <summary> Constructor for a new instance of the Home_MySobekViewer class </summary>
        /// <param name="CurrentMode"> Mode / navigation information for the current request (including interface code) </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Logon_MySobekViewer(SobekCM_Navigation_Object CurrentMode, Custom_Tracer Tracer)
            : base(null)
        {
            Tracer.Add_Trace("Logon_MySobekViewer.Constructor", String.Empty);

            this.CurrentMode = CurrentMode;

            errorMessage = String.Empty;

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

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

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

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

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

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

                        // Forward back to their original URL (unless the original URL was this logon page)
                        string raw_url = HttpContext.Current.Items["Original_URL"].ToString();
                        if (raw_url.ToLower().IndexOf("my/logon") > 0)
                        {
                            currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                            currentMode.Redirect();
                        }
                        else
                        {
                            HttpContext.Current.Response.Redirect(raw_url, false);
                            HttpContext.Current.ApplicationInstance.CompleteRequest();
                            currentMode.Request_Completed = true;
                        }
                    }
                    else
                    {
                        errorMessage = "Invalid user/password entered";
                    }
                }
            }
        }
Beispiel #14
0
        /// <summary> Get the navigation bar html for a view, given information about the current request </summary>
        /// <param name="Item_View"> View for which to generate the html </param>
        /// <param name="Resource_Type"> Current resource type, which determines the text in several viewer's tabs</param>
        /// <param name="Skin_Code"> Code for the current web sking, which determines which tab images to use </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Page_Sequence"> Current page sequence </param>
        /// <param name="Translator"> Language support object provides support for translating common user interface elements, like the names of these tabs </param>
        /// <param name="Show_Zoomable"> Flag indicates if the zoomable server is online and should be displayable </param>
        /// <returns> Collection of the html for the navigation bar (one view could have multiple tabs)</returns>
        public static List <string> Get_Nav_Bar_HTML(View_Object Item_View, string Resource_Type,
                                                     string Skin_Code, SobekCM_Navigation_Object Current_Mode, int Page_Sequence,
                                                     Language_Support_Info Translator, bool Show_Zoomable, SobekCM_Item Current_Item)
        {
            List <string> returnVal = new List <string>();

            switch (Item_View.View_Type)
            {
            case View_Enum.ALL_VOLUMES:
                string allVolumeCode       = "allvolumes";
                string resource_type_upper = Resource_Type.ToUpper();
                if (Current_Mode.ViewerCode.IndexOf("allvolumes") == 0)
                {
                    allVolumeCode = Current_Mode.ViewerCode;
                }
                if (resource_type_upper.IndexOf("NEWSPAPER") >= 0)
                {
                    returnVal.Add(HTML_Helper(Skin_Code, allVolumeCode, Translator.Get_Translation("ALL ISSUES", Current_Mode.Language), Current_Mode));
                }
                else
                {
                    if (resource_type_upper.IndexOf("MAP") >= 0)
                    {
                        returnVal.Add(HTML_Helper(Skin_Code, allVolumeCode, Translator.Get_Translation("RELATED MAPS", Current_Mode.Language), Current_Mode));
                    }
                    else
                    {
                        returnVal.Add(resource_type_upper.IndexOf("AERIAL") >= 0
                                              ? HTML_Helper(Skin_Code, allVolumeCode, Translator.Get_Translation("RELATED FLIGHTS", Current_Mode.Language), Current_Mode)
                                              : HTML_Helper(Skin_Code, allVolumeCode, Translator.Get_Translation("ALL VOLUMES", Current_Mode.Language), Current_Mode));
                    }
                }
                break;

            case View_Enum.CITATION:
                if ((Current_Mode.ViewerCode == "citation") || (Current_Mode.ViewerCode == "marc") || (Current_Mode.ViewerCode == "metadata") || (Current_Mode.ViewerCode == "usage"))
                {
                    returnVal.Add(HTML_Helper(Skin_Code, Current_Mode.ViewerCode, Translator.Get_Translation("CITATION", Current_Mode.Language), Current_Mode));
                }
                else
                {
                    returnVal.Add(HTML_Helper(Skin_Code, "citation", Translator.Get_Translation("CITATION", Current_Mode.Language), Current_Mode));
                }
                break;

            case View_Enum.DATASET_CODEBOOK:
                returnVal.Add(HTML_Helper(Skin_Code, "dscodebook", Translator.Get_Translation("DATA STRUCTURE", Current_Mode.Language), Current_Mode));
                break;

            case View_Enum.DATASET_REPORTS:
                returnVal.Add(HTML_Helper(Skin_Code, "dsreports", Translator.Get_Translation("REPORTS", Current_Mode.Language), Current_Mode));
                break;

            case View_Enum.DATASET_VIEWDATA:
                returnVal.Add(HTML_Helper(Skin_Code, "dsview", Translator.Get_Translation("EXPLORE DATA", Current_Mode.Language), Current_Mode));
                break;

            case View_Enum.DOWNLOADS:
                returnVal.Add(HTML_Helper(Skin_Code, "downloads", Translator.Get_Translation("DOWNLOADS", Current_Mode.Language), Current_Mode));
                break;

            case View_Enum.FEATURES:
                returnVal.Add(HTML_Helper(Skin_Code, "features", Translator.Get_Translation("FEATURES", Current_Mode.Language), Current_Mode));
                break;

            case View_Enum.FLASH:
                returnVal.Add(Item_View.Label.Length == 0
                                      ? HTML_Helper(Skin_Code, "flash", Translator.Get_Translation("FLASH VIEW", Current_Mode.Language), Current_Mode)
                                      : HTML_Helper(Skin_Code, "flash", Translator.Get_Translation(Item_View.Label.ToUpper(), Current_Mode.Language), Current_Mode));
                break;

            case View_Enum.GOOGLE_MAP:
                if (Current_Mode.Coordinates.Length > 0)
                {
                    if (Current_Mode.ViewerCode == "mapsearch")
                    {
                        returnVal.Add(HTML_Helper(Skin_Code, "mapsearch", Translator.Get_Translation("MAP SEARCH", Current_Mode.Language), Current_Mode));
                    }
                    else
                    {
                        if ((Current_Item.Web.Static_PageCount > 1) || (Current_Item.Bib_Info.SobekCM_Type != TypeOfResource_SobekCM_Enum.Map))
                        {
                            returnVal.Add(HTML_Helper(Skin_Code, "map", Translator.Get_Translation("SEARCH RESULTS", Current_Mode.Language), Current_Mode));
                        }
                        else
                        {
                            returnVal.Add(HTML_Helper(Skin_Code, "map", Translator.Get_Translation("MAP COVERAGE", Current_Mode.Language), Current_Mode));
                        }
                    }
                }
                else
                {
                    returnVal.Add(HTML_Helper(Skin_Code, "map", Translator.Get_Translation("MAP IT!", Current_Mode.Language), Current_Mode));
                }
                break;

            case View_Enum.GOOGLE_MAP_BETA:
                if (Current_Mode.Coordinates.Length > 0)
                {
                    if (Current_Mode.ViewerCode == "mapsearchbeta")
                    {
                        returnVal.Add(HTML_Helper(Skin_Code, "mapsearchbeta", Translator.Get_Translation("MAP SEARCH", Current_Mode.Language), Current_Mode));
                    }
                    else
                    {
                        if ((Current_Item.Web.Static_PageCount > 1) || (Current_Item.Bib_Info.SobekCM_Type != TypeOfResource_SobekCM_Enum.Map_Beta))
                        {
                            returnVal.Add(HTML_Helper(Skin_Code, "mapbeta", Translator.Get_Translation("SEARCH RESULTS", Current_Mode.Language), Current_Mode));
                        }
                        else
                        {
                            returnVal.Add(HTML_Helper(Skin_Code, "mapbeta", Translator.Get_Translation("MAP COVERAGE", Current_Mode.Language), Current_Mode));
                        }
                    }
                }
                else
                {
                    returnVal.Add(HTML_Helper(Skin_Code, "map", Translator.Get_Translation("MAP IT!", Current_Mode.Language), Current_Mode));
                }
                break;

            case View_Enum.HTML:
                returnVal.Add(Item_View.Label.Length > 0
                                      ? HTML_Helper(Skin_Code, "html", Item_View.Label.ToUpper(), Current_Mode)
                                      : HTML_Helper(Skin_Code, "html", "HTML LINK", Current_Mode));
                break;

            case View_Enum.JPEG:
                returnVal.Add(HTML_Helper_PageView(Skin_Code, Page_Sequence.ToString() + "j", Translator.Get_Translation("STANDARD", Current_Mode.Language), Current_Mode));
                break;

            case View_Enum.JPEG_TEXT_TWO_UP:
                returnVal.Add(HTML_Helper_PageView(Skin_Code, Page_Sequence.ToString() + "u", Translator.Get_Translation("PAGE IMAGE WITH TEXT", Current_Mode.Language), Current_Mode));
                break;

            case View_Enum.JPEG2000:
                if (Show_Zoomable)
                {
                    returnVal.Add(HTML_Helper_PageView(Skin_Code, Page_Sequence.ToString() + "x", Translator.Get_Translation("ZOOMABLE", Current_Mode.Language), Current_Mode));
                }
                break;

            case View_Enum.PDF:
                returnVal.Add(HTML_Helper(Skin_Code, "pdf", Translator.Get_Translation("PDF VIEWER", Current_Mode.Language), Current_Mode));
                break;

            case View_Enum.RELATED_IMAGES:
                returnVal.Add(Current_Mode.ViewerCode.IndexOf("thumbs") >= 0
                                      ? HTML_Helper(Skin_Code, Current_Mode.ViewerCode, Translator.Get_Translation("THUMBNAILS", Current_Mode.Language), Current_Mode)
                                      : HTML_Helper(Skin_Code, "thumbs", Translator.Get_Translation("THUMBNAILS", Current_Mode.Language), Current_Mode));
                break;

            case View_Enum.SEARCH:
                returnVal.Add(HTML_Helper(Skin_Code, "search", Translator.Get_Translation("SEARCH", Current_Mode.Language), Current_Mode));
                break;

            case View_Enum.SIMPLE_HTML_LINK:
                returnVal.Add("<li> <a href=\"" + Item_View.Attributes + "\" target=\"_blank\" alt=\"Link to '" + Item_View.Label + "'\"> " + Translator.Get_Translation(Item_View.Label.ToUpper(), Current_Mode.Language) + " </a></li>");
                break;

            case View_Enum.STREETS:
                returnVal.Add(HTML_Helper(Skin_Code, "streets", Translator.Get_Translation("STREETS", Current_Mode.Language), Current_Mode));
                break;

            case View_Enum.TEXT:
                returnVal.Add(HTML_Helper_PageView(Skin_Code, Page_Sequence.ToString() + "t", Translator.Get_Translation("PAGE TEXT", Current_Mode.Language), Current_Mode));
                break;

            case View_Enum.TOC:
                // returnVal.Add(base.HTML_Helper(Skin_Code, "TC", "Table of Contents", Current_Mode));
                break;

            case View_Enum.RESTRICTED:
                returnVal.Add(HTML_Helper(Skin_Code, "restricted", Translator.Get_Translation("RESTRICTED", Current_Mode.Language), Current_Mode));
                break;

            case View_Enum.EAD_CONTAINER_LIST:
                returnVal.Add(HTML_Helper(Skin_Code, "container", Translator.Get_Translation("CONTAINER LIST", Current_Mode.Language), Current_Mode));
                break;

            case View_Enum.EAD_DESCRIPTION:
                // Return nothing, this is currently written when writing the CITATION, for
                // all EAD type items.
                //returnVal.Add(HTML_Helper(Skin_Code, "description", Translator.Get_Translation("DESCRIPTION", Current_Mode.Language), Current_Mode));
                break;

            case View_Enum.PAGE_TURNER:
                returnVal.Add(HTML_Helper(Skin_Code, "pageturner#page/1/mode/2up", Translator.Get_Translation("PAGE TURNER", Current_Mode.Language), Current_Mode));
                break;

            case View_Enum.YOUTUBE_VIDEO:
                returnVal.Add(HTML_Helper(Skin_Code, "youtube", Translator.Get_Translation("VIDEO", Current_Mode.Language), Current_Mode));
                break;

            case View_Enum.EMBEDDED_VIDEO:
                returnVal.Add(HTML_Helper(Skin_Code, "video", Translator.Get_Translation("VIDEO", Current_Mode.Language), Current_Mode));
                break;

            case View_Enum.TRACKING:
                // DO nothing in this case.. do not write any tab
                break;

            case View_Enum.TRACKING_SHEET:
                //DO nothing in this case.. do not write any tab
                break;

            case View_Enum.QUALITY_CONTROL:
                // DO nothing in this case.. do not write any tab
                break;
            }

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

            currentMode      = CurrentMode;
            validationErrors = new List <string>();

            // Set the text to use for each value (since we use if for the validation errors as well)
            mySobekText = "my" + currentMode.SobekCM_Instance_Abbreviation;

            // Get the labels to use, by language
            accountInfoLabel       = "Account Information";
            userNameLabel          = "UserName";
            personalInfoLabel      = "Personal Information";
            familyNamesLabel       = "Last/Family Name(s)";
            givenNamesLabel        = "First/Given Name(s)";
            nicknameLabel          = "Nickname";
            emailLabel             = "Email";
            emailStatsLabel        = "Send me monthly usage statistics for my items";
            affilitionInfoLabel    = "Current Affiliation Information";
            organizationLabel      = "Organization/University";
            collegeLabel           = "College";
            departmentLabel        = "Department";
            unitLabel              = "Unit";
            selfSubmittalPrefLabel = "Self-Submittal Preferences";
            sendEmailLabel         = "Send me an email when I submit new items";
            templateLabel          = "Template";
            projectLabel           = "Default Metadata";
            defaultRightsLabel     = "Default Rights";
            rightsExplanationLabel = "(These are the default rights you give for sharing, repurposing, or remixing your item to other users. You can set this with each new item you submit, but this will be the default that appears.)";
            rightsInstructionLabel = "You may also select a <a title=\"Explanation of different creative commons licenses.\" href=\"http://creativecommons.org/about/licenses/\">Creative Commons License</a> option below.";
            otherPreferencesLabel  = "Other Preferences";
            languageLabel          = "Language";
            passwordLabel          = "Password";
            confirmPasswordLabel   = "Confirm Password";
            col1Width              = "15px";
            col2Width              = "100px";
            col3Width              = "605px";

            if (currentMode.Language == Web_Language_Enum.French)
            {
                accountInfoLabel       = "Informations sur le Compte";
                userNameLabel          = "Nom du Compte";
                personalInfoLabel      = "Des Renseignements Personnels";
                familyNamesLabel       = "Nom de Famille";
                givenNamesLabel        = "Prénoms";
                nicknameLabel          = "Pseudo";
                emailLabel             = "Email";
                affilitionInfoLabel    = "Information Affiliation Actuel";
                organizationLabel      = "Organisation / Université";
                collegeLabel           = "Collège";
                departmentLabel        = "Département";
                unitLabel              = "Unité";
                selfSubmittalPrefLabel = "Préférences Auto-Soumission";
                sendEmailLabel         = "Envoyez-moi un email lorsque je présente les nouveaux éléments";
                templateLabel          = "Modèle";
                projectLabel           = "Métadonnées par Défaut";
                defaultRightsLabel     = "Droits par Défaut";
                rightsExplanationLabel = "(Ce sont les droits par défaut que vous donnez de partager, d'adapter, ou remixer votre article à d'autres utilisateurs. Vous pouvez fixer cette valeur à chaque nouvel élément que vous soumettez, mais ce sera la valeur par défaut qui s'affiche.)";
                rightsInstructionLabel = "Vous pouvez également sélectionner une option <a title=\"Explication des différentes licences Creative Commons.\" href=\"http://creativecommons.org/about/licenses/\">Creative Commons License</a> ci-dessous.";
                otherPreferencesLabel  = "Autres Préférences";
                languageLabel          = "Langue";
                passwordLabel          = "Mot de Passe";
                confirmPasswordLabel   = "Confirmer Mot de Passe";
                col1Width              = "10px";
                col2Width              = "220px";
                col3Width              = "490px";
            }

            if (currentMode.Language == Web_Language_Enum.Spanish)
            {
                accountInfoLabel       = "Información de la Cuenta";
                userNameLabel          = "Nombre de la Cuenta";
                personalInfoLabel      = "Información Personal";
                familyNamesLabel       = "Familia Nombre";
                givenNamesLabel        = "Nombre de Pila";
                nicknameLabel          = "Nickname";
                emailLabel             = "Correo Electrónico";
                affilitionInfoLabel    = "Información de la Afiliación Actual";
                organizationLabel      = "Organización/Universidad";
                collegeLabel           = "Colegio";
                departmentLabel        = "Departamento";
                unitLabel              = "Unidad";
                selfSubmittalPrefLabel = "Preferencias de Presentación Auto-";
                sendEmailLabel         = "Enviadme un correo electrónico cuando se presento nuevos temas";
                templateLabel          = "Plantilla";
                projectLabel           = "Metadatos Predeterminado";
                defaultRightsLabel     = "Derechos por Defecto";
                rightsExplanationLabel = "(Estos son los derechos por defecto le dan para compartir, reutilización, o remezclando el tema a otros usuarios. Puede establecer esto con cada artículo nuevo que presentar, pero esto será el valor por defecto que aparece.)";
                rightsInstructionLabel = "También puede seleccionar una opción de  <a title=\"Explicación de las diferentes licencias Creative Commons\" href=\"http://creativecommons.org/about/licenses/\">Creative Commons License</a> a continuación.";
                otherPreferencesLabel  = "Otras preferencias";
                languageLabel          = "Idioma";
                passwordLabel          = "Contraseña";
                confirmPasswordLabel   = "Confirmar Contraseña";
                col1Width              = "10px";
                col2Width              = "220px";
                col3Width              = "490px";
            }

            // Is this for registration
            registration = (HttpContext.Current.Session["user"] == null);
            if (registration)
            {
                user = new User_Object();
            }


            // Set some default first
            send_usages_emails = true;
            family_name        = String.Empty;
            given_name         = String.Empty;
            nickname           = String.Empty;
            email          = String.Empty;
            organization   = String.Empty;
            college        = String.Empty;
            department     = String.Empty;
            unit           = String.Empty;
            template       = String.Empty;
            project        = String.Empty;
            username       = String.Empty;
            password       = String.Empty;
            password2      = String.Empty;
            ufid           = String.Empty;
            language       = String.Empty;
            default_rights = String.Empty;

            // Handle post back
            if (currentMode.isPostBack)
            {
                // Loop through and get the dataa
                string[] getKeys = HttpContext.Current.Request.Form.AllKeys;
                foreach (string thisKey in getKeys)
                {
                    switch (thisKey)
                    {
                    case "prefUserName":
                        username = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "password_enter":
                        password = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "password_confirm":
                        password2 = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefUfid":
                        ufid = HttpContext.Current.Request.Form[thisKey].Trim().Replace("-", "");
                        break;

                    case "prefFamilyName":
                        family_name = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefGivenName":
                        given_name = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefNickName":
                        nickname = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefEmail":
                        email = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefOrganization":
                        organization = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefCollege":
                        college = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefDepartment":
                        department = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefUnit":
                        unit = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefLanguage":
                        string language_temp = HttpContext.Current.Request.Form[thisKey];
                        if (language_temp == "es")
                        {
                            language = "Español";
                        }
                        if (language_temp == "fr")
                        {
                            language = "Français";
                        }
                        break;

                    case "prefTemplate":
                        template = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefProject":
                        project = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefAllowSubmit":
                        string submit_value = HttpContext.Current.Request.Form[thisKey];
                        if (submit_value == "allowsubmit")
                        {
                            desire_to_upload = true;
                        }
                        break;

                    case "prefSendEmail":
                        string submit_value2 = HttpContext.Current.Request.Form[thisKey];
                        send_email_on_submission = submit_value2 == "sendemail";
                        break;

                    case "prefEmailStats":
                        string submit_value3 = HttpContext.Current.Request.Form[thisKey];
                        send_usages_emails = submit_value3 == "sendemail";
                        break;

                    case "prefRights":
                        default_rights = HttpContext.Current.Request.Form[thisKey];
                        break;
                    }
                }

                if (registration)
                {
                    if (username.Trim().Length == 0)
                    {
                        validationErrors.Add("Username is a required field");
                    }
                    else if (username.Trim().Length < 8)
                    {
                        validationErrors.Add("Username must be at least eight digits");
                    }
                    if ((password.Trim().Length == 0) || (password2.Trim().Length == 0))
                    {
                        validationErrors.Add("Select and confirm a password");
                    }
                    if (password.Trim() != password2.Trim())
                    {
                        validationErrors.Add("Passwords do not match");
                    }
                    else if (password.Length < 8)
                    {
                        validationErrors.Add("Password must be at least eight digits");
                    }
                    if (ufid.Trim().Length > 0)
                    {
                        if (ufid.Trim().Length != 8)
                        {
                            validationErrors.Add("UFIDs are always eight digits");
                        }
                        else
                        {
                            int ufid_convert_test;
                            if (!Int32.TryParse(ufid, out ufid_convert_test))
                            {
                                validationErrors.Add("UFIDs are always numeric");
                            }
                        }
                    }
                }

                // Validate the basic data is okay
                if (family_name.Trim().Length == 0)
                {
                    validationErrors.Add("Family name is a required field");
                }
                if (given_name.Trim().Length == 0)
                {
                    validationErrors.Add("Given name is a required field");
                }
                if ((email.Trim().Length == 0) || (email.IndexOf("@") < 0))
                {
                    validationErrors.Add("A valid email is required");
                }
                if (default_rights.Trim().Length > 1000)
                {
                    validationErrors.Add("Rights statement truncated to 1000 characters.");
                    default_rights = default_rights.Substring(0, 1000);
                }

                if ((registration) && (validationErrors.Count == 0))
                {
                    bool email_exists;
                    bool username_exists;
                    SobekCM_Database.UserName_Exists(username, email, out username_exists, out email_exists, Tracer);
                    if (email_exists)
                    {
                        validationErrors.Add("An account for that email address already exists.");
                    }
                    else if (username_exists)
                    {
                        validationErrors.Add("That username is taken.  Please choose another.");
                    }
                }

                if (validationErrors.Count == 0)
                {
                    user.College      = college.Trim();
                    user.Department   = department.Trim();
                    user.Email        = email.Trim();
                    user.Family_Name  = family_name.Trim();
                    user.Given_Name   = given_name.Trim();
                    user.Nickname     = nickname.Trim();
                    user.Organization = organization.Trim();
                    user.Unit         = unit.Trim();
                    user.Set_Default_Template(template.Trim());
                    // See if the project is different, if this is not registration
                    if ((!registration) && (user.Default_Metadata_Sets[0] != project.Trim()))
                    {
                        // Determine the in process directory for this
                        string user_in_process_directory = SobekCM_Library_Settings.In_Process_Submission_Location + "\\" + user.UserName;
                        if (user.ShibbID.Trim().Length > 0)
                        {
                            user_in_process_directory = SobekCM_Library_Settings.In_Process_Submission_Location + "\\" + user.ShibbID;
                        }
                        if (Directory.Exists(user_in_process_directory))
                        {
                            if (File.Exists(user_in_process_directory + "\\TEMP000001_00001.mets"))
                            {
                                File.Delete(user_in_process_directory + "\\TEMP000001_00001.mets");
                            }
                        }
                    }
                    user.Set_Current_Default_Metadata(project.Trim());
                    user.Preferred_Language       = language;
                    user.Default_Rights           = default_rights;
                    user.Send_Email_On_Submission = send_email_on_submission;
                    user.Receive_Stats_Emails     = send_usages_emails;

                    if (registration)
                    {
                        user.Can_Submit = false;
                        user.Send_Email_On_Submission = true;
                        user.ShibbID  = ufid;
                        user.UserName = username;
                        user.UserID   = -1;

                        // Save this new user
                        SobekCM_Database.Save_User(user, password, user.Authentication_Type, Tracer);

                        // Retrieve the user from the database
                        user = SobekCM_Database.Get_User(username, password, Tracer);

                        // Special code in case this is the very first user
                        if (user.UserID == 1)
                        {
                            // Add each template and project
                            DataSet       projectTemplateSet = SobekCM_Database.Get_All_Template_DefaultMetadatas(Tracer);
                            List <string> templates          = (from DataRow thisTemplate in projectTemplateSet.Tables[1].Rows select thisTemplate["TemplateCode"].ToString()).ToList();
                            List <string> projects           = (from DataRow thisProject in projectTemplateSet.Tables[0].Rows select thisProject["MetadataCode"].ToString()).ToList();

                            // Save the updates to this admin user
                            SobekCM_Database.Save_User(user, password, User_Authentication_Type_Enum.Sobek, Tracer);
                            SobekCM_Database.Update_SobekCM_User(user.UserID, true, true, true, true, true, true, true, "edit_internal", "editmarc_internal", true, true, true, Tracer);
                            SobekCM_Database.Update_SobekCM_User_DefaultMetadata(user.UserID, new ReadOnlyCollection <string>(projects), Tracer);
                            SobekCM_Database.Update_SobekCM_User_Templates(user.UserID, new ReadOnlyCollection <string>(templates), Tracer);

                            // Retrieve the user information again
                            user = SobekCM_Database.Get_User(username, password, Tracer);
                        }

                        user.Is_Just_Registered             = true;
                        HttpContext.Current.Session["user"] = user;

                        // If they want to be able to contribue, send an email
                        if (desire_to_upload)
                        {
                            SobekCM_Database.Send_Database_Email(SobekCM_Library_Settings.System_Email, "Submittal rights requested by " + user.Full_Name, "New user requested ability to submit new items.<br /><br /><blockquote>Name: " + user.Full_Name + "<br />Email: " + user.Email + "<br />Organization: " + user.Organization + "<br />User ID: " + user.UserID + "</blockquote>", true, false, -1, -1);
                        }

                        // Email the user their registation information
                        if (desire_to_upload)
                        {
                            SobekCM_Database.Send_Database_Email(email, "Welcome to " + mySobekText, "<strong>Thank you for registering for " + mySobekText + "</strong><br /><br />You can access this directly through the following link: <a href=\"" + currentMode.Base_URL + "/my\">" + currentMode.Base_URL + "/my</a><br /><br />Full Name: " + user.Full_Name + "<br />User Name: " + user.UserName + "<br /><br />You will receive an email when your request to submit items has been processed.", true, false, -1, -1);
                        }
                        else
                        {
                            SobekCM_Database.Send_Database_Email(email, "Welcome to " + mySobekText, "<strong>Thank you for registering for " + mySobekText + "</strong><br /><br />You can access this directly through the following link: <a href=\"" + currentMode.Base_URL + "/my\">" + currentMode.Base_URL + "/my</a><br /><br />Full Name: " + user.Full_Name + "<br />User Name: " + user.UserName, true, false, -1, -1);
                        }

                        // Now, forward back to the My Sobek home page
                        currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;

                        // If this is the first user to register (who would have been set to admin), send to the
                        // system-wide settings screen
                        if (user.UserID == 1)
                        {
                            currentMode.Mode       = Display_Mode_Enum.Administrative;
                            currentMode.Admin_Type = Admin_Type_Enum.Settings;
                        }
                        currentMode.Redirect();
                    }
                    else
                    {
                        HttpContext.Current.Session["user"] = user;
                        SobekCM_Database.Save_User(user, String.Empty, user.Authentication_Type, Tracer);

                        // Now, forward back to the My Sobek home page
                        currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                        currentMode.Redirect();
                    }
                }
            }
            else
            {
                family_name              = user.Family_Name;
                given_name               = user.Given_Name;
                nickname                 = user.Nickname;
                email                    = user.Email;
                organization             = user.Organization;
                college                  = user.College;
                department               = user.Department;
                unit                     = user.Unit;
                username                 = user.UserName;
                ufid                     = user.ShibbID;
                language                 = user.Preferred_Language;
                send_email_on_submission = user.Send_Email_On_Submission;
                default_rights           = user.Default_Rights;
            }
        }
Beispiel #16
0
 /// <summary> Constructor for a new instance of the Private_Items_AggregationViewer class </summary>
 /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
 /// <param name="Current_Aggregation"> Current item aggregation object to display </param>
 /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
 public Private_Items_AggregationViewer(SobekCM_Navigation_Object Current_Mode, Item_Aggregation Current_Aggregation, Custom_Tracer Tracer) : base(Current_Aggregation, Current_Mode)
 {
     privateItems = SobekCM_Database.Tracking_Get_Aggregation_Private_Items(currentCollection.Code, (int)RESULTS_PER_PAGE, currentMode.Page, currentMode.Sort, Tracer);
 }
Beispiel #17
0
        /// <summary> Constructor for a new instance of the Metadata_Browse_AggregationViewer class </summary>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Current_Aggregation"> Current item aggregation object to display </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Map_Browse_AggregationViewer(SobekCM_Navigation_Object Current_Mode, Item_Aggregation Current_Aggregation, Custom_Tracer Tracer) : base(Current_Aggregation, Current_Mode)
        {
            // Get the coordinate information
            DataTable coordinates = SobekCM_Database.Get_All_Coordinate_Points_By_Aggregation(Current_Aggregation.Code, Tracer);

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

            scriptBuilder.AppendLine("<script type=\"text/javascript\" src=\"http://maps.google.com/maps/api/js?sensor=false\"></script>");
            scriptBuilder.AppendLine("<script type=\"text/javascript\" src=\"" + Current_Mode.Base_URL + "default/scripts/keydragzoom_packed.js\"></script>");
            scriptBuilder.AppendLine("<script type=\"text/javascript\">");
            scriptBuilder.AppendLine("  //<![CDATA[");
            scriptBuilder.AppendLine("  // Global values");
            scriptBuilder.AppendLine("  var map, bounds, custom_icon, info_window, last_center;");
            scriptBuilder.AppendLine();
            scriptBuilder.AppendLine("  // Initialize the map on load ");
            scriptBuilder.AppendLine("  function load() { ");

            string center_latitude  = "27.75";
            string center_longitude = "-84";

            if ((coordinates != null) && (coordinates.Rows.Count == 1))
            {
                center_latitude  = coordinates.Rows[0]["Point_Latitude"].ToString();
                center_longitude = coordinates.Rows[0]["Point_Longitude"].ToString();
            }
            scriptBuilder.AppendLine("    // Create the map and set some values");
            scriptBuilder.AppendLine("    var latlng = new google.maps.LatLng(" + center_latitude + ", " + center_longitude + ");");
            scriptBuilder.AppendLine("    var myOptions = { zoom: 7, center: latlng, mapTypeId: google.maps.MapTypeId.TERRAIN, streetViewControl: false  };");
            scriptBuilder.AppendLine("    map = new google.maps.Map(document.getElementById('sbkMbav_MapDiv'), myOptions);");
            scriptBuilder.AppendLine("    map.enableKeyDragZoom();");

            if ((coordinates != null) && (coordinates.Rows.Count > 0))
            {
                scriptBuilder.AppendLine();
                scriptBuilder.AppendLine("    // Create the custom icon / marker image");
                scriptBuilder.AppendLine("    var iconSize = new google.maps.Size(11, 11);");
                scriptBuilder.AppendLine("    var iconAnchor = new google.maps.Point(5, 5);");
                scriptBuilder.AppendLine("    var pointer_image = '" + currentMode.Base_URL + "/default/images/map_point.png';");
                scriptBuilder.AppendLine("    custom_icon = new google.maps.MarkerImage(pointer_image, iconSize, null, iconAnchor);");

                scriptBuilder.AppendLine();
                scriptBuilder.AppendLine("    // Create the bounds");
                scriptBuilder.AppendLine("    bounds = new google.maps.LatLngBounds();");

                scriptBuilder.AppendLine();
                scriptBuilder.AppendLine("    // Create the info window for display");
                scriptBuilder.AppendLine("    info_window = new google.maps.InfoWindow();");
                scriptBuilder.AppendLine("    google.maps.event.addListener(info_window, 'closeclick', function() { if (last_center != null) { map.panTo(last_center); last_center = null; } });");

                scriptBuilder.AppendLine();
                scriptBuilder.AppendLine("    // Add all the points");
                string         last_latitude        = coordinates.Rows[0]["Point_Latitude"].ToString();
                string         last_longitude       = coordinates.Rows[0]["Point_Longitude"].ToString();
                List <DataRow> bibids_in_this_point = new List <DataRow>();
                foreach (DataRow thisRow in coordinates.Rows)
                {
                    string latitude  = thisRow["Point_Latitude"].ToString();
                    string longitude = thisRow["Point_Longitude"].ToString();

                    // Is this upcoming point new?
                    if ((latitude != last_latitude) || (longitude != last_longitude))
                    {
                        // Write the last point, if there was one
                        if (bibids_in_this_point.Count > 0)
                        {
                            // Add the point
                            add_single_point(last_latitude, last_longitude, Current_Mode, bibids_in_this_point, scriptBuilder);

                            // Assign this as the last value
                            last_latitude  = latitude;
                            last_longitude = longitude;

                            // Clear the list of newspapers linked to this point
                            bibids_in_this_point.Clear();
                        }

                        // Start a new list and include this bib id
                        bibids_in_this_point.Add(thisRow);
                    }
                    else
                    {
                        // Add this bibid to the list
                        bibids_in_this_point.Add(thisRow);
                    }
                }

                // Write the last point, if there was one
                if (bibids_in_this_point.Count > 0)
                {
                    // Add the point
                    add_single_point(last_latitude, last_longitude, Current_Mode, bibids_in_this_point, scriptBuilder);

                    // Clear the list of newspapers linked to this point
                    bibids_in_this_point.Clear();
                }
            }

            scriptBuilder.AppendLine("  }");
            scriptBuilder.AppendLine();
            scriptBuilder.AppendLine("  // Add a single point ");
            scriptBuilder.AppendLine("  function add_point(latitude, longitude, window_content) {");
            scriptBuilder.AppendLine("    var point = new google.maps.LatLng(latitude, longitude);");
            scriptBuilder.AppendLine("    bounds.extend(point);");
            scriptBuilder.AppendLine("    var marker = new google.maps.Marker({ position: point, draggable: false, map: map, icon: custom_icon });");
            scriptBuilder.AppendLine("    google.maps.event.addListener(marker, 'click', function() { info_window.setContent(window_content); last_center = map.getCenter(); info_window.open(map, marker); });");

            scriptBuilder.AppendLine("  }");
            scriptBuilder.AppendLine("  //]]>");
            scriptBuilder.AppendLine("</script>");
            scriptIncludeName = scriptBuilder.ToString();
        }
Beispiel #18
0
        private static string Menu_HTML_Helper(string SkinCode, Search_Type_Enum Search_Type, string Display_Text, SobekCM_Navigation_Object Current_Mode)
        {
            if (Current_Mode.Is_Robot)
            {
                if ((Current_Mode.Mode == Display_Mode_Enum.Search) && (Current_Mode.Search_Type == Search_Type))
                {
                    return("<li class=\"selected-sf-menu-item-link\"><a href=\"\">" + Display_Text + "</a></li>" + Environment.NewLine);
                }
                else
                {
                    return("<li><a href=\"\">" + Display_Text + "</a></li>" + Environment.NewLine);
                }
            }

            if ((Current_Mode.Mode == Display_Mode_Enum.Search) && (Current_Mode.Search_Type == Search_Type))
            {
                return("<li class=\"selected-sf-menu-item-link\"><a href=\"" + Current_Mode.Redirect_URL() + "\">" + Display_Text + "</a></li>" + Environment.NewLine);
            }

            // else...
            Search_Type_Enum  currentSearchType2 = Current_Mode.Search_Type;
            Display_Mode_Enum currentMode2       = Current_Mode.Mode;

            Current_Mode.Search_Type = Search_Type;
            Current_Mode.Mode        = Display_Mode_Enum.Search;
            string toReturn2 = "<li><a href=\"" + Current_Mode.Redirect_URL() + "\">" + Display_Text + "</a></li>" + Environment.NewLine;

            Current_Mode.Search_Type = currentSearchType2;
            Current_Mode.Mode        = currentMode2;
            return(toReturn2);
        }
Beispiel #19
0
        /// <summary> Constructor for a new instance of the Aliases_AdminViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="CurrentMode"> Mode / navigation information for the current request</param>
        /// <param name="Aggregation_Aliases"> Dictionary of all current item aggregation aliases </param>
        /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> Postback from handling an edit or new item aggregation alias is handled here in the constructor </remarks>
        public Aliases_AdminViewer(User_Object User, SobekCM_Navigation_Object CurrentMode, Dictionary <string, string> Aggregation_Aliases, Aggregation_Code_Manager Code_Manager, Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("Aliases_AdminViewer.Constructor", String.Empty);

            // Save the mode and settings  here
            currentMode        = CurrentMode;
            aggregationAliases = Aggregation_Aliases;

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

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

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

                    string save_value = form["admin_forwarding_tosave"].ToLower().Trim();
                    string new_alias  = form["admin_forwarding_alias"].ToLower().Trim();

                    // Was this a save request
                    if (save_value.Length > 0)
                    {
                        // If this starts with a '-' this is a delete
                        if (save_value[0] == '-')
                        {
                            if ((user.Is_System_Admin) && (save_value.Length > 1))
                            {
                                save_value = save_value.Substring(1);
                                Tracer.Add_Trace("Aliases_AdminViewer.Constructor", "Delete alias '" + save_value + "'");
                                if (SobekCM_Database.Delete_Aggregation_Alias(save_value, Tracer))
                                {
                                    if (aggregationAliases.ContainsKey(save_value))
                                    {
                                        aggregationAliases.Remove(save_value);
                                    }

                                    actionMessage = "Deleted existing aggregation alias <i>" + save_value + "</i>";
                                }
                            }
                        }
                        else
                        {
                            Tracer.Add_Trace("Aliases_AdminViewer.Constructor", "Save alias '" + save_value + "'");

                            // Was this to save a new alias (from the main page) or edit an existing (from the popup form)?
                            if (save_value == new_alias)
                            {
                                string new_code = form["admin_forwarding_code"].ToLower().Trim();

                                // Validate the code
                                if (new_code.Length > 20)
                                {
                                    actionMessage = "New alias code must be twenty characters long or less";
                                }
                                else if (new_code.Length == 0)
                                {
                                    actionMessage = "You must enter a CODE for this aggregation alias";
                                }
                                else if (Code_Manager[new_code.ToUpper()] != null)
                                {
                                    actionMessage = "Aggregation with this code already exists";
                                }
                                else if (SobekCM_Library_Settings.Reserved_Keywords.Contains(new_code.ToLower()))
                                {
                                    actionMessage = "That code is a system-reserved keyword.  Try a different code.";
                                }

                                // Save this new forwarding
                                if (SobekCM_Database.Save_Aggregation_Alias(save_value, new_code, Tracer))
                                {
                                    if (aggregationAliases.ContainsKey(save_value))
                                    {
                                        aggregationAliases[save_value] = new_code;
                                    }
                                    else
                                    {
                                        aggregationAliases.Add(save_value, new_code);
                                    }

                                    actionMessage = "Saved new aggregation alias <i>" + save_value + "</i>";
                                }
                                else
                                {
                                    actionMessage = "Unable to save new aggregation alias <i>" + save_value + "</i>";
                                }
                            }
                            else
                            {
                                string edit_code = form["form_forwarding_code"].ToLower().Trim();

                                // Save this existing forwarding
                                if (SobekCM_Database.Save_Aggregation_Alias(save_value, edit_code, Tracer))
                                {
                                    if (aggregationAliases.ContainsKey(save_value))
                                    {
                                        aggregationAliases[save_value] = edit_code;
                                    }
                                    else
                                    {
                                        aggregationAliases.Add(save_value, edit_code);
                                    }

                                    actionMessage = "Edited existing aggregation alias <i>" + save_value + "</i>";
                                }
                                else
                                {
                                    actionMessage = "Unable to save existing aggregation alias <i>" + save_value + "</i>";
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    actionMessage = "Unknown error caught while processing request";
                }
            }
        }
Beispiel #20
0
        /// <summary> Returns the HTML for one tab which appears over the search box in the collection view </summary>
        /// <param name="ThisView"> Collection view type for this tab </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request, to see if the tab is currently selected or not and determine current skin language </param>
        /// <param name="Translations"> Language support object for writing the name of the view in the appropriate interface language </param>
        /// <param name="Downward_Tabs"> Flag indicates if this tab faces downward, rather than the default upward </param>
        /// <returns> HTML to display the tab, including the link if it is not currently selected </returns>
        public static string Tabs2_Get_Nav_Bar_HTML(Item_Aggregation.CollectionViewsAndSearchesEnum ThisView, SobekCM_Navigation_Object Current_Mode, Language_Support_Info Translations, bool Downward_Tabs)
        {
            string skinCode = Current_Mode.Base_Skin;

            switch (ThisView)
            {
            case Item_Aggregation.CollectionViewsAndSearchesEnum.Advanced_Search:
            case Item_Aggregation.CollectionViewsAndSearchesEnum.Advanced_Search_YearRange:
                if (Current_Mode.Is_Robot)
                {
                    return("<img src=\"" + Current_Mode.Base_URL + "design/skins/" + skinCode + "/tabs/cL.gif\" border=\"0\" class=\"tab_image\" alt=\"\" /><span class=\"tab\"> ADVANCED SEARCH </span><img src=\"" + Current_Mode.Base_URL + "design/skins/" + skinCode + "/tabs/cR.gif\" border=\"0\" class=\"tab_image\" alt=\"\" />" + Environment.NewLine);
                }
                return(Tabs_HTML_Helper(skinCode, Search_Type_Enum.Advanced, Translations.Get_Translation("ADVANCED SEARCH", Current_Mode.Language), Current_Mode, Downward_Tabs));

            case Item_Aggregation.CollectionViewsAndSearchesEnum.Basic_Search:
            case Item_Aggregation.CollectionViewsAndSearchesEnum.Basic_Search_YearRange:
                return(Tabs_HTML_Helper(skinCode, Search_Type_Enum.Basic, Translations.Get_Translation("BASIC SEARCH", Current_Mode.Language), Current_Mode, Downward_Tabs));

            case Item_Aggregation.CollectionViewsAndSearchesEnum.Map_Search:
                return(Tabs_HTML_Helper(skinCode, Search_Type_Enum.Map, Translations.Get_Translation("MAP SEARCH", Current_Mode.Language), Current_Mode, Downward_Tabs));

            case Item_Aggregation.CollectionViewsAndSearchesEnum.Map_Search_Beta:
                return(Tabs_HTML_Helper(skinCode, Search_Type_Enum.Map_Beta, Translations.Get_Translation("MAP SEARCH", Current_Mode.Language), Current_Mode, Downward_Tabs));

            case Item_Aggregation.CollectionViewsAndSearchesEnum.Newspaper_Search:
                return(Tabs_HTML_Helper(skinCode, Search_Type_Enum.Newspaper, Translations.Get_Translation("NEWSPAPER SEARCH", Current_Mode.Language), Current_Mode, Downward_Tabs));

            case Item_Aggregation.CollectionViewsAndSearchesEnum.Admin_View:
                return(String.Empty);    // HTML_Helper(Skin_Code, SobekCM.Library.Navigation.Search_Type_Enum.Admin_View, Translations.Get_Translation("ADMIN", Current_Mode.Language), Current_Mode, Downward_Tabs);

            case Item_Aggregation.CollectionViewsAndSearchesEnum.DLOC_FullText_Search:
                return(Tabs_HTML_Helper(skinCode, Search_Type_Enum.dLOC_Full_Text, Translations.Get_Translation("TEXT SEARCH", Current_Mode.Language), Current_Mode, Downward_Tabs));

            case Item_Aggregation.CollectionViewsAndSearchesEnum.FullText_Search:
                return(Tabs_HTML_Helper(skinCode, Search_Type_Enum.Full_Text, Translations.Get_Translation("TEXT SEARCH", Current_Mode.Language), Current_Mode, Downward_Tabs));
            }

            return(String.Empty);
        }
Beispiel #21
0
        private static string HTML_Helper_PageView(string interface_code, string Viewer_Code, string Display_Text, SobekCM_Navigation_Object Current_Mode)
        {
            string previousViewerCode = Current_Mode.ViewerCode;

            Current_Mode.ViewerCode = Viewer_Code;
            string returnValue = "<a href=\"" + Current_Mode.Redirect_URL() + "\">" + Display_Text + "</a>";

            Current_Mode.ViewerCode = previousViewerCode;
            return(returnValue);
        }
Beispiel #22
0
        private static string Tabs_HTML_Helper(string SkinCode, Search_Type_Enum Search_Type, string Display_Text, SobekCM_Navigation_Object Current_Mode, bool Downward_Tabs)
        {
            if (Downward_Tabs)
            {
                if ((Current_Mode.Mode == Display_Mode_Enum.Search) && (Current_Mode.Search_Type == Search_Type))
                {
                    return("<img src=\"" + Current_Mode.Base_URL + "design/skins/" + SkinCode + "/tabs/cLD_s.gif\" border=\"0\" class=\"tab_image\" alt=\"\" /><span class=\"tab_s\"> " + Display_Text + " </span><img src=\"" + Current_Mode.Base_URL + "design/skins/" + SkinCode + "/tabs/cRD_s.gif\" border=\"0\" class=\"tab_image\" alt=\"\" />" + Environment.NewLine);
                }
                Search_Type_Enum  currentSearchType = Current_Mode.Search_Type;
                Display_Mode_Enum currentMode       = Current_Mode.Mode;
                Current_Mode.Search_Type = Search_Type;
                Current_Mode.Mode        = Display_Mode_Enum.Search;
                string toReturn = "<a href=\"" + Current_Mode.Redirect_URL() + "\"> " + "<img src=\"" + Current_Mode.Base_URL + "design/skins/" + SkinCode + "/tabs/cLD.gif\" border=\"0\" class=\"tab_image\" alt=\"\" /><span class=\"tab\"> " + Display_Text + " </span><img src=\"" + Current_Mode.Base_URL + "design/skins/" + SkinCode + "/tabs/cRD.gif\" border=\"0\" class=\"tab_image\" alt=\"\" /></a>" + Environment.NewLine;
                Current_Mode.Search_Type = currentSearchType;
                Current_Mode.Mode        = currentMode;
                return(toReturn);
            }

            if ((Current_Mode.Mode == Display_Mode_Enum.Search) && (Current_Mode.Search_Type == Search_Type))
            {
                return("<img src=\"" + Current_Mode.Base_URL + "design/skins/" + SkinCode + "/tabs/cL_s.gif\" border=\"0\" class=\"tab_image\" alt=\"\" /><span class=\"tab_s\"> " + Display_Text + " </span><img src=\"" + Current_Mode.Base_URL + "design/skins/" + SkinCode + "/tabs/cR_s.gif\" border=\"0\" class=\"tab_image\" alt=\"\" />" + Environment.NewLine);
            }

            // else...
            Search_Type_Enum  currentSearchType2 = Current_Mode.Search_Type;
            Display_Mode_Enum currentMode2       = Current_Mode.Mode;

            Current_Mode.Search_Type = Search_Type;
            Current_Mode.Mode        = Display_Mode_Enum.Search;
            string toReturn2 = "<a href=\"" + Current_Mode.Redirect_URL() + "\"> <img src=\"" + Current_Mode.Base_URL + "design/skins/" + SkinCode + "/tabs/cL.gif\" border=\"0\" class=\"tab_image\" alt=\"\" /><span class=\"tab\"> " + Display_Text + " </span><img src=\"" + Current_Mode.Base_URL + "design/skins/" + SkinCode + "/tabs/cR.gif\" border=\"0\" class=\"tab_image\" alt=\"\" /> </a>" + Environment.NewLine;

            Current_Mode.Search_Type = currentSearchType2;
            Current_Mode.Mode        = currentMode2;
            return(toReturn2);
        }
Beispiel #23
0
        private static string HTML_Helper(string interface_code, string Viewer_Code, string Display_Text, SobekCM_Navigation_Object Current_Mode)
        {
            if (Current_Mode.ViewerCode == Viewer_Code)
            {
                return("<li id=\"selected-sf-menu-item\">" + Display_Text + "</li>");
            }

            // When rendering for robots, provide the text and image, but not the text
            if (Current_Mode.Is_Robot)
            {
                return("<li class=\"selected-sf-menu-item\">" + Display_Text + "</li>");
            }

            string previousViewerCode = Current_Mode.ViewerCode;

            Current_Mode.ViewerCode = Viewer_Code;
            string returnValue = "<li><a href=\"" + Current_Mode.Redirect_URL() + "\">" + Display_Text + "</a></li>";

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

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

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

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

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

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

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

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

                            if (values_cleared == 0)
                            {
                                actionMessage = "Html skin <i>" + reset_value.ToUpper() + "</i> was not in the application cache";
                            }
                            else
                            {
                                actionMessage = "Removed " + values_cleared + " values from the cache for <i>" + reset_value.ToUpper() + "</i>";
                            }
                        }
                    }
                    else
                    {
                        // Or.. was this a save request
                        if (save_value.Length > 0)
                        {
                            Tracer.Add_Trace("Skins_AdminViewer.Constructor", "Save html skin '" + save_value + "'");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    actionMessage = "Edited existing html skin <i>" + save_value + "</i>";
                                }
                                else
                                {
                                    actionMessage = "Unable to edit existing html skin <i>" + save_value + "</i>";
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    actionMessage = "Unknown error caught while handing your request.";
                }
            }
        }
Beispiel #25
0
        /// <summary> Constructor for a new instance of the Static_Browse_Info_AggregationViewer class </summary>
        /// <param name="Browse_Object"> Browse or information object to be displayed </param>
        /// <param name="Static_Web_Content"> HTML content-based browse, info, or imple CMS-style web content objects.  These are objects which are read from a static HTML file and much of the head information must be maintained </param>
        /// <param name="Current_Collection"> Current collection being displayed</param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Current_User"> Current user/session information </param>
        public Static_Browse_Info_AggregationViewer(Item_Aggregation_Child_Page Browse_Object, HTML_Based_Content Static_Web_Content, Item_Aggregation Current_Collection, SobekCM_Navigation_Object Current_Mode, User_Object Current_User) : base(Current_Collection, Current_Mode)
        {
            browseObject     = Browse_Object;
            staticWebContent = Static_Web_Content;
            currentUser      = Current_User;

            bool isAdmin = (currentUser != null) && (currentUser.Is_Aggregation_Admin(currentCollection.Code));

            if ((currentMode.Aggregation_Type == Aggregation_Type_Enum.Child_Page_Edit) && (!isAdmin))
            {
                currentMode.Aggregation_Type = Aggregation_Type_Enum.Browse_Info;
            }

            NameValueCollection form = HttpContext.Current.Request.Form;

            if ((currentMode.Aggregation_Type == Aggregation_Type_Enum.Child_Page_Edit) && (form["sbkSbia_ChildTextEdit"] != null) && (currentUser != null))
            {
                string aggregation_folder = SobekCM_Library_Settings.Base_Design_Location + "aggregations\\" + currentCollection.Code + "\\";
                string file = aggregation_folder + browseObject.Get_Static_HTML_Source(currentMode.Language);

                // Get the header information as well
                if (!String.IsNullOrEmpty(form["admin_childpage_title"]))
                {
                    staticWebContent.Title = form["admin_childpage_title"];
                }
                if (form["admin_childpage_author"] != null)
                {
                    staticWebContent.Author = form["admin_childpage_author"];
                }
                if (form["admin_childpage_date"] != null)
                {
                    staticWebContent.Date = form["admin_childpage_date"];
                }
                if (form["admin_childpage_description"] != null)
                {
                    staticWebContent.Description = form["admin_childpage_description"];
                }
                if (form["admin_childpage_keywords"] != null)
                {
                    staticWebContent.Keywords = form["admin_childpage_keywords"];
                }
                if (form["admin_childpage_extrahead"] != null)
                {
                    staticWebContent.Extra_Head_Info = form["admin_childpage_extrahead"];
                }


                // Make a backup from today, if none made yet
                if (File.Exists(file))
                {
                    DateTime lastWrite = (new FileInfo(file)).LastWriteTime;
                    string   new_file  = file.ToLower().Replace(".txt", "").Replace(".html", "").Replace(".htm", "") + lastWrite.Year + lastWrite.Month.ToString().PadLeft(2, '0') + lastWrite.Day.ToString().PadLeft(2, '0') + ".bak";
                    if (File.Exists(new_file))
                    {
                        File.Delete(new_file);
                    }
                    File.Move(file, new_file);
                }


                // Assign the new text
                Static_Web_Content.Static_Text = form["sbkSbia_ChildTextEdit"];
                Static_Web_Content.Date        = DateTime.Now.ToLongDateString();
                Static_Web_Content.Save_To_File(file);

                // Also save this change
                SobekCM_Database.Save_Item_Aggregation_Milestone(currentCollection.Code, "Child page '" + browseObject.Code + "' edited (" + Web_Language_Enum_Converter.Enum_To_Name(currentMode.Language) + ")", currentUser.Full_Name);

                // Forward along
                currentMode.Aggregation_Type = Aggregation_Type_Enum.Browse_Info;
                if (Browse_Object.Browse_Type == Item_Aggregation_Child_Page.Visibility_Type.METADATA_BROWSE_BY)
                {
                    currentMode.Aggregation_Type = Aggregation_Type_Enum.Browse_By;
                }

                string redirect_url = currentMode.Redirect_URL();
                if (redirect_url.IndexOf("?") > 0)
                {
                    redirect_url = redirect_url + "&refresh=always";
                }
                else
                {
                    redirect_url = redirect_url + "?refresh=always";
                }
                currentMode.Request_Completed = true;
                HttpContext.Current.Response.Redirect(redirect_url, false);
                HttpContext.Current.ApplicationInstance.CompleteRequest();
            }
        }
        /// <summary> Returns a built collection viewer matching request </summary>
        /// <param name="ViewType"> Aggregation view type </param>
        /// <param name="Current_Aggregation"> Current item aggregation object </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request </param>
        /// <returns> Collection viewer that extends the <see cref="abstractAggregationViewer"/> class. </returns>
        public static abstractAggregationViewer Get_Viewer(Item_Aggregation.CollectionViewsAndSearchesEnum ViewType, Item_Aggregation Current_Aggregation, SobekCM_Navigation_Object Current_Mode)
        {
            switch (ViewType)
            {
            case Item_Aggregation.CollectionViewsAndSearchesEnum.Advanced_Search:
                return(new Advanced_Search_AggregationViewer(Current_Aggregation, Current_Mode));

            case Item_Aggregation.CollectionViewsAndSearchesEnum.Basic_Search:
                string frontBannerImage = Current_Aggregation.Front_Banner_Image(Current_Mode.Language);
                if ((frontBannerImage.Length > 0) && (Current_Aggregation.Highlights.Count > 0))
                {
                    return(new Rotating_Highlight_Search_AggregationViewer(Current_Aggregation, Current_Mode));
                }
                return(new Basic_Search_AggregationViewer(Current_Aggregation, Current_Mode));

            case Item_Aggregation.CollectionViewsAndSearchesEnum.FullText_Search:
                return(new Full_Text_Search_AggregationViewer(Current_Aggregation, Current_Mode));

            case Item_Aggregation.CollectionViewsAndSearchesEnum.No_Home_Search:
                return(new No_Search_AggregationViewer());

            case Item_Aggregation.CollectionViewsAndSearchesEnum.Newspaper_Search:
                return(new Newspaper_Search_AggregationViewer(Current_Aggregation, Current_Mode));

            case Item_Aggregation.CollectionViewsAndSearchesEnum.Map_Search:
                return(new Map_Search_AggregationViewer(Current_Aggregation, Current_Mode));

            case Item_Aggregation.CollectionViewsAndSearchesEnum.dLOC_FullText_Search:
                return(new dLOC_Search_AggregationViewer(Current_Aggregation, Current_Mode));

            default:
                return(null);
            }
        }
Beispiel #27
0
        protected void Page_Load(object Sender, EventArgs E)
        {
            // Pull out the http request
            HttpRequest request = HttpContext.Current.Request;

            if (String.IsNullOrEmpty(SobekCM_Database.Connection_String))
            {
                Custom_Tracer tracer = new Custom_Tracer();
                try
                {
                    tracer.Add_Trace("SobekCM_Page_Globals.Constructor", String.Empty);

                    // Don't really need to *build* these, so just define them as a new ones if null
                    if (Global.Checked_List == null)
                    {
                        Global.Checked_List = new Checked_Out_Items_List();
                    }
                    if (Global.Search_History == null)
                    {
                        Global.Search_History = new Recent_Searches();
                    }

                    // Make sure all the needed data is loaded into the Application State
                    Application_State_Builder.Build_Application_State(tracer, false, ref Global.Skins, ref Global.Translation,
                                                                      ref Global.Codes, ref Global.Item_List, ref Global.Icon_List,
                                                                      ref Global.Stats_Date_Range, ref Global.Thematic_Headings, ref Global.Collection_Aliases, ref Global.IP_Restrictions,
                                                                      ref Global.URL_Portals, ref Global.Mime_Types, ref Global.Item_Viewer_Priority);

                    tracer.Add_Trace("SobekCM_Page_Globals.Constructor", "Application State validated or built");

                    // Check that something is saved for the original requested URL (may not exist if not forwarded)
                    if (!HttpContext.Current.Items.Contains("Original_URL"))
                    {
                        HttpContext.Current.Items["Original_URL"] = request.Url.ToString();
                    }
                }
                catch (Exception ee)
                {
                    // Send to the dashboard
                    if ((HttpContext.Current.Request.UserHostAddress == "127.0.0.1") || (HttpContext.Current.Request.UserHostAddress == HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"]) || (HttpContext.Current.Request.Url.ToString().IndexOf("localhost") >= 0))
                    {
                        // Create an error message
                        string errorMessage;
                        if ((SobekCM_Library_Settings.Database_Connections.Count == 0) || (String.IsNullOrEmpty(SobekCM_Library_Settings.Database_Connections[0].Connection_String)))
                        {
                            errorMessage = "No database connection string found!";
                            string configFileLocation = AppDomain.CurrentDomain.BaseDirectory + "config/sobekcm.xml";
                            try
                            {
                                if (!File.Exists(configFileLocation))
                                {
                                    errorMessage = "Missing config/sobekcm.xml configuration file on the web server.<br />Ensure the configuration file 'sobekcm.xml' exists in a 'config' subfolder directly under the web application.<br />Example configuration is:" +
                                                   "<div style=\"background-color: #bbbbbb; margin-left: 30px; margin-top:10px; padding: 3px;\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;  ?&gt;<br /> &lt;configuration&gt;<br /> &nbsp; &nbsp &lt;connection_string type=&quot;MSSQL&quot;&gt;data source=localhost\\instance;initial catalog=SobekCM;integrated security=Yes;&lt;/connection_string&gt;<br /> &nbsp; &nbsp &lt;error_emails&gt;[email protected]&lt;/error_emails&gt;<br /> &nbsp; &nbsp &lt;error_page&gt;http://ufdc.ufl.edu/error.html&lt;/error_page&gt;<br />&lt;/configuration&gt;</div>";
                                }
                            }
                            catch
                            {
                                errorMessage = "No database connection string found.<br />Likely an error reading the configuration file due to permissions on the web server.<br />Ensure the configuration file 'sobekcm.xml' exists in a 'config' subfolder directly under the web application.<br />Example configuration is:" +
                                               "<div style=\"background-color: #bbbbbb; margin-left: 30px; margin-top:10px; padding: 3px;\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;  ?&gt;<br /> &lt;configuration&gt;<br /> &nbsp; &nbsp &lt;connection_string type=&quot;MSSQL&quot;&gt;data source=localhost\\instance;initial catalog=SobekCM;integrated security=Yes;&lt;/connection_string&gt;<br /> &nbsp; &nbsp &lt;error_emails&gt;[email protected]&lt;/error_emails&gt;<br /> &nbsp; &nbsp &lt;error_page&gt;http://ufdc.ufl.edu/error.html&lt;/error_page&gt;<br />&lt;/configuration&gt;</div>";
                            }
                        }
                        else
                        {
                            if (ee.Message.IndexOf("The EXECUTE permission") >= 0)
                            {
                                errorMessage = "Permissions error while connecting to the database and pulling necessary data.<br /><br />Confirm the following:<ul><li>IIS is configured correctly to use anonymous authentication</li><li>Anonymous user (or service account) is part of the sobek_users role in the database.</li></ul>";
                            }
                            else
                            {
                                errorMessage = "Error connecting to the database and pulling necessary data.<br /><br />Confirm the following:<ul><li>Database connection string is correct ( " + SobekCM_Library_Settings.Database_Connections[0].Connection_String + ")</li><li>IIS is configured correctly to use anonymous authentication</li><li>Anonymous user (or service account) is part of the sobek_users role in the database.</li></ul>";
                            }
                        }
                        // Wrap this into the SobekCM Exception
                        SobekCM_Traced_Exception newException = new SobekCM_Traced_Exception(errorMessage, ee, tracer);

                        // Save this to the session state, and then forward to the dashboard
                        HttpContext.Current.Session["Last_Exception"] = newException;
                        HttpContext.Current.Response.Redirect("dashboard.aspx", true);
                    }
                    else
                    {
                        throw ee;
                    }
                }
            }


            string bibID = null;
            string vid   = null;

            // Is this a robot?  They should never get access to files this way
            if (SobekCM_Navigation_Object.Is_UserAgent_IP_Robot(request.UserAgent, request.UserHostAddress))
            {
                Response.Clear();
                Response.Output.WriteLine("RESTRICTED ITEM");
                return;
            }

            // Get any url rewrite which occurred
            if (Request.QueryString["urlrelative"] != null)
            {
                string urlrewrite = Request.QueryString["urlrelative"].ToLower();
                if (urlrewrite.Length > 4)
                {
                    // Split the url relative list
                    string[]      url_relative_info = urlrewrite.Split("/".ToCharArray());
                    List <string> url_relative_list = (from thisPart in url_relative_info where thisPart.Length > 0 select thisPart.ToLower()).ToList();

                    // Now, look for BIBID and VID
                    //if ((SobekCM_Database.Verify_Item_Lookup_Object(true, ref Global.Item_List, null)) && (Global.Item_List.Contains_BibID(url_relative_list[2].ToUpper())))
                    if ((url_relative_list.Count > 2) && (url_relative_list[2].Length == 10))
                    {
                        // This is a BibID for an existing title with at least one public item
                        bibID = url_relative_list[2].ToUpper();

                        // Is the next part a VID?
                        if (url_relative_list.Count > 3)
                        {
                            string possible_vid = url_relative_list[3].Trim().PadLeft(5, '0');
                            int    vid_as_int;
                            if (Int32.TryParse(possible_vid, out vid_as_int))
                            {
                                vid = possible_vid;
                            }
                        }
                    }

                    // Only continue if there is a BibID / VID
                    if ((!String.IsNullOrEmpty(bibID)) && (!String.IsNullOrEmpty(vid)))
                    {
                        // Determine the new URL
                        StringBuilder urlBuilder = new StringBuilder(SobekCM_Library_Settings.Image_Server_Network + bibID.Substring(0, 2) + "\\" + bibID.Substring(2, 2) + "\\" + bibID.Substring(4, 2) + "\\" + bibID.Substring(6, 2) + "\\" + bibID.Substring(8) + "\\" + vid + "\\" + url_relative_list[4], 250);
                        for (int i = 5; i < url_relative_list.Count; i++)
                        {
                            urlBuilder.Append("\\" + url_relative_list[i]);
                        }

                        file_url = urlBuilder.ToString();


                        // Get the extension
                        string extension = Path.GetExtension(file_url);
                        if (extension != null)
                        {
                            // Lookup the MIME type by extension
                            Mime_Type_Info mimeType = null;
                            if (Global.Mime_Types.ContainsKey(extension.ToLower()))
                            {
                                mimeType = Global.Mime_Types[extension.ToLower()];
                            }

                            if ((mimeType != null) && (!mimeType.isBlocked))
                            {
                                // Since everything is valid, check the database
                                bool  isDark;
                                short restrictions;
                                SobekCM_Database.Get_Item_Restrictions(bibID, vid, null, out isDark, out restrictions);

                                // If not DARK, and is restricted, check for access here
                                if ((!isDark) && (restrictions > 0))
                                {
                                    // Does this user already have IP restriction mask determined?
                                    // Determine which IP Ranges this IP address belongs to, if not already determined.

                                    if (HttpContext.Current.Session["IP_Range_Membership"] == null)
                                    {
                                        int ip_mask = Global.IP_Restrictions.Restrictive_Range_Membership(request.UserHostAddress);
                                        HttpContext.Current.Session["IP_Range_Membership"] = ip_mask;
                                    }

                                    int current_user_mask = Convert.ToInt32(HttpContext.Current.Session["IP_Range_Membership"]);

                                    // Perform bitwise comparison
                                    int comparison = restrictions & current_user_mask;
                                    if (comparison == 0)
                                    {
                                        // If the user is Shibboleth authenticated, that is okay
                                        User_Object possible_user = HttpContext.Current.Session["user"] as User_Object;
                                        if ((possible_user == null) || (possible_user.Authentication_Type != User_Authentication_Type_Enum.Shibboleth))
                                        {
                                            isDark = true;
                                        }
                                    }
                                }

                                if (!isDark)
                                {
                                    // Should this be forwarded for this mimetype?
                                    if (mimeType.shouldForward)
                                    {
                                        StringBuilder forwardBuilder = new StringBuilder(SobekCM_Library_Settings.Image_URL + bibID.Substring(0, 2) + "/" + bibID.Substring(2, 2) + "/" + bibID.Substring(4, 2) + "/" + bibID.Substring(6, 2) + "/" + bibID.Substring(8) + "/" + vid + "/" + url_relative_list[4], 250);
                                        for (int i = 5; i < url_relative_list.Count; i++)
                                        {
                                            forwardBuilder.Append("/" + url_relative_list[i]);
                                        }
                                        Response.Redirect(forwardBuilder.ToString());
                                    }
                                    else
                                    {
                                        Response.Clear();
                                        Response.ContentType = mimeType.MIME_Type;

                                        string filename = file_url;

                                        if (File.Exists(filename))
                                        {
                                            using (FileStream sourceStream = File.OpenRead(filename))
                                            {
                                                sourceStream.CopyTo(Response.OutputStream, 32768);
                                            }
                                        }

                                        Response.End();
                                    }
                                }
                                else
                                {
                                    Response.Clear();
                                    Response.Output.WriteLine("RESTRICTED ITEM");
                                }
                            }
                        }
                    }
                }
            }

            //public static async Task CopyToAsync(this Stream source, Stream destination)
            //{
            //    int i = 0;
            //    var buffers = new [] { new byte[0x1000], new byte[0x1000] };
            //    Task writeTask = null;
            //    while(true)
            //    {
            //        var readTask = source.ReadAsync(buffers[i], 0, buffers[i].Length))>0;
            //        if (writeTask != null) await Task.WhenAll(readTask, writeTask);
            //        int bytesRead = await readTask;
            //        if (bytesRead == 0) break;
            //        writeTask = destination.WriteAsync(buffers[i], 0, bytesRead);
            //        i ^= 1; // swap buffers
            //    }
            //}
        }
        /// <summary> Returns a built collection viewer matching request </summary>
        /// <param name="SearchType"> Type of search from the current http request </param>
        /// <param name="Current_Aggregation"> Current item aggregation object </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request </param>
        /// <param name="Current_User"> Currently logged on user, if there is one </param>
        /// <returns> Collection viewer that extends the <see cref="abstractAggregationViewer"/> class. </returns>
        public static abstractAggregationViewer Get_Viewer(Search_Type_Enum SearchType, Item_Aggregation Current_Aggregation, SobekCM_Navigation_Object Current_Mode, User_Object Current_User)
        {
            switch (SearchType)
            {
            case Search_Type_Enum.Advanced:
                return(new Advanced_Search_AggregationViewer(Current_Aggregation, Current_Mode));

            case Search_Type_Enum.Basic:
                if ((Current_Aggregation.Front_Banner_Image(Current_Mode.Language).Length > 0) && (Current_Aggregation.Highlights.Count > 0))
                {
                    return(new Rotating_Highlight_Search_AggregationViewer(Current_Aggregation, Current_Mode));
                }
                return(new Basic_Search_AggregationViewer(Current_Aggregation, Current_Mode));

            case Search_Type_Enum.Full_Text:
                return(new Full_Text_Search_AggregationViewer(Current_Aggregation, Current_Mode));

            case Search_Type_Enum.Newspaper:
                return(new Newspaper_Search_AggregationViewer(Current_Aggregation, Current_Mode));

            case Search_Type_Enum.Map:
                return(new Map_Search_AggregationViewer(Current_Aggregation, Current_Mode));

            case Search_Type_Enum.dLOC_Full_Text:
                return(new dLOC_Search_AggregationViewer(Current_Aggregation, Current_Mode));

            default:
                return(null);
            }
        }
        /// <summary> Constructor for a new instance of the Map_Search_AggregationViewer class </summary>
        /// <param name="Current_Aggregation"> Current item aggregation object </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        public Map_Search_AggregationViewer(Item_Aggregation Current_Aggregation, SobekCM_Navigation_Object Current_Mode) : base(Current_Aggregation, Current_Mode)
        {
            // Compute the redirect stem to use
            string fields        = currentMode.Search_Fields;
            string search_string = currentMode.Search_String;

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

            currentMode.Mode          = Display_Mode_Enum.Search;
            currentMode.Search_String = search_string;
            currentMode.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 (currentMode.Search_String.Length > 0)
            {
                string[] splitter = currentMode.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();

            scriptBuilder.AppendLine("<script type=\"text/javascript\" src=\"http://maps.google.com/maps/api/js?v=3.2&sensor=false\"></script>");
            scriptBuilder.AppendLine("<script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/sobekcm_map_search.js\"></script>");
            scriptBuilder.AppendLine("<script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/sobekcm_map_tool.js\"></script>");

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

            switch (Current_Aggregation.Map_Search % 100)
            {
            case 0:      // WORLD
                scriptBuilder.AppendLine("    load_search_map(0, 0, 1, \"map1\");");
                break;

            case 1:      // FLORIDA
                scriptBuilder.AppendLine("    load_search_map(28, -84.5, 6, \"map1\");");
                break;

            case 2:      // UNITED STATES
                scriptBuilder.AppendLine("    load_search_map(48, -95, 3, \"map1\");");
                break;

            case 3:      // NORTH AMERICA
                scriptBuilder.AppendLine("    load_search_map(48, -95, 3, \"map1\");");
                mapHeight = 600;
                break;

            case 4:      // CARIBBEAN
                scriptBuilder.AppendLine("    load_search_map(19, -74, 4, \"map1\");");
                break;

            case 5:      // SOUTH AMERICA
                scriptBuilder.AppendLine("    load_search_map(-22, -60, 3, \"map1\");");
                mapHeight = 600;
                break;

            case 6:       // AFRICA
                scriptBuilder.AppendLine("    load_search_map(6, 19.5, 3, \"map1\");");
                mapHeight = 600;
                break;

            case 7:       // EUROPE
                scriptBuilder.AppendLine("    load_search_map(49.5, 13.35, 4, \"map1\");");
                break;

            case 8:       // ASIA
                scriptBuilder.AppendLine("    load_search_map(36, 96, 3, \"map1\");");
                break;

            case 9:       // MIDDLE EAST
                scriptBuilder.AppendLine("    load_search_map(31, 39, 4, \"map1\");");
                break;
            }

            // If no point searching is allowed, disable it
            if (currentCollection.Map_Search >= 100)
            {
                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>");
            scriptIncludeName = scriptBuilder.ToString();

            // Get the action name for the button
            scriptActionName = "map_search_sobekcm('" + redirect_stem + "');";
        }
        /// <summary> Constructor for a new instance of the Aggregations_Mgmt_AdminViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="CurrentMode"> Mode / navigation information for the current request</param>
        /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param>
        /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the home page are organized </param>       
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> Postback from handling an edit or new aggregation is handled here in the constructor </remarks>
        public Aggregations_Mgmt_AdminViewer(User_Object User, SobekCM_Navigation_Object CurrentMode, Aggregation_Code_Manager Code_Manager, List<Thematic_Heading> Thematic_Headings, Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("Aggregations_Mgmt_AdminViewer.Constructor", String.Empty);

            codeManager = Code_Manager;
            currentMode = CurrentMode;
            thematicHeadings = Thematic_Headings;

            // Set some defaults
            actionMessage = String.Empty;
            enteredCode = String.Empty;
            enteredParent = String.Empty;
            enteredType = String.Empty;
            enteredShortname = String.Empty;
            enteredName = String.Empty;
            enteredDescription = String.Empty;
            enteredIsActive = false;
            enteredIsHidden = false;

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

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

                    string save_value = form["admin_aggr_tosave"].ToUpper().Trim();
                    string new_aggregation_code = String.Empty;
                    if ( form["admin_aggr_code"] != null )
                        new_aggregation_code = form["admin_aggr_code"].ToUpper().Trim();

                    // Check for reset request as well
                    string reset_aggregation_code = String.Empty;
                    if (form["admin_aggr_reset"] != null)
                        reset_aggregation_code = form["admin_aggr_reset"].ToLower().Trim();

                    string delete_aggregation_code = String.Empty;
                    if (form["admin_aggr_delete"] != null)
                        delete_aggregation_code = form["admin_aggr_delete"].ToLower().Trim();

                    // Was this to delete the aggregation?
                    if ( delete_aggregation_code.Length > 0)
                    {
                        string delete_error;
                        int errorCode = SobekCM_Database.Delete_Item_Aggregation(delete_aggregation_code, user.Is_System_Admin, user.Full_Name, Tracer, out delete_error);
                        if (errorCode <= 0)
                        {
                            string delete_folder = SobekCM_Library_Settings.Base_Design_Location + "aggregations\\" + delete_aggregation_code;
                            if (SobekCM_File_Utilities.Delete_Folders_Recursively(delete_folder))
                                actionMessage = "Deleted '" + delete_aggregation_code + "' aggregation<br /><br />Unable to remove aggregation directory<br /><br />Some of the files may be in use";
                            else
                                actionMessage = "Deleted '" + delete_aggregation_code + "' aggregation";
                        }
                        else
                        {
                            actionMessage = delete_error;
                        }

                        // Reload the list of all codes, to include this new one and the new hierarchy
                        lock (codeManager)
                        {
                            SobekCM_Database.Populate_Code_Manager(codeManager, Tracer);
                        }
                    }

                    // If there is a reset request here, purge the aggregation from the cache
                    if (reset_aggregation_code.Length > 0)
                    {
                        Cached_Data_Manager.Remove_Item_Aggregation(reset_aggregation_code, Tracer);
                    }

                    // If there was a save value continue to pull the rest of the data
                    if (save_value.Length > 0)
                    {

                        bool is_active = false;
                        bool is_hidden = true;

                        // Was this to save a new aggregation (from the main page) or edit an existing (from the popup form)?
                        if (save_value == new_aggregation_code)
                        {

                            // Pull the values from the submitted form
                            string new_type = form["admin_aggr_type"];
                            string new_parent = form["admin_aggr_parent"].Trim();
                            string new_name = form["admin_aggr_name"].Trim();
                            string new_shortname = form["admin_aggr_shortname"].Trim();
                            string new_description = form["admin_aggr_desc"].Trim();
                            string new_link = form["admin_aggr_link"].Trim();

                            object temp_object = form["admin_aggr_isactive"];
                            if (temp_object != null)
                            {
                                is_active = true;
                            }

                            temp_object = form["admin_aggr_ishidden"];
                            if (temp_object != null)
                            {
                                is_hidden = false;
                            }

                            // Convert to the integer id for the parent and begin to do checking
                            List<string> errors = new List<string>();
                            int parentid = -1;
                            if (new_parent.Length > 0)
                            {
                                try
                                {
                                    parentid = Convert.ToInt32(new_parent);
                                }
                                catch
                                {
                                    errors.Add("Invalid parent id selected!");
                                }
                            }
                            else
                            {
                                errors.Add("You must select a PARENT for this new aggregation");
                            }

                            // Validate the code
                            if (new_aggregation_code.Length > 20)
                            {
                                errors.Add("New aggregation code must be twenty characters long or less");
                            }
                            else if (new_aggregation_code.Length == 0)
                            {
                                errors.Add("You must enter a CODE for this item aggregation");

                            }
                            else if (codeManager[new_aggregation_code.ToUpper()] != null)
                            {
                                errors.Add("New code must be unique... <i>" + new_aggregation_code + "</i> already exists");
                            }
                            else if (SobekCM_Library_Settings.Reserved_Keywords.Contains(new_aggregation_code.ToLower()))
                            {
                                errors.Add("That code is a system-reserved keyword.  Try a different code.");
                            }

                            // Was there a type and name
                            if (new_type.Length == 0)
                            {
                                errors.Add("You must select a TYPE for this new aggregation");
                            }
                            if (new_description.Length == 0)
                            {
                                errors.Add("You must enter a DESCRIPTION for this new aggregation");
                            }
                            if (new_name.Length == 0)
                            {
                                errors.Add("You must enter a NAME for this new aggregation");
                            }
                            else
                            {
                                if (new_shortname.Length == 0)
                                    new_shortname = new_name;
                            }

                            if (errors.Count > 0)
                            {
                                // Create the error message
                                actionMessage = "ERROR: Invalid entry for new item aggregation<br />";
                                foreach (string error in errors)
                                    actionMessage = actionMessage + "<br />" + error;

                                // Save all the values that were entered
                                enteredCode = new_aggregation_code;
                                enteredDescription = new_description;
                                enteredIsActive = is_active;
                                enteredIsHidden = is_hidden;
                                enteredName = new_name;
                                enteredParent = new_parent;
                                enteredShortname = new_shortname;
                                enteredType = new_type;
                                enteredLink = new_link;
                            }
                            else
                            {
                                // Get the correct type
                                string correct_type = "Collection";
                                switch (new_type)
                                {
                                    case "coll":
                                        correct_type = "Collection";
                                        break;

                                    case "group":
                                        correct_type = "Collection Group";
                                        break;

                                    case "subcoll":
                                        correct_type = "SubCollection";
                                        break;

                                    case "inst":
                                        correct_type = "Institution";
                                        break;

                                    case "exhibit":
                                        correct_type = "Exhibit";
                                        break;

                                    case "subinst":
                                        correct_type = "Institutional Division";
                                        break;
                                }
                                // Make sure inst and subinst start with 'i'
                                if (new_type.IndexOf("inst") >= 0)
                                {
                                    if (new_aggregation_code[0] == 'I')
                                        new_aggregation_code = "i" + new_aggregation_code.Substring(1);
                                    if (new_aggregation_code[0] != 'i')
                                        new_aggregation_code = "i" + new_aggregation_code;
                                }

                                // Get the thematic heading id (no checks here)
                                int thematicHeadingId = -1;
                                if (form["admin_aggr_heading"] != null)
                                    thematicHeadingId = Convert.ToInt32(form["admin_aggr_heading"]);

                                // Try to save the new item aggregation
                                if (SobekCM_Database.Save_Item_Aggregation(new_aggregation_code, new_name, new_shortname, new_description, thematicHeadingId, correct_type, is_active, is_hidden, new_link, parentid, user.Full_Name, Tracer))
                                {
                                    // Ensure a folder exists for this, otherwise create one
                                    try
                                    {
                                        string folder = SobekCM_Library_Settings.Base_Design_Location + "aggregations\\" + new_aggregation_code.ToLower();
                                        if (!Directory.Exists(folder))
                                        {
                                            // Create this directory and all the subdirectories
                                            Directory.CreateDirectory(folder);
                                            Directory.CreateDirectory(folder + "/html");
                                            Directory.CreateDirectory(folder + "/images");
                                            Directory.CreateDirectory(folder + "/html/home");
                                            Directory.CreateDirectory(folder + "/images/buttons");
                                            Directory.CreateDirectory(folder + "/images/banners");

                                            // Create a default home text file
                                            StreamWriter writer = new StreamWriter(folder + "/html/home/text.html");
                                            writer.WriteLine("<br />New collection home page text goes here.<br /><br />To edit this, log on as the aggregation admin and hover over this text to edit it.<br /><br />");
                                            writer.Flush();
                                            writer.Close();

                                            // Copy the default banner and buttons from images
                                            if (File.Exists(SobekCM_Library_Settings.Base_Directory + "default/images/default_button.png"))
                                                File.Copy(SobekCM_Library_Settings.Base_Directory + "default/images/default_button.png", folder + "/images/buttons/coll.png");
                                            if (File.Exists(SobekCM_Library_Settings.Base_Directory + "default/images/default_button.gif"))
                                                File.Copy(SobekCM_Library_Settings.Base_Directory + "default/images/default_button.gif", folder + "/images/buttons/coll.gif");

                                            // Try to create a new custom banner
                                            bool custom_banner_created = false;
                                            // Create the banner with the name of the collection
                                            if (Directory.Exists(SobekCM_Library_Settings.Application_Server_Network + "\\default\\banner_images"))
                                            {
                                                try
                                                {
                                                    string[] banners = Directory.GetFiles(SobekCM_Library_Settings.Application_Server_Network + "\\default\\banner_images", "*.jpg");
                                                    if (banners.Length > 0)
                                                    {
                                                        Random randomizer = new Random();
                                                        string banner_to_use = banners[randomizer.Next(0, banners.Length - 1)];
                                                        Bitmap bitmap = (Bitmap)System.Drawing.Bitmap.FromFile(banner_to_use);

                                                        RectangleF rectf = new RectangleF(30, bitmap.Height - 55, bitmap.Width - 40, 40);
                                                        Graphics g = Graphics.FromImage(bitmap);
                                                        g.SmoothingMode = SmoothingMode.AntiAlias;
                                                        g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                                                        g.PixelOffsetMode = PixelOffsetMode.HighQuality;
                                                        g.DrawString(new_name, new Font("Tahoma", 25, FontStyle.Bold), Brushes.Black, rectf);
                                                        g.Flush();

                                                        string new_file = folder + "/images/banners/coll.jpg";
                                                        if (!File.Exists(new_file))
                                                        {
                                                            bitmap.Save(new_file, ImageFormat.Jpeg);
                                                            custom_banner_created = true;
                                                        }
                                                    }
                                                }
                                                catch (Exception ee)
                                                {
                                                    string msg = ee.Message;
                                                }
                                            }

                                            if ((!custom_banner_created) && (!File.Exists(folder + "/images/banners/coll.jpg")))
                                            {
                                                if (File.Exists(SobekCM_Library_Settings.Base_Directory + "default/images/default_banner.jpg"))
                                                    File.Copy(SobekCM_Library_Settings.Base_Directory + "default/images/default_banner.jpg", folder + "/images/banners/coll.jpg");
                                            }

                                            // Now, try to create the item aggregation and write the configuration file
                                            Item_Aggregation itemAggregation = Item_Aggregation_Builder.Get_Item_Aggregation(new_aggregation_code, String.Empty, null, false, false, Tracer);
                                            itemAggregation.Write_Configuration_File(SobekCM_Library_Settings.Base_Design_Location + itemAggregation.ObjDirectory);
                                        }
                                    }
                                    catch
                                    {
                                        actionMessage = "ERROR saving the new item aggregation to the database";
                                    }

                                    // Reload the list of all codes, to include this new one and the new hierarchy
                                    lock (codeManager)
                                    {
                                        SobekCM_Database.Populate_Code_Manager(codeManager, Tracer);
                                    }
                                    if ( !String.IsNullOrEmpty(actionMessage))
                                        actionMessage = "New item aggregation <i>" + new_aggregation_code + "</i> saved successfully";
                                }
                                else
                                {
                                    actionMessage = "ERROR saving the new item aggregation to the database";
                                }
                            }
                        }
                    }
                }
                catch
                {
                    actionMessage = "General error while reading postback information";
                }
            }
        }