private void Save_Page_Appearance_Postback(NameValueCollection Form) { // Log any uploaded banners if (HttpContext.Current.Session[itemAggregation.Code + "|Banners"] != null) { string files = HttpContext.Current.Session[itemAggregation.Code + "|Banners"].ToString().Replace("|", ", "); SobekCM_Database.Save_Item_Aggregation_Milestone(itemAggregation.Code, "Added banner file " + files, RequestSpecificValues.Current_User.Full_Name); HttpContext.Current.Session.Remove(itemAggregation.Code + "|Banners"); } // Some interesting custom actions on this page, so get the actions // query string first string action = Form["admin_aggr_action"]; if (action.Length > 0) { switch (action) { case "enable_css": itemAggregation.CSS_File = itemAggregation.Code + ".css"; string file = aggregationDirectory + "\\" + itemAggregation.CSS_File; if (!File.Exists(file)) { StreamWriter writer = new StreamWriter(file); writer.WriteLine("/** Aggregation-level CSS for " + itemAggregation.Code + " **/"); writer.WriteLine(); writer.Flush(); writer.Close(); } break; case "disable_css": itemAggregation.CSS_File = null; break; case "add_home": string language = Form["admin_aggr_new_home_lang"]; string copyFrom = Form["admin_aggr_new_home_copy"]; if (language.Length > 0) { Web_Language_Enum enumVal = Web_Language_Enum_Converter.Code_To_Enum(language); string new_file_name = "text_" + language.ToLower() + ".html"; string new_file = aggregationDirectory + "\\html\\home\\" + new_file_name; if (!Directory.Exists(aggregationDirectory + "\\html\\home")) Directory.CreateDirectory(aggregationDirectory + "\\html\\home"); bool created_exists = false; if (copyFrom.Length > 0) { string copy_file = aggregationDirectory + "\\" + copyFrom; if (File.Exists(copy_file)) { File.Copy(copy_file, new_file, true); created_exists = true; } } if ((!created_exists) && (!File.Exists(new_file))) { StreamWriter writer = new StreamWriter(new_file); writer.WriteLine("New home page text in " + language + " goes here."); writer.Flush(); writer.Close(); } itemAggregation.Add_Home_Page_File("html\\home\\" + new_file_name, enumVal, false); // Add this to the list of JUST ADDED home pages, which can't be edited or viewed until saved List<Web_Language_Enum> newLanguages = HttpContext.Current.Session["Item_Aggr_Edit_" + itemAggregation.Code + "_NewLanguages"] as List<Web_Language_Enum> ?? new List<Web_Language_Enum>(); newLanguages.Add(enumVal); HttpContext.Current.Session["Item_Aggr_Edit_" + itemAggregation.Code + "_NewLanguages"] = newLanguages; } break; case "add_banner": string blanguage = Form["admin_aggr_new_banner_lang"]; string bfile = Form["admin_aggr_new_banner_image"]; string btype = Form["admin_aggr_new_banner_type"]; if (blanguage.Length > 0) { Web_Language_Enum enumVal = Web_Language_Enum_Converter.Code_To_Enum(blanguage); if (btype == "standard") { itemAggregation.Add_Banner_Image("images\\banners\\" + bfile, enumVal); } else { Item_Aggregation_Front_Banner_Type_Enum btypeEnum = Item_Aggregation_Front_Banner_Type_Enum.Full; if (btype == "left") btypeEnum = Item_Aggregation_Front_Banner_Type_Enum.Left; if (btype == "right") btypeEnum = Item_Aggregation_Front_Banner_Type_Enum.Right; Item_Aggregation_Front_Banner newFront = new Item_Aggregation_Front_Banner("images\\banners\\" + bfile) { Type = btypeEnum }; try { string banner_file = aggregationDirectory + "\\images\\banners\\" + bfile; if (File.Exists(banner_file)) { using (Image bannerImage = Image.FromFile(banner_file)) { newFront.Width = (ushort)bannerImage.Width; newFront.Height = (ushort)bannerImage.Height; bannerImage.Dispose(); } } } catch (Exception) { } itemAggregation.Add_Front_Banner_Image(newFront, enumVal); } } break; default: if (action.IndexOf("delete_home_") == 0) { string code_to_delete = action.Replace("delete_home_", ""); Web_Language_Enum enum_to_delete = Web_Language_Enum_Converter.Code_To_Enum(code_to_delete); itemAggregation.Delete_Home_Page(enum_to_delete); } if (action.IndexOf("delete_standard_") == 0) { string code_to_delete = action.Replace("delete_standard_", ""); Web_Language_Enum enum_to_delete = Web_Language_Enum_Converter.Code_To_Enum(code_to_delete); if (itemAggregation.Banner_Dictionary != null) itemAggregation.Banner_Dictionary.Remove(enum_to_delete); } if (action.IndexOf("delete_front_") == 0) { string code_to_delete = action.Replace("delete_front_", ""); Web_Language_Enum enum_to_delete = Web_Language_Enum_Converter.Code_To_Enum(code_to_delete); if (itemAggregation.Front_Banner_Dictionary != null) itemAggregation.Front_Banner_Dictionary.Remove(enum_to_delete); } if ((action.Length > 0) && (action.IndexOf("delete_image_") == 0)) { string banner_file = action.Replace("delete_image_", ""); string path_file = aggregationDirectory + "\\images\\banners\\" + banner_file; if (File.Exists(path_file)) { try { File.Delete(path_file); SobekCM_Database.Save_Item_Aggregation_Milestone(itemAggregation.Code, "Deleted unused banner file " + banner_file, RequestSpecificValues.Current_User.Full_Name); } catch { } } } if ((action.IndexOf("customize_") == 0) || (action.IndexOf("uncustomize_") == 0)) { string code = action.Replace("uncustomize_", "").Replace("customize_", ""); Web_Language_Enum asEnum = Web_Language_Enum_Converter.Code_To_Enum(code); if (itemAggregation.Home_Page_File_Dictionary.ContainsKey(asEnum)) { itemAggregation.Home_Page_File_Dictionary[asEnum].isCustomHome = (action.IndexOf("uncustomize_") != 0); } } break; } } // Set the web skin itemAggregation.Web_Skins = null; itemAggregation.Default_Skin = null; foreach (string thisKey in Form.AllKeys) { if ((thisKey.IndexOf("admin_aggr_skin_") == 0) && ( Form[thisKey] != null ) && ( Form[thisKey].Length > 0 )) { if (itemAggregation.Web_Skins == null) itemAggregation.Web_Skins = new List<string>(); itemAggregation.Web_Skins.Add(Form[thisKey]); if (String.IsNullOrEmpty(itemAggregation.Default_Skin)) itemAggregation.Default_Skin = Form[thisKey]; } } //if ((Form["admin_aggr_skin_1"] != null) && (Form["admin_aggr_skin_1"].Length > 0)) //{ // itemAggregation.Web_Skins = new List<string> { Form["admin_aggr_skin_1"] }; // itemAggregation.Default_Skin = Form["admin_aggr_skin_1"]; //} }
/// <summary> Constructor for a new instance of the Rotating_Highlight_MimeType_AggregationViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <param name="ViewBag"> Aggregation-specific request information, such as aggregation object and any browse object requested </param> public Rotating_Highlight_MimeType_AggregationViewer(RequestCache RequestSpecificValues, AggregationViewBag ViewBag) : base(RequestSpecificValues, ViewBag) { // Determine the sub text to use const string SUB_CODE = "s="; Sharing_Buttons_HTML = String.Empty; // Save the search term if (RequestSpecificValues.Current_Mode.Search_String.Length > 0) { textBoxValue = RequestSpecificValues.Current_Mode.Search_String; } // Determine the complete script action name Display_Mode_Enum displayMode = RequestSpecificValues.Current_Mode.Mode; Aggregation_Type_Enum aggrType = RequestSpecificValues.Current_Mode.Aggregation_Type; Search_Type_Enum searchType = RequestSpecificValues.Current_Mode.Search_Type; RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Results; RequestSpecificValues.Current_Mode.Search_Type = Search_Type_Enum.Basic; RequestSpecificValues.Current_Mode.Search_Precision = Search_Precision_Type_Enum.Inflectional_Form; string search_string = RequestSpecificValues.Current_Mode.Search_String; RequestSpecificValues.Current_Mode.Search_String = String.Empty; RequestSpecificValues.Current_Mode.Search_Fields = String.Empty; arg2 = String.Empty; arg1 = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation; RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Browse_Info; RequestSpecificValues.Current_Mode.Info_Browse_Mode = "all"; browse_url = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); RequestSpecificValues.Current_Mode.Info_Browse_Mode = String.Empty; RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home; if ((!RequestSpecificValues.Current_Mode.Show_Selection_Panel.HasValue) || (!RequestSpecificValues.Current_Mode.Show_Selection_Panel.Value) || (ViewBag.Hierarchy_Object.Children_Count == 0)) { Search_Script_Action = "basic_search_sobekcm('" + arg1 + "', '" + browse_url + "')"; } else { Search_Script_Action = "basic_select_search_sobekcm('" + arg1 + "', '" + SUB_CODE + "')"; arg2 = SUB_CODE; } RequestSpecificValues.Current_Mode.Mode = displayMode; RequestSpecificValues.Current_Mode.Aggregation_Type = aggrType; RequestSpecificValues.Current_Mode.Search_Type = searchType; RequestSpecificValues.Current_Mode.Search_String = search_string; // Get the front banner frontBannerInfo = ViewBag.Hierarchy_Object.FrontBannerObj; }
/// <summary> /// Add the special front banner image that displays on the home page only for this aggregation, by language /// </summary> /// <param name = "Banner"> special front banner image source file for this aggregation </param> /// <param name = "Language"> Language code </param> /// <returns> Build front banner image information object </returns> public Item_Aggregation_Front_Banner Add_Front_Banner_Image(Item_Aggregation_Front_Banner Banner, Web_Language_Enum Language) { if (Front_Banner_Dictionary == null) Front_Banner_Dictionary = new Dictionary<Web_Language_Enum, Item_Aggregation_Front_Banner>(); // If no language code, then always use this as the default if (Language == Web_Language_Enum.DEFAULT) { Front_Banner_Dictionary[defaultUiLanguage] = Banner; } else { // Save this under the normalized language code Front_Banner_Dictionary[Language] = Banner; } return Banner; }