Properties

$_majorVersion

$_majorVersion : integer

Major version number.

Type

integer

$_minorVersion

$_minorVersion : integer

Minor version number.

Type

integer

$_browser

$_browser : string

Browser name.

Type

string

$_agent

$_agent : string

Full user agent string.

Type

string

$_lowerAgent

$_lowerAgent : string

Lower-case user agent string.

Type

string

$_accept

$_accept : string

HTTP_ACCEPT string

Type

string

$_platform

$_platform : string

Platform the browser is running on.

Type

string

$_robotAgents

$_robotAgents : array

Known robots.

Type

array

$_robotAgentRegexp

$_robotAgentRegexp : string

Regexp for matching those robot strings.

Type

string

$_mobileAgents

$_mobileAgents : 

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.

Type

$_tvAgents

$_tvAgents : 

List of televison user agents.

Type

$_mobile

$_mobile : boolean

Is this a mobile browser?

Type

boolean

$_tablet

$_tablet : boolean

Is this a tablet browser?

Type

boolean

$_features

$_features : array

Features.

Type

array

$_quirks

$_quirks : array

Quirks.

Type

array

$_images

$_images : array

List of viewable image MIME subtypes.

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

Type

array

Methods

__construct()

__construct(string  $userAgent = null, string  $accept = null) 

Creates a browser instance (Constructor).

Parameters

string $userAgent

The browser string to parse.

string $accept

The HTTP_ACCEPT settings to use.

match()

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.

Parameters

string $userAgent

The browser string to parse.

string $accept

The HTTP_ACCEPT settings to use.

getPlatform()

getPlatform() : string

Returns the currently matched platform.

Returns

string —

The user's platform.

setBrowser()

setBrowser(string  $browser) 

Sets the current browser.

Parameters

string $browser

The browser to set as current.

isBrowser()

isBrowser(string  $browser) : boolean

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

Parameters

string $browser

The browser to check.

Returns

boolean —

Is the given browser the same as the current?

setMobile()

setMobile(boolean  $mobile) 

Set this browser as a mobile device.

Parameters

boolean $mobile

True if the browser is a mobile device.

isMobile()

isMobile() : boolean

Is the current browser to be a mobile device?

Returns

boolean —

True if we do, false if we don't.

setTablet()

setTablet(boolean  $tablet) 

Set this browser as a tablet device.

Parameters

boolean $tablet

True if the browser is a tablet device.

isTablet()

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.

Returns

boolean —

True if we do, false if we don't.

isRobot()

isRobot() : boolean

Is the browser a robot?

Returns

boolean —

True if browser is a known robot.

getBrowser()

getBrowser() : string

Returns the current browser.

Returns

string —

The current browser.

getMajor()

getMajor() : integer

Returns the current browser's major version.

Returns

integer —

The current browser's major version.

getMinor()

getMinor() : integer

Returns the current browser's minor version.

Returns

integer —

The current browser's minor version.

getVersion()

getVersion() : string

Returns the current browser's version.

Returns

string —

The current browser's version.

getAgentString()

getAgentString() : string

Returns the full browser agent string.

Returns

string —

The browser agent string.

setQuirk()

setQuirk(string  $quirk, string  $value = true) 

Sets unique behavior for the current browser.

Parameters

string $quirk

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
string $value

Special behavior parameter.

hasQuirk()

hasQuirk(string  $quirk) : boolean

Checks unique behavior for the current browser.

Parameters

string $quirk

The behavior to check.

Returns

boolean —

Does the browser have the behavior set?

getQuirk()

getQuirk(string  $quirk) : string

Returns unique behavior for the current browser.

Parameters

string $quirk

The behavior to retrieve.

Returns

string —

The value for the requested behavior.

setFeature()

setFeature(string  $feature, string  $value = true) 

Sets capabilities for the current browser.

Parameters

string $feature

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
string $value

Special capability parameter.

hasFeature()

hasFeature(string  $feature) : boolean

Checks the current browser capabilities.

Parameters

string $feature

The capability to check.

Returns

boolean —

Does the browser have the capability set?

getFeature()

getFeature(string  $feature) : string

Returns the current browser capability.

Parameters

string $feature

The capability to retrieve.

Returns

string —

The value of the requested capability.

usingSSLConnection()

usingSSLConnection() : boolean

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

Returns

boolean —

True if using SSL, false if not.

getHTTPProtocol()

getHTTPProtocol() : string

Returns the server protocol in use on the current server.

Returns

string —

The HTTP server protocol version.

getIPAddress()

getIPAddress() : string

Returns the IP address of the client.

Returns

string —

The client IP address.

allowFileUploads()

allowFileUploads() : integer

Determines if files can be uploaded to the system.

Returns

integer —

If uploads allowed, returns the maximum size of the upload in bytes. Returns 0 if uploads are not allowed.

wasFileUploaded()

wasFileUploaded(string  $field, string  $name = null) 

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

Parameters

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

Throws

\Horde_Browser_Exception

downloadHeaders()

downloadHeaders(string  $filename = 'unknown', string  $cType = null, boolean  $inline = false, string  $cLength = null) 

Returns the headers for a browser download.

Parameters

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.

isViewable()

isViewable(string  $mimetype) : boolean

Determines if a browser can display a given MIME type.

Parameters

string $mimetype

The MIME type to check.

Returns

boolean —

True if the browser can display the MIME type.

_setPlatform()

_setPlatform() 

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.