Documentation

BrowserDetector
in package

Class BrowserDetector This class is an experiment for the job of correctly detecting browsers and settings needed for them.

  • Detects the following browsers
  • Opera, Webkit, Firefox, Web_tv, Konqueror, IE, Gecko
  • Webkit variants: Chrome, iphone, blackberry, android, safari, ipad, ipod
  • Opera Versions: 6, 7, 8 ... 10 ... and mobile mini and mobi
  • Firefox Versions: 1, 2, 3 .... 11 ...
  • Chrome Versions: 1 ... 18 ...
  • IE Versions: 4, 5, 5.5, 6, 7, 8, 9, 10 ... mobile and Mac
  • MS Edge
  • Nokia

Table of Contents

Properties

$obj  : mixed
An instance of this class.
$_browsers  : array<string|int, mixed>
$_is_mobile  : bool

Methods

call()  : mixed
Convenience method.
detectBrowser()  : void
The main method of this class, you know the one that does the job: detect the thing.
isBrowser()  : bool
Are we using this browser?
isEdge()  : bool
Determine if the browser is Edge or not
isFirefox()  : bool
Determine if the browser is Firefox or one of its variants
isGecko()  : bool
Determine if the browser is Gecko or not
isIe()  : bool
Determine if the browser is IE or not
isIe11()  : bool
Determine if the browser is IE11 or not
isKonqueror()  : bool
Determine if the browser is konqueror or not
isOpera()  : bool
Determine if the browser is Opera or not
isOperaMini()  : bool
Determine if the browser is Opera Mini or not
isOperaMobi()  : bool
Determine if the browser is Opera Mobile or not
isWebkit()  : bool
Determine if the browser is a Webkit based one or not
isWebTv()  : bool
Determine if the browser is WebTv or not
fillInformation()  : void
Fill out the historical array - needed to support old mods that don't use isBrowser
setupBrowserPriority()  : void
Get the browser name that we will use in the <body id="this_browser"> - The order of each browser in $browser_priority is important - if you want to have id='ie6' and not id='ie' then it must appear first in the list of ie browsers - only sets browsers that may need some help via css for compatibility
setupEdge()  : void
Sets the version number for MS edge.
setupFirefox()  : void
Additional firefox checks.
setupIe()  : void
Additional IE checks and settings.
setupOpera()  : void
More Opera checks if we are opera.
setupWebkit()  : void
Detect Safari / Chrome / iP[ao]d / iPhone / Android / Blackberry from webkit.

Properties

$_browsers

private array<string|int, mixed> $_browsers = []

Holds all the browser information. Its contents will be placed into Utils::$context['browser']

$_is_mobile

private bool $_is_mobile = false

Whether or not this might be a mobile device

Methods

detectBrowser()

The main method of this class, you know the one that does the job: detect the thing.

public detectBrowser() : void
  • determines the user agent (browser) as best it can.

isBrowser()

Are we using this browser?

public static isBrowser(string $browser) : bool
Parameters
$browser : string

The browser we are checking for.

Return values
bool

Whether or not the current browser is what we're looking for.

isEdge()

Determine if the browser is Edge or not

public isEdge() : bool
Return values
bool

Whether or not the browser is Edge

isFirefox()

Determine if the browser is Firefox or one of its variants

public isFirefox() : bool
Return values
bool

Whether or not this is Firefox (or one of its variants)

isGecko()

Determine if the browser is Gecko or not

public isGecko() : bool
Return values
bool

Whether or not this is a Gecko-based browser

isIe()

Determine if the browser is IE or not

public isIe() : bool
Return values
bool

true Whether or not the browser is IE

isIe11()

Determine if the browser is IE11 or not

public isIe11() : bool
Return values
bool

Whether or not the browser is IE11

isKonqueror()

Determine if the browser is konqueror or not

public isKonqueror() : bool
Return values
bool

Whether or not this is Konqueror

isOpera()

Determine if the browser is Opera or not

public isOpera() : bool
Return values
bool

Whether or not this is Opera

isOperaMini()

Determine if the browser is Opera Mini or not

public isOperaMini() : bool
Return values
bool

Whether or not this is Opera Mini

isOperaMobi()

Determine if the browser is Opera Mobile or not

public isOperaMobi() : bool
Return values
bool

Whether or not this is Opera Mobile

isWebkit()

Determine if the browser is a Webkit based one or not

public isWebkit() : bool
Return values
bool

Whether or not this is a Webkit-based browser

isWebTv()

Determine if the browser is WebTv or not

public isWebTv() : bool
Return values
bool

Whether or not this is WebTV

fillInformation()

Fill out the historical array - needed to support old mods that don't use isBrowser

private fillInformation() : void

setupBrowserPriority()

Get the browser name that we will use in the <body id="this_browser"> - The order of each browser in $browser_priority is important - if you want to have id='ie6' and not id='ie' then it must appear first in the list of ie browsers - only sets browsers that may need some help via css for compatibility

private setupBrowserPriority() : void

setupEdge()

Sets the version number for MS edge.

private setupEdge() : void

setupFirefox()

Additional firefox checks.

private setupFirefox() : void
  • Gets the version of the FF browser in use
  • Considers all FF variants as FF including IceWeasel, IceCat, Shiretoko and Minefiled

setupIe()

Additional IE checks and settings.

private setupIe() : void
  • determines the version of the IE browser in use
  • detects ie4 onward
  • attempts to distinguish between IE and IE in compatibility view
  • checks for old IE on macs as well, since we can

setupOpera()

More Opera checks if we are opera.

private setupOpera() : void
  • checks for the version of Opera in use
  • uses checks for 10 first and falls through to <9

setupWebkit()

Detect Safari / Chrome / iP[ao]d / iPhone / Android / Blackberry from webkit.

private setupWebkit() : void
  • set the browser version for Safari and Chrome
  • set the mobile flag for mobile based useragents

        
On this page

Search results