Пример #1
0
        /// <summary> Resets all the application-level data  </summary>
        public static void ResetAll()
        {
            Engine_ApplicationCache_Gateway.RefreshAll();

            WebContent_Hierarchy_Clear();

            ItemViewer_Factory.Clear();

            HtmlLayoutManager.Clear();
        }
        /// <summary> Constructor for a new instance of the JPEG_ItemViewer class, used to display JPEGs linked to
        /// pages in a digital resource </summary>
        /// <param name="BriefItem"> Digital resource object </param>
        /// <param name="CurrentUser"> Current user, who may or may not be logged on </param>
        /// <param name="CurrentRequest"> Information about the current request </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        /// <param name="JPEG_ViewerCode"> JPEG viewer code, as determined by configuration files </param>
        /// <param name="FileExtensions"> File extensions that this viewer allows, as determined by configuration files </param>
        public JPEG_ItemViewer(BriefItemInfo BriefItem, User_Object CurrentUser, Navigation_Object CurrentRequest, Custom_Tracer Tracer, string JPEG_ViewerCode, string[] FileExtensions)
        {
            // Add the trace
            if (Tracer != null)
            {
                Tracer.Add_Trace("JPEG_ItemViewer.Constructor");
            }

            // Save the arguments for use later
            this.BriefItem      = BriefItem;
            this.CurrentUser    = CurrentUser;
            this.CurrentRequest = CurrentRequest;

            // Set the behavior properties
            Behaviors = EmptyBehaviors;

            // Is the JPEG2000 viewer included in this item?
            bool zoomableViewerIncluded = BriefItem.UI.Includes_Viewer_Type("JPEG2000");

            string[] jpeg2000_extensions = null;
            if (zoomableViewerIncluded)
            {
                iItemViewerPrototyper jp2Prototyper = ItemViewer_Factory.Get_Viewer_By_ViewType("JPEG2000");
                if (jp2Prototyper == null)
                {
                    zoomableViewerIncluded = false;
                }
                else
                {
                    zoomableViewerCode  = jp2Prototyper.ViewerCode;
                    jpeg2000_extensions = jp2Prototyper.FileExtensions;
                }
            }

            // Set some default values
            width  = 500;
            height = -1;
            includeLinkToZoomable = false;

            // Determine the page
            page = 1;
            if (!String.IsNullOrEmpty(CurrentRequest.ViewerCode))
            {
                int tempPageParse;
                if (Int32.TryParse(CurrentRequest.ViewerCode.Replace(JPEG_ViewerCode.Replace("#", ""), ""), out tempPageParse))
                {
                    page = tempPageParse;
                }
            }

            // Just a quick range check
            if (page > BriefItem.Images.Count)
            {
                page = 1;
            }

            // Try to set the file information here
            if ((!set_file_information(FileExtensions, zoomableViewerIncluded, jpeg2000_extensions)) && (page != 1))
            {
                // If there was an error, just set to the first page
                page = 1;
                set_file_information(FileExtensions, zoomableViewerIncluded, jpeg2000_extensions);
            }

            // Since this is a paging viewer, set the viewer code
            if (String.IsNullOrEmpty(CurrentRequest.ViewerCode))
            {
                CurrentRequest.ViewerCode = JPEG_ViewerCode.Replace("#", page.ToString());
            }
        }
Пример #3
0
        /// <summary> Writes the tracking tabs for all these related viewers </summary>
        /// <param name="Output"> Response stream for the item viewer to write directly to </param>
        /// <param name="CurrentRequest"> Information about the current request </param>
        /// <param name="BriefItem"> Digital resource object </param>
        public static void Write_Tracking_Tabs(TextWriter Output, Navigation_Object CurrentRequest, BriefItemInfo BriefItem)
        {
            // Set the text
            const string MILESTONES_VIEW = "MILESTONES";
            const string TRACKING_VIEW   = "HISTORY";
            const string MEDIA_VIEW      = "MEDIA";
            const string ARCHIVE_VIEW    = "ARCHIVES";
            const string DIRECTORY_VIEW  = "DIRECTORY";

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

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

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

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

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

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

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

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

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

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

            CurrentRequest.ViewerCode = viewer_code;
        }
        public void Add_Main_Menu(TextWriter Output, string CurrentCode, bool ItemRestrictedFromUserByIP, bool ItemCheckedOutByOtherUser, BriefItemInfo CurrentItem, Navigation_Object CurrentMode, User_Object CurrentUser, bool Include_Links, Custom_Tracer Tracer)
        {
            // Can this user (if there is one) edit this item?
            bool canManage = (CurrentUser != null) && (CurrentUser.Can_Edit_This_Item(CurrentItem.BibID, CurrentItem.Type, CurrentItem.Behaviors.Source_Institution_Aggregation, CurrentItem.Behaviors.Holding_Location_Aggregation, CurrentItem.Behaviors.Aggregation_Code_List));

            // Add the item views
            Output.WriteLine("<!-- Add the different view and social options -->");
            Output.WriteLine("<nav class=\"sbkMenu_Bar\" id=\"sbkIsw_MenuBar\" role=\"navigation\" aria-label=\"Item menu\">");
            Output.WriteLine("\t<h2 class=\"hidden-element\">Item menu</h2>");

            // Add the sharing buttons if this is not restricted by IP address or checked out
            if ((!ItemRestrictedFromUserByIP) && (!ItemCheckedOutByOtherUser) && (!CurrentMode.Is_Robot))
            {
                string add_text    = "Add";
                string remove_text = "Remove";
                string send_text   = "Send";
                string print_text  = "Print";
                if (canManage)
                {
                    add_text    = String.Empty;
                    remove_text = String.Empty;
                    send_text   = String.Empty;
                    print_text  = String.Empty;
                }

                string logOnUrl   = String.Empty;
                bool   isLoggedOn = CurrentUser != null && CurrentUser.LoggedOn;
                if (!isLoggedOn)
                {
                    string returnUrl = UrlWriterHelper.Redirect_URL(CurrentMode);

                    CurrentMode.Mode          = Display_Mode_Enum.My_Sobek;
                    CurrentMode.My_Sobek_Type = My_Sobek_Type_Enum.Logon;
                    CurrentMode.Return_URL    = returnUrl;
                    logOnUrl               = UrlWriterHelper.Redirect_URL(CurrentMode);
                    CurrentMode.Mode       = Display_Mode_Enum.Item_Display;
                    CurrentMode.Return_URL = String.Empty;
                }

                Output.WriteLine("\t<div id=\"menu-right-actions\">");

                if ((CurrentItem.Web != null) && (CurrentItem.Web.ItemID > 0))
                {
                    string print_item_form_open_url = UI_ApplicationCache_Gateway.Settings.Servers.Engine_URL + "items/html/print/" + CurrentItem.BibID + "/" + CurrentItem.VID + "/" + CurrentMode.ViewerCode;
                    Output.WriteLine("\t\t<span id=\"printbuttonitem\" class=\"action-sf-menu-item\" onclick=\"print_form_open('" + print_item_form_open_url + "');\"><img src=\"" + Static_Resources_Gateway.Printer_Png + "\" alt=\"\" style=\"vertical-align:middle\" /><span id=\"printbuttonspan\">" + print_text + "</span></span>");
                }
                else
                {
                    Output.WriteLine("\t\t<span id=\"printbuttonitem\" class=\"action-sf-menu-item\" onclick=\"window.print();return false;\"><img src=\"" + Static_Resources_Gateway.Printer_Png + "\" alt=\"\" style=\"vertical-align:middle\" /><span id=\"printbuttonspan\">" + print_text + "</span></span>");
                }


                if (isLoggedOn)
                {
                    string email_item_form_open_url = UI_ApplicationCache_Gateway.Settings.Servers.Engine_URL + "items/html/send/" + CurrentItem.BibID + "/" + CurrentItem.VID;
                    Output.WriteLine("\t\t<span id=\"sendbuttonitem\" class=\"action-sf-menu-item\" onclick=\"email_form_open('" + email_item_form_open_url + "');\"><img src=\"" + Static_Resources_Gateway.Email_Png + "\" alt=\"\" style=\"vertical-align:middle\" /><span id=\"sendbuttonspan\">" + send_text + "</span></span>");


                    if ((CurrentItem.Web != null) && (CurrentItem.Web.ItemID > 0))
                    {
                        if (CurrentUser.Is_In_Bookshelf(CurrentItem.BibID, CurrentItem.VID))
                        {
                            Output.WriteLine("\t\t<span id=\"addbuttonitem\" class=\"action-sf-menu-item\" onclick=\"return remove_item_itemviewer();\"><img src=\"" + Static_Resources_Gateway.Minussign_Png + "\" alt=\"\" style=\"vertical-align:middle\" /><span id=\"addbuttonspan\">" + remove_text + "</span></span>");
                        }
                        else
                        {
                            // Determine the URL
                            string add_item_form_open_url = UI_ApplicationCache_Gateway.Settings.Servers.Engine_URL + "items/html/bookshelf/" + CurrentUser.UserID + "/" + CurrentItem.BibID + "/" + CurrentItem.VID;
                            Output.WriteLine("\t\t<span id=\"addbuttonitem\" class=\"action-sf-menu-item\" onclick=\"add_item_form_open('" + add_item_form_open_url + "');return false;\"><img src=\"" + Static_Resources_Gateway.Plussign_Png + "\" alt=\"\" style=\"vertical-align:middle\" /><span id=\"addbuttonspan\">" + add_text + "</span></span>");
                        }
                    }
                }
                else
                {
                    Output.WriteLine("\t\t<span id=\"sendbuttonitem\" class=\"action-sf-menu-item\" onclick=\"window.location='" + logOnUrl + "';return false;\"><img src=\"" + Static_Resources_Gateway.Email_Png + "\" alt=\"\" style=\"vertical-align:middle\" /><span id=\"sendbuttonspan\">" + send_text + "</span></span>");

                    if ((CurrentItem.Web != null) && (CurrentItem.Web.ItemID > 0))
                    {
                        Output.WriteLine("\t\t<span id=\"addbuttonitem\" class=\"action-sf-menu-item\" onclick=\"window.location='" + logOnUrl + "';return false;\"><img src=\"" + Static_Resources_Gateway.Plussign_Png + "\" alt=\"\" style=\"vertical-align:middle\" /><span id=\"addbuttonspan\">" + add_text + "</span></span>");
                    }
                }

                string share_item_form_open_url = UI_ApplicationCache_Gateway.Settings.Servers.Engine_URL + "items/html/share/" + CurrentItem.BibID + "/" + CurrentItem.VID;
                Output.WriteLine("\t\t<span id=\"sharebuttonitem\" class=\"action-sf-menu-item\" onclick=\"toggle_share_form('share_button', '" + share_item_form_open_url + "');\"><span id=\"sharebuttonspan\">Share</span></span>");


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


            Output.WriteLine("\t<ul class=\"sf-menu\" id=\"sbkIhs_Menu\">");


            // Save the current view type
            ushort page       = CurrentMode.Page.HasValue ? CurrentMode.Page.Value : (ushort)1;
            ushort subpage    = CurrentMode.SubPage.HasValue ? CurrentMode.SubPage.Value : (ushort)1;
            string viewerCode = CurrentMode.ViewerCode;

            CurrentMode.SubPage = 0;

            // Add any PRE-MENU instance options
            string first_pre_menu_option  = String.Empty;
            string second_pre_menu_option = String.Empty;
            string third_pre_menu_option  = String.Empty;

            if (UI_ApplicationCache_Gateway.Settings.Contains_Additional_Setting("Item Viewer.Static First Menu Item"))
            {
                first_pre_menu_option = UI_ApplicationCache_Gateway.Settings.Get_Additional_Setting("Item Viewer.Static First Menu Item");
            }
            if (UI_ApplicationCache_Gateway.Settings.Contains_Additional_Setting("Item Viewer.Static Second Menu Item"))
            {
                second_pre_menu_option = UI_ApplicationCache_Gateway.Settings.Get_Additional_Setting("Item Viewer.Static Second Menu Item");
            }
            if (UI_ApplicationCache_Gateway.Settings.Contains_Additional_Setting("Item Viewer.Static Third Menu Item"))
            {
                third_pre_menu_option = UI_ApplicationCache_Gateway.Settings.Get_Additional_Setting("Item Viewer.Static Third Menu Item");
            }
            if ((first_pre_menu_option.Length > 0) || (second_pre_menu_option.Length > 0) || (third_pre_menu_option.Length > 0))
            {
                if (first_pre_menu_option.Length > 0)
                {
                    string[] first_splitter = first_pre_menu_option.Replace("[", "").Replace("]", "").Split(";".ToCharArray());
                    if (first_splitter.Length > 0)
                    {
                        Output.WriteLine("\t\t<li><a href=\"" + first_splitter[1] + "\" title=\"" + HttpUtility.HtmlEncode(first_splitter[0]) + "\">" + HttpUtility.HtmlEncode(first_splitter[0]) + "</a></li>");
                    }
                }
                if (second_pre_menu_option.Length > 0)
                {
                    string[] second_splitter = second_pre_menu_option.Replace("[", "").Replace("]", "").Split(";".ToCharArray());
                    if (second_splitter.Length > 0)
                    {
                        Output.WriteLine("\t\t<li><a href=\"" + second_splitter[1] + "\" title=\"" + HttpUtility.HtmlEncode(second_splitter[0]) + "\">" + HttpUtility.HtmlEncode(second_splitter[0]) + "</a></li>");
                    }
                }
                if (third_pre_menu_option.Length > 0)
                {
                    string[] third_splitter = third_pre_menu_option.Replace("[", "").Replace("]", "").Split(";".ToCharArray());
                    if (third_splitter.Length > 0)
                    {
                        Output.WriteLine("\t\t<li><a href=\"" + third_splitter[1] + "\" title=\"" + HttpUtility.HtmlEncode(third_splitter[0]) + "\">" + HttpUtility.HtmlEncode(third_splitter[0]) + "</a></li>");
                    }
                }
            }

            // Add the item level viewers - collect the menu portions
            List <Item_MenuItem> menuItems = new List <Item_MenuItem>();

            foreach (string viewType in CurrentItem.UI.Viewers_Menu_Order)
            {
                iItemViewerPrototyper prototyper = ItemViewer_Factory.Get_Viewer_By_ViewType(viewType);
                if (prototyper.Has_Access(CurrentItem, CurrentUser, ItemRestrictedFromUserByIP))
                {
                    prototyper.Add_Menu_Items(CurrentItem, CurrentUser, CurrentMode, menuItems, ItemRestrictedFromUserByIP);
                }
            }

            // Now, get ready to start adding the menu items
            Dictionary <string, List <Item_MenuItem> > topMenuToChildren = new Dictionary <string, List <Item_MenuItem> >(StringComparer.OrdinalIgnoreCase);

            foreach (Item_MenuItem menuItem in menuItems)
            {
                if (topMenuToChildren.ContainsKey(menuItem.MenuStripText))
                {
                    topMenuToChildren[menuItem.MenuStripText].Add(menuItem);
                }
                else
                {
                    topMenuToChildren[menuItem.MenuStripText] = new List <Item_MenuItem> {
                        menuItem
                    };
                }
            }

            // Now, step through the menu items
            foreach (Item_MenuItem topMenuItem in menuItems)
            {
                HTML_Helper(Output, topMenuItem, CurrentMode, CurrentCode, topMenuToChildren, Include_Links);
            }

            // Set current submode back
            CurrentMode.Page       = page;
            CurrentMode.ViewerCode = viewerCode;
            CurrentMode.SubPage    = subpage;

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


            Output.WriteLine("<!-- Initialize the main item menu -->");
            Output.WriteLine("<script>");
            Output.WriteLine("\tjQuery(document).ready(function () { jQuery('ul.sf-menu').superfish(); });");
            Output.WriteLine("</script>");
            Output.WriteLine();
        }