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])
Afficher le fichier Open project: horde/horde Class Usage Examples

Protected Properties

Свойство 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.

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode Description
_setPlatform ( ) Matches the platform of the browser.

Method Details

__construct() public méthode

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 méthode

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 méthode

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

downloadHeaders() public méthode

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 méthode

Returns the full browser agent string.
public getAgentString ( ) : string
Résultat string The browser agent string.

getBrowser() public méthode

Returns the current browser.
public getBrowser ( ) : string
Résultat string The current browser.

getFeature() public méthode

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

getHTTPProtocol() public méthode

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

getIPAddress() public méthode

Returns the IP address of the client.
public getIPAddress ( ) : string
Résultat string The client IP address.

getMajor() public méthode

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

getMinor() public méthode

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

getPlatform() public méthode

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

getQuirk() public méthode

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

getVersion() public méthode

Returns the current browser's version.
public getVersion ( ) : string
Résultat string The current browser's version.

hasFeature() public méthode

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

hasQuirk() public méthode

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

isBrowser() public méthode

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

isMobile() public méthode

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

isRobot() public méthode

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

isTablet() public méthode

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
Résultat boolean True if we do, false if we don't.

isViewable() public méthode

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

match() public méthode

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 méthode

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

setFeature() public méthode

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 méthode

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

setQuirk() public méthode

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 méthode

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 méthode

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

wasFileUploaded() public méthode

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
Résultat string

$_agent protected_oe property

Full user agent string.
protected string $_agent
Résultat string

$_browser protected_oe property

Browser name.
protected string $_browser
Résultat string

$_features protected_oe property

Features.
protected array $_features
Résultat array

$_images protected_oe property

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

$_lowerAgent protected_oe property

Lower-case user agent string.
protected string $_lowerAgent
Résultat string

$_majorVersion protected_oe property

Major version number.
protected int $_majorVersion
Résultat integer

$_minorVersion protected_oe property

Minor version number.
protected int $_minorVersion
Résultat integer

$_mobile protected_oe property

Is this a mobile browser?
protected bool $_mobile
Résultat 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
Résultat string

$_quirks protected_oe property

Quirks.
protected array $_quirks
Résultat array

$_robotAgentRegexp protected_oe property

Regexp for matching those robot strings.
protected string $_robotAgentRegexp
Résultat string

$_robotAgents protected_oe property

Known robots.
protected array $_robotAgents
Résultat array

$_tablet protected_oe property

Is this a tablet browser?
protected bool $_tablet
Résultat boolean

$_tvAgents protected_oe property

List of televison user agents.
protected $_tvAgents