PHP Class Horde_Browser, horde

Browser identification is performed by examining the HTTP_USER_AGENT environment variable provided by the web server.
Author: Chuck Hagenbuch ([email protected])
Author: Jon Parise ([email protected])
Mostra file Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_accept string HTTP_ACCEPT string
$_agent string Full user agent string.
$_browser string Browser name.
$_features array Features.
$_images array This list of viewable images works for IE and Netscape/Mozilla.
$_lowerAgent string Lower-case user agent string.
$_majorVersion integer Major version number.
$_minorVersion integer Minor version number.
$_mobile boolean Is this a mobile browser?
$_mobileAgents 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.
$_platform string Platform the browser is running on.
$_quirks array Quirks.
$_robotAgentRegexp string Regexp for matching those robot strings.
$_robotAgents array Known robots.
$_tablet boolean Is this a tablet browser?
$_tvAgents List of televison user agents.

Public Methods

Method Description
__construct ( string $userAgent = null, string $accept = null ) Creates a browser instance (Constructor).
allowFileUploads ( ) : integer Determines if files can be uploaded to the system.
downloadHeaders ( string $filename = 'unknown', string $cType = null, boolean $inline = false, string $cLength = null ) Returns the headers for a browser download.
getAgentString ( ) : string Returns the full browser agent string.
getBrowser ( ) : string Returns the current browser.
getFeature ( string $feature ) : string Returns the current browser capability.
getHTTPProtocol ( ) : string Returns the server protocol in use on the current server.
getIPAddress ( ) : string Returns the IP address of the client.
getMajor ( ) : integer Returns the current browser's major version.
getMinor ( ) : integer Returns the current browser's minor version.
getPlatform ( ) : string Returns the currently matched platform.
getQuirk ( string $quirk ) : string Returns unique behavior for the current browser.
getVersion ( ) : string Returns the current browser's version.
hasFeature ( string $feature ) : boolean Checks the current browser capabilities.
hasQuirk ( string $quirk ) : boolean Checks unique behavior for the current browser.
isBrowser ( string $browser ) : boolean Determines if the given browser is the same as the current.
isMobile ( ) : boolean Is the current browser to be a mobile device?
isRobot ( ) : boolean Is the browser a robot?
isTablet ( ) : boolean Is the current browser a tablet device? This is not 100% reliable, as most browsers do not differentiate between smartphone and tablet versions.
isViewable ( string $mimetype ) : boolean Determines if a browser can display a given MIME type.
match ( string $userAgent = null, string $accept = null ) Parses the user agent string and inititializes the object with all the known features and quirks for the given browser.
setBrowser ( string $browser ) Sets the current browser.
setFeature ( string $feature, string $value = true ) Sets capabilities for the current browser.
setMobile ( boolean $mobile ) Set this browser as a mobile device.
setQuirk ( string $quirk, string $value = true ) Sets unique behavior for the current browser.
setTablet ( boolean $tablet ) Set this browser as a tablet device.
usingSSLConnection ( ) : boolean Determines if we are using a secure (SSL) connection.
wasFileUploaded ( string $field, string $name = null ) Determines if the file was uploaded or not. If not, will return the appropriate error message.

Protected Methods

Method Description
_setPlatform ( ) Matches the platform of the browser.

Method Details

__construct() public method

Creates a browser instance (Constructor).
public __construct ( string $userAgent = null, string $accept = null )
$userAgent string The browser string to parse.
$accept string The HTTP_ACCEPT settings to use.

_setPlatform() protected method

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.
protected _setPlatform ( )

allowFileUploads() public static method

Determines if files can be uploaded to the system.
public static allowFileUploads ( ) : integer
return integer If uploads allowed, returns the maximum size of the upload in bytes. Returns 0 if uploads are not allowed.

downloadHeaders() public method

Returns the headers for a browser download.
public downloadHeaders ( string $filename = 'unknown', string $cType = null, boolean $inline = false, string $cLength = null )
$filename string The filename of the download.
$cType string The content-type description of the file.
$inline boolean True if inline, false if attachment.
$cLength string The content-length of this file.

getAgentString() public method

Returns the full browser agent string.
public getAgentString ( ) : string
return string The browser agent string.

getBrowser() public method

Returns the current browser.
public getBrowser ( ) : string
return string The current browser.

getFeature() public method

Returns the current browser capability.
public getFeature ( string $feature ) : string
$feature string The capability to retrieve.
return string The value of the requested capability.

getHTTPProtocol() public method

Returns the server protocol in use on the current server.
public getHTTPProtocol ( ) : string
return string The HTTP server protocol version.

getIPAddress() public method

Returns the IP address of the client.
public getIPAddress ( ) : string
return string The client IP address.

getMajor() public method

Returns the current browser's major version.
public getMajor ( ) : integer
return integer The current browser's major version.

getMinor() public method

Returns the current browser's minor version.
public getMinor ( ) : integer
return integer The current browser's minor version.

getPlatform() public method

Returns the currently matched platform.
public getPlatform ( ) : string
return string The user's platform.

getQuirk() public method

Returns unique behavior for the current browser.
public getQuirk ( string $quirk ) : string
$quirk string The behavior to retrieve.
return string The value for the requested behavior.

getVersion() public method

Returns the current browser's version.
public getVersion ( ) : string
return string The current browser's version.

hasFeature() public method

Checks the current browser capabilities.
public hasFeature ( string $feature ) : boolean
$feature string The capability to check.
return boolean Does the browser have the capability set?

hasQuirk() public method

Checks unique behavior for the current browser.
public hasQuirk ( string $quirk ) : boolean
$quirk string The behavior to check.
return boolean Does the browser have the behavior set?

isBrowser() public method

Determines if the given browser is the same as the current.
public isBrowser ( string $browser ) : boolean
$browser string The browser to check.
return boolean Is the given browser the same as the current?

isMobile() public method

Is the current browser to be a mobile device?
public isMobile ( ) : boolean
return boolean True if we do, false if we don't.

isRobot() public method

Is the browser a robot?
public isRobot ( ) : boolean
return boolean True if browser is a known robot.

isTablet() public method

Is the current browser a tablet device? This is not 100% reliable, as most browsers do not differentiate between smartphone and tablet versions.
Since: 2.1.0
public isTablet ( ) : boolean
return boolean True if we do, false if we don't.

isViewable() public method

Determines if a browser can display a given MIME type.
public isViewable ( string $mimetype ) : boolean
$mimetype string The MIME type to check.
return boolean True if the browser can display the MIME type.

match() public method

Parses the user agent string and inititializes the object with all the known features and quirks for the given browser.
public match ( string $userAgent = null, string $accept = null )
$userAgent string The browser string to parse.
$accept string The HTTP_ACCEPT settings to use.

setBrowser() public method

Sets the current browser.
public setBrowser ( string $browser )
$browser string The browser to set as current.

setFeature() public method

Sets capabilities for the current browser.
public setFeature ( string $feature, string $value = true )
$feature string The capability to set. Features: - accesskey - ajax - cite - dataurl - dom - frames - hdml - html - homepage - iframes - images - ischrome - iskonqueror - issafari - java - javascript - optgroup - rte - tables - utf - wml - xmlhttpreq
$value string Special capability parameter.

setMobile() public method

Set this browser as a mobile device.
public setMobile ( boolean $mobile )
$mobile boolean True if the browser is a mobile device.

setQuirk() public method

Sets unique behavior for the current browser.
public setQuirk ( string $quirk, string $value = true )
$quirk string The behavior to set. Quirks: - avoid_popup_windows - break_disposition_header - break_disposition_filename - broken_multipart_form - buggy_compression - cache_same_url - cache_ssl_downloads - double_linebreak_textarea - empty_file_input_value - must_cache_forms - no_filename_spaces - no_hidden_overflow_tables - ow_gui_1.3 - png_transparency - scrollbar_in_way - scroll_tds - windowed_controls
$value string Special behavior parameter.

setTablet() public method

Set this browser as a tablet device.
Since: 2.1.0
public setTablet ( boolean $tablet )
$tablet boolean True if the browser is a tablet device.

usingSSLConnection() public method

Determines if we are using a secure (SSL) connection.
public usingSSLConnection ( ) : boolean
return boolean True if using SSL, false if not.

wasFileUploaded() public method

Determines if the file was uploaded or not. If not, will return the appropriate error message.
public wasFileUploaded ( string $field, string $name = null )
$field string The name of the field containing the uploaded file.
$name string The file description string to use in the error message. Default: 'file'.

Property Details

$_accept protected_oe property

HTTP_ACCEPT string
protected string $_accept
return string

$_agent protected_oe property

Full user agent string.
protected string $_agent
return string

$_browser protected_oe property

Browser name.
protected string $_browser
return string

$_features protected_oe property

Features.
protected array $_features
return array

$_images protected_oe property

This list of viewable images works for IE and Netscape/Mozilla.
protected array $_images
return array

$_lowerAgent protected_oe property

Lower-case user agent string.
protected string $_lowerAgent
return string

$_majorVersion protected_oe property

Major version number.
protected int $_majorVersion
return integer

$_minorVersion protected_oe property

Minor version number.
protected int $_minorVersion
return integer

$_mobile protected_oe property

Is this a mobile browser?
protected bool $_mobile
return boolean

$_mobileAgents protected_oe property

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.
protected $_mobileAgents

$_platform protected_oe property

Platform the browser is running on.
protected string $_platform
return string

$_quirks protected_oe property

Quirks.
protected array $_quirks
return array

$_robotAgentRegexp protected_oe property

Regexp for matching those robot strings.
protected string $_robotAgentRegexp
return string

$_robotAgents protected_oe property

Known robots.
protected array $_robotAgents
return array

$_tablet protected_oe property

Is this a tablet browser?
protected bool $_tablet
return boolean

$_tvAgents protected_oe property

List of televison user agents.
protected $_tvAgents