コード例 #1
0
        public void LanguageDropDown_Changed(object sender, EventArgs e)
        {
            BaseLocale locale = null;

            locale = Locales.FindLocaleByName(this.LanguageDropDown.SelectedValue);

            ((TBWebPage)this.Page).Locale = locale;

            //NOTE: this is not a good solution to the Singleton pattern
            DynamicEdit.ResetFirst();
            DynamicEditPage.ResetFirst();

            Response.Redirect(Request.Url.AbsoluteUri, true);
        }
コード例 #2
0
        /// <summary>
        /// Update the XML resource file with the appropriate data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void DynamicEdit_Submit(object sender, EventArgs e)
        {
            if (!AdminUtil.IsAdminLoggedIn())
            {
                throw new Exception("Cannot modify XML - Admin not logged in.");
            }

            //get the sender control
            DynamicEdit control = (DynamicEdit)((WebControl)sender).NamingContainer;

            //get the Key from the control
            String key = control.Key;

            //open the appropriate language XML file
            XmlDocument doc = new XmlDocument();

            string filename = Localization.ResourceManager.GetCurrentFilename();

            doc.PreserveWhitespace = true;

            doc.Load(filename);

            //find the node with the matching key
            XmlNode node = doc.SelectSingleNode("Resource/item[@name='" + key + "']");

            if (node != null)
            {
                //enter this data into the node
                node.InnerXml = control.EditText;
            }
            else
            {
                //else create a node with the key
                XmlNode    root = doc.SelectSingleNode("Resource");
                XmlElement item = doc.CreateElement("item");
                item.SetAttribute("name", key);
                item.InnerXml = control.EditText;

                root.AppendChild(item);
            }

            //save the xml file
            doc.Save(filename);

            //clear the cache of text
            Localization.ResourceManager.ClearCache();
        }
コード例 #3
0
        public void CheckFlags()
        {
            //handle flag clicks
            //NOTE: this has been handled by GET to allow for Googlebots to search
            if (Request["lang"] != null)
            {
                switch (Request["lang"])
                {
                case "en":
                    ((TBWebPage)this.Page).Locale = Locales.America;
                    break;

                case "pt":
                    ((TBWebPage)this.Page).Locale = Locales.Brazil;
                    break;

                case "ja":
                    ((TBWebPage)this.Page).Locale = Locales.Japan;
                    break;

                case "es":
                    ((TBWebPage)this.Page).Locale = Locales.Peru;
                    break;
                }


                string uri = Request.Url.AbsoluteUri;

                uri = System.Text.RegularExpressions.Regex.Replace(uri, "lang=..", "");

                //NOTE: this is not a good solution to the Singleton pattern
                DynamicEdit.ResetFirst();
                DynamicEditPage.ResetFirst();

                //redirect with the new language
                Response.Redirect(uri, true);
            }
        }