Show
Ignore:
Timestamp:
2007-12-01 16:40:50 (10 months ago)
Author:
fredck
Message:

Fixed #1548 : Added Safari and Opera detection to FCKeditor.Net.
For #79 : Introduced the FCKeditor.IsCompatibleBrowser static function, to check if the requesting browser is compatible with FCKeditor.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • FCKeditor.Net/trunk/FCKeditor.cs

    r182 r1161  
    373373                } 
    374374 
     375                #endregion 
     376 
     377                #region Compatibility Check 
     378 
    375379                public bool CheckBrowserCompatibility() 
    376380                { 
    377                         System.Web.HttpBrowserCapabilities oBrowser = Page.Request.Browser ; 
     381                        return IsCompatibleBrowser( Page.Request ); 
     382                } 
     383 
     384                /// <summary> 
     385                /// Checks if the current HTTP request comes from a browser compatible 
     386                /// with FCKeditor. 
     387                /// </summary> 
     388                /// <returns>"true" if the browser is compatible.</returns> 
     389                public static bool IsCompatibleBrowser() 
     390                { 
     391                        return IsCompatibleBrowser( System.Web.HttpContext.Current.Request ); 
     392                } 
     393 
     394                /// <summary> 
     395                /// Checks if the provided HttpRequest object comes from a browser 
     396                /// compatible with FCKeditor. 
     397                /// </summary> 
     398                /// <returns>"true" if the browser is compatible.</returns> 
     399                public static bool IsCompatibleBrowser( System.Web.HttpRequest request ) 
     400                { 
     401                        System.Web.HttpBrowserCapabilities oBrowser = request.Browser; 
    378402 
    379403                        // Internet Explorer 5.5+ for Windows 
    380                         if (oBrowser.Browser == "IE" && ( oBrowser.MajorVersion >= 6 || ( oBrowser.MajorVersion == 5 && oBrowser.MinorVersion >= 0.5 ) ) && oBrowser.Win32) 
    381                                 return true ; 
    382                         else 
    383                         { 
    384                                 Match oMatch = Regex.Match( this.Page.Request.UserAgent, @"(?<=Gecko/)\d{8}" ) ; 
    385                                 return ( oMatch.Success && int.Parse( oMatch.Value, CultureInfo.InvariantCulture ) >= 20030210 ) ; 
    386                         } 
     404                        if ( oBrowser.Browser == "IE" && ( oBrowser.MajorVersion >= 6 || ( oBrowser.MajorVersion == 5 && oBrowser.MinorVersion >= 0.5 ) ) && oBrowser.Win32 ) 
     405                                return true; 
     406 
     407                        string sUserAgent = request.UserAgent; 
     408 
     409                        if ( sUserAgent.Contains( "Gecko/" ) ) 
     410                        { 
     411                                Match oMatch = Regex.Match( request.UserAgent, @"(?<=Gecko/)\d{8}" ); 
     412                                return ( oMatch.Success && int.Parse( oMatch.Value, CultureInfo.InvariantCulture ) >= 20030210 ); 
     413                        } 
     414 
     415                        if ( sUserAgent.Contains( "Opera/" ) ) 
     416                        { 
     417                                Match oMatch = Regex.Match( request.UserAgent, @"(?<=Opera/)[\d\.]+" ); 
     418                                return ( oMatch.Success && float.Parse( oMatch.Value, CultureInfo.InvariantCulture ) >= 9.5 ); 
     419                        } 
     420 
     421                        if ( sUserAgent.Contains( "AppleWebKit/" ) ) 
     422                        { 
     423                                Match oMatch = Regex.Match( request.UserAgent, @"(?<=AppleWebKit/)\d+" ); 
     424                                return ( oMatch.Success && int.Parse( oMatch.Value, CultureInfo.InvariantCulture ) >= 522 ); 
     425                        } 
     426 
     427                        return false; 
    387428                } 
    388429