예제 #1
0
        public ActionResult LstLanguages()
        {
            LanguageSwitcher ls = new LanguageSwitcher();
            Appleseed.Framework.Web.UI.WebControls.LanguageCultureCollection lcc = Appleseed.Framework.Localization.LanguageSwitcher.GetLanguageCultureList();

            List<string[]> datos = new List<string[]>();

            foreach (Appleseed.Framework.Web.UI.WebControls.LanguageCultureItem l in lcc)
            {
                string[] dato = new string[3];
                string aux = l.ToString();
                char[] array = new char[1];
                array[0] = '/';
                string[] lang = aux.Split(array);

                dato[0] = HttpUrlBuilder.BuildUrl("~/site/0/Home?lang="+lang[0]);

                LanguageSwitcher lswitcher = new LanguageSwitcher();
                dato[1] = lswitcher.GetFlagImgLCI(l);
                dato[1] = dato[1].Replace("images", "~/aspnet_client");

                dato[1] = HttpUrlBuilder.BuildUrl(dato[1]);

                dato[2] = lswitcher.getNameLCI(l);
                datos.Add(dato);
            }

            ViewData["datos"] = datos;
            return View();
        }
예제 #2
0
 /// <summary>
 /// Get current Language from ViewState
 /// </summary>
 /// <param name="switcher">
 /// The switcher.
 /// </param>
 /// <returns>
 /// </returns>
 private static LanguageCultureItem InternalGetViewState(LanguageSwitcher switcher)
 {
     return(switcher != null && switcher.ViewState["RB_Language_CurrentUICulture"] != null &&
            switcher.ViewState["RB_Language_CurrentCulture"] != null
                ? new LanguageCultureItem(
                (CultureInfo)switcher.ViewState["RB_Language_CurrentUICulture"],
                (CultureInfo)switcher.ViewState["RB_Language_CurrentCulture"])
                : null);
 }
예제 #3
0
        /// <summary>
        /// Examines/combines all the variables involved and sets
        ///   CurrentUICulture and CurrentCulture
        /// </summary>
        /// <param name="langList">
        /// Languages list. Something like it=it-IT;en=en-US
        /// </param>
        /// <param name="cookieAlias">
        /// Alias used to make this cookie unique. Use null is you do not want cookies.
        /// </param>
        /// <param name="switcher">
        /// A referenced to a Switcher control for accessing view state
        /// </param>
        internal static void ProcessCultures(string langList, string cookieAlias, LanguageSwitcher switcher)
        {
            var myLanguagesCultureList = (LanguageCultureCollection)langList;

            // Verify that at least on language is provided
            if (myLanguagesCultureList.Count <= 0)
            {
                throw new ArgumentException("Please provide at least one language in the list.", "langList");
            }

            // Language Item
            // Query string
            var langItem = InternalGetQuerystring(myLanguagesCultureList);

            // Trace.WriteLine("Evaluated InternalGetQuerystring: '" + (langItem == null ? "null" : langItem) + "'");
            if (langItem != null)
            {
                goto setLanguage;
            }

            // View state
            langItem = InternalGetViewState(switcher);

            // Trace.WriteLine("Evaluated InternalGetViewState: '" + (langItem == null ? "null" : langItem) + "'");
            if (langItem != null)
            {
                goto setLanguage;
            }

            // Cookie
            langItem = InternalGetCookie(myLanguagesCultureList, cookieAlias);

            // Trace.WriteLine("Evaluated InternalGetCookie: '" + (langItem == null ? "null" : langItem) + "'");
            if (langItem != null)
            {
                goto setLanguage;
            }

            // UserLanguageList
            langItem = InternalGetUserLanguages(myLanguagesCultureList);

            // Trace.WriteLine("Evaluated InternalGetUserLanguages: '" + (langItem == null ? "null" : langItem) + "'");
            if (langItem != null)
            {
                goto setLanguage;
            }

            // Default
            langItem = InternalGetDefault(myLanguagesCultureList);

            // Trace.WriteLine("Evaluated InternalGetDefault: '" + (langItem == null ? "null" : langItem) + "'");
setLanguage:

            // Updates current cultures
            SetCurrentLanguage(langItem, cookieAlias);
        }
예제 #4
0
        /// <summary>
        /// The set current language.
        /// </summary>
        /// <param name="langItem">The lang item.</param>
        /// <param name="cookieAlias">Cookie name used for persist Language</param>
        /// <param name="switcher">The switcher.</param>
        internal static void SetCurrentLanguage(
            LanguageCultureItem langItem, string cookieAlias, LanguageSwitcher switcher)
        {
            Thread.CurrentThread.CurrentUICulture = langItem.UICulture;
            Thread.CurrentThread.CurrentCulture   = langItem.Culture;

            // Persists choice
            InternalSetViewState(langItem, switcher);
            InternalSetCookie(langItem, cookieAlias);
        }
        /// <summary>
        /// Component is the instance of the component or control that
        /// this designer object is associated with. This property is
        /// inherited from System.ComponentModel.ComponentDesigner.
        /// </summary>
        /// <returns></returns>
        public override string GetDesignTimeHtml()
        {
            try
            {
                LanguageSwitcher langSwitcher = (LanguageSwitcher)Component;

                StringWriter   sw = new StringWriter(CultureInfo.CurrentUICulture);               //IFormatProvider should be passed
                HtmlTextWriter tw = new HtmlTextWriter(sw);

                langSwitcher.RenderControl(tw);

                return(sw.ToString());
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Exception occurred rendering Language Switcher at design time: ");
                Debug.WriteLine(ex.Message);
                throw;
            }
        }
예제 #6
0
        /// <summary>
        /// Binds the control and all its child controls to the specified data source.
        /// </summary>
        public override void DataBind()
        {
            if (HttpContext.Current != null)
            {
                //Init data
                ArrayList list = new ArrayList();

                // Obtain PortalSettings from Current Context
                PortalSettings PortalSettings = (PortalSettings) HttpContext.Current.Items["PortalSettings"];

                string homeLink = "<a";
                string menuLink;

                // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                if (CssClass.Length != 0)
                    homeLink = homeLink + " class=\"" + CssClass + "\"";

                homeLink = homeLink + " href='" + HttpUrlBuilder.BuildUrl() + "'>" +
                           General.GetString("Appleseed", "HOME") + "</a>";

                // If user logged in, customize welcome message
                if (HttpContext.Current.Request.IsAuthenticated == true)
                {
                    if (ShowWelcome)
                    {
                        list.Add(General.GetString("HEADER_WELCOME", "Welcome", this) + "&#160;" +
                                 PortalSettings.CurrentUser.Identity.Name + "!");
                    }

                    if (ShowHome)
                    {
                        list.Add(homeLink);
                    }

                    if (ShowHelp)
                    {
                        list.Add(GetHelpLink());
                    }

                    // Added by Mario Endara <*****@*****.**> (2004/11/06)
                    // Find Tab module to see if the user has add/edit rights
                    ModulesDB modules = new ModulesDB();
                    Guid TabGuid = new Guid("{1C575D94-70FC-4A83-80C3-2087F726CBB3}");
                    // Added by Xu Yiming <*****@*****.**> (2004/12/6)
                    // Modify for support Multi or zero Pages Modules in a single portal.
                    bool HasEditPermissionsOnTabs = false;
                    int TabModuleID = 0;

            //					SqlDataReader result = modules.FindModulesByGuid(PortalSettings.PortalID, TabGuid);
            //					while(result.Read())
            //					{
            //						TabModuleID=(int)result["ModuleId"];

                    foreach (ModuleItem m in modules.FindModuleItemsByGuid(PortalSettings.PortalID, TabGuid))
                    {
                        HasEditPermissionsOnTabs = PortalSecurity.HasEditPermissions(m.ID);
                        if (HasEditPermissionsOnTabs)
                        {
                            TabModuleID = m.ID;
                            break;
                        }
                    }

                    // If user logged in and has Edit permission in the Tab module, reach tab management just one click
                    if ((ShowTabMan) && (HasEditPermissionsOnTabs))
                    {
                        // added by Mario Endara 2004/08/06 so PageLayout can return to this page
                        // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                            menuLink = menuLink + " class=\"" + CssClass + "\"";

                        // added mID by Mario Endara <*****@*****.**> to support security check (2004/11/09)
                        var url = HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Pages/PageLayout.aspx?PageID=") +
                                   PortalSettings.ActivePage.PageID + "&amp;mID=" + TabModuleID.ToString() +
                                   "&amp;Alias=" + PortalSettings.PortalAlias + "&amp;lang=" + PortalSettings.PortalUILanguage +
                                   "&amp;returntabid=" + PortalSettings.ActivePage.PageID;
                        menuLink = menuLink + " href='" + url + "' onclick=\"openInModal('" + url + "','" + General.GetString("HEADER_MANAGE_TAB", "Edit This Page", null) + "');return false;\");>" +
                                   General.GetString("HEADER_MANAGE_TAB", "Edit This Page", null) + "</a>";
                        list.Add(menuLink);
                    }

                    if (ShowDragNDrop && HasEditPermissionsOnTabs) {

                        menuLink = "<a";
                        if (CssClass.Length != 0)
                            menuLink = menuLink + " class=\"" + CssClass + "\"";

                        menuLink = menuLink + " href='javascript:DnD();'>" + General.GetString("DRAGNDROP", "DragNDrop", null) + "</a>";
                        list.Add(menuLink);
                    }

                    if (ShowEditProfile)
                    {
                        // 19/08/2004 Jonathan Fong
                        // www.gt.com.au
                        if ( Context.User.Identity.AuthenticationType == "LDAP" ) {
                            // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                            menuLink = "<a";
                            if ( CssClass.Length != 0 )
                                menuLink = menuLink + " class=\"" + CssClass + "\"";

                            menuLink = menuLink + " href='" +
                                       HttpUrlBuilder.BuildUrl( "~/DesktopModules/CoreModules/Register/Register.aspx") +
                                       "'>" + "Profile" + "</a>";
                            list.Add( menuLink );
                        }
                        // If user is form add edit user link
                        else if ( !( HttpContext.Current.User is WindowsPrincipal ) ) {
                            // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                            menuLink = "<a";
                            if ( CssClass.Length != 0 )
                                menuLink = menuLink + " class=\"" + CssClass + "\"";

                            menuLink = menuLink + " href='" +
                                       HttpUrlBuilder.BuildUrl( "~/DesktopModules/CoreModules/Register/Register.aspx") +
                                       "'>" +
                                       General.GetString( "HEADER_EDIT_PROFILE", "Edit profile", this ) + "</a>";
                            list.Add( menuLink );
                        }
                    }

                    // if authentication mode is Cookie, provide a logoff link
                    if (Context.User.Identity.AuthenticationType == "Forms" ||
                        Context.User.Identity.AuthenticationType == "LDAP")
                    {
                        if (ShowLogOff)
                        {
                            // Corrections when ShowSecureLogon is true. [email protected] (05/07/2004)
                            string href = HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Admin/Logoff.aspx");
                            if (ShowSecureLogon && Context.Request.IsSecureConnection)
                            {
                                string auxref = Context.Request.Url.AbsoluteUri;
                                auxref = auxref.Substring(0, auxref.IndexOf(Context.Request.Url.PathAndQuery));
                                href = auxref + href;
                                href = href.Replace("https", "http");
                            }
                            // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                            menuLink = "<a";
                            if (CssClass.Length != 0)
                                menuLink = menuLink + " class=\"" + CssClass + "\"";

                            menuLink = menuLink + " href='" + href + "'>" +
                                       General.GetString("HEADER_LOGOFF", "Logoff", null) + "</a>";

                            list.Add(menuLink);
                        }
                    }
                }
                else
                {
                    if (ShowHome)
                    {
                        list.Add(homeLink);
                    }

                    if (ShowHelp)
                    {
                        list.Add(GetHelpLink());
                    }

                    // if not authenticated and ShowLogon is true, provide a logon link

                    if (ShowLogon)
                    {
                        // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                            menuLink = menuLink + " class=\"" + CssClass + "\"";

                        menuLink += string.Concat(" id=\"", this.ClientID, "_logon_link" , "\"");
                        menuLink = menuLink + " href='" + HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Admin/Logon.aspx") +
                                   "'>" + General.GetString("LOGON", "Logon", null) + "</a>";
                        list.Add(menuLink);
                    }

                    var allowNewRegistration = false;
                    if (PortalSettings.CustomSettings["SITESETTINGS_ALLOW_NEW_REGISTRATION"] != null)
                        if (bool.Parse(PortalSettings.CustomSettings["SITESETTINGS_ALLOW_NEW_REGISTRATION"].ToString()))
                            allowNewRegistration = true;

                    if (ShowRegister && allowNewRegistration) {

                        menuLink = "<a";
                        if (CssClass.Length != 0)
                            menuLink = menuLink + " class=\"" + CssClass + "\"";

                        menuLink = menuLink + " href='" + HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Register/Register.aspx") +
                                   "'>" + General.GetString("REGISTER", "Register", null) + "</a>";
                        list.Add(menuLink);
                    }

                    // Thierry (Tiptopweb) 5 May 2003 : Secure Logon to Secure Directory
                    if (ShowSecureLogon)
                    {
                        // Added localized support. [email protected] (05/07/2004)
                        // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                            menuLink = menuLink + " class=\"" + CssClass + "\"";

                        menuLink = menuLink + " href='" + PortalSettings.PortalSecurePath + "/Logon.aspx'>" +
                                   General.GetString("LOGON", "Logon", null) + "</a>";
                        list.Add(menuLink);
                    }
                }

                LanguageSwitcher ls = new LanguageSwitcher();
                Appleseed.Framework.Web.UI.WebControls.LanguageCultureCollection lcc = Appleseed.Framework.Localization.LanguageSwitcher.GetLanguageCultureList();
                if ((ShowLanguages)  && (lcc.Count > 1))
                {
                    var mb = new StringBuilder();

                    mb.Append("<a");
                    if (CssClass.Length != 0)
                        mb.AppendFormat(" class=\"{0}\"", CssClass);

                    mb.AppendFormat("id = \"popUpLang\" >");

                    if ((ShowLangString) || (ShowLanguages)){
                        string aux = General.GetString("LANGUAGE", "Language", null);
                        mb.AppendFormat("{0}", aux);
                    }
                    if (ShowFlags){
                        CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
                        string dir = HttpUrlBuilder.BuildUrl("~/aspnet_client/flags/flags_"+cultureInfo.ToString() +".gif");
                        mb.AppendFormat("<img src=\"{0}\" alt=\"\" style=\"left:13px;position:relative\"/>",dir);
                    }
                    mb.Append("</a>");
                    list.Add(mb);
                }

                innerDataSource = list;
            }
            base.DataBind();
            if (ShowLogon && DialogLogon)
            {
                //this new list control won't appear in the list, since it has no DataItem. However we need it for "holding" the Signin Control.
                var newItem = new DataListItem(this.Controls.Count, ListItemType.Item);
                this.Controls.Add(newItem);

                var logonDialogPlaceHolder = new PlaceHolder();
                newItem.Controls.Add(logonDialogPlaceHolder);

                if (_logonControl == null) //we ask this in case someone call the Databind more than once.
                {
                    _logonControl = Page.LoadControl(DialogLogonControlPath);
                    _logonControl.ViewStateMode = System.Web.UI.ViewStateMode.Enabled;
                }
                logonDialogPlaceHolder.Controls.Add(_logonControl);
            }
        }
예제 #7
0
        /// <summary>
        /// Internals the state of the set view.
        /// </summary>
        /// <param name="myLanguageCultureItem">My language culture item.</param>
        /// <param name="switcher">The switcher.</param>
        private static void InternalSetViewState(LanguageCultureItem myLanguageCultureItem, LanguageSwitcher switcher)
        {
            if (switcher == null)
            {
                return;
            }

            // Trace.WriteLine("Persisting in view state");
            switcher.ViewState["RB_Language_CurrentUICulture"] = myLanguageCultureItem.UICulture;
            switcher.ViewState["RB_Language_CurrentCulture"]   = myLanguageCultureItem.Culture;
        }
예제 #8
0
        /// <summary>
        /// Binds the control and all its child controls to the specified data source.
        /// </summary>
        public override void DataBind()
        {
            if (HttpContext.Current != null)
            {
                //Init data
                ArrayList list = new ArrayList();

                // Obtain PortalSettings from Current Context
                PortalSettings PortalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

                string homeLink = "<a";
                string menuLink;

                // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                if (CssClass.Length != 0)
                {
                    homeLink = homeLink + " class=\"" + CssClass + "\"";
                }

                homeLink = homeLink + " href='" + HttpUrlBuilder.BuildUrl() + "'>" +
                           General.GetString("Appleseed", "HOME") + "</a>";

                // If user logged in, customize welcome message
                if (HttpContext.Current.Request.IsAuthenticated == true)
                {
                    if (ShowWelcome)
                    {
                        list.Add(General.GetString("HEADER_WELCOME", "Welcome", this) + "&#160;" +
                                 PortalSettings.CurrentUser.Identity.Name + "!");
                    }

                    if (ShowHome)
                    {
                        list.Add(homeLink);
                    }

                    if (ShowHelp)
                    {
                        list.Add(GetHelpLink());
                    }

                    // Added by Mario Endara <*****@*****.**> (2004/11/06)
                    // Find Tab module to see if the user has add/edit rights
                    ModulesDB modules = new ModulesDB();
                    Guid      TabGuid = new Guid("{1C575D94-70FC-4A83-80C3-2087F726CBB3}");
                    // Added by Xu Yiming <*****@*****.**> (2004/12/6)
                    // Modify for support Multi or zero Pages Modules in a single portal.
                    bool HasEditPermissionsOnTabs = false;
                    int  TabModuleID = 0;

                    //					SqlDataReader result = modules.FindModulesByGuid(PortalSettings.PortalID, TabGuid);
                    //					while(result.Read())
                    //					{
                    //						TabModuleID=(int)result["ModuleId"];

                    foreach (ModuleItem m in modules.FindModuleItemsByGuid(PortalSettings.PortalID, TabGuid))
                    {
                        HasEditPermissionsOnTabs = PortalSecurity.HasEditPermissions(m.ID);
                        if (HasEditPermissionsOnTabs)
                        {
                            TabModuleID = m.ID;
                            break;
                        }
                    }

                    if (!HasEditPermissionsOnTabs || !ShowTabMan)
                    {
                        if (UserProfile.HasEditThisPageAccess())
                        {
                            HasEditPermissionsOnTabs = true;
                            this.ShowTabMan          = true;
                        }
                    }

                    // If user logged in and has Edit permission in the Tab module, reach tab management just one click
                    if ((ShowTabMan) && (HasEditPermissionsOnTabs))
                    {
                        // added by Mario Endara 2004/08/06 so PageLayout can return to this page
                        // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                        {
                            menuLink = menuLink + " class=\"" + CssClass + "\"";
                        }

                        // added mID by Mario Endara <*****@*****.**> to support security check (2004/11/09)
                        var url = HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Pages/PageLayout.aspx?PageID=") +
                                  PortalSettings.ActivePage.PageID + "&amp;mID=" + TabModuleID.ToString() +
                                  "&amp;Alias=" + PortalSettings.PortalAlias + "&amp;lang=" + PortalSettings.PortalUILanguage +
                                  "&amp;returntabid=" + PortalSettings.ActivePage.PageID;
                        menuLink = menuLink + " href='" + url + "' onclick=\"openInModal('" + url + "','" + General.GetString("HEADER_MANAGE_TAB", "Edit This Page", null) + "');return false;\");>" +
                                   General.GetString("HEADER_MANAGE_TAB", "Edit This Page", null) + "</a>";
                        list.Add(menuLink);
                    }

                    if (ShowDragNDrop && HasEditPermissionsOnTabs)
                    {
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                        {
                            menuLink = menuLink + " class=\"" + CssClass + "\"";
                        }

                        menuLink = menuLink + " href='javascript:DnD();'>" + General.GetString("DRAGNDROP", "DragNDrop", null) + "</a>";
                        list.Add(menuLink);
                    }

                    if (ShowEditProfile)
                    {
                        // 19/08/2004 Jonathan Fong
                        // www.gt.com.au
                        if (Context.User.Identity.AuthenticationType == "LDAP")
                        {
                            // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                            menuLink = "<a";
                            if (CssClass.Length != 0)
                            {
                                menuLink = menuLink + " class=\"" + CssClass + "\"";
                            }

                            menuLink = menuLink + " href='" +
                                       HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Register/Register.aspx") +
                                       "'>" + "Profile" + "</a>";
                            list.Add(menuLink);
                        }
                        // If user is form add edit user link
                        else if (!(HttpContext.Current.User is WindowsPrincipal))
                        {
                            // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                            menuLink = "<a";
                            if (CssClass.Length != 0)
                            {
                                menuLink = menuLink + " class=\"" + CssClass + "\"";
                            }

                            menuLink = menuLink + " href='" +
                                       HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Register/Register.aspx") +
                                       "'>" +
                                       General.GetString("HEADER_EDIT_PROFILE", "Edit profile", this) + "</a>";
                            list.Add(menuLink);
                        }
                    }

                    // if authentication mode is Cookie, provide a logoff link
                    if (Context.User.Identity.AuthenticationType == "Forms" ||
                        Context.User.Identity.AuthenticationType == "LDAP")
                    {
                        if (ShowLogOff)
                        {
                            // Corrections when ShowSecureLogon is true. [email protected] (05/07/2004)
                            string href = Context.Request.Url.AbsolutePath;
                            if (ShowSecureLogon && Context.Request.IsSecureConnection)
                            {
                                string auxref = Context.Request.Url.AbsoluteUri;
                                auxref = auxref.Substring(0, auxref.IndexOf(Context.Request.Url.PathAndQuery));
                                href   = auxref + href;
                                href   = href.Replace("https", "http");
                            }
                            // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                            menuLink = "<a";
                            if (CssClass.Length != 0)
                            {
                                menuLink = menuLink + " class=\"" + CssClass + "\"";
                            }

                            // added code for redirection on same page after logged out
                            menuLink = menuLink + " href='javascript:void();' onclick=\"if(confirm('" + General.GetString("LOGOFF_CNF_MSG", "Log Off Confirmation: \\nAre you sure you want to log off?", null) + "')){window.location = '/DesktopModules/CoreModules/Admin/Logoff.aspx?redirecturl=" + href + "';  }else{return false;} \">" + General.GetString("HEADER_LOGOFF", "Logoff", null) + "</a>";



                            list.Add(menuLink);
                        }
                    }
                }
                else
                {
                    if (ShowHome)
                    {
                        list.Add(homeLink);
                    }

                    if (ShowHelp)
                    {
                        list.Add(GetHelpLink());
                    }

                    // if not authenticated and ShowLogon is true, provide a logon link

                    if (ShowLogon)
                    {
                        // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                        {
                            menuLink = menuLink + " class=\"" + CssClass + "\"";
                        }

                        menuLink += string.Concat(" id=\"", this.ClientID, "_logon_link", "\"");
                        menuLink  = menuLink + " href='" + HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Admin/Logon.aspx") +
                                    "'>" + General.GetString("LOGON", "Logon", null) + "</a>";
                        list.Add(menuLink);
                    }

                    var allowNewRegistration = false;
                    if (PortalSettings.CustomSettings["SITESETTINGS_ALLOW_NEW_REGISTRATION"] != null)
                    {
                        if (bool.Parse(PortalSettings.CustomSettings["SITESETTINGS_ALLOW_NEW_REGISTRATION"].ToString()))
                        {
                            allowNewRegistration = true;
                        }
                    }

                    if (ShowRegister && allowNewRegistration)
                    {
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                        {
                            menuLink = menuLink + " class=\"" + CssClass + "\"";
                        }

                        menuLink = menuLink + " href='" + HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Register/Register.aspx") +
                                   "'>" + General.GetString("REGISTER", "Register", null) + "</a>";
                        list.Add(menuLink);
                    }



                    // Thierry (Tiptopweb) 5 May 2003 : Secure Logon to Secure Directory
                    if (ShowSecureLogon)
                    {
                        // Added localized support. [email protected] (05/07/2004)
                        // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                        {
                            menuLink = menuLink + " class=\"" + CssClass + "\"";
                        }

                        menuLink = menuLink + " href='" + PortalSettings.PortalSecurePath + "/Logon.aspx'>" +
                                   General.GetString("LOGON", "Logon", null) + "</a>";
                        list.Add(menuLink);
                    }
                }

                LanguageSwitcher ls = new LanguageSwitcher();
                Appleseed.Framework.Web.UI.WebControls.LanguageCultureCollection lcc = Appleseed.Framework.Localization.LanguageSwitcher.GetLanguageCultureList();
                if ((ShowLanguages) && (lcc.Count > 1))
                {
                    var mb = new StringBuilder();

                    mb.Append("<a");
                    if (CssClass.Length != 0)
                    {
                        mb.AppendFormat(" class=\"{0}\"", CssClass);
                    }

                    mb.AppendFormat("id = \"popUpLang\" >");

                    if ((ShowLangString) || (ShowLanguages))
                    {
                        string aux = General.GetString("LANGUAGE", "Language", null);
                        mb.AppendFormat("{0}", aux);
                    }
                    if (ShowFlags)
                    {
                        CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
                        string      dir         = HttpUrlBuilder.BuildUrl("~/aspnet_client/flags/flags_" + cultureInfo.ToString() + ".gif");
                        mb.AppendFormat("<img src=\"{0}\" alt=\"\" style=\"left:13px;position:relative\"/>", dir);
                    }
                    mb.Append("</a>");
                    list.Add(mb);
                }

                innerDataSource = list;
            }
            base.DataBind();
            if (ShowLogon && DialogLogon)
            {
                //this new list control won't appear in the list, since it has no DataItem. However we need it for "holding" the Signin Control.
                var newItem = new DataListItem(this.Controls.Count, ListItemType.Item);
                this.Controls.Add(newItem);

                var logonDialogPlaceHolder = new PlaceHolder();
                newItem.Controls.Add(logonDialogPlaceHolder);

                if (_logonControl == null) //we ask this in case someone call the Databind more than once.
                {
                    _logonControl = Page.LoadControl(DialogLogonControlPath);
                    _logonControl.ViewStateMode = System.Web.UI.ViewStateMode.Enabled;
                }
                logonDialogPlaceHolder.Controls.Add(_logonControl);
            }
        }
예제 #9
0
        /// <summary>
        /// Internals the state of the set view.
        /// </summary>
        /// <param name="myLanguageCultureItem">My language culture item.</param>
        /// <param name="switcher">The switcher.</param>
        private static void InternalSetViewState(LanguageCultureItem myLanguageCultureItem, LanguageSwitcher switcher)
        {
            if (switcher == null)
            {
                return;
            }

            // Trace.WriteLine("Persisting in view state");
            switcher.ViewState["RB_Language_CurrentUICulture"] = myLanguageCultureItem.UICulture;
            switcher.ViewState["RB_Language_CurrentCulture"] = myLanguageCultureItem.Culture;
        }
예제 #10
0
 /// <summary>
 /// Get current Language from ViewState
 /// </summary>
 /// <param name="switcher">
 /// The switcher.
 /// </param>
 /// <returns>
 /// </returns>
 private static LanguageCultureItem InternalGetViewState(LanguageSwitcher switcher)
 {
     return switcher != null && switcher.ViewState["RB_Language_CurrentUICulture"] != null &&
            switcher.ViewState["RB_Language_CurrentCulture"] != null
                ? new LanguageCultureItem(
                      (CultureInfo)switcher.ViewState["RB_Language_CurrentUICulture"],
                      (CultureInfo)switcher.ViewState["RB_Language_CurrentCulture"])
                : null;
 }
예제 #11
0
        /// <summary>
        /// The set current language.
        /// </summary>
        /// <param name="langItem">The lang item.</param>
        /// <param name="cookieAlias">Cookie name used for persist Language</param>
        /// <param name="switcher">The switcher.</param>
        internal static void SetCurrentLanguage(
            LanguageCultureItem langItem, string cookieAlias, LanguageSwitcher switcher)
        {
            Thread.CurrentThread.CurrentUICulture = langItem.UICulture;
            Thread.CurrentThread.CurrentCulture = langItem.Culture;

            // Persists choice
            InternalSetViewState(langItem, switcher);
            InternalSetCookie(langItem, cookieAlias);
        }
예제 #12
0
        /// <summary>
        /// Examines/combines all the variables involved and sets
        ///   CurrentUICulture and CurrentCulture
        /// </summary>
        /// <param name="langList">
        /// Languages list. Something like it=it-IT;en=en-US
        /// </param>
        /// <param name="cookieAlias">
        /// Alias used to make this cookie unique. Use null is you do not want cookies.
        /// </param>
        /// <param name="switcher">
        /// A referenced to a Switcher control for accessing view state
        /// </param>
        internal static void ProcessCultures(string langList, string cookieAlias, LanguageSwitcher switcher)
        {
            var myLanguagesCultureList = (LanguageCultureCollection)langList;

            // Verify that at least on language is provided
            if (myLanguagesCultureList.Count <= 0)
            {
                throw new ArgumentException("Please provide at least one language in the list.", "langList");
            }

            // Language Item
            // Query string
            var langItem = InternalGetQuerystring(myLanguagesCultureList);

            // Trace.WriteLine("Evaluated InternalGetQuerystring: '" + (langItem == null ? "null" : langItem) + "'");
            if (langItem != null)
            {
                goto setLanguage;
            }

            // View state
            langItem = InternalGetViewState(switcher);

            // Trace.WriteLine("Evaluated InternalGetViewState: '" + (langItem == null ? "null" : langItem) + "'");
            if (langItem != null)
            {
                goto setLanguage;
            }

            // Cookie
            langItem = InternalGetCookie(myLanguagesCultureList, cookieAlias);

            // Trace.WriteLine("Evaluated InternalGetCookie: '" + (langItem == null ? "null" : langItem) + "'");
            if (langItem != null)
            {
                goto setLanguage;
            }

            // UserLanguageList
            langItem = InternalGetUserLanguages(myLanguagesCultureList);

            // Trace.WriteLine("Evaluated InternalGetUserLanguages: '" + (langItem == null ? "null" : langItem) + "'");
            if (langItem != null)
            {
                goto setLanguage;
            }

            // Default
            langItem = InternalGetDefault(myLanguagesCultureList);

            // Trace.WriteLine("Evaluated InternalGetDefault: '" + (langItem == null ? "null" : langItem) + "'");
            setLanguage:

            // Updates current cultures
            SetCurrentLanguage(langItem, cookieAlias);
        }