/// <summary>Reads the item aggregation browse or info file and returns a built <see cref="Item_Aggregation_Child_Page"/> object for /// inclusion in the item aggregation </summary> /// <param name="FileName"> Filename of the browse or info file</param> /// <param name="Browse_Type"> Flag indicates if this is a browse or info file</param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param> /// <returns> Built object containing all of the pertinent details about this info or browse </returns> private static Complete_Item_Aggregation_Child_Page Get_Item_Aggregation_Browse_Info(string FileName, Item_Aggregation_Child_Visibility_Enum Browse_Type, Custom_Tracer Tracer) { HTML_Based_Content fileContent = HTML_Based_Content_Reader.Read_HTML_File(FileName, false, Tracer); Complete_Item_Aggregation_Child_Page returnObject = new Complete_Item_Aggregation_Child_Page(Browse_Type, Item_Aggregation_Child_Source_Data_Enum.Static_HTML, fileContent.Code, FileName, fileContent.Title ?? "Missing Title"); return(returnObject); }
/// <summary>Reads the item aggregation browse or info file and returns a built <see cref="Item_Aggregation_Child_Page"/> object for /// inclusion in the item aggregation </summary> /// <param name="FileName"> Filename of the browse or info file</param> /// <param name="Browse_Type"> Flag indicates if this is a browse or info file</param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param> /// <returns> Built object containing all of the pertinent details about this info or browse </returns> private static Item_Aggregation_Child_Page Get_Item_Aggregation_Browse_Info(string FileName, Item_Aggregation_Child_Page.Visibility_Type Browse_Type, Custom_Tracer Tracer) { HTML_Based_Content fileContent = HTML_Based_Content_Reader.Read_HTML_File(FileName, false, Tracer); Item_Aggregation_Child_Page returnObject = new Item_Aggregation_Child_Page(Browse_Type, Item_Aggregation_Child_Page.Source_Type.Static_HTML, fileContent.Code, FileName, fileContent.Title); return(returnObject); }
/// <summary>Reads the item aggregation browse or info file and returns a built <see cref="Item_Aggregation_Browse_Info"/> object for /// inclusion in the item aggregation </summary> /// <param name="fileName"> Filename of the browse or info file</param> /// <param name="Browse_Type"> Flag indicates if this is a browse or info file</param> /// <param name="tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param> /// <returns> Built object containing all of the pertinent details about this info or browse </returns> private static Item_Aggregation_Browse_Info Get_Item_Aggregation_Browse_Info(string fileName, Item_Aggregation_Browse_Info.Browse_Info_Type Browse_Type, Custom_Tracer tracer) { HTML_Based_Content fileContent = HTML_Based_Content_Reader.Read_HTML_File(fileName, false, tracer); Item_Aggregation_Browse_Info returnObject = new Item_Aggregation_Browse_Info(Browse_Type, Item_Aggregation_Browse_Info.Source_Type.Static_HTML, fileContent.Code, fileName, fileContent.Title); return(returnObject); }
/// <summary> Constructor for a new instance of the Web_Content_HtmlSubwriter class </summary> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Static_Web_Content"> Object contains all the basic information about this info display </param> /// <param name="Site_Map"> Optional site map object used to render a navigational tree-view on left side of page</param> public Web_Content_HtmlSubwriter(Item_Aggregation Hierarchy_Object, SobekCM_Navigation_Object Current_Mode, SobekCM_Skin_Object HTML_Skin, HTML_Based_Content Static_Web_Content, SobekCM_SiteMap Site_Map) { base.Hierarchy_Object = Hierarchy_Object; currentMode = Current_Mode; Skin = HTML_Skin; thisStaticBrowseObject = Static_Web_Content; siteMap = Site_Map; // If there is a sitemap, check if this is a robot request and then if the URL // for the sitemap pages is URL restricted if ((siteMap != null) && (siteMap.Is_URL_Restricted_For_Robots) && (currentMode.Is_Robot)) { if (currentMode.Base_URL != siteMap.Restricted_Robot_URL) { currentMode.Base_URL = siteMap.Restricted_Robot_URL; string redirect_url = currentMode.Redirect_URL(); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Status = "301 Moved Permanently"; HttpContext.Current.Response.AddHeader("Location", redirect_url); HttpContext.Current.Response.End(); } } }
/// <summary> [HELPER] Gets the all information, including the HTML, for an item aggregation child page </summary> /// <param name="AggregationCode"> Code for the aggregation </param> /// <param name="RequestedLanguage"> Requested language to retrieve </param> /// <param name="DefaultLanguage"> Default interface language, in case the requested language does not exist </param> /// <param name="ChildPageCode"> Code the requested child page </param> /// <param name="Tracer"></param> /// <returns> Fully built object, based on the aggregation configuration and reading the source HTML file </returns> /// <remarks> This may be public now, but this will be converted into a private helped class with /// the release of SobekCM 5.0 </remarks> public static HTML_Based_Content get_item_aggregation_html_child_page(string AggregationCode, Web_Language_Enum RequestedLanguage, Web_Language_Enum DefaultLanguage, string ChildPageCode, Custom_Tracer Tracer) { // Try to pull from the cache HTML_Based_Content cacheInst = CachedDataManager.Aggregations.Retrieve_Aggregation_HTML_Based_Content(AggregationCode, RequestedLanguage, ChildPageCode, Tracer); if (cacheInst != null) { Tracer.Add_Trace("AggregationServices.get_item_aggregation_html_child_page", "Found built child page in the cache"); return(cacheInst); } // Get the language-specific item aggregation object Item_Aggregation itemAggr = get_item_aggregation(AggregationCode, RequestedLanguage, DefaultLanguage, Tracer); if (itemAggr == null) { Tracer.Add_Trace("AggregationServices.get_item_aggregation_html_child_page", "Item aggregation object was NULL.. May not be a valid aggregation code"); return(null); } // Get the child page object Tracer.Add_Trace("AggregationServices.get_item_aggregation_html_child_page", "Get child page object from the language-specific item aggregation"); Item_Aggregation_Child_Page childPage = itemAggr.Child_Page_By_Code(ChildPageCode); if (childPage == null) { Tracer.Add_Trace("AggregationServices.get_item_aggregation_html_child_page", "Child page does not exist in language-specific item agggregation"); return(null); } if (childPage.Source_Data_Type != Item_Aggregation_Child_Source_Data_Enum.Static_HTML) { Tracer.Add_Trace("AggregationServices.get_item_aggregation_html_child_page", "Child page exists in language-specific item aggregation, but it is not of type static html"); return(null); } string path = Path.Combine("/design/", itemAggr.ObjDirectory, childPage.Source); string file = HttpContext.Current.Server.MapPath(path); Tracer.Add_Trace("AggregationServices.get_item_aggregation_html_child_page", "Attempting to read source file for child page"); HTML_Based_Content results = HTML_Based_Content_Reader.Read_HTML_File(file, true, Tracer); if (results != null) { Tracer.Add_Trace("AggregationServices.get_item_aggregation_html_child_page", "Storing build child page in the cache"); CachedDataManager.Aggregations.Store_Aggregation_HTML_Based_Content(AggregationCode, RequestedLanguage, ChildPageCode, results, Tracer); } else { Tracer.Add_Trace("AggregationServices.get_item_aggregation_html_child_page", "Child page object returned from HTML_Based_Content_Reader was null.. returning NULL"); } return(results); }
/// <summary> Constructor for a new instance of the AggregationViewBag class </summary> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="Results_Statistics"> Information about the entire set of results for a browse </param> /// <param name="Paged_Results"> Single page of results for a browse, within the entire set </param> /// <param name="Browse_Object"> Object contains all the basic information about any browse or info display </param> /// <param name="Static_Web_Content"> HTML content-based aggregation browse or info. These are objects which are read from a static HTML file and much of the head information must be maintained </param> public AggregationViewBag(Item_Aggregation Hierarchy_Object, Search_Results_Statistics Results_Statistics, List <iSearch_Title_Result> Paged_Results, Item_Aggregation_Child_Page Browse_Object, HTML_Based_Content Static_Web_Content) { this.Hierarchy_Object = Hierarchy_Object; this.Results_Statistics = Results_Statistics; this.Paged_Results = Paged_Results; this.Browse_Object = Browse_Object; this.Static_Web_Content = Static_Web_Content; }
/// <summary> Constructor for a new instance of the Text_MainWriter class </summary> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </param> /// <param name="Paged_Results"> Single page of results for a search or browse, within the entire set </param> /// <param name="Browse_Object"> Object contains all the basic information about any browse or info display </param> /// <param name="Current_Item"> Current item to display </param> /// <param name="Current_Page"> Current page within the item</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> public Text_MainWriter(SobekCM_Navigation_Object Current_Mode, Item_Aggregation Hierarchy_Object, Search_Results_Statistics Results_Statistics, List <iSearch_Title_Result> Paged_Results, Item_Aggregation_Browse_Info Browse_Object, SobekCM_Item Current_Item, Page_TreeNode Current_Page, HTML_Based_Content Static_Web_Content) : base(Current_Mode, Hierarchy_Object, Results_Statistics, Paged_Results, Browse_Object, Current_Item, Current_Page, Static_Web_Content) { // All work done in base class }
/// <summary> Constructor for a new instance of the abstractMainWriter abstract class </summary> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="Results_Statistics"> Information about the entire set of results for a search or browse </param> /// <param name="Paged_Results"> Single page of results for a search or browse, within the entire set </param> /// <param name="Browse_Object"> Object contains all the basic information about any browse or info display </param> /// <param name="Current_Item"> Current item to display </param> /// <param name="Current_Page"> Current page within the item</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> protected abstractMainWriter(SobekCM_Navigation_Object Current_Mode, Item_Aggregation Hierarchy_Object, Search_Results_Statistics Results_Statistics, List <iSearch_Title_Result> Paged_Results, Item_Aggregation_Browse_Info Browse_Object, SobekCM_Item Current_Item, Page_TreeNode Current_Page, HTML_Based_Content Static_Web_Content) { currentMode = Current_Mode; hierarchyObject = Hierarchy_Object; results_statistics = Results_Statistics; paged_results = Paged_Results; thisBrowseObject = Browse_Object; currentItem = Current_Item; currentPage = Current_Page; htmlBasedContent = Static_Web_Content; }
/// <summary> Method gets the HOME PAGE html for the appropriate UI settings </summary> /// <param name="CompAggr"> Complete item aggregation object </param> /// <param name = "Language"> Current language of the user interface </param> /// <param name = "Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> /// <returns>Home page HTML</returns> private static HTML_Based_Content Get_Home_HTML(Complete_Item_Aggregation CompAggr, Web_Language_Enum Language, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Home_HTML", "Reading home text source file"); } string homeFileSource = ""; // Get the home file source if (CompAggr.Home_Page_File(Language) != null) { homeFileSource = Path.Combine(Engine_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location, CompAggr.ObjDirectory, CompAggr.Home_Page_File(Language).Source); } // If no home file source even found, return a message to that affect if (homeFileSource.Length == 0) { return(new HTML_Based_Content("<div class=\"error_div\">NO HOME PAGE SOURCE FILE FOUND</div>", null, homeFileSource)); } // Do the rest in a try/catch try { // Does the file exist? if (!File.Exists(homeFileSource)) { return(new HTML_Based_Content("<div class=\"error_div\">HOME PAGE SOURCE FILE '" + homeFileSource + "' DOES NOT EXIST.</div>", null, homeFileSource)); } HTML_Based_Content content = HTML_Based_Content_Reader.Read_HTML_File(homeFileSource, true, Tracer); content.Source = homeFileSource; return(content); } catch (Exception ee) { return(new HTML_Based_Content("<div class=\"error_div\">EXCEPTION CAUGHT WHILE TRYING TO READ THE HOME PAGE SOURCE FILE '" + homeFileSource + "'.<br /><br />ERROR: " + ee.Message + "</div>", null, homeFileSource)); } }
/// <summary> Retrieve the aggregation-level static HTML browse object, including the text itself, from the cache </summary> /// <param name="Aggregation_Code"> Aggregation code </param> /// <param name="Language"> Requested language version </param> /// <param name="ChildPageCode"> Code for the child page in question </param> /// <param name="Tracer">The tracer.</param> /// <returns> Fully built object with the information about the aggregation-level HTML browse object </returns> public HTML_Based_Content Retrieve_Aggregation_HTML_Based_Content(string Aggregation_Code, Web_Language_Enum Language, string ChildPageCode, Custom_Tracer Tracer) { // If the cache is disabled, just return before even tracing if (settings.Disabled) { return(null); } if (Tracer != null) { Tracer.Add_Trace("CachedDataManager_AggregationServices.Retrieve_Aggregation_HTML_Based_Content", ""); } // Determine the key string key = "AGGR|" + Aggregation_Code.ToUpper() + "|" + Web_Language_Enum_Converter.Enum_To_Code(Language) + "|" + ChildPageCode; // See if this is in the local cache first HTML_Based_Content returnValue = HttpContext.Current.Cache.Get(key) as HTML_Based_Content; if (returnValue != null) { if (Tracer != null) { Tracer.Add_Trace("CachedDataManager_AggregationServices.Retrieve_Aggregation_HTML_Based_Content", "Found aggregation HTML based content on local cache"); } return(returnValue); } if (Tracer != null) { Tracer.Add_Trace("CachedDataManager_AggregationServices.Retrieve_Aggregation_HTML_Based_Content", "Aggregation HTML based content not found in either the local cache"); } // Since everything failed, just return null return(null); }
/// <summary> Constructor for a new instance of the Delete_Verify_WebContentViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <param name="StaticPage"> Static page info for this request </param> public Delete_Verify_WebContentViewer(RequestCache RequestSpecificValues, HTML_Based_Content StaticPage) : base(RequestSpecificValues, StaticPage) { // Pull the web content page if (RequestSpecificValues.Current_Mode.WebContentID.HasValue) { webContent = SobekEngineClient.WebContent.Get_HTML_Based_Content(RequestSpecificValues.Current_Mode.WebContentID.Value, true, RequestSpecificValues.Tracer); } // This should never occur, but just a double check if ((webContent == null) || (!webContent.WebContentID.HasValue)) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // Ensure there IS a logged on user RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Delete_Verify_WebContentViewer", "Validate user"); if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn)) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // If the user was logged on, but did not have permissions, show an error message canDelete = true; deleted = false; if (!webContent.Can_Delete(RequestSpecificValues.Current_User)) { errorMessage = "ERROR: You do not have permission to delete this page"; canDelete = false; } else if (HttpContext.Current.Request.RequestType == "POST") { string save_value = HttpContext.Current.Request.Form["admin_delete_item"]; // Better say "DELETE", or just send back to the item if ((save_value != null) && (String.Compare(save_value, "DELETE", StringComparison.OrdinalIgnoreCase) == 0)) { string entered_value = HttpContext.Current.Request.Form["admin_delete_confirm"]; if ((entered_value == null) || (entered_value.ToUpper() != "DELETE")) { errorMessage = "ERROR: To verify this deletion, type DELETE into the text box and press CONFIRM"; } else { string deleteReason = "Requested via web application"; RestResponseMessage message = SobekEngineClient.WebContent.Delete_HTML_Based_Content(webContent.WebContentID.Value, RequestSpecificValues.Current_User.Full_Name, deleteReason, RequestSpecificValues.Tracer); errorMessage = message.Message; if ((message.ErrorTypeEnum != ErrorRestTypeEnum.Successful) && (String.IsNullOrEmpty(errorMessage))) { errorMessage = "Error encountered on SobekCM engine."; } else { errorMessage = "Successfully deleted this web content page."; // Clear cached data here on the client CachedDataManager.WebContent.Clear_All_Web_Content_Lists(); CachedDataManager.WebContent.Clear_All_Web_Content_Pages(); CachedDataManager.WebContent.Clear_Page_Details(); UI_ApplicationCache_Gateway.WebContent_Hierarchy_Clear(); deleted = true; } } } } }
/// <summary> Constructor for a new instance of the Usage_Statistics_WebContentViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <param name="StaticPage"> Static page info for this request </param> public Usage_Statistics_WebContentViewer(RequestCache RequestSpecificValues, HTML_Based_Content StaticPage) : base(RequestSpecificValues, StaticPage) { }
/// <summary> Constructor for a new instance of the User_Permissions_WebContentViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <param name="StaticPage"> Static page info for this request </param> public User_Permissions_WebContentViewer(RequestCache RequestSpecificValues, HTML_Based_Content StaticPage) : base(RequestSpecificValues, StaticPage) { }
/// <summary> /// Store_s the content of the aggregation_ HTM l_ based_. /// </summary> /// <param name="Aggregation_Code">The aggregation_ code.</param> /// <param name="Language">The language.</param> /// <param name="ChildPageCode">The child page code.</param> /// <param name="StoreObject">The store object.</param> /// <param name="Tracer">The tracer.</param> public void Store_Aggregation_HTML_Based_Content(string Aggregation_Code, Web_Language_Enum Language, string ChildPageCode, HTML_Based_Content StoreObject, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("CachedDataManager_AggregationServices.Store_Aggregation_HTML_Based_Content", "Entering Store_Aggregation_HTML_Based_Content method"); } // If the cache is disabled, just return before even tracing if (settings.Disabled) { if (Tracer != null) { Tracer.Add_Trace("CachedDataManager_AggregationServices.Store_Aggregation_HTML_Based_Content", "Caching is disabled"); } return; } // Determine the key string key = "AGGR|" + Aggregation_Code.ToUpper() + "|" + Web_Language_Enum_Converter.Enum_To_Code(Language) + "|" + ChildPageCode; // Check the number of item aggregationPermissions currently locally cached const int LOCAL_EXPIRATION = 15; // Locally cache if this doesn't exceed the limit if (Tracer != null) { Tracer.Add_Trace("CachedDataManager_AggregationServices.Store_Aggregation_HTML_Based_Content", "Adding object '" + key + "' to the local cache with expiration of " + LOCAL_EXPIRATION + " minute(s)"); } HttpContext.Current.Cache.Insert(key, StoreObject, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(LOCAL_EXPIRATION)); }
/// <summary> Constructor for a new instance of the Manage_Menu_WebContentViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <param name="StaticPage"> Static page info for this request </param> public Manage_Menu_WebContentViewer(RequestCache RequestSpecificValues, HTML_Based_Content StaticPage) : base(RequestSpecificValues, StaticPage) { }
/// <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> public Static_Browse_Info_AggregationViewer(Item_Aggregation_Browse_Info Browse_Object, HTML_Based_Content Static_Web_Content) : base(null, null) { browseObject = Browse_Object; staticWebContent = Static_Web_Content; }
/// <summary> Constructor for objects which implement this abstract class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <param name="StaticPage"> Static page info for this request </param> protected abstractWebContentViewer(RequestCache RequestSpecificValues, HTML_Based_Content StaticPage) { this.RequestSpecificValues = RequestSpecificValues; this.StaticPage = StaticPage; }
/// <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> Constructor for a new instance of the Work_History_WebContentViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <param name="StaticPage"> Static page info for this request </param> public Work_History_WebContentViewer(RequestCache RequestSpecificValues, HTML_Based_Content StaticPage) : base(RequestSpecificValues, StaticPage) { }
/// <summary> Returns a built collection viewer matching request </summary> /// <param name="ViewType"> Web content view type </param> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <param name="StaticPage"> Static page info for this request </param> /// <returns> Web content viewer that extends the <see cref="abstractWebContentViewer"/> class. </returns> public static abstractWebContentViewer Get_Viewer(WebContent_Type_Enum ViewType, RequestCache RequestSpecificValues, HTML_Based_Content StaticPage) { switch (ViewType) { case WebContent_Type_Enum.Delete_Verify: return(new Delete_Verify_WebContentViewer(RequestSpecificValues, StaticPage)); case WebContent_Type_Enum.Manage_Menu: return(new Manage_Menu_WebContentViewer(RequestSpecificValues, StaticPage)); case WebContent_Type_Enum.Milestones: return(new Work_History_WebContentViewer(RequestSpecificValues, StaticPage)); case WebContent_Type_Enum.Permissions: return(new User_Permissions_WebContentViewer(RequestSpecificValues, StaticPage)); case WebContent_Type_Enum.Usage: return(new Usage_Statistics_WebContentViewer(RequestSpecificValues, StaticPage)); default: return(null); } }
/// <summary> Get the language specific item aggregation, from the complete item aggregation object </summary> /// <param name="CompAggr"> Copmlete item aggregation object </param> /// <param name="RequestedLanguage"> Language version requested </param> /// <param name="Tracer"></param> /// <returns> The language-specific aggregation, built from the complete aggregation object, or NULL if an error occurred </returns> public static Item_Aggregation Get_Item_Aggregation(Complete_Item_Aggregation CompAggr, Web_Language_Enum RequestedLanguage, Custom_Tracer Tracer) { // If the complete aggregation was null, return null if (CompAggr == null) { if (Tracer != null) { Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Complete item aggregation was NULL.. aborting and returning NULL"); } return(null); } if (Tracer != null) { Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Building language-specific item aggregation from the complete object"); } // Build the item aggregation Item_Aggregation returnValue = new Item_Aggregation(RequestedLanguage, CompAggr.ID, CompAggr.Code) { Active = CompAggr.Active, BannerImage = CompAggr.Banner_Image(RequestedLanguage, null), Child_Types = CompAggr.Child_Types, Contact_Email = CompAggr.Contact_Email, ContactForm = CompAggr.ContactForm, CSS_File = CompAggr.CSS_File, Default_BrowseBy = CompAggr.Default_BrowseBy, Default_Result_View = CompAggr.Default_Result_View, Default_Skin = CompAggr.Default_Skin, Description = CompAggr.Description, Display_Options = CompAggr.Display_Options, FrontBannerObj = CompAggr.Front_Banner_Image(RequestedLanguage), Hidden = CompAggr.Hidden, Last_Item_Added = CompAggr.Last_Item_Added, Name = CompAggr.Name, Rotating_Highlights = CompAggr.Rotating_Highlights, ShortName = CompAggr.ShortName, Statistics = CompAggr.Statistics, Type = CompAggr.Type }; // Copy the map search and browse information if (CompAggr.Map_Search_Display != null) { returnValue.Map_Search_Display = CompAggr.Map_Search_Display.Copy(); } if (CompAggr.Map_Browse_Display != null) { returnValue.Map_Browse_Display = CompAggr.Map_Browse_Display.Copy(); } // Copy any children aggregations over if (CompAggr.Active_Children_Count > 0) { if (Tracer != null) { Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "...Copying children objects"); } returnValue.Children = new List <Item_Aggregation_Related_Aggregations>(); foreach (Item_Aggregation_Related_Aggregations thisAggr in CompAggr.Children) { returnValue.Children.Add(thisAggr); } } // Copy any parent aggregations over if (CompAggr.Parent_Count > 0) { if (Tracer != null) { Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "...Copying parent objects"); } returnValue.Parents = new List <Item_Aggregation_Related_Aggregations>(); foreach (Item_Aggregation_Related_Aggregations thisAggr in CompAggr.Parents) { returnValue.Parents.Add(thisAggr); } } // Copy all the facet information over if (Tracer != null) { Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "...Copying facets"); } foreach (short thisFacet in CompAggr.Facets) { returnValue.Facets.Add(thisFacet); } // Copy over all the results views if (Tracer != null) { Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "...Copying result views"); } foreach (string display in CompAggr.Result_Views) { returnValue.Result_Views.Add(display); } // Copy all the views and searches over if (Tracer != null) { Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "...Copying views and searches"); } if (CompAggr.Views_And_Searches != null) { foreach (Item_Aggregation_Views_Searches_Enum viewsSearches in CompAggr.Views_And_Searches) { returnValue.Views_And_Searches.Add(viewsSearches); } } // Copy all the setting values if ((CompAggr.Settings != null) && (CompAggr.Settings.Count > 0)) { foreach (StringKeyValuePair setting in CompAggr.Settings) { returnValue.Add_Setting(setting.Key, setting.Value); } } // Copy over any web skin limitations if ((CompAggr.Web_Skins != null) && (CompAggr.Web_Skins.Count > 0)) { if (Tracer != null) { Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "...Copying web skins"); } returnValue.Web_Skins = new List <string>(); foreach (string thisSkin in CompAggr.Web_Skins) { returnValue.Web_Skins.Add(thisSkin); } } // Language-specific (and simplified) metadata type info if (Tracer != null) { Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "...Copying search anbd browseable fields"); } foreach (Complete_Item_Aggregation_Metadata_Type thisAdvSearchField in CompAggr.Search_Fields) { returnValue.Search_Fields.Add(new Item_Aggregation_Metadata_Type(thisAdvSearchField.DisplayTerm, thisAdvSearchField.SobekCode)); } foreach (Complete_Item_Aggregation_Metadata_Type thisAdvSearchField in CompAggr.Browseable_Fields) { returnValue.Browseable_Fields.Add(new Item_Aggregation_Metadata_Type(thisAdvSearchField.DisplayTerm, thisAdvSearchField.SobekCode)); } // Language-specific (and simplified) child pages information if ((CompAggr.Child_Pages != null) && (CompAggr.Child_Pages.Count > 0)) { if (Tracer != null) { Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "...Copying child pages"); } returnValue.Child_Pages = new List <Item_Aggregation_Child_Page>(); foreach (Complete_Item_Aggregation_Child_Page fullPage in CompAggr.Child_Pages) { Item_Aggregation_Child_Page newPage = new Item_Aggregation_Child_Page { Browse_Type = fullPage.Browse_Type, Code = fullPage.Code, Parent_Code = fullPage.Parent_Code, Source_Data_Type = fullPage.Source_Data_Type }; string label = fullPage.Get_Label(RequestedLanguage); if (!String.IsNullOrEmpty(label)) { newPage.Label = label; } string source = fullPage.Get_Static_HTML_Source(RequestedLanguage); if (!String.IsNullOrEmpty(label)) { newPage.Source = source; } returnValue.Child_Pages.Add(newPage); } } // Language-specific (and simplified) highlight information if ((CompAggr.Highlights != null) && (CompAggr.Highlights.Count > 0)) { if (Tracer != null) { Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "...Copying relevant highlights"); } returnValue.Highlights = new List <Item_Aggregation_Highlights>(); int day_integer = DateTime.Now.DayOfYear + 1; int highlight_to_use = day_integer % CompAggr.Highlights.Count; // If this is for rotating highlights, show up to eight if ((CompAggr.Rotating_Highlights.HasValue) && (CompAggr.Rotating_Highlights.Value)) { // Copy over just the eight highlights we should use int number = Math.Min(8, CompAggr.Highlights.Count); for (int i = 0; i < number; i++) { Complete_Item_Aggregation_Highlights thisHighlight = CompAggr.Highlights[highlight_to_use]; Item_Aggregation_Highlights newHighlight = new Item_Aggregation_Highlights { Image = thisHighlight.Image, Link = thisHighlight.Link }; string text = thisHighlight.Get_Text(RequestedLanguage); if (!String.IsNullOrEmpty(text)) { newHighlight.Text = text; } string tooltip = thisHighlight.Get_Tooltip(RequestedLanguage); if (!String.IsNullOrEmpty(tooltip)) { newHighlight.Tooltip = tooltip; } returnValue.Highlights.Add(newHighlight); highlight_to_use++; if (highlight_to_use >= CompAggr.Highlights.Count) { highlight_to_use = 0; } } } else { Complete_Item_Aggregation_Highlights thisHighlight = CompAggr.Highlights[highlight_to_use]; Item_Aggregation_Highlights newHighlight = new Item_Aggregation_Highlights { Image = thisHighlight.Image, Link = thisHighlight.Link }; string text = thisHighlight.Get_Text(RequestedLanguage); if (!String.IsNullOrEmpty(text)) { newHighlight.Text = text; } string tooltip = thisHighlight.Get_Tooltip(RequestedLanguage); if (!String.IsNullOrEmpty(tooltip)) { newHighlight.Tooltip = tooltip; } returnValue.Highlights.Add(newHighlight); } } // Language-specific source page if (Tracer != null) { Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Getting the home page source"); } returnValue.HomePageSource = String.Empty; HTML_Based_Content homeHtml = Get_Home_HTML(CompAggr, RequestedLanguage, null); returnValue.HomePageHtml = homeHtml; returnValue.Custom_Home_Page = (CompAggr.Home_Page_File(RequestedLanguage) != null) && (CompAggr.Home_Page_File(RequestedLanguage).isCustomHome); if (Tracer != null) { Tracer.Add_Trace("Item_Aggregation_Utilities.Get_Item_Aggregation", "Returning fully built item aggregation object"); } return(returnValue); }
/// <summary> Gets the all information, including the HTML, for an item aggregation child page </summary> /// <param name="Response"></param> /// <param name="UrlSegments"></param> /// <param name="QueryString"></param> /// <param name="Protocol"></param> /// <param name="IsDebug"></param> public void GetCollectionStaticPage(HttpResponse Response, List <string> UrlSegments, NameValueCollection QueryString, Microservice_Endpoint_Protocol_Enum Protocol, bool IsDebug) { if (UrlSegments.Count > 2) { Custom_Tracer tracer = new Custom_Tracer(); try { // Get the code and language from the URL string aggrCode = UrlSegments[0]; string language = UrlSegments[1]; string childCode = UrlSegments[2]; Web_Language_Enum langEnum = Web_Language_Enum_Converter.Code_To_Enum(language); if (langEnum == Web_Language_Enum.UNDEFINED) { tracer.Add_Trace("AggregationServices.GetCollectionStaticPage", "Language code '" + language + "' not recognized"); } // Build the language-specific item aggregation tracer.Add_Trace("AggregationServices.GetCollectionStaticPage", "Build and return child page '" + childCode + "' in aggregation '" + aggrCode + "' for '" + Web_Language_Enum_Converter.Enum_To_Name(langEnum) + "'"); // Get the aggregation code manager HTML_Based_Content returnValue = get_item_aggregation_html_child_page(aggrCode, langEnum, Engine_ApplicationCache_Gateway.Settings.System.Default_UI_Language, childCode, tracer); // If this was debug mode, then just write the tracer if (IsDebug) { Response.ContentType = "text/plain"; Response.Output.WriteLine("DEBUG MODE DETECTED"); Response.Output.WriteLine(); Response.Output.WriteLine(tracer.Text_Trace); return; } // Get the JSON-P callback function string json_callback = "parseCollectionStaticPage"; if ((Protocol == Microservice_Endpoint_Protocol_Enum.JSON_P) && (!String.IsNullOrEmpty(QueryString["callback"]))) { json_callback = QueryString["callback"]; } // Use the base class to serialize the object according to request protocol Serialize(returnValue, Response, Protocol, json_callback); } catch (Exception ee) { if (IsDebug) { Response.ContentType = "text/plain"; Response.Output.WriteLine("EXCEPTION CAUGHT!"); Response.Output.WriteLine(); Response.Output.WriteLine(ee.Message); Response.Output.WriteLine(); Response.Output.WriteLine(ee.StackTrace); Response.Output.WriteLine(); Response.Output.WriteLine(tracer.Text_Trace); return; } Response.ContentType = "text/plain"; Response.Output.WriteLine("Error completing request"); Response.StatusCode = 500; } } }
/// <summary> Add the HTML to be displayed below the search box </summary> /// <param name="Output"> Textwriter to write the HTML for this viewer</param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param> /// <remarks> This writes the HTML from the static browse or info page here </remarks> public override void Add_Secondary_HTML(TextWriter Output, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("Metadata_Browse_AggregationViewer.Add_Secondary_HTML", "Adding HTML"); } // Get collection of (public) browse bys linked to this aggregation ReadOnlyCollection <Item_Aggregation_Child_Page> public_browses = ViewBag.Hierarchy_Object.Browse_By_Pages; // Determine if this is an internal user and create list of internal user browses List <string> internal_browses = new List <string>(); if ((RequestSpecificValues.Current_User != null) && ((RequestSpecificValues.Current_User.Is_Internal_User) || (RequestSpecificValues.Current_User.Is_Aggregation_Curator(RequestSpecificValues.Current_Mode.Aggregation)))) { // Just add every metadata field here foreach (Item_Aggregation_Metadata_Type field in ViewBag.Hierarchy_Object.Browseable_Fields) { internal_browses.Add(field.DisplayTerm); } } // Retain the original short code (or the first public code) string original_browse_mode = RequestSpecificValues.Current_Mode.Info_Browse_Mode.ToLower(); // Get any paging URL and retain original page int current_page = RequestSpecificValues.Current_Mode.Page.HasValue ? RequestSpecificValues.Current_Mode.Page.Value : 1; RequestSpecificValues.Current_Mode.Page = 1; string page_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode, false); string url_options = UrlWriterHelper.URL_Options(RequestSpecificValues.Current_Mode); if (url_options.Length > 0) { url_options = "?" + url_options.Replace("&", "&"); } if ((public_browses.Count > 1) || (internal_browses.Count > 0)) { Output.WriteLine("<table>"); Output.WriteLine("<tr style=\"vertical-align:top;\">"); Output.WriteLine("<td id=\"sbkMebv_FacetOuterColumn\">"); Output.WriteLine("<div class=\"sbkMebv_FacetColumn\">"); Output.WriteLine("<div class=\"sbkMebv_FacetColumnTitle\">BROWSE BY:</div>"); Output.WriteLine("<br />"); if (public_browses.Count > 0) { // Sort these by title SortedList <string, Item_Aggregation_Child_Page> sortedBrowses = new SortedList <string, Item_Aggregation_Child_Page>(); foreach (Item_Aggregation_Child_Page thisBrowse in public_browses) { if (thisBrowse.Source_Data_Type == Item_Aggregation_Child_Source_Data_Enum.Static_HTML) { sortedBrowses[thisBrowse.Code.ToLower()] = thisBrowse; } else { Metadata_Search_Field facetField = UI_ApplicationCache_Gateway.Settings.Metadata_Search_Field_By_Name(thisBrowse.Code); if (facetField != null) { string facetName = facetField.Display_Term; if (internal_browses.Contains(facetName)) { internal_browses.Remove(facetName); } sortedBrowses[facetName.ToLower()] = thisBrowse; } } } Output.WriteLine(internal_browses.Count > 0 ? "<b> Public Browses</b><br />" : "<b> Browses</b><br />"); Output.WriteLine("<div class=\"sbkMebv_FacetBox\">"); foreach (Item_Aggregation_Child_Page thisBrowse in sortedBrowses.Values) { // Static HTML or metadata browse by? if (thisBrowse.Source_Data_Type == Item_Aggregation_Child_Source_Data_Enum.Static_HTML) { if (original_browse_mode != thisBrowse.Code) { RequestSpecificValues.Current_Mode.Info_Browse_Mode = thisBrowse.Code; Output.WriteLine("<a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode).Replace("&", "&") + "\">" + thisBrowse.Label + "</a><br />"); } else { Output.WriteLine(thisBrowse.Label + "<br />"); } } else { Metadata_Search_Field facetField = UI_ApplicationCache_Gateway.Settings.Metadata_Search_Field_By_Display_Name(thisBrowse.Code); if (thisBrowse.Code.ToLower().Replace("_", " ") != original_browse_mode.Replace("_", " ")) { RequestSpecificValues.Current_Mode.Info_Browse_Mode = thisBrowse.Code.ToLower().Replace(" ", "_"); Output.WriteLine("<a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode).Replace("&", "&") + "\">" + facetField.Display_Term + "</a><br />"); } else { Output.WriteLine(facetField.Display_Term + "<br />"); } } } Output.WriteLine("</div>"); Output.WriteLine("<br />"); } if (internal_browses.Count > 0) { Output.WriteLine("<b> Internal Browses</b><br />"); Output.WriteLine("<div class=\"sbkMebv_FacetBox\">"); foreach (string thisShort in internal_browses) { Metadata_Search_Field facetField = UI_ApplicationCache_Gateway.Settings.Metadata_Search_Field_By_Facet_Name(thisShort); if (facetField != null) { if (thisShort.ToLower() != original_browse_mode) { RequestSpecificValues.Current_Mode.Info_Browse_Mode = thisShort.ToLower().Replace(" ", "_"); Output.WriteLine("<a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode).Replace("&", "&") + "\">" + facetField.Display_Term + "</a><br />"); } else { Output.WriteLine(facetField.Display_Term + "<br />"); } } } Output.WriteLine("</div>"); Output.WriteLine("<br />"); } Output.WriteLine("<br />"); Output.WriteLine("<br />"); Output.WriteLine("<br />"); Output.WriteLine("<br />"); Output.WriteLine("<br />"); Output.WriteLine("</div>"); Output.WriteLine("</td>"); Output.WriteLine("<td>"); } Output.WriteLine("<div class=\"sbkMebv_ResultsPanel\" id=\"main-content\" role=\"main\">"); RequestSpecificValues.Current_Mode.Info_Browse_Mode = original_browse_mode; // Was this static or metadata browse by? if ((browseObject != null) && (browseObject.Source_Data_Type == Item_Aggregation_Child_Source_Data_Enum.Static_HTML)) { // Read the content file for this browse string source_file = UI_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + ViewBag.Hierarchy_Object.ObjDirectory.Replace("/", "\\") + browseObject.Source; HTML_Based_Content staticBrowseContent = HTML_Based_Content_Reader.Read_HTML_File(source_file, true, Tracer); if (staticBrowseContent == null) { staticBrowseContent = new HTML_Based_Content("Unable to find source file!\n\n" + ViewBag.Hierarchy_Object.ObjDirectory.Replace("/", "\\") + browseObject.Source, browseObject.Code); } // Apply current user settings for this string browseInfoDisplayText = staticBrowseContent.Apply_Settings_To_Static_Text(staticBrowseContent.Content, ViewBag.Hierarchy_Object, RequestSpecificValues.HTML_Skin.Skin_Code, RequestSpecificValues.HTML_Skin.Base_Skin_Code, RequestSpecificValues.Current_Mode.Base_URL, UrlWriterHelper.URL_Options(RequestSpecificValues.Current_Mode), Tracer); // Is this an admin? bool isAdmin = (RequestSpecificValues.Current_User != null) && (RequestSpecificValues.Current_User.Is_Aggregation_Admin(ViewBag.Hierarchy_Object.Code)); Aggregation_Type_Enum aggrType = RequestSpecificValues.Current_Mode.Aggregation_Type; // Output the adjusted home html if (isAdmin) { Output.WriteLine("<div id=\"sbkSbia_MainTextEditable\">"); Output.WriteLine(browseInfoDisplayText); RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Child_Page_Edit; Output.WriteLine(" <div id=\"sbkSbia_EditableTextLink\"><a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "\" title=\"Edit this page's text\"><img src=\"" + Static_Resources_Gateway.Edit_Gif + "\" alt=\"\" />edit content</a></div>"); RequestSpecificValues.Current_Mode.Aggregation_Type = aggrType; Output.WriteLine("</div>"); Output.WriteLine(); Output.WriteLine("<script>"); Output.WriteLine(" $(\"#sbkSbia_MainTextEditable\").mouseover(function() { $(\"#sbkSbia_EditableTextLink\").css(\"display\",\"inline-block\"); });"); Output.WriteLine(" $(\"#sbkSbia_MainTextEditable\").mouseout(function() { $(\"#sbkSbia_EditableTextLink\").css(\"display\",\"none\"); });"); Output.WriteLine("</script>"); Output.WriteLine(); } else { Output.WriteLine("<div id=\"sbkSbia_MainText\">"); Output.WriteLine(browseInfoDisplayText); Output.WriteLine("</div>"); } } else { //Output the results if ((results != null) && (results.Count > 0)) { // Determine which letters appear List <char> letters_appearing = new List <char>(); char last_char = '\n'; if (results.Count > 100) { foreach (string thisValue in results) { if (thisValue.Length > 0) { char this_first_char = Char.ToLower(thisValue[0]); int ascii = this_first_char; if (ascii < 97) { this_first_char = 'a'; } if (ascii > 122) { this_first_char = 'z'; } if (this_first_char != last_char) { if (!letters_appearing.Contains(this_first_char)) { letters_appearing.Add(this_first_char); } last_char = this_first_char; } } } } // Get the search URL RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Results; RequestSpecificValues.Current_Mode.Search_Precision = Search_Precision_Type_Enum.Exact_Match; RequestSpecificValues.Current_Mode.Search_Type = Search_Type_Enum.Advanced; Metadata_Search_Field facetField = UI_ApplicationCache_Gateway.Settings.Metadata_Search_Field_By_Display_Name(original_browse_mode); RequestSpecificValues.Current_Mode.Search_Fields = facetField.Web_Code; RequestSpecificValues.Current_Mode.Search_String = "\"<%TERM%>\""; string search_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); Output.WriteLine("<br />"); if (results.Count < 100) { foreach (string thisResult in results) { Output.WriteLine("<a href=\"" + search_url.Replace("%3c%25TERM%25%3e", thisResult.Trim().Replace(",", "%2C").Replace("&", "%26").Replace("\"", "%22").Replace("&", "&")) + "\">" + thisResult.Replace("\"", """).Replace("&", "&") + "</a><br />"); } } else if (results.Count < 500) { // Determine the actual page first int first_valid_page = -1; if ((letters_appearing.Contains('a')) || (letters_appearing.Contains('b'))) { first_valid_page = 1; } if ((letters_appearing.Contains('c')) || (letters_appearing.Contains('d')) || (letters_appearing.Contains('e'))) { if (first_valid_page < 0) { first_valid_page = 2; } } if ((letters_appearing.Contains('f')) || (letters_appearing.Contains('g')) || (letters_appearing.Contains('h'))) { if (first_valid_page < 0) { first_valid_page = 3; } } if ((letters_appearing.Contains('i')) || (letters_appearing.Contains('j')) || (letters_appearing.Contains('k'))) { if (first_valid_page < 0) { first_valid_page = 4; } } if ((letters_appearing.Contains('l')) || (letters_appearing.Contains('m')) || (letters_appearing.Contains('n'))) { if (first_valid_page < 0) { first_valid_page = 5; } } if ((letters_appearing.Contains('o')) || (letters_appearing.Contains('p')) || (letters_appearing.Contains('q'))) { if (first_valid_page < 0) { first_valid_page = 6; } } if ((letters_appearing.Contains('r')) || (letters_appearing.Contains('s')) || (letters_appearing.Contains('t'))) { if (first_valid_page < 0) { first_valid_page = 7; } } if ((letters_appearing.Contains('u')) || (letters_appearing.Contains('v')) || (letters_appearing.Contains('w'))) { if (first_valid_page < 0) { first_valid_page = 8; } } if ((letters_appearing.Contains('x')) || (letters_appearing.Contains('y')) || (letters_appearing.Contains('z'))) { if (first_valid_page < 0) { first_valid_page = 9; } } // Define the limits of the page value if ((current_page < first_valid_page) || (current_page > 9)) { current_page = first_valid_page; } // Add the links for paging through results Output.WriteLine("<div class=\"sbkMebv_NavRow\">"); if ((letters_appearing.Contains('a')) || (letters_appearing.Contains('b'))) { if (current_page == 1) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">AB</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/1" + url_options + "\" class=\"mbb1\">AB</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">AB</span> "); } if ((letters_appearing.Contains('c')) || (letters_appearing.Contains('d')) || (letters_appearing.Contains('e'))) { if (current_page == 2) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">CDE</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/2" + url_options + "\">CDE</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">CDE</span> "); } if ((letters_appearing.Contains('f')) || (letters_appearing.Contains('g')) || (letters_appearing.Contains('h'))) { if (current_page == 3) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">FGH</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/3" + url_options + "\">FGH</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">FGH</span> "); } if ((letters_appearing.Contains('i')) || (letters_appearing.Contains('j')) || (letters_appearing.Contains('k'))) { if (current_page == 4) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">IJK</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/4" + url_options + "\">IJK</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">IJK</span> "); } if ((letters_appearing.Contains('l')) || (letters_appearing.Contains('m')) || (letters_appearing.Contains('n'))) { if (current_page == 5) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">LMN</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/5" + url_options + "\">LMN</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">LMN</span> "); } if ((letters_appearing.Contains('o')) || (letters_appearing.Contains('p')) || (letters_appearing.Contains('q'))) { if (current_page == 6) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">OPQ</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/6" + url_options + "\">OPQ</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">OPQ</span> "); } if ((letters_appearing.Contains('r')) || (letters_appearing.Contains('s')) || (letters_appearing.Contains('t'))) { if (current_page == 7) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">RST</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/7" + url_options + "\">RST</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">RST</span> "); } if ((letters_appearing.Contains('u')) || (letters_appearing.Contains('v')) || (letters_appearing.Contains('w'))) { if (current_page == 8) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">UVW</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/8" + url_options + "\">UVW</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">UVW</span> "); } if ((letters_appearing.Contains('x')) || (letters_appearing.Contains('y')) || (letters_appearing.Contains('z'))) { if (current_page == 9) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">XYZ</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/9" + url_options + "\">XYZ</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\" >XYZ</span> "); } Output.WriteLine("</div>"); Output.WriteLine("<br />"); Output.WriteLine("<br />"); // Find the start character and last character, per the page char first_char = ' '; char stop_char = 'c'; switch (current_page) { case 2: first_char = 'c'; stop_char = 'f'; break; case 3: first_char = 'f'; stop_char = 'i'; break; case 4: first_char = 'i'; stop_char = 'l'; break; case 5: first_char = 'l'; stop_char = 'o'; break; case 6: first_char = 'o'; stop_char = 'r'; break; case 7: first_char = 'r'; stop_char = 'u'; break; case 8: first_char = 'u'; stop_char = 'x'; break; case 9: first_char = 'x'; stop_char = '}'; break; } // Add the pertinent rows foreach (string thisValue in results) { if (thisValue.Length > 0) { char this_first_char = Char.ToLower(thisValue[0]); if ((this_first_char >= first_char) && (this_first_char < stop_char)) { Output.WriteLine("<a href=\"" + search_url.Replace("%3c%25TERM%25%3e", thisValue.Trim().Replace(",", "%2C").Replace("&", "%26").Replace("\"", "%22")).Replace("&", "&") + "\">" + thisValue.Replace("\"", """).Replace("&", "&") + "</a><br />"); } } } } else { // Determine the first valid page char label_char = 'a'; int first_valid_page = -1; int counter = 1; while (label_char <= 'z') { if (letters_appearing.Contains(label_char)) { if (first_valid_page < 0) { first_valid_page = counter; } } counter++; label_char = (char)((label_char) + 1); } // Define the limits of the page value if ((current_page < first_valid_page) || (current_page > 26)) { current_page = first_valid_page; } // Add the links for paging through results label_char = 'a'; counter = 1; Output.WriteLine("<div class=\"sbkMebv_NavRow\">"); while (label_char <= 'z') { if (letters_appearing.Contains(label_char)) { if (current_page == counter) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">" + Char.ToUpper(label_char) + "</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/" + counter + url_options + "\" >" + Char.ToUpper(label_char) + "</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\" >" + Char.ToUpper(label_char) + "</span> "); } counter++; label_char = (char)((label_char) + 1); } Output.WriteLine("</div>"); Output.WriteLine("<br />"); Output.WriteLine("<br />"); // Find the start character and last character, per the page char first_char = ' '; char stop_char = 'b'; if (current_page > 1) { first_char = (char)(96 + current_page); stop_char = (char)(97 + current_page); } // Add the pertinent rows foreach (string thisValue in results) { if (thisValue.Length > 0) { char this_first_char = Char.ToLower(thisValue[0]); if ((this_first_char >= first_char) && (this_first_char < stop_char)) { Output.WriteLine("<a href=\"" + search_url.Replace("%3c%25TERM%25%3e", thisValue.Trim().Replace(",", "%2C").Replace("&", "%26").Replace("\"", "%22")).Replace("&", "&") + "\">" + thisValue.Replace("\"", """).Replace("&", "&") + "</a><br />"); } } } } } else { Output.WriteLine("<br /><br /><br /><br />"); Output.WriteLine(RequestSpecificValues.Current_Mode.Info_Browse_Mode.Length == 0 ? "<center>Select a metadata field to browse by from the list on the left</center>" : "<center>NO MATCHING VALUES</center>"); Output.WriteLine("<br /><br />"); } } // Set the current mode back RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation; RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Browse_By; Output.WriteLine("</div>"); Output.WriteLine("<br />"); if ((public_browses.Count > 1) || (internal_browses.Count > 0)) { Output.WriteLine("</td>"); Output.WriteLine("</tr>"); Output.WriteLine("</table>"); } Output.WriteLine(); }
/// <summary> Add the HTML to be displayed below the search box </summary> /// <param name="Output"> Textwriter to write the HTML for this viewer</param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param> /// <remarks> This writes the HTML from the static browse or info page here </remarks> public override void Add_Secondary_HTML(TextWriter Output, Custom_Tracer Tracer) { if (Tracer != null) { Tracer.Add_Trace("Metadata_Browse_AggregationViewer.Add_Secondary_HTML", "Adding HTML"); } // Get collection of (public) browse bys linked to this aggregation ReadOnlyCollection <Item_Aggregation_Child_Page> public_browses = currentCollection.Browse_By_Pages(currentMode.Language); // Determine if this is an internal user and create list of internal user browses List <string> internal_browses = new List <string>(); if ((currentUser != null) && ((currentUser.Is_Internal_User) || (currentUser.Is_Aggregation_Curator(currentMode.Aggregation)))) { // Just add every metadata field here foreach (Metadata_Search_Field field in SobekCM_Library_Settings.All_Metadata_Fields) { if ((field.Web_Code.Length > 0) && (currentCollection.Browseable_Fields.Contains(field.ID))) { internal_browses.Add(field.Display_Term); } } } // Retain the original short code (or the first public code) string original_browse_mode = currentMode.Info_Browse_Mode.ToLower(); // Get any paging URL and retain original page int current_page = currentMode.Page; currentMode.Page = 1; string page_url = currentMode.Redirect_URL(false); string url_options = currentMode.URL_Options(); if (url_options.Length > 0) { url_options = "?" + url_options.Replace("&", "&"); } if ((public_browses.Count > 1) || (internal_browses.Count > 0)) { Output.WriteLine("<table>"); Output.WriteLine("<tr style=\"vertical-align:top;\">"); Output.WriteLine("<td id=\"sbkMebv_FacetOuterColumn\">"); Output.WriteLine("<div class=\"sbkMebv_FacetColumn\">"); Output.WriteLine("<div class=\"sbkMebv_FacetColumnTitle\">BROWSE BY:</div>"); Output.WriteLine("<br />"); if (public_browses.Count > 0) { // Sort these by title SortedList <string, Item_Aggregation_Child_Page> sortedBrowses = new SortedList <string, Item_Aggregation_Child_Page>(); foreach (Item_Aggregation_Child_Page thisBrowse in public_browses) { if (thisBrowse.Source == Item_Aggregation_Child_Page.Source_Type.Static_HTML) { sortedBrowses[thisBrowse.Code.ToLower()] = thisBrowse; } else { Metadata_Search_Field facetField = SobekCM_Library_Settings.Metadata_Search_Field_By_Name(thisBrowse.Code); if (facetField != null) { string facetName = facetField.Display_Term; if (internal_browses.Contains(facetName)) { internal_browses.Remove(facetName); } sortedBrowses[facetName.ToLower()] = thisBrowse; } } } Output.WriteLine(internal_browses.Count > 0 ? "<b> Public Browses</b><br />" : "<b> Browses</b><br />"); Output.WriteLine("<div class=\"sbkMebv_FacetBox\">"); foreach (Item_Aggregation_Child_Page thisBrowse in sortedBrowses.Values) { // Static HTML or metadata browse by? if (thisBrowse.Source == Item_Aggregation_Child_Page.Source_Type.Static_HTML) { if (original_browse_mode != thisBrowse.Code) { currentMode.Info_Browse_Mode = thisBrowse.Code; Output.WriteLine("<a href=\"" + currentMode.Redirect_URL().Replace("&", "&") + "\">" + thisBrowse.Get_Label(currentMode.Language) + "</a><br />"); } else { Output.WriteLine(thisBrowse.Get_Label(currentMode.Language) + "<br />"); } } else { Metadata_Search_Field facetField = SobekCM_Library_Settings.Metadata_Search_Field_By_Display_Name(thisBrowse.Code); if (thisBrowse.Code.ToLower().Replace("_", " ") != original_browse_mode.Replace("_", " ")) { currentMode.Info_Browse_Mode = thisBrowse.Code.ToLower().Replace(" ", "_"); Output.WriteLine("<a href=\"" + currentMode.Redirect_URL().Replace("&", "&") + "\">" + facetField.Display_Term + "</a><br />"); } else { Output.WriteLine(facetField.Display_Term + "<br />"); } } } Output.WriteLine("</div>"); Output.WriteLine("<br />"); } if (internal_browses.Count > 0) { Output.WriteLine("<b> Internal Browses</b><br />"); Output.WriteLine("<div class=\"sbkMebv_FacetBox\">"); foreach (string thisShort in internal_browses) { Metadata_Search_Field facetField = SobekCM_Library_Settings.Metadata_Search_Field_By_Facet_Name(thisShort); if (facetField != null) { if (thisShort.ToLower() != original_browse_mode) { currentMode.Info_Browse_Mode = thisShort.ToLower().Replace(" ", "_"); Output.WriteLine("<a href=\"" + currentMode.Redirect_URL().Replace("&", "&") + "\">" + facetField.Display_Term + "</a><br />"); } else { Output.WriteLine(facetField.Display_Term + "<br />"); } } } Output.WriteLine("</div>"); Output.WriteLine("<br />"); } Output.WriteLine("<br />"); Output.WriteLine("<br />"); Output.WriteLine("<br />"); Output.WriteLine("<br />"); Output.WriteLine("<br />"); Output.WriteLine("</div>"); Output.WriteLine("</td>"); Output.WriteLine("<td>"); } Output.WriteLine("<div class=\"sbkMebv_ResultsPanel\">"); currentMode.Info_Browse_Mode = original_browse_mode; // Was this static or metadata browse by? if ((browseObject != null) && (browseObject.Source == Item_Aggregation_Child_Page.Source_Type.Static_HTML)) { // Read the content file for this browse HTML_Based_Content staticBrowseContent = browseObject.Get_Static_Content(currentMode.Language, currentMode.Base_URL, SobekCM_Library_Settings.Base_Design_Location + currentCollection.ObjDirectory, Tracer); // Apply current user settings for this string browseInfoDisplayText = staticBrowseContent.Apply_Settings_To_Static_Text(staticBrowseContent.Static_Text, currentCollection, htmlSkin.Skin_Code, htmlSkin.Base_Skin_Code, currentMode.Base_URL, currentMode.URL_Options(), Tracer); // Add this to the output stream Output.WriteLine(browseInfoDisplayText); } else { //Output the results if ((results != null) && (results.Count > 0)) { // Determine which letters appear List <char> letters_appearing = new List <char>(); char last_char = '\n'; if (results.Count > 100) { foreach (string thisValue in results) { if (thisValue.Length > 0) { char this_first_char = Char.ToLower(thisValue[0]); int ascii = this_first_char; if (ascii < 97) { this_first_char = 'a'; } if (ascii > 122) { this_first_char = 'z'; } if (this_first_char != last_char) { if (!letters_appearing.Contains(this_first_char)) { letters_appearing.Add(this_first_char); } last_char = this_first_char; } } } } // Get the search URL currentMode.Mode = Display_Mode_Enum.Results; currentMode.Search_Precision = Search_Precision_Type_Enum.Exact_Match; currentMode.Search_Type = Search_Type_Enum.Advanced; Metadata_Search_Field facetField = SobekCM_Library_Settings.Metadata_Search_Field_By_Display_Name(original_browse_mode); currentMode.Search_Fields = facetField.Web_Code; currentMode.Search_String = "\"<%TERM%>\""; string search_url = currentMode.Redirect_URL(); Output.WriteLine("<br />"); if (results.Count < 100) { foreach (string thisResult in results) { Output.WriteLine("<a href=\"" + search_url.Replace("%3c%25TERM%25%3e", thisResult.Trim().Replace(",", "%2C").Replace("&", "%26").Replace("\"", "%22").Replace("&", "&")) + "\">" + thisResult.Replace("\"", """).Replace("&", "&") + "</a><br />"); } } else if (results.Count < 500) { // Determine the actual page first int first_valid_page = -1; if ((letters_appearing.Contains('a')) || (letters_appearing.Contains('b'))) { first_valid_page = 1; } if ((letters_appearing.Contains('c')) || (letters_appearing.Contains('d')) || (letters_appearing.Contains('e'))) { if (first_valid_page < 0) { first_valid_page = 2; } } if ((letters_appearing.Contains('f')) || (letters_appearing.Contains('g')) || (letters_appearing.Contains('h'))) { if (first_valid_page < 0) { first_valid_page = 3; } } if ((letters_appearing.Contains('i')) || (letters_appearing.Contains('j')) || (letters_appearing.Contains('k'))) { if (first_valid_page < 0) { first_valid_page = 4; } } if ((letters_appearing.Contains('l')) || (letters_appearing.Contains('m')) || (letters_appearing.Contains('n'))) { if (first_valid_page < 0) { first_valid_page = 5; } } if ((letters_appearing.Contains('o')) || (letters_appearing.Contains('p')) || (letters_appearing.Contains('q'))) { if (first_valid_page < 0) { first_valid_page = 6; } } if ((letters_appearing.Contains('r')) || (letters_appearing.Contains('s')) || (letters_appearing.Contains('t'))) { if (first_valid_page < 0) { first_valid_page = 7; } } if ((letters_appearing.Contains('u')) || (letters_appearing.Contains('v')) || (letters_appearing.Contains('w'))) { if (first_valid_page < 0) { first_valid_page = 8; } } if ((letters_appearing.Contains('x')) || (letters_appearing.Contains('y')) || (letters_appearing.Contains('z'))) { if (first_valid_page < 0) { first_valid_page = 9; } } // Define the limits of the page value if ((current_page < first_valid_page) || (current_page > 9)) { current_page = first_valid_page; } // Add the links for paging through results Output.WriteLine("<div class=\"sbkMebv_NavRow\">"); if ((letters_appearing.Contains('a')) || (letters_appearing.Contains('b'))) { if (current_page == 1) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">AB</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/1" + url_options + "\" class=\"mbb1\">AB</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">AB</span> "); } if ((letters_appearing.Contains('c')) || (letters_appearing.Contains('d')) || (letters_appearing.Contains('e'))) { if (current_page == 2) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">CDE</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/2" + url_options + "\">CDE</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">CDE</span> "); } if ((letters_appearing.Contains('f')) || (letters_appearing.Contains('g')) || (letters_appearing.Contains('h'))) { if (current_page == 3) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">FGH</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/3" + url_options + "\">FGH</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">FGH</span> "); } if ((letters_appearing.Contains('i')) || (letters_appearing.Contains('j')) || (letters_appearing.Contains('k'))) { if (current_page == 4) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">IJK</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/4" + url_options + "\">IJK</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">IJK</span> "); } if ((letters_appearing.Contains('l')) || (letters_appearing.Contains('m')) || (letters_appearing.Contains('n'))) { if (current_page == 5) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">LMN</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/5" + url_options + "\">LMN</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">LMN</span> "); } if ((letters_appearing.Contains('o')) || (letters_appearing.Contains('p')) || (letters_appearing.Contains('q'))) { if (current_page == 6) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">OPQ</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/6" + url_options + "\">OPQ</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">OPQ</span> "); } if ((letters_appearing.Contains('r')) || (letters_appearing.Contains('s')) || (letters_appearing.Contains('t'))) { if (current_page == 7) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">RST</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/7" + url_options + "\">RST</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">RST</span> "); } if ((letters_appearing.Contains('u')) || (letters_appearing.Contains('v')) || (letters_appearing.Contains('w'))) { if (current_page == 8) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">UVW</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/8" + url_options + "\">UVW</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\">UVW</span> "); } if ((letters_appearing.Contains('x')) || (letters_appearing.Contains('y')) || (letters_appearing.Contains('z'))) { if (current_page == 9) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">XYZ</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/9" + url_options + "\">XYZ</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\" >XYZ</span> "); } Output.WriteLine("</div>"); Output.WriteLine("<br />"); Output.WriteLine("<br />"); // Find the start character and last character, per the page char first_char = ' '; char stop_char = 'c'; switch (current_page) { case 2: first_char = 'c'; stop_char = 'f'; break; case 3: first_char = 'f'; stop_char = 'i'; break; case 4: first_char = 'i'; stop_char = 'l'; break; case 5: first_char = 'l'; stop_char = 'o'; break; case 6: first_char = 'o'; stop_char = 'r'; break; case 7: first_char = 'r'; stop_char = 'u'; break; case 8: first_char = 'u'; stop_char = 'x'; break; case 9: first_char = 'x'; stop_char = '}'; break; } // Add the pertinent rows foreach (string thisValue in results) { if (thisValue.Length > 0) { char this_first_char = Char.ToLower(thisValue[0]); if ((this_first_char >= first_char) && (this_first_char < stop_char)) { Output.WriteLine("<a href=\"" + search_url.Replace("%3c%25TERM%25%3e", thisValue.Trim().Replace(",", "%2C").Replace("&", "%26").Replace("\"", "%22")).Replace("&", "&") + "\">" + thisValue.Replace("\"", """).Replace("&", "&") + "</a><br />"); } } } } else { // Determine the first valid page char label_char = 'a'; int first_valid_page = -1; int counter = 1; while (label_char <= 'z') { if (letters_appearing.Contains(label_char)) { if (first_valid_page < 0) { first_valid_page = counter; } } counter++; label_char = (char)((label_char) + 1); } // Define the limits of the page value if ((current_page < first_valid_page) || (current_page > 26)) { current_page = first_valid_page; } // Add the links for paging through results label_char = 'a'; counter = 1; Output.WriteLine("<div class=\"sbkMebv_NavRow\">"); while (label_char <= 'z') { if (letters_appearing.Contains(label_char)) { if (current_page == counter) { Output.WriteLine("<span class=\"sbkMebv_NavRowCurrent\">" + Char.ToUpper(label_char) + "</span> "); } else { Output.WriteLine("<a href=\"" + page_url + "/" + counter + url_options + "\" >" + Char.ToUpper(label_char) + "</a> "); } } else { Output.WriteLine("<span class=\"sbkMebv_NavRowDisabled\" >" + Char.ToUpper(label_char) + "</span> "); } counter++; label_char = (char)((label_char) + 1); } Output.WriteLine("</div>"); Output.WriteLine("<br />"); Output.WriteLine("<br />"); // Find the start character and last character, per the page char first_char = ' '; char stop_char = 'b'; if (current_page > 1) { first_char = (char)(96 + current_page); stop_char = (char)(97 + current_page); } // Add the pertinent rows foreach (string thisValue in results) { if (thisValue.Length > 0) { char this_first_char = Char.ToLower(thisValue[0]); if ((this_first_char >= first_char) && (this_first_char < stop_char)) { Output.WriteLine("<a href=\"" + search_url.Replace("%3c%25TERM%25%3e", thisValue.Trim().Replace(",", "%2C").Replace("&", "%26").Replace("\"", "%22")).Replace("&", "&") + "\">" + thisValue.Replace("\"", """).Replace("&", "&") + "</a><br />"); } } } } } else { Output.WriteLine("<br /><br /><br /><br />"); Output.WriteLine(currentMode.Info_Browse_Mode.Length == 0 ? "<center>Select a metadata field to browse by from the list on the left</center>" : "<center>NO MATCHING VALUES</center>"); Output.WriteLine("<br /><br />"); } } // Set the current mode back currentMode.Mode = Display_Mode_Enum.Aggregation; currentMode.Aggregation_Type = Aggregation_Type_Enum.Browse_By; Output.WriteLine("</div>"); Output.WriteLine("<br />"); if ((public_browses.Count > 1) || (internal_browses.Count > 0)) { Output.WriteLine("</td>"); Output.WriteLine("</tr>"); Output.WriteLine("</table>"); } Output.WriteLine(); }
/// <summary> Gets the browse or info object and any other needed data for display ( text to display) </summary> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Aggregation_Object"> Item Aggregation object</param> /// <param name="Base_Directory"> Base directory location under which the the CMS/info source file will be found</param> /// <param name="Current_User"> Currently logged on user, which can determine which items to show </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> /// <param name="Browse_Object"> [OUT] Stores all the information about this browse or info </param> /// <param name="Complete_Result_Set_Info"> [OUT] Information about the entire set of results </param> /// <param name="Paged_Results"> [OUT] List of search results for the requested page of results </param> /// <param name="Browse_Info_Display_Text"> [OUT] Static HTML-based content to be displayed if this is browing a staticly created html source file </param> /// <returns> TRUE if successful, otherwise FALSE </returns> /// <remarks> This attempts to pull the objects from the cache. If unsuccessful, it builds the objects from the /// database and hands off to the <see cref="CachedDataManager" /> to store in the cache </remarks> protected static bool Get_Browse_Info(Navigation_Object Current_Mode, Item_Aggregation Aggregation_Object, string Base_Directory, User_Object Current_User, Custom_Tracer Tracer, out Item_Aggregation_Child_Page Browse_Object, out Search_Results_Statistics Complete_Result_Set_Info, out List <iSearch_Title_Result> Paged_Results, out HTML_Based_Content Browse_Info_Display_Text) { if (Tracer != null) { Tracer.Add_Trace("abstractHtmlSubwriter.Get_Browse_Info", String.Empty); } // Set output initially to null Paged_Results = null; Complete_Result_Set_Info = null; Browse_Info_Display_Text = null; // First, make sure the browse submode is valid Browse_Object = Aggregation_Object.Child_Page_By_Code(Current_Mode.Info_Browse_Mode); if (Browse_Object == null) { Current_Mode.Error_Message = "Unable to retrieve browse/info item '" + Current_Mode.Info_Browse_Mode + "'"; return(false); } // Is this a table result, or a string? switch (Browse_Object.Source_Data_Type) { case Item_Aggregation_Child_Source_Data_Enum.Database_Table: // Set the current sort to ZERO, if currently set to ONE and this is an ALL BROWSE. // Those two sorts are the same in this case int sort = Current_Mode.Sort.HasValue ? Math.Max(Current_Mode.Sort.Value, ((ushort)1)) : 1; if ((sort == 0) && (Browse_Object.Code == "all")) { sort = 1; } // Special code if this is a JSON browse string browse_code = Current_Mode.Info_Browse_Mode; if (Current_Mode.Writer_Type == Writer_Type_Enum.JSON) { browse_code = browse_code + "_JSON"; sort = 12; } // Get the page count in the results int current_page_index = Current_Mode.Page.HasValue ? Math.Max(Current_Mode.Page.Value, ((ushort)1)) : 1; // Determine if this is a special search type which returns more rows and is not cached. // This is used to return the results as XML and DATASET bool special_search_type = false; int results_per_page = 20; if ((Current_Mode.Writer_Type == Writer_Type_Enum.XML) || (Current_Mode.Writer_Type == Writer_Type_Enum.DataSet)) { results_per_page = 1000000; special_search_type = true; sort = 2; // Sort by BibID always for these } Tracer.Add_Trace("abstractHtmlSubwriter.Get_Browse_Info", "Current_Mode.Writer_Type=[" + Current_Mode.Writer_Type.ToString() + "]."); Tracer.Add_Trace("abstractHtmlSubwriter.Get_Browse_Info", "Current_Mode.Results_Display_Type=[" + Current_Mode.Result_Display_Type + "]."); if (String.Equals(Current_Mode.Result_Display_Type, "timeline", StringComparison.OrdinalIgnoreCase)) { Tracer.Add_Trace("abstractHtmlSubwriter.Get_Browse_Info", "Is timeline, setting browse results_per_page and sort."); results_per_page = 20000; sort = 12; } // Set the flags for how much data is needed. (i.e., do we need to pull ANYTHING? or // perhaps just the next page of results ( as opposed to pulling facets again). bool need_browse_statistics = true; bool need_paged_results = true; if ((!special_search_type) && (Current_User == null)) { // Look to see if the browse statistics are available on any cache for this browse Complete_Result_Set_Info = CachedDataManager.Retrieve_Browse_Result_Statistics(Aggregation_Object.Code, browse_code, Tracer); if (Complete_Result_Set_Info != null) { need_browse_statistics = false; } // Look to see if the paged results are available on any cache.. Paged_Results = CachedDataManager.Retrieve_Browse_Results(Aggregation_Object.Code, browse_code, current_page_index, sort, (uint)results_per_page, Tracer); if (Paged_Results != null) { need_paged_results = false; } } // Was a copy found in the cache? if ((!need_browse_statistics) && (!need_paged_results)) { if (Tracer != null) { Tracer.Add_Trace("SobekCM_Assistant.Get_Browse_Info", "Browse statistics and paged results retrieved from cache"); } } else { if (Tracer != null) { Tracer.Add_Trace("SobekCM_Assistant.Get_Browse_Info", "Building results information"); } // Try to pull more than one page, so we can cache the next page or so List <List <iSearch_Title_Result> > pagesOfResults; // Get from the hierarchy object Multiple_Paged_Results_Args returnArgs = Item_Aggregation_Utilities.Get_Browse_Results(Aggregation_Object, Browse_Object, current_page_index, sort, results_per_page, !special_search_type, need_browse_statistics, Current_User, Tracer); if (need_browse_statistics) { Complete_Result_Set_Info = returnArgs.Statistics; } pagesOfResults = returnArgs.Paged_Results; if ((pagesOfResults != null) && (pagesOfResults.Count > 0)) { Paged_Results = pagesOfResults[0]; } // Save the overall result set statistics to the cache if something was pulled if ((!special_search_type) && (Current_User == null)) { if ((need_browse_statistics) && (Complete_Result_Set_Info != null)) { CachedDataManager.Store_Browse_Result_Statistics(Aggregation_Object.Code, browse_code, Complete_Result_Set_Info, Tracer); } // Save the overall result set statistics to the cache if something was pulled if ((need_paged_results) && (Paged_Results != null)) { CachedDataManager.Store_Browse_Results(Aggregation_Object.Code, browse_code, current_page_index, sort, (uint)results_per_page, pagesOfResults, Tracer); } } } break; case Item_Aggregation_Child_Source_Data_Enum.Static_HTML: Browse_Info_Display_Text = SobekEngineClient.Aggregations.Get_Aggregation_HTML_Child_Page(Aggregation_Object.Code, Aggregation_Object.Language, UI_ApplicationCache_Gateway.Settings.System.Default_UI_Language, Browse_Object.Code, Tracer); break; } return(true); }
/// <summary> Constructor for a new instance of the WebContent_Add_New_AdminViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <remarks> Postback from handling an edit or new aggregation is handled here in the constructor </remarks> public WebContent_Add_New_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("WebContent_Add_New_AdminViewer.Constructor", String.Empty); // Set some defaults actionMessage = String.Empty; // Ensure the user is the system admin or portal admin if ((RequestSpecificValues.Current_User == null) || ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin))) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek; RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // If this is posted back, look for the reset if (RequestSpecificValues.Current_Mode.isPostBack) { // Pull the standard values NameValueCollection form = HttpContext.Current.Request.Form; // Get the values from the form if (form["admin_webcontent_title"] != null) { title = form["admin_webcontent_title"]; } if (form["admin_webcontent_desc"] != null) { description = form["admin_webcontent_desc"]; } if (form["admin_webcontent_redirect"] != null) { redirect_url = form["admin_webcontent_redirect"]; } if (form["admin_webcontent_skin"] != null) { webSkin = form["admin_webcontent_skin"]; } inheritFromParent = form["admin_webcontent_inherit"] != null; // Get the level values from the form if ((form["admin_webcontent_level1"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level1"]))) { level1 = form["admin_webcontent_level1"]; if ((form["admin_webcontent_level2"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level2"]))) { level2 = form["admin_webcontent_level2"]; if ((form["admin_webcontent_level3"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level3"]))) { level3 = form["admin_webcontent_level3"]; if ((form["admin_webcontent_level4"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level4"]))) { level4 = form["admin_webcontent_level4"]; if ((form["admin_webcontent_level5"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level5"]))) { level5 = form["admin_webcontent_level5"]; if ((form["admin_webcontent_level6"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level6"]))) { level6 = form["admin_webcontent_level6"]; if ((form["admin_webcontent_level7"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level7"]))) { level7 = form["admin_webcontent_level7"]; if ((form["admin_webcontent_level8"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level8"]))) { level8 = form["admin_webcontent_level8"]; } } } } } } } } // Perform validation actionMessage = String.Empty; if ((String.IsNullOrEmpty(title)) || (String.IsNullOrEmpty(level1))) { actionMessage = "Error - required fields are missing<br />"; if (String.IsNullOrEmpty(title)) { actionMessage = actionMessage + " TITLE is a required field.<br />"; } if (String.IsNullOrEmpty(level1)) { actionMessage = actionMessage + " LEVEL1 is a required field.<br />"; } } string save_value = HttpContext.Current.Request.Form["admin_webcontent_save"]; if ((!String.IsNullOrEmpty(save_value)) && (save_value == "save")) { // Just ensure everything is emptied out if (String.IsNullOrEmpty(actionMessage)) { // Build this web content page HTML_Based_Content newContent = new HTML_Based_Content { WebContentID = -1, Level1 = level1, Level2 = level2, Level3 = level3, Level4 = level4, Level5 = level5, Level6 = level6, Level7 = level7, Level8 = level8, Title = title, Description = description, Web_Skin = webSkin, Author = RequestSpecificValues.Current_User.Full_Name, Date = DateTime.Now.ToShortDateString() }; if (!String.IsNullOrEmpty(description)) { newContent.Content = "<h2>" + title + "</h2>" + Environment.NewLine + "<p>" + description + "</p>"; } else { newContent.Content = "<h2>" + title + "</h2>" + Environment.NewLine + "<p>New web content page text goes here.</p>"; } newContent.ContentSource = newContent.Content; // Call the engine endpoint to put this RestResponseMessage msg = SobekEngineClient.WebContent.Add_HTML_Based_Content(newContent, RequestSpecificValues.Current_User.Full_Name, inheritFromParent, RequestSpecificValues.Tracer); // Clear the hierarchy CachedDataManager.WebContent.Clear_Hierarchy(); UI_ApplicationCache_Gateway.WebContent_Hierarchy_Clear(); // If successful, just send to it if (msg != null) { if (msg.ErrorTypeEnum == ErrorRestTypeEnum.Successful) { if (String.IsNullOrEmpty(msg.URI)) { actionMessage = "Page added, but new URI was not returned"; } else { RequestSpecificValues.Current_Mode.Request_Completed = true; HttpContext.Current.Response.Redirect(msg.URI, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); return; } } else { actionMessage = "ERROR: " + msg.Message; } } else { actionMessage = "ERROR: Exception deserializing the REST response message."; } } } } else { // Get any level filter information from the query string if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l1"])) { level1 = HttpContext.Current.Request.QueryString["l1"]; if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l2"])) { level2 = HttpContext.Current.Request.QueryString["l2"]; if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l3"])) { level3 = HttpContext.Current.Request.QueryString["l3"]; if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l4"])) { level4 = HttpContext.Current.Request.QueryString["l4"]; if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l5"])) { level5 = HttpContext.Current.Request.QueryString["l5"]; if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l6"])) { level6 = HttpContext.Current.Request.QueryString["l6"]; if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l7"])) { level7 = HttpContext.Current.Request.QueryString["l7"]; if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l8"])) { level8 = HttpContext.Current.Request.QueryString["l8"]; } } } } } } } } } }