コード例 #1
0
        /// <summary>
        ///   Add the special front banner image that displays on the home page only for this aggregation, by language
        /// </summary>
        /// <param name = "Banner_Image"> special front banner image source file for this aggregation </param>
        /// <param name = "Language"> Language code </param>
        /// <returns> Build front banner image information object </returns>
        internal Item_Aggregation_Front_Banner Add_Front_Banner_Image(string Banner_Image, Web_Language_Enum Language)
        {
            Item_Aggregation_Front_Banner banner = new Item_Aggregation_Front_Banner(Banner_Image);

            // If no language code, then always use this as the default
            if (Language == Web_Language_Enum.DEFAULT)
            {
                frontBannerImageByLanguage[SobekCM_Library_Settings.Default_UI_Language] = banner;
            }
            else
            {
                // Save this under the normalized language code
                frontBannerImageByLanguage[Language] = banner;
            }
            return banner;
        }
        private void Save_Page_5_Postback(NameValueCollection Form)
        {
            // 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 = String.Empty;
                        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.Home_Page_File_Dictionary[enumVal] = "html\\home\\" + new_file_name;

                            // 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.Banner_Dictionary[enumVal] = "images\\banners\\" + bfile;
                            }
                            else
                            {
                                Item_Aggregation_Front_Banner.Item_Aggregation_Front_Banner_Type btypeEnum = Item_Aggregation_Front_Banner.Item_Aggregation_Front_Banner_Type.FULL;
                                if ( btype == "left" )
                                    btypeEnum = Item_Aggregation_Front_Banner.Item_Aggregation_Front_Banner_Type.LEFT;
                                if ( btype == "right" )
                                    btypeEnum = Item_Aggregation_Front_Banner.Item_Aggregation_Front_Banner_Type.RIGHT;
                                Item_Aggregation_Front_Banner newFront = new Item_Aggregation_Front_Banner("images\\banners\\" + bfile) {Banner_Type = btypeEnum};

                                try
                                {
                                    string banner_file = aggregationDirectory + "\\images\\banners\\" + bfile;
                                    if (File.Exists(banner_file))
                                    {
                                        using (System.Drawing.Image bannerImage = System.Drawing.Image.FromFile(banner_file))
                                        {
                                            newFront.Width = (ushort) bannerImage.Width;
                                            newFront.Height = (ushort) bannerImage.Height;
                                            bannerImage.Dispose();
                                        }
                                    }
                                }
                                catch (Exception)
                                {

                                }

                                itemAggregation.Front_Banner_Dictionary[enumVal] = newFront;
                            }
                        }

                        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);
                            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);
                            itemAggregation.Front_Banner_Dictionary.Remove(enum_to_delete);
                        }
                        break;

                }
            }

            // Set the web skin
            itemAggregation.Web_Skins.Clear();
            itemAggregation.Default_Skin = String.Empty;
            if (( Form["admin_aggr_skin_1"] != null ) && ( Form["admin_aggr_skin_1"].Length > 0 ))
            {
                itemAggregation.Web_Skins.Add( Form["admin_aggr_skin_1"] );
                itemAggregation.Default_Skin = Form["admin_aggr_skin_1"];
            }

            // Set the custom home source file
            if (Form["admin_aggr_custom_home"] != null)
            {
                itemAggregation.Custom_Home_Page_Source_File = Form["admin_aggr_custom_home"].Trim();
            }
        }
        /// <summary> Constructor for a new instance of the Basic_Search_AggregationViewer class </summary>
        /// <param name="Current_Aggregation"> Current item aggregation object </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        public Rotating_Highlight_Search_AggregationViewer(Item_Aggregation Current_Aggregation, SobekCM_Navigation_Object Current_Mode)
            : base(Current_Aggregation, Current_Mode)
        {
            // Determine the sub text to use
            const string SUB_CODE = "s=";
            Sharing_Buttons_HTML = String.Empty;

            // Save the search term
            if (currentMode.Search_String.Length > 0)
            {
                textBoxValue = currentMode.Search_String;
            }

            // Determine the complete script action name
            Display_Mode_Enum displayMode = currentMode.Mode;
            Aggregation_Type_Enum aggrType = currentMode.Aggregation_Type;
            Search_Type_Enum searchType = currentMode.Search_Type;
            currentMode.Mode = Display_Mode_Enum.Results;
            currentMode.Search_Type = Search_Type_Enum.Basic;
            currentMode.Search_Precision = Search_Precision_Type_Enum.Inflectional_Form;
            string search_string = currentMode.Search_String;
            currentMode.Search_String = String.Empty;
            currentMode.Search_Fields = String.Empty;
            arg2 = String.Empty;
            arg1 = currentMode.Redirect_URL();
            currentMode.Aggregation_Type = Aggregation_Type_Enum.Browse_Info;
            currentMode.Info_Browse_Mode = "all";
            browse_url = currentMode.Redirect_URL();
            currentMode.Info_Browse_Mode = String.Empty;
            currentMode.Aggregation_Type = Aggregation_Type_Enum.Home;
            if ((!currentMode.Show_Selection_Panel) || (Current_Aggregation.Children_Count == 0))
            {
                scriptActionName = "basic_search_sobekcm('" + arg1 + "', '" + browse_url + "')";
             }
            else
            {
                scriptActionName = "basic_select_search_sobekcm('" + arg1 + "', '" + SUB_CODE + "')";
                arg2 = SUB_CODE;
             }
            currentMode.Mode = displayMode;
            currentMode.Aggregation_Type = aggrType;
            currentMode.Search_Type = searchType;
            currentMode.Search_String = search_string;

            // Get the front banner
            frontBannerInfo = Current_Aggregation.Front_Banner_Image(currentMode.Language);
        }
コード例 #4
0
        private static void read_banners(XmlNodeReader NodeReader, Item_Aggregation HierarchyObject)
        {
            while (NodeReader.Read())
            {
                // If this is the beginning tag for an element, assign the next values accordingly
                if (NodeReader.NodeType == XmlNodeType.Element)
                {
                    // Get the node name, trimmed and to upper
                    string nodeName = NodeReader.Name.Trim().ToUpper();

                    // switch the rest based on the tag name
                    switch (nodeName)
                    {
                    case "HI:SOURCE":
                        // Check for any attributes to this banner node
                        string lang    = String.Empty;
                        bool   special = false;
                        Item_Aggregation_Front_Banner.Item_Aggregation_Front_Banner_Type type = Item_Aggregation_Front_Banner.Item_Aggregation_Front_Banner_Type.LEFT;
                        ushort width  = 550;
                        ushort height = 230;

                        if (NodeReader.HasAttributes)
                        {
                            if (NodeReader.MoveToAttribute("lang"))
                            {
                                lang = NodeReader.Value.Trim().ToUpper();
                            }
                            if (NodeReader.MoveToAttribute("type"))
                            {
                                if ((NodeReader.Value.Trim().ToUpper() == "HIGHLIGHT") || (NodeReader.Value.Trim().ToUpper() == "FRONT"))
                                {
                                    special = true;
                                }
                            }
                            if (NodeReader.MoveToAttribute("side"))
                            {
                                switch (NodeReader.Value.Trim().ToUpper())
                                {
                                case "RIGHT":
                                    type = Item_Aggregation_Front_Banner.Item_Aggregation_Front_Banner_Type.RIGHT;
                                    break;

                                case "LEFT":
                                    type = Item_Aggregation_Front_Banner.Item_Aggregation_Front_Banner_Type.LEFT;
                                    break;

                                case "FULL":
                                    type = Item_Aggregation_Front_Banner.Item_Aggregation_Front_Banner_Type.FULL;
                                    break;
                                }
                            }
                            if (NodeReader.MoveToAttribute("width"))
                            {
                                ushort.TryParse(NodeReader.Value, out width);
                            }
                            if (NodeReader.MoveToAttribute("height"))
                            {
                                ushort.TryParse(NodeReader.Value, out height);
                            }
                        }

                        // Now read the banner information and add to the aggregation object
                        NodeReader.Read();
                        if (special)
                        {
                            Item_Aggregation_Front_Banner bannerObj = HierarchyObject.Add_Front_Banner_Image(NodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(lang));
                            bannerObj.Width       = width;
                            bannerObj.Height      = height;
                            bannerObj.Banner_Type = type;
                        }
                        else
                        {
                            HierarchyObject.Add_Banner_Image(NodeReader.Value, Web_Language_Enum_Converter.Code_To_Enum(lang));
                        }


                        break;
                    }
                }

                if ((NodeReader.NodeType == XmlNodeType.EndElement) && (NodeReader.Name.Trim().ToUpper() == "HI:BANNER"))
                {
                    return;
                }
            }
        }