Horde_Browser
in package
This 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.
Tags
Table of Contents
- $_accept : string
- HTTP_ACCEPT string
- $_agent : string
- Full user agent string.
- $_browser : string
- Browser name.
- $_features : array<string|int, mixed>
- Features.
- $_images : array<string|int, mixed>
- List of viewable image MIME subtypes.
- $_lowerAgent : string
- Lower-case user agent string.
- $_majorVersion : int
- Major version number.
- $_minorVersion : int
- Minor version number.
- $_mobile : bool
- Is this a mobile browser?
- $_mobileAgents : mixed
- List of mobile user agents.
- $_platform : string
- Platform the browser is running on.
- $_quirks : array<string|int, mixed>
- Quirks.
- $_robotAgentRegexp : string
- Regexp for matching those robot strings.
- $_robotAgents : array<string|int, mixed>
- Known robots.
- $_tablet : bool
- Is this a tablet browser?
- $_tvAgents : mixed
- List of televison user agents.
- __construct() : mixed
- Creates a browser instance (Constructor).
- allowFileUploads() : int
- Determines if files can be uploaded to the system.
- downloadHeaders() : mixed
- Returns the headers for a browser download.
- getAgentString() : string
- Returns the full browser agent string.
- getBrowser() : string
- Returns the current browser.
- getFeature() : 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() : int
- Returns the current browser's major version.
- getMinor() : int
- Returns the current browser's minor version.
- getPlatform() : string
- Returns the currently matched platform.
- getQuirk() : string
- Returns unique behavior for the current browser.
- getVersion() : string
- Returns the current browser's version.
- hasFeature() : bool
- Checks the current browser capabilities.
- hasQuirk() : bool
- Checks unique behavior for the current browser.
- isBrowser() : bool
- Determines if the given browser is the same as the current.
- isMobile() : bool
- Is the current browser to be a mobile device?
- isRobot() : bool
- Is the browser a robot?
- isTablet() : bool
- Is the current browser a tablet device? This is not 100% reliable, as most browsers do not differentiate between smartphone and tablet versions.
- isViewable() : bool
- Determines if a browser can display a given MIME type.
- match() : mixed
- Parses the user agent string and inititializes the object with all the known features and quirks for the given browser.
- setBrowser() : mixed
- Sets the current browser.
- setFeature() : mixed
- Sets capabilities for the current browser.
- setMobile() : mixed
- Set this browser as a mobile device.
- setQuirk() : mixed
- Sets unique behavior for the current browser.
- setTablet() : mixed
- Set this browser as a tablet device.
- usingSSLConnection() : bool
- Determines if we are using a secure (SSL) connection.
- wasFileUploaded() : mixed
- Determines if the file was uploaded or not. If not, will return the appropriate error message.
- _setPlatform() : mixed
- Matches the platform of the browser.
Properties
$_accept
HTTP_ACCEPT string
protected
string
$_accept
= ''
$_agent
Full user agent string.
protected
string
$_agent
= ''
$_browser
Browser name.
protected
string
$_browser
= ''
$_features
Features.
protected
array<string|int, mixed>
$_features
= array('frames' => \true, 'html' => \true, 'images' => \true, 'java' => \true, 'javascript' => \true, 'tables' => \true)
$_images
List of viewable image MIME subtypes.
protected
array<string|int, mixed>
$_images
= array('jpeg', 'gif', 'png', 'pjpeg', 'x-png', 'bmp')
This list of viewable images works for IE and Netscape/Mozilla.
$_lowerAgent
Lower-case user agent string.
protected
string
$_lowerAgent
= ''
$_majorVersion
Major version number.
protected
int
$_majorVersion
= 0
$_minorVersion
Minor version number.
protected
int
$_minorVersion
= 0
$_mobile
Is this a mobile browser?
protected
bool
$_mobile
= \false
$_mobileAgents
List of mobile user agents.
protected
mixed
$_mobileAgents
= array('Blackberry', 'Blazer', 'Handspring', 'iPhone', 'iPod', 'Kyocera', 'LG', 'Motorola', 'Nokia', 'Palm', 'PlayStation Portable', 'Samsung', 'Smartphone', 'SonyEricsson', 'Symbian', 'WAP', 'Windows CE')
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.
Tags
$_platform
Platform the browser is running on.
protected
string
$_platform
= ''
$_quirks
Quirks.
protected
array<string|int, mixed>
$_quirks
= array()
$_robotAgentRegexp
Regexp for matching those robot strings.
protected
string
$_robotAgentRegexp
= \null
$_robotAgents
Known robots.
protected
array<string|int, mixed>
$_robotAgents
= array(
/* The most common ones. */
'Slurp',
'Yahoo',
/* The rest alphabetically. */
'appie',
'Arachnoidea',
'ArchitextSpider',
'Ask Jeeves',
'Baiduspider',
'cfetch',
'ConveraCrawler',
'ExtractorPro',
'FAST-WebCrawler',
'fido',
'findlinks',
'Francis',
'grub-client',
'Gulliver',
'HTTrack',
'ia_archiver',
'iaskspider',
'iCCrawler',
'InfoSeek',
'KIT-Fireball',
'larbin',
'LEIA',
'lmspider',
'lwp-trivial',
'Lycos_Spider',
'Mediapartners-Google',
'MuscatFerret',
'Pompos',
'Scooter',
'sogou spider',
'sproose',
'Teoma',
'Twiceler',
'Ultraseek',
'Vagabondo/Kliksafe',
'voyager',
'W3C-checklink',
'webbandit',
'www.almaden.ibm.com/cs/crawler',
'yacy',
'ZyBorg',
)
$_tablet
Is this a tablet browser?
protected
bool
$_tablet
= \false
$_tvAgents
List of televison user agents.
protected
mixed
$_tvAgents
= array('Nintendo Wii', 'Playstation 3', 'WebTV')
Tags
Methods
__construct()
Creates a browser instance (Constructor).
public
__construct([string $userAgent = null ][, string $accept = null ]) : mixed
Parameters
- $userAgent : string = null
-
The browser string to parse.
- $accept : string = null
-
The HTTP_ACCEPT settings to use.
Return values
mixed —allowFileUploads()
Determines if files can be uploaded to the system.
public
static allowFileUploads() : int
Return values
int —If uploads allowed, returns the maximum size of the upload in bytes. Returns 0 if uploads are not allowed.
downloadHeaders()
Returns the headers for a browser download.
public
downloadHeaders([string $filename = 'unknown' ][, string $cType = null ][, bool $inline = false ][, string $cLength = null ]) : mixed
Parameters
- $filename : string = 'unknown'
-
The filename of the download.
- $cType : string = null
-
The content-type description of the file.
- $inline : bool = false
-
True if inline, false if attachment.
- $cLength : string = null
-
The content-length of this file.
Return values
mixed —getAgentString()
Returns the full browser agent string.
public
getAgentString() : string
Return values
string —The browser agent string.
getBrowser()
Returns the current browser.
public
getBrowser() : string
Return values
string —The current browser.
getFeature()
Returns the current browser capability.
public
getFeature(string $feature) : string
Parameters
- $feature : string
-
The capability to retrieve.
Return values
string —The value of the requested capability.
getHTTPProtocol()
Returns the server protocol in use on the current server.
public
getHTTPProtocol() : string
Return values
string —The HTTP server protocol version.
getIPAddress()
Returns the IP address of the client.
public
getIPAddress() : string
Return values
string —The client IP address.
getMajor()
Returns the current browser's major version.
public
getMajor() : int
Return values
int —The current browser's major version.
getMinor()
Returns the current browser's minor version.
public
getMinor() : int
Return values
int —The current browser's minor version.
getPlatform()
Returns the currently matched platform.
public
getPlatform() : string
Return values
string —The user's platform.
getQuirk()
Returns unique behavior for the current browser.
public
getQuirk(string $quirk) : string
Parameters
- $quirk : string
-
The behavior to retrieve.
Return values
string —The value for the requested behavior.
getVersion()
Returns the current browser's version.
public
getVersion() : string
Return values
string —The current browser's version.
hasFeature()
Checks the current browser capabilities.
public
hasFeature(string $feature) : bool
Parameters
- $feature : string
-
The capability to check.
Return values
bool —Does the browser have the capability set?
hasQuirk()
Checks unique behavior for the current browser.
public
hasQuirk(string $quirk) : bool
Parameters
- $quirk : string
-
The behavior to check.
Return values
bool —Does the browser have the behavior set?
isBrowser()
Determines if the given browser is the same as the current.
public
isBrowser(string $browser) : bool
Parameters
- $browser : string
-
The browser to check.
Return values
bool —Is the given browser the same as the current?
isMobile()
Is the current browser to be a mobile device?
public
isMobile() : bool
Return values
bool —True if we do, false if we don't.
isRobot()
Is the browser a robot?
public
isRobot() : bool
Return values
bool —True if browser is a known robot.
isTablet()
Is the current browser a tablet device? This is not 100% reliable, as most browsers do not differentiate between smartphone and tablet versions.
public
isTablet() : bool
Tags
Return values
bool —True if we do, false if we don't.
isViewable()
Determines if a browser can display a given MIME type.
public
isViewable(string $mimetype) : bool
Parameters
- $mimetype : string
-
The MIME type to check.
Return values
bool —True if the browser can display the MIME type.
match()
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 ]) : mixed
Parameters
- $userAgent : string = null
-
The browser string to parse.
- $accept : string = null
-
The HTTP_ACCEPT settings to use.
Return values
mixed —setBrowser()
Sets the current browser.
public
setBrowser(string $browser) : mixed
Parameters
- $browser : string
-
The browser to set as current.
Return values
mixed —setFeature()
Sets capabilities for the current browser.
public
setFeature(string $feature[, string $value = true ]) : mixed
Parameters
- $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 = true
-
Special capability parameter.
Return values
mixed —setMobile()
Set this browser as a mobile device.
public
setMobile(bool $mobile) : mixed
Parameters
- $mobile : bool
-
True if the browser is a mobile device.
Return values
mixed —setQuirk()
Sets unique behavior for the current browser.
public
setQuirk(string $quirk[, string $value = true ]) : mixed
Parameters
- $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 = true
-
Special behavior parameter.
Return values
mixed —setTablet()
Set this browser as a tablet device.
public
setTablet(bool $tablet) : mixed
Parameters
- $tablet : bool
-
True if the browser is a tablet device.
Tags
Return values
mixed —usingSSLConnection()
Determines if we are using a secure (SSL) connection.
public
usingSSLConnection() : bool
Return values
bool —True if using SSL, false if not.
wasFileUploaded()
Determines if the file was uploaded or not. If not, will return the appropriate error message.
public
wasFileUploaded(string $field[, string $name = null ]) : mixed
Parameters
- $field : string
-
The name of the field containing the uploaded file.
- $name : string = null
-
The file description string to use in the error message. Default: 'file'.
Tags
Return values
mixed —_setPlatform()
Matches the platform of the browser.
protected
_setPlatform() : mixed
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.