Class JBrowser

Description

Browser class, provides capability information about the current web client.

Browser identification is performed by examining the HTTP_USER_AGENT environment variable provided by the web server.

This class has many influences from the lib/Browser.php code in version 3 of Horde by Chuck Hagenbuch and Jon Parise.

  • deprecated: This API may be changed in the near future and should not be considered stable
  • since: 11.1

Located in /libraries/joomla/environment/browser.php (line 26)

JObject
   |
   --JBrowser
Variable Summary
static array $instances
string $_accept
string $_agent
string $_browser
array $_features
array $_images
string $_lowerAgent
integer $_majorVersion
integer $_minorVersion
boolean $_mobile
string $_platform
array $_quirks
array $_robots
Method Summary
static JBrowser getInstance ([string $userAgent = null], [string $accept = null])
static void _sortMime (string $a, string $b)
JBrowser __construct ([string $userAgent = null], [string $accept = null])
string getAgentString ()
string getBrowser ()
string getFeature (string $feature)
string getHTTPProtocol ()
integer getMajor ()
integer getMinor ()
string getPlatform ()
string getQuirk (string $quirk)
string getVersion ()
boolean hasFeature (string $feature)
boolean hasQuirk (string $quirk)
boolean isBrowser (string $browser)
boolean isMobile ()
boolean isRobot ()
boolean isSSLConnection ()
boolean isViewable (string $mimetype)
void match ([string $userAgent = null], [string $accept = null])
void setBrowser (string $browser)
void setFeature (string $feature, [string $value = true])
void setQuirk (string $quirk, [string $value = true])
void _setFeature (string $feature, [string $value = true])
void _setPlatform ()
void _setQuirk (string $quirk, [string $value = true])
Variables
static array $instances = array() (line 197)
  • var: JBrowser instances container.
  • since: 11.3
  • access: protected
string $_accept = '' (line 63)
  • var: HTTP_ACCEPT string.
  • since: 11.1
  • access: protected
array $_accept_parsed = array() (line 69)
  • var: Parsed HTTP_ACCEPT string
  • since: 11.1
  • access: protected
string $_agent = '' (line 51)
  • var: Full user agent string.
  • since: 11.1
  • access: protected
string $_browser = '' (line 45)
  • var: Browser name.
  • since: 11.1
  • access: protected
array $_features = array(
'html' => true,
'wml' => false,
'images' => true,
'iframes' => false,
'frames' => true,
'tables' => true,
'java' => true,
'javascript' => true,
'dom' => false,
'utf' => false,
'rte' => false,
'homepage' => false,
'accesskey' => false,
'xmlhttpreq' => false,
'xhtml+xml' => false,
'mathml' => false,
'svg' => false
)
(line 141)
  • var: Features.
  • deprecated: 12.1 This variable will be dropped without replacement
  • since: 11.1
  • access: protected
array $_images = array('jpeg', 'gif', 'png', 'pjpeg', 'x-png', 'bmp') (line 191)

List of viewable image MIME subtypes.

This list of viewable images works for IE and Netscape/Mozilla.

  • since: 11.1
  • access: protected
string $_lowerAgent = '' (line 57)
  • var: Lower-case user agent string
  • since: 11.1
  • access: protected
integer $_majorVersion = 0 (line 33)
  • var: Major version number
  • since: 11.1
  • access: protected
integer $_minorVersion = 0 (line 39)
  • var: Minor version number
  • since: 11.1
  • access: protected
boolean $_mobile = false (line 134)
  • var: Is this a mobile browser?
  • since: 11.1
  • access: protected
string $_platform = '' (line 75)
  • var: Platform the browser is running on
  • since: 11.1
  • access: protected
array $_quirks = array(
'avoid_popup_windows' => false,
'break_disposition_header' => false,
'break_disposition_filename' => false,
'broken_multipart_form' => false,
'cache_same_url' => false,
'cache_ssl_downloads' => false,
'double_linebreak_textarea' => false,
'empty_file_input_value' => false,
'must_cache_forms' => false,
'no_filename_spaces' => false,
'no_hidden_overflow_tables' => false,
'ow_gui_1.3' => false,
'png_transparency' => false,
'scrollbar_in_way' => false,
'scroll_tds' => false,
'windowed_controls' => false)
(line 166)
  • var: Quirks.
  • deprecated: 12.1 This variable will be dropped without replacement
  • since: 11.1
  • access: protected
array $_robots = array(
/* The most common ones. */
'Googlebot',
'msnbot',
'Slurp',
'Yahoo',
/* The rest alphabetically. */
'Arachnoidea',
'ArchitextSpider',
'Ask Jeeves',
'B-l-i-t-z-Bot',
'Baiduspider',
'BecomeBot',
'cfetch',
'ConveraCrawler',
'ExtractorPro',
'FAST-WebCrawler',
'FDSE robot',
'fido',
'geckobot',
'Gigabot',
'Girafabot',
'grub-client',
'Gulliver',
'HTTrack',
'ia_archiver',
'InfoSeek',
'kinjabot',
'KIT-Fireball',
'larbin',
'LEIA',
'lmspider',
'Lycos_Spider',
'Mediapartners-Google',
'MuscatFerret',
'NaverBot',
'OmniExplorer_Bot',
'polybot',
'Pompos',
'Scooter',
'Teoma',
'TheSuBot',
'TurnitinBot',
'Ultraseek',
'ViolaBot',
'webbandit',
'www.almaden.ibm.com/cs/crawler',
'ZyBorg')
(line 81)
  • var: Known robots.
  • since: 11.1
  • access: protected

Inherited Variables

Inherited from JObject

JObject::$_errors
Methods
static method getInstance (line 223)

Returns the global Browser object, only creating it if it doesn't already exist.

  • return: The Browser object.
  • since: 11.1
  • access: public
static JBrowser getInstance ([string $userAgent = null], [string $accept = null])
  • string $userAgent: The browser string to parse.
  • string $accept: The HTTP_ACCEPT settings to use.
static method _sortMime (line 245)

Identify which of two types is preferred

  • since: 11.1
  • access: public
static void _sortMime (string $a, string $b)
  • string $a: The first item in the comparision
  • string $b: The second item in the comparison
Constructor __construct (line 207)

Create a browser instance (constructor).

  • since: 11.1
  • access: public
JBrowser __construct ([string $userAgent = null], [string $accept = null])
  • string $userAgent: The browser string to parse.
  • string $accept: The HTTP_ACCEPT settings to use.

Redefinition of:
JObject::__construct()
Class constructor, overridden in descendant classes.
getAgentString (line 837)

Return the full browser agent string.

  • return: The browser agent string
  • since: 11.1
  • access: public
string getAgentString ()
getBrowser (line 789)

Retrieve the current browser.

  • return: The current browser.
  • since: 11.1
  • access: public
string getBrowser ()
getFeature (line 985)

Retrieve the current browser capability.

  • return: The value of the requested capability.
  • deprecated: 12.1 This function will be dropped without replacement
  • since: 11.1
  • access: public
string getFeature (string $feature)
  • string $feature: The capability to retrieve.
getHTTPProtocol (line 849)

Returns the server protocol in use on the current server.

  • return: The HTTP server protocol version.
  • since: 11.1
  • access: public
string getHTTPProtocol ()
getMajor (line 801)

Retrieve the current browser's major version.

  • return: The current browser's major version
  • since: 11.1.
  • access: public
integer getMajor ()
getMinor (line 813)

Retrieve the current browser's minor version.

  • return: The current browser's minor version.
  • since: 11.1
  • access: public
integer getMinor ()
getPlatform (line 763)

Return the currently matched platform.

  • return: The user's platform.
  • since: 11.1
  • access: public
string getPlatform ()
getQuirk (line 920)

Retrieve unique behavior for the current browser.

  • return: The value for the requested behavior.
  • deprecated: 12.1 This function will be dropped without replacement
  • since: 11.1
  • access: public
string getQuirk (string $quirk)
  • string $quirk: The behavior to retrieve.
getVersion (line 825)

Retrieve the current browser's version.

  • return: The current browser's version.
  • since: 11.1
  • access: public
string getVersion ()
hasFeature (line 969)

Check the current browser capabilities.

  • return: Does the browser have the capability set?
  • deprecated: 12.1 This function will be dropped without replacement
  • since: 11.1
  • access: public
boolean hasFeature (string $feature)
  • string $feature: The capability to check.
hasQuirk (line 904)

Check unique behavior for the current browser.

  • return: Does the browser have the behavior set?
  • deprecated: 12.1 This function will be dropped without replacement
  • since: 11.1
  • access: public
boolean hasQuirk (string $quirk)
  • string $quirk: The behavior to check.
isBrowser (line 1056)

Determine if the given browser is the same as the current.

  • return: Is the given browser the same as the current?
  • since: 11.1
  • access: public
boolean isBrowser (string $browser)
  • string $browser: The browser to check.
isMobile (line 1087)

Determines if the browser is mobile version or not.

  • return: True if browser is a known mobile version.
  • since: 11.1
  • access: public
boolean isMobile ()
isRobot (line 1068)

Determines if the browser is a robot or not.

  • return: True if browser is a known robot.
  • since: 11.1
  • access: public
boolean isRobot ()
isSSLConnection (line 1099)

Determine if we are using a secure (SSL) connection.

  • return: True if using SSL, false if not.
  • since: 11.1
  • access: public
boolean isSSLConnection ()
isViewable (line 1004)

Determines if a browser can display a given MIME type.

Note that image/jpeg and image/pjpeg *appear* to be the same entity, but Mozilla doesn't seem to want to accept the latter. For our purposes, we will treat them the same.

  • return: True if the browser can display the MIME type.
  • since: 11.1
  • access: public
boolean isViewable (string $mimetype)
  • string $mimetype: The MIME type to check.
match (line 272)

Parses the user agent string and inititializes the object with all the known features and quirks for the given browser.

  • since: 11.1
  • access: public
void match ([string $userAgent = null], [string $accept = null])
  • string $userAgent: The browser string to parse.
  • string $accept: The HTTP_ACCEPT settings to use.
setBrowser (line 777)

Sets the current browser.

  • since: 11.1
  • access: public
void setBrowser (string $browser)
  • string $browser: The browser to set as current.
setFeature (line 953)

Set capabilities for the current browser.

  • deprecated: 12.1 This function will be dropped without replacement
  • since: 11.1
  • access: public
void setFeature (string $feature, [string $value = true])
  • string $feature: The capability to set.
  • string $value: Special capability parameter.
setQuirk (line 888)

Internal copy of JBrowser::setQuirk() to prevent deprecation warning.

  • deprecated: 12.1 This function will be dropped without replacement
  • since: 11.1
  • access: public
void setQuirk (string $quirk, [string $value = true])
  • string $quirk: The behavior to set.
  • string $value: Special behavior parameter.
_setFeature (line 937)

Internal copy of JBrowser::setFeature() to prevent deprecation warning.

  • deprecated: 12.1 This function will be dropped without replacement
  • since: 11.4
  • access: private
void _setFeature (string $feature, [string $value = true])
  • string $feature: The capability to set.
  • string $value: Special capability parameter.
_setPlatform (line 740)

Match the platform of the browser.

This is a pretty simplistic implementation, but it's intended to let us tell what line breaks to send, so it's good enough for its purpose.

  • since: 11.1
  • access: protected
void _setPlatform ()
_setQuirk (line 872)

Set unique behavior for the current browser.

  • deprecated: 12.1 This function will be dropped without replacement
  • since: 11.1
  • access: private
void _setQuirk (string $quirk, [string $value = true])
  • string $quirk: The behavior to set.
  • string $value: Special behavior parameter.

Inherited Methods

Inherited From JObject

JObject::__construct()
JObject::def()
JObject::get()
JObject::getError()
JObject::getErrors()
JObject::getProperties()
JObject::set()
JObject::setError()
JObject::setProperties()
JObject::toString()
JObject::__toString()

Documentation generated on Mon, 25 Jun 2012 13:52:38 -0500 by phpDocumentor 1.4.4