Class Browser

Description

The Browser:: class provides capability information for the current web client.

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

Located in /Browser/Browser.php (line 27)


	
			
Variable Summary
 string $_accept
 string $_agent
 string $_browser
 array $_features
 array $_images
 string $_lowerAgent
 integer $_majorVersion
 integer $_minorVersion
 boolean $_mobile
 string $_platform
 array $_quirks
 mixed $_tvAgents
Method Summary
 Browser Browser ([string $userAgent = null], [string $accept = null])
 integer allowFileUploads ()
 void downloadHeaders ([string $filename = 'unknown'], [string $cType = null], [boolean $inline = false], [string $cLength = null])
 string escapeJSCode (string $code)
 string getAgentString ()
 string getBrowser ()
 string getFeature (string $feature)
 string getHTTPProtocol ()
 mixed getIEVersion ()
 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 isViewable (string $mimetype)
 void match ([string $userAgent = null], [string $accept = null])
 void setBrowser (string $browser)
 void setFeature (string $feature, [string $value = true])
 void setIEVersion (string $ver)
 void setQuirk (string $quirk, [string $value = true])
 Browser &singleton ([string $userAgent = null], [string $accept = null])
 boolean usingSSLConnection ()
 mixed wasFileUploaded (string $field, [string $name = null])
 void _setPlatform ()
Variables
string $_accept = '' (line 69)

HTTP_ACCEPT string

string $_agent = '' (line 55)

Full user agent string.

string $_browser = '' (line 48)

Browser name.

array $_features = array(
'html' => true,
'hdml' => false,
'wml' => false,
'images' => true,
'iframes' => false,
'frames' => true,
'tables' => true,
'java' => true,
'javascript' => true,
'dom' => false,
'utf' => false,
'rte' => false,
'homepage' => false,
'accesskey' => false,
'optgroup' => false,
'xmlhttpreq' => false,
'cite' => false,
'issafari' => false,
)
(line 210)

Features.

array $_images = array('jpeg', 'gif', 'png', 'pjpeg', 'x-png', 'bmp') (line 262)

List of viewable image MIME subtypes.

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

string $_lowerAgent = '' (line 62)

Lower-case user agent string.

integer $_majorVersion = 0 (line 34)

Major version number.

integer $_minorVersion = 0 (line 41)

Minor version number.

boolean $_mobile = false (line 203)

Is this a mobile browser?

mixed $_mobileAgents = array(
'Blackberry',
'Blazer',
'Handspring',
'iPhone',
'iPod',
'Kyocera',
'LG',
'Motorola',
'Nokia',
'Palm',
'PlayStation Portable',
'Samsung',
'Smartphone',
'SonyEricsson',
'Symbian',
'WAP',
'Windows CE',
)
(line 166)

List of mobile user agents.

Browsers like Mobile Safari (iPhone, iPod Touch) are much more full featured than OpenWave style browsers. This makes it dicey in some cases to treat all "mobile" browsers the same way.

  • TODO: This list is not used in isMobile yet nor does it provide the same results as isMobile(). It is here for reference and future work.
string $_platform = '' (line 76)

Platform the browser is running on.

array $_quirks = array(
'avoid_popup_windows' => false,
'break_disposition_header' => false,
'break_disposition_filename' => false,
'broken_multipart_form' => false,
'buggy_compression' => 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 236)

Quirks

string $_robotAgentRegexp = null (line 153)

Regexp for matching those robot strings.

array $_robotAgents = array(
/* The most common ones. */
'Googlebot',
'msnbot',
'Slurp',
'Yahoo',
/* The rest alphabetically. */
'appie',
'Arachnoidea',
'ArchitextSpider',
'Ask Jeeves',
'B-l-i-t-z-Bot',
'Baiduspider',
'BecomeBot',
'cfetch',
'ConveraCrawler',
'ExtractorPro',
'FAST-WebCrawler',
'FDSE robot',
'fido',
'findlinks',
'Francis',
'geckobot',
'Gigabot',
'Girafabot',
'grub-client',
'Gulliver',
'HTTrack',
'ia_archiver',
'iaskspider',
'iCCrawler',
'InfoSeek',
'kinjabot',
'KIT-Fireball',
'larbin',
'LEIA',
'lmspider',
'lwp-trivial',
'Lycos_Spider',
'Mediapartners-Google',
'MSRBOT',
'MuscatFerret',
'NaverBot',
'OmniExplorer_Bot',
'polybot',
'Pompos',
'RufusBot',
'Scooter',
'Seekbot',
'sogou spider',
'sproose',
'Teoma',
'TheSuBot',
'TurnitinBot',
'Twiceler',
'Ultraseek',
'ViolaBot',
'voyager',
'W3C-checklink',
'webbandit',
'www.almaden.ibm.com/cs/crawler',
'yacy',
'ZyBorg',
)
(line 83)

Known robots.

mixed $_tvAgents = array(
'Nintendo Wii',
'Playstation 3',
'WebTV',
)
(line 192)

List of tv user agents.

  • TODO: This list is not yet used anywhere. It is here for future media-type differentiation.
Methods
Constructor Browser (line 294)

Creates a browser instance (Constructor).

Browser Browser ([string $userAgent = null], [string $accept = null])
  • string $userAgent: The browser string to parse.
  • string $accept: The HTTP_ACCEPT settings to use.
allowFileUploads (line 972)

Determines if files can be uploaded to the system.

  • return: If uploads allowed, returns the maximum size of the upload in bytes. Returns 0 if uploads are not allowed.
integer allowFileUploads ()
downloadHeaders (line 1077)

Returns the headers for a browser download.

void downloadHeaders ([string $filename = 'unknown'], [string $cType = null], [boolean $inline = false], [string $cLength = null])
  • string $filename: The filename of the download.
  • string $cType: The content-type description of the file.
  • boolean $inline: True if inline, false if attachment.
  • string $cLength: The content-length of this file.
escapeJSCode (line 1197)

Escapes characters in javascript code if the browser requires it. %23, %26, and %2B (for some browsers) and %27 need to be escaped or else javascript will interpret it as a single quote, pound sign, or ampersand and refuse to work.

  • return: The escaped code.
string escapeJSCode (string $code)
  • string $code: The JS code to escape.
getAgentString (line 858)

Returns the full browser agent string.

  • return: The browser agent string.
string getAgentString ()
getBrowser (line 818)

Returns the current browser.

  • return: The current browser.
string getBrowser ()
getFeature (line 930)

Returns the current browser capability.

  • return: The value of the requested capability.
string getFeature (string $feature)
  • string $feature: The capability to retrieve.
getHTTPProtocol (line 954)

Returns the server protocol in use on the current server.

  • return: The HTTP server protocol version.
string getHTTPProtocol ()
getIEVersion (line 1230)

Returns the IE version stored in the session, if available.

  • return: The IE Version string or null if no string is stored.
mixed getIEVersion ()
getMajor (line 828)

Returns the current browser's major version.

  • return: The current browser's major version.
integer getMajor ()
getMinor (line 838)

Returns the current browser's minor version.

  • return: The current browser's minor version.
integer getMinor ()
getPlatform (line 758)

Returns the currently matched platform.

  • return: The user's platform.
string getPlatform ()
getQuirk (line 893)

Returns unique behavior for the current browser.

  • return: The value for the requested behavior.
string getQuirk (string $quirk)
  • string $quirk: The behavior to retrieve.
getVersion (line 848)

Returns the current browser's version.

  • return: The current browser's version.
string getVersion ()
hasFeature (line 918)

Checks the current browser capabilities.

  • return: Does the browser have the capability set?
boolean hasFeature (string $feature)
  • string $feature: The capability to check.
hasQuirk (line 881)

Checks unique behavior for the current browser.

  • return: Does the browser have the behavior set?
boolean hasQuirk (string $quirk)
  • string $quirk: The behavior to check.
isBrowser (line 780)

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

  • return: Is the given browser the same as the current?
boolean isBrowser (string $browser)
  • string $browser: The browser to check.
isMobile (line 790)

Do we consider the current browser to be a mobile device?

  • return: True if we do, false if we don't.
boolean isMobile ()
isRobot (line 800)

Determines if the browser is a robot or not.

  • return: True if browser is a known robot.
boolean isRobot ()
isViewable (line 1147)

Determines if a browser can display a given MIME type.

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

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

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 768)

Sets the current browser.

void setBrowser (string $browser)
  • string $browser: The browser to set as current.
setFeature (line 906)

Sets capabilities for the current browser.

void setFeature (string $feature, [string $value = true])
  • string $feature: The capability to set.
  • string $value: Special capability parameter.
setIEVersion (line 1218)

Sets the IE version in the session.

void setIEVersion (string $ver)
  • string $ver: The IE Version string.
setQuirk (line 869)

Sets unique behavior for the current browser.

void setQuirk (string $quirk, [string $value = true])
  • string $quirk: The behavior to set.
  • string $value: Special behavior parameter.
singleton (line 276)

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

This method must be invoked as:

  1.    $browser &Browser::singleton([$userAgent[$accept]]);

  • return: The Browser object.
Browser &singleton ([string $userAgent = null], [string $accept = null])
  • string $userAgent: The browser string to parse.
  • string $accept: The HTTP_ACCEPT settings to use.
usingSSLConnection (line 942)

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

  • return: True if using SSL, false if not.
boolean usingSSLConnection ()
wasFileUploaded (line 1024)

Determines if the file was uploaded or not. If not, will return the appropriate error message.

  • return: True on success, PEAR_Error on error.
mixed wasFileUploaded (string $field, [string $name = null])
  • string $field: The name of the field containing the uploaded file.
  • string $name: The file description string to use in the error message. Default: 'file'.
_setPlatform (line 742)

Matches 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.

void _setPlatform ()

Documentation generated on Sun, 30 Nov 2008 02:32:56 -0500 by phpDocumentor 1.4.0