Example #1
0
			public static TabInfo LocaliseTab(TabInfo tab, int portalId)
			{
				var culture = DNNAbstract.GetCurrentCulture();
				Dictionary<int, EaloTabInfo> ealoTabs;
				if (!ealoTabLookup.TryGetValue(culture, out ealoTabs))
				{
					ealoTabs = Tabs.GetAllTabsAsDictionary(culture, true);
					lock (ealoTabLookup)
					{
						if (!ealoTabLookup.ContainsKey(culture))
						{
							ealoTabLookup.Add(culture, ealoTabs);
						}
					}
				}

				EaloTabInfo ealoTab;
				if (ealoTabs.TryGetValue(tab.TabID, out ealoTab))
				{
					if (ealoTab.EaloTabName != null)
					{
						tab.TabName = ealoTab.EaloTabName.StringTextOrFallBack;
					}
					if (ealoTab.EaloTitle != null)
					{
						tab.Title = ealoTab.EaloTitle.StringTextOrFallBack;
					}
				}
				return tab;
			}
Example #2
0
		public TabInfo LocaliseTab(TabInfo tab, int portalId)
		{
			return EaloWorker.LocaliseTab(tab, portalId);
		}
        public override string FriendlyUrl( TabInfo tab, string path, string pageName )
        {
            PortalSettings _portalSettings = PortalController.GetCurrentPortalSettings();

            return FriendlyUrl( tab, path, pageName, _portalSettings );
        }
        public override string FriendlyUrl( TabInfo tab, string path )
        {
            PortalSettings _portalSettings = PortalController.GetCurrentPortalSettings();

            return FriendlyUrl( tab, path, Globals.glbDefaultPage, _portalSettings );
        }
        /// <summary>
        /// GetFriendlyQueryString gets the Querystring part of the friendly url
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name="tab">The tab whose url is being formatted.</param>
        /// <param name="path">The path to format.</param>
        /// <returns>The formatted url</returns>
        /// <history>
        ///		[cnurse]	12/16/2004	created
        ///		[smcculloch]10/10/2005	Regex update for rewritten characters
        /// </history>
        private string GetFriendlyQueryString( TabInfo tab, string path, string pageName )
        {
            string friendlyPath = path;
            Match queryStringMatch = Regex.Match( friendlyPath, "(.[^\\\\?]*)\\\\?(.*)", RegexOptions.IgnoreCase );
            string queryStringSpecialChars = "";

            if( !( queryStringMatch == Match.Empty ) )
            {
                friendlyPath = queryStringMatch.Groups[1].Value;
                friendlyPath = Regex.Replace( friendlyPath, Globals.glbDefaultPage, "", RegexOptions.IgnoreCase );

                string queryString = queryStringMatch.Groups[2].Value.Replace( "&amp;", "&" );
                if( queryString.StartsWith( "?" ) )
                {
                    queryString = queryString.TrimStart( Convert.ToChar( "?" ) );
                }

                string[] nameValuePairs = queryString.Split( Convert.ToChar( "&" ) );
                for( int i = 0; i <= nameValuePairs.Length - 1; i++ )
                {
                    string pathToAppend = "";
                    string[] pair = nameValuePairs[i].Split( Convert.ToChar( "=" ) );

                    //Add name part of name/value pair
                    if( friendlyPath.EndsWith( "/" ) )
                    {
                        pathToAppend = pathToAppend + pair[0];
                    }
                    else
                    {
                        pathToAppend = pathToAppend + "/" + pair[0];
                    }

                    if( pair.Length > 1 )
                    {
                        if( pair[1].Length > 0 )
                        {
                            if( Regex.IsMatch( pair[1], _regexMatch ) == false )
                            {
                                // Contains Non-AlphaNumeric Characters
                                if( pair[0].ToLower() == "tabid" )
                                {
                                    if( Information.IsNumeric( pair[1] ) )
                                    {
                                        if( !( tab == null ) )
                                        {
                                            int tabId = Convert.ToInt32( pair[1] );
                                            if( tab.TabID == tabId )
                                            {
                                                if( ( tab.TabPath != Null.NullString ) && IncludePageName )
                                                {
                                                    pathToAppend = tab.TabPath.Replace( "//", "/" ).TrimStart( '/' ) + "/" + pathToAppend;
                                                }
                                            }
                                        }
                                    }
                                }

                                pathToAppend = pathToAppend + "/" + pair[1].Replace( " ", HttpUtility.UrlEncode( ( '\u0020' ).ToString() ) );
                            }
                            else
                            {
                                // Rewrite into URL, contains only alphanumeric and the % or space
                                if( queryStringSpecialChars.Length == 0 )
                                {
                                    queryStringSpecialChars = pair[0] + "=" + pair[1];
                                }
                                else
                                {
                                    queryStringSpecialChars = queryStringSpecialChars + "&" + pair[0] + "=" + pair[1];
                                }

                                pathToAppend = "";
                            }
                        }
                        else
                        {
                            pathToAppend = pathToAppend + "/" + HttpUtility.UrlEncode( ( '\u0020' ).ToString() );
                        }
                    }

                    friendlyPath = friendlyPath + pathToAppend;
                }
            }

            if( queryStringSpecialChars.Length > 0 )
            {
                return AddPage( friendlyPath, pageName ) + "?" + queryStringSpecialChars;
            }
            else
            {
                return AddPage( friendlyPath, pageName );
            }
        }
        public override string FriendlyUrl( TabInfo tab, string path, string pageName, string portalAlias )
        {
            string friendlyPath = path;
            string matchString = "";

            //Call GetFriendlyAlias to get the Alias part of the url
            friendlyPath = GetFriendlyAlias( path, portalAlias );

            //Call GetFriendlyQueryString to get the QueryString part of the url
            friendlyPath = GetFriendlyQueryString( tab, friendlyPath, pageName );

            return friendlyPath;
        }