Пример #1
0
        /// <summary>
        /// Examines/combines all the variables involved and sets
        /// CurrentUICulture and CurrentCulture.
        /// Can be overridden.
        /// </summary>
        /// <param name="e">The <see cref="Appleseed.Framework.Web.UI.WebControls.LanguageSwitcherEventArgs"/> instance containing the event data.</param>
        protected virtual void OnChangeLanguage(LanguageSwitcherEventArgs e)
        {
            // Updates current cultures
            SetCurrentLanguage(e.CultureItem, SwitcherCookieName, this);

            if (this.ChangeLanguage != null)
            {
                this.ChangeLanguage(this, e); // Invokes the delegates
            }
        }
Пример #2
0
        /// <summary>
        /// Examines/combines all the variables involved and sets
        /// CurrentUICulture and CurrentCulture.  instance containing the event data.
        /// </summary>
        /// <param name="e">Language switcher event arguments.</param>
        protected override void OnChangeLanguage(LanguageSwitcherEventArgs e)
        {
            if (this.Context == null)
            {
                return;
            }

            var mId = 0;
            if (this.Context.Request.Params["Mid"] != null)
            {
                mId = Int32.Parse(this.Context.Request.Params["Mid"]);
            }

            var tId = 0;
            if (this.Context.Request.Params["PageID"] != null)
            {
                tId = Int32.Parse(this.Context.Request.Params["PageID"]);
            }
            else if (this.Context.Request.Params["TabID"] != null)
            {
                tId = Int32.Parse(this.Context.Request.Params["TabID"]);
            }

            var auxUrl = this.Context.Request.Url.AbsolutePath;
            var auxApplication = this.Context.Request.ApplicationPath;
            var index = auxUrl.ToLower().IndexOf(auxApplication.ToLower());
            if (index != -1)
            {
                auxUrl = auxUrl.Substring(index + auxApplication.Length);
            }

            if (auxUrl.StartsWith("/"))
            {
                auxUrl = "~" + auxUrl;
            }
            else
            {
                auxUrl = "~/" + auxUrl;
            }

            var customParams =
                this.Context.Request.QueryString.Keys.Cast<string>().Where(
                    key =>
                    !key.ToLower().Equals("mid") && !key.ToLower().Equals("tabid") && !key.ToLower().Equals("lang")).
                    Aggregate(
                        string.Empty,
                        (current, key) => current + string.Format("&{0}={1}", key, this.Context.Request.Params[key]));

            var returnUrl = HttpUrlBuilder.BuildUrl(
                auxUrl, tId, mId, e.CultureItem.Culture, customParams, string.Empty, string.Empty);
            if (returnUrl.ToLower().IndexOf("lang") == -1)
            {
                customParams += "&Lang=" + e.CultureItem.Culture.Name;
                returnUrl = HttpUrlBuilder.BuildUrl(
                    auxUrl, tId, mId, e.CultureItem.Culture, customParams, string.Empty, string.Empty);
            }

            // System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(e.CultureItem
            // LanguageCultureItem lci = new LanguageCultureItem(e.CultureItem.Culture.Name, e.CultureItem.Culture.Name)
            SetCurrentLanguage(e.CultureItem);
            this.Context.Response.Redirect(returnUrl);
        }
Пример #3
0
        /// <summary>
        /// Examines/combines all the variables involved and sets
        /// CurrentUICulture and CurrentCulture.
        /// Can be overridden.
        /// </summary>
        /// <param name="e">The <see cref="Appleseed.Framework.Web.UI.WebControls.LanguageSwitcherEventArgs"/> instance containing the event data.</param>
        protected virtual void OnChangeLanguage(LanguageSwitcherEventArgs e)
        {
            // Updates current cultures
            SetCurrentLanguage(e.CultureItem, SwitcherCookieName, this);

            if (this.ChangeLanguage != null)
            {
                this.ChangeLanguage(this, e); // Invokes the delegates
            }
        }
Пример #4
0
        /// <summary>
        /// Examines/combines all the variables involved and sets
        /// CurrentUICulture and CurrentCulture.  instance containing the event data.
        /// </summary>
        /// <param name="e">Language switcher event arguments.</param>
        protected override void OnChangeLanguage(LanguageSwitcherEventArgs e)
        {
            if (this.Context == null)
            {
                return;
            }

            var mId = 0;

            if (this.Context.Request.Params["Mid"] != null)
            {
                mId = Int32.Parse(this.Context.Request.Params["Mid"]);
            }

            var tId = 0;

            if (this.Context.Request.Params["PageID"] != null)
            {
                tId = Int32.Parse(this.Context.Request.Params["PageID"]);
            }
            else if (this.Context.Request.Params["TabID"] != null)
            {
                tId = Int32.Parse(this.Context.Request.Params["TabID"]);
            }

            var auxUrl         = this.Context.Request.Url.AbsolutePath;
            var auxApplication = this.Context.Request.ApplicationPath;
            var index          = auxUrl.ToLower().IndexOf(auxApplication.ToLower());

            if (index != -1)
            {
                auxUrl = auxUrl.Substring(index + auxApplication.Length);
            }

            if (auxUrl.StartsWith("/"))
            {
                auxUrl = "~" + auxUrl;
            }
            else
            {
                auxUrl = "~/" + auxUrl;
            }

            var customParams =
                this.Context.Request.QueryString.Keys.Cast <string>().Where(
                    key =>
                    !key.ToLower().Equals("mid") && !key.ToLower().Equals("tabid") && !key.ToLower().Equals("lang")).
                Aggregate(
                    string.Empty,
                    (current, key) => current + string.Format("&{0}={1}", key, this.Context.Request.Params[key]));

            var returnUrl = HttpUrlBuilder.BuildUrl(
                auxUrl, tId, mId, e.CultureItem.Culture, customParams, string.Empty, string.Empty);

            if (returnUrl.ToLower().IndexOf("lang") == -1)
            {
                customParams += "&Lang=" + e.CultureItem.Culture.Name;
                returnUrl     = HttpUrlBuilder.BuildUrl(
                    auxUrl, tId, mId, e.CultureItem.Culture, customParams, string.Empty, string.Empty);
            }

            // System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(e.CultureItem
            // LanguageCultureItem lci = new LanguageCultureItem(e.CultureItem.Culture.Name, e.CultureItem.Culture.Name)
            SetCurrentLanguage(e.CultureItem);
            this.Context.Response.Redirect(returnUrl);
        }