コード例 #1
0
        /// <summary> Performs the final HTML writing which completes the item table and adds the final page navigation buttons at the bottom of the page </summary>
        /// <param name="Main_PlaceHolder"> Main place holder ( &quot;mainPlaceHolder&quot; ) in the itemNavForm form, widely used throughout the application</param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        public void Add_Main_Viewer_Section(PlaceHolder Main_PlaceHolder, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Item_HtmlSubwriter.Add_Main_Viewer_Section", "Rendering HTML ( add any controls which the item viewer needs to add )");

            // Add the main viewer section
            if ( PageViewer != null)
            {
                // Was this to draw a fragment?
                if ( !String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.Fragment))
                {
                    switch( RequestSpecificValues.Current_Mode.Fragment )
                    {
                        case "printform":
                            PrintForm_Fragment_ItemViewer printform_viewer = new PrintForm_Fragment_ItemViewer(RequestSpecificValues.Current_Page, PageViewer) {CurrentItem = RequestSpecificValues.Current_Item, CurrentMode = RequestSpecificValues.Current_Mode, Translator = PageViewer.Translator, CurrentUser = RequestSpecificValues.Current_User};
                            printform_viewer.Add_Main_Viewer_Section(Main_PlaceHolder, Tracer);
                            break;

                        case "shareform":
                            Share_Fragment_ItemViewer share_viewer = new Share_Fragment_ItemViewer {CurrentItem = RequestSpecificValues.Current_Item, CurrentMode = RequestSpecificValues.Current_Mode, Translator = PageViewer.Translator, CurrentUser = RequestSpecificValues.Current_User};
                            share_viewer.Add_Main_Viewer_Section(Main_PlaceHolder, Tracer);
                            break;

                        case "addform":
                            AddRemove_Fragment_ItemViewer add_viewer = new AddRemove_Fragment_ItemViewer {CurrentItem = RequestSpecificValues.Current_Item, CurrentMode = RequestSpecificValues.Current_Mode, Translator = PageViewer.Translator, CurrentUser = RequestSpecificValues.Current_User};
                            add_viewer.Add_Main_Viewer_Section(Main_PlaceHolder, Tracer);
                            break;

                        case "sendform":
                            Send_Fragment_ItemViewer send_viewer = new Send_Fragment_ItemViewer {CurrentItem = RequestSpecificValues.Current_Item, CurrentMode = RequestSpecificValues.Current_Mode, Translator = PageViewer.Translator, CurrentUser = RequestSpecificValues.Current_User};
                            send_viewer.Add_Main_Viewer_Section(Main_PlaceHolder, Tracer);
                            break;
                    }
                }
                else
                {
                    Tracer.Add_Trace("Html_MainWriter.Add_Controls", "Allowing page viewer to add main viewer section to <i>mainPlaceHolder</i>");
                    PageViewer.Add_Main_Viewer_Section(Main_PlaceHolder, Tracer);
                }
            }
        }
コード例 #2
0
        /// <summary> Performs the final HTML writing which completes the item table and adds the final page navigation buttons at the bottom of the page </summary>
        /// <param name="placeHolder"> Main place holder ( &quot;mainPlaceHolder&quot; ) in the itemNavForm form, widely used throughout the application</param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        public void Add_Main_Viewer_Section(PlaceHolder placeHolder, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Item_HtmlSubwriter.Add_Main_Viewer_Section", "Rendering HTML ( add page view and finish the main viewer section )");

            // Add the main viewer section
            if ( PageViewer != null)
            {
                // Was this to draw a fragment?
                if ( !String.IsNullOrEmpty(currentMode.Fragment))
                {
                    switch( currentMode.Fragment )
                    {
                        case "printform":
                            PrintForm_Fragment_ItemViewer printform_viewer = new PrintForm_Fragment_ItemViewer(currentPage, PageViewer);
                            printform_viewer.CurrentItem = currentItem;
                            printform_viewer.CurrentMode = currentMode;
                            printform_viewer.Translator = PageViewer.Translator;
                            printform_viewer.CurrentUser = currentUser;
                            printform_viewer.Add_Main_Viewer_Section(placeHolder, Tracer);
                            break;

                        case "shareform":
                            Share_Fragment_ItemViewer share_viewer = new Share_Fragment_ItemViewer();
                            share_viewer.CurrentItem = currentItem;
                            share_viewer.CurrentMode = currentMode;
                            share_viewer.Translator = PageViewer.Translator;
                            share_viewer.CurrentUser = currentUser;
                            share_viewer.Add_Main_Viewer_Section(placeHolder, Tracer);
                            break;

                        case "addform":
                            AddRemove_Fragment_ItemViewer add_viewer = new AddRemove_Fragment_ItemViewer();
                            add_viewer.CurrentItem = currentItem;
                            add_viewer.CurrentMode = currentMode;
                            add_viewer.Translator = PageViewer.Translator;
                            add_viewer.CurrentUser = currentUser;
                            add_viewer.Add_Main_Viewer_Section(placeHolder, Tracer);
                            break;

                        case "sendform":
                            Send_Fragment_ItemViewer send_viewer = new Send_Fragment_ItemViewer();
                            send_viewer.CurrentItem = currentItem;
                            send_viewer.CurrentMode = currentMode;
                            send_viewer.Translator = PageViewer.Translator;
                            send_viewer.CurrentUser = currentUser;
                            send_viewer.Add_Main_Viewer_Section(placeHolder, Tracer);
                            break;

                    }

                    return;
                }
                else
                {
                    Tracer.Add_Trace("Html_MainWriter.Add_Controls", "Allowing page viewer to add main viewer section to <i>mainPlaceHolder</i>");
                    PageViewer.Add_Main_Viewer_Section(placeHolder, Tracer);
                }
            }

            // If this is the page turner viewer, don't draw anything else
            if ((PageViewer != null) && (PageViewer.ItemViewer_Type == ItemViewer_Type_Enum.GnuBooks_PageTurner))
            {
                return;
            }

            StringBuilder buildResult = new StringBuilder();

            buildResult.AppendLine("\t</tr>");

            if ((PageViewer != null) && (PageViewer.PageCount != 1))
            {
                buildResult.AppendLine("\t<tr>");
                buildResult.AppendLine("\t\t<td>");

                // ADD NAVIGATION BUTTONS
                if (PageViewer.PageCount != 1)
                {
                    string first_page = "First Page";
                    string previous_page = "Previous Page";
                    string next_page = "Next Page";
                    string last_page = "Last Page";

                    if (currentMode.Language == Web_Language_Enum.Spanish)
                    {
                        first_page = "Primera Página";
                        previous_page = "Página Anterior";
                        next_page = "Página Siguiente";
                        last_page = "Última Página";
                    }

                    if (currentMode.Language == Web_Language_Enum.French)
                    {
                        first_page = "Première Page";
                        previous_page = "Page Précédente";
                        next_page = "Page Suivante";
                        last_page = "Dernière Page";
                    }

                    string language_suffix = currentMode.Language_Code;
                    if (language_suffix.Length > 0)
                        language_suffix = "_" + language_suffix;

                    buildResult.AppendLine("\t\t\t<div class=\"SobekPageNavBar\">");

                    // Get the URL for the first and previous buttons
                    string firstButtonURL = PageViewer.First_Page_URL;
                    string prevButtonURL = PageViewer.Previous_Page_URL;

                    // Only continue if there is an item and mode, and there is previous pages to go to
                    if ((PageViewer.Current_Page > 1) && ((firstButtonURL.Length > 0) || (prevButtonURL.Length > 0)))
                    {
                        buildResult.AppendLine("              <span class=\"leftButtons\">");
                        buildResult.AppendLine("                <a href=\"" + firstButtonURL + "\"><img src=\"" + currentMode.Base_URL + "design/skins/" + htmlSkin.Base_Skin_Code + "/buttons/first_button" + language_suffix + ".gif\" alt=\"" + first_page + "\" /></a>&nbsp;");
                        buildResult.AppendLine("                <a href=\"" + prevButtonURL + "\"><img src=\"" + currentMode.Base_URL + "design/skins/" + htmlSkin.Base_Skin_Code + "/buttons/previous_button" + language_suffix + ".gif\" alt=\"" + previous_page + "\" /></a>");
                        buildResult.AppendLine("              </span>");
                    }

                    // Get the URL for the first and previous buttons
                    string lastButtonURL = PageViewer.Last_Page_URL;
                    string nextButtonURL = PageViewer.Next_Page_URL;

                    // Only continue if there is an item and mode, and there is previous pages to go to
                    if ((PageViewer.Current_Page < PageViewer.PageCount) && ((lastButtonURL.Length > 0) || (nextButtonURL.Length > 0)))
                    {
                        buildResult.AppendLine("              <span class=\"rightButtons\">");
                        buildResult.AppendLine("                <a href=\"" + nextButtonURL + "\"><img src=\"" + currentMode.Base_URL + "design/skins/" + htmlSkin.Base_Skin_Code + "/buttons/next_button" + language_suffix + ".gif\" alt=\"" + next_page + "\" /></a>&nbsp;");
                        buildResult.AppendLine("                <a href=\"" + lastButtonURL + "\"><img src=\"" + currentMode.Base_URL + "design/skins/" + htmlSkin.Base_Skin_Code + "/buttons/last_button" + language_suffix + ".gif\" alt =\"" + last_page + "\" /></a>");
                        buildResult.AppendLine("              </span>");
                    }

                    // Create the page selection if that is the type to display.  This is where it is actually
                    // built as well, althouogh it is subsequently used further up the page
                    if (PageViewer.Page_Selector == ItemViewer_PageSelector_Type_Enum.PageLinks)
                    {
                        StringBuilder pageLinkBuilder = new StringBuilder();

                        //Get the total page count
                        int num_of_pages = PageViewer.PageCount;
                        string[] page_urls = PageViewer.Go_To_Names;

                        pageLinkBuilder.AppendLine("\t\t\t\t<div id=\"pageNumbersBottom\" style=\"float:center; font-weight: bold\">");

                        //Display the first, last, current page numbers, and 2 pages before and after the current page
                        if (num_of_pages <= 7 && num_of_pages > 1)
                        {
                            for (int i = 1; i <= num_of_pages; i++)
                            {
                                if (i == PageViewer.Current_Page)
                                    pageLinkBuilder.AppendLine("\t\t\t\t\t<a class=\"thumbnailPageNumberCurrent\" href=\"" + page_urls[i - 1] + "\">" + i + "</a>&nbsp;");
                                else
                                    pageLinkBuilder.AppendLine("\t\t\t\t\t<a class=\"thumbnailPageNumber\" href=\"" + page_urls[i - 1] + "\">" + i + "</a>&nbsp;");
                            }
                        }
                        else if (num_of_pages > 7)
                        {
                            if (PageViewer.Current_Page > 4 && PageViewer.Current_Page < num_of_pages - 3)
                            {
                                pageLinkBuilder.AppendLine("\t\t\t\t\t<a class=\"thumbnailPageNumber\" href=\"" + page_urls[0] + "\">" + 1 + "</a>" + "...");
                                for (int i = PageViewer.Current_Page - 2; i <= PageViewer.Current_Page + 2; i++)
                                {
                                    if (i == PageViewer.Current_Page)
                                        pageLinkBuilder.AppendLine("\t\t\t\t\t<a class=\"thumbnailPageNumberCurrent\" href=\"" + page_urls[i - 1] + "\">" + i + "</a>&nbsp;");
                                    else
                                        pageLinkBuilder.AppendLine("\t\t\t\t\t<a class=\"thumbnailPageNumber\" href=\"" + page_urls[i - 1] + "\">" + i + "</a>&nbsp;");
                                }
                                pageLinkBuilder.AppendLine("\t\t\t\t\t..." + "<a class=\"thumbnailPageNumber\" href=\"" + page_urls[page_urls.Length - 1] + "\">" + num_of_pages + "</a>");
                            }

                            else if (PageViewer.Current_Page <= 4 && PageViewer.Current_Page < num_of_pages - 3)
                            {
                                for (int i = 1; i <= (PageViewer.Current_Page + 2); i++)
                                {
                                    if (i == PageViewer.Current_Page)
                                        pageLinkBuilder.AppendLine("\t\t\t\t\t<a class=\"thumbnailPageNumberCurrent\" href=\"" + page_urls[i - 1] + "\">" + i + "</a>&nbsp;");
                                    else
                                        pageLinkBuilder.AppendLine("\t\t\t\t\t<a class=\"thumbnailPageNumber\" href=\"" + page_urls[i - 1] + "\">" + i + "</a>&nbsp;");
                                }
                                pageLinkBuilder.AppendLine("\t\t\t\t\t..." + "<a href=\"" + page_urls[page_urls.Length - 1] + "\">" + num_of_pages + "</a>");
                            }

                            else if (PageViewer.Current_Page > 4 && PageViewer.Current_Page >= num_of_pages - 3)
                            {
                                pageLinkBuilder.AppendLine("\t\t\t\t\t<a class=\"thumbnailPageNumber\" href=\"" + page_urls[0] + "\">" + 1 + "</a>" + "...");
                                for (int i = PageViewer.Current_Page - 2; i <= num_of_pages; i++)
                                {
                                    if (i == PageViewer.Current_Page)
                                        pageLinkBuilder.AppendLine("\t\t\t\t\t<a class=\"thumbnailPageNumberCurrent\" href=\"" + page_urls[i - 1] + "\">" + i + "</a>&nbsp;");
                                    else
                                        pageLinkBuilder.AppendLine("\t\t\t\t\t<a class=\"thumbnailPageNumber\" href=\"" + page_urls[i - 1] + "\">" + i + "</a>&nbsp;");
                                }

                            }
                        }

                        pageLinkBuilder.AppendLine("\t\t\t\t</div>");

                        pageselectorhtml = pageLinkBuilder.ToString();
                        buildResult.AppendLine(pageselectorhtml);

                    }

                    buildResult.AppendLine("\t\t\t</div>");
                }

                buildResult.AppendLine("\t\t</td>");
                buildResult.AppendLine("\t</tr>");
            }

            if (PageViewer != null && ((currentItem.Behaviors.CheckOut_Required) && (PageViewer.ItemViewer_Type != ItemViewer_Type_Enum.Checked_Out)))
            {
                buildResult.AppendLine("<tr><td><span style=\"color:gray; font-size: 0.8em\">This item contains copyrighted material and is reserved for single (fair) use.  Once you finish working with this item,<br />it will return to the digital stacks in fifteen minutes for another patron to use.<br /><br /></span></td></tr>");
            }
            buildResult.AppendLine("</table>");

            // Add a spot for padding
            buildResult.AppendLine();
            buildResult.AppendLine("<!-- Division is used to add extra bottom padding, if the left nav bar is taller than the item viewer -->");
            buildResult.AppendLine("<div id=\"itemviewerbottompadding\"></div>");
            buildResult.AppendLine();

            // None of the sharing options are available if the user is restricted from this item
            // or if we are generating this as a static page source for robots
            if ((!itemRestrictedFromUserByIp) && (!itemCheckedOutByOtherUser) && (!currentMode.Is_Robot))
            {
                // Add the hidden field
                buildResult.AppendLine("<!-- Hidden field is used for postbacks to indicate what to save and reset -->");
                buildResult.AppendLine("<input type=\"hidden\" id=\"item_action\" name=\"item_action\" value=\"\" />");
                buildResult.AppendLine();

                // Add the scripts needed
                buildResult.AppendLine("<!-- Add references to the jquery and sobekcm javascript files -->");
                buildResult.AppendLine("<script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/jquery/jquery-1.6.2.min.js\"></script>");
                buildResult.AppendLine("<script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/jquery/jquery-ui-1.8.16.custom.min.js\"></script>");
                buildResult.AppendLine("<script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/sobekcm_form.js\" ></script>");
                buildResult.AppendLine("<script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/sobekcm_item.js\" ></script>");
                buildResult.AppendLine("<script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/superfish/hoverIntent.js\" ></script>");
                buildResult.AppendLine("<script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/superfish/superfish.js\" ></script>");
                buildResult.AppendLine();

                // Initialize the navigation menu

            }

            Literal closeTableLiteral = new Literal {Text = buildResult.ToString()};
            placeHolder.Controls.Add(closeTableLiteral);
        }