Http/UserAgent.php

Show: PublicProtectedPrivateinherited
Table of Contents
Zend Framework
LICENSE This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to license@zend.com so we can send you a copy immediately.
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Http_UserAgent  
Subpackage
UserAgent  

\Zend_Http_UserAgent

Package: Zend_Http_UserAgent\UserAgent
Lists of User Agent chains for testing :
- http://www.useragentstring.com/layout/useragentstring.php - http://user-agent-string.info/list-of-ua - http://www.user-agents.org/allagents.xml - http://en.wikipedia.org/wiki/List_of_user_agents_for_mobile_phones - http://www.mobilemultimedia.be/fr/
Implements
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

>VConstant  DEFAULT_IDENTIFICATION_SEQUENCE = 'mobile,desktop'
'desktop' by default if the sequence return false for each item or is empty
>VConstant  DEFAULT_PERSISTENT_STORAGE_ADAPTER = 'Session'
Default persitent storage adapter : Session or NonPersitent
>VConstant  DEFAULT_BROWSER_TYPE = 'desktop'
'desktop' by default if the sequence return false for each item
>VConstant  DEFAULT_HTTP_USER_AGENT = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)'
Default User Agent chain to prevent empty value
>VConstant  DEFAULT_HTTP_ACCEPT = "application/xhtml+xml"
Default Http Accept param to prevent empty value
>VConstant  DEFAULT_MARKUP_LANGUAGE = "xhtml"
Default markup language

Properties

>VPropertyprotectedstring $_browserType
Browser type
Details
Type
string
>VPropertyprotectedarray $_browserTypeClass = array()
Browser type class
Map of browser types to classes.
Default valuearray()Details
Type
array
>VPropertyprotectedarray $_config = array('identification_sequence' => self::DEFAULT_IDENTIFICATION_SEQUENCE, 'storage' => array('adapter' => self::DEFAULT_PERSISTENT_STORAGE_ADAPTER))
Array to store config
Default values are provided to ensure specific keys are present at instantiation.
Default valuearray('identification_sequence' => self::DEFAULT_IDENTIFICATION_SEQUENCE, 'storage' => array('adapter' => self::DEFAULT_PERSISTENT_STORAGE_ADAPTER))Details
Type
array
>VPropertyprotected\Zend_Http_UserAgent_Device $_device
Identified device
>VPropertyprotectedbool $_immutable = false
Whether or not this instance is immutable.
If true, none of the following may be modified: - $_server - $_browserType - User-Agent (defined in $_server) - HTTP Accept value (defined in $_server) - $_storage
Default valuefalseDetails
Type
bool
>VPropertyprotectedarray $_loaderTypes = array('storage', 'device')
Valid plugin loader types
Default valuearray('storage', 'device')Details
Type
array
>VPropertyprotectedarray $_loaders = array()
Plugin loaders
Default valuearray()Details
Type
array
>VPropertyprotectedarray $_matchLog = array()
Trace of items matched to identify the browser type
Default valuearray()Details
Type
array
>VPropertyprotectedarray $_server
Server variable
Details
Type
array
>VPropertyprotected\Zend_Http_UserAgent_Storage $_storage
Persistent storage handler

Methods

methodpublic__construct(null | array | \Zend_Config | \ArrayAccess $options = null) : void

Constructor

Parameters
NameTypeDescription
$optionsnull | array | \Zend_Config | \ArrayAccess
methodprotected_createDevice() : void

Creates device object instance

methodprotected_getUserAgentDevice(string $browserType) : string

Loads class for a user agent device

Parameters
NameTypeDescription
$browserTypestring

Browser type

Returns
TypeDescription
string
Throws
ExceptionDescription
\Zend_Loader_PluginLoader_Exceptionif unable to load UA device
methodprotected_match(string $deviceClass) : bool

Comparison of the UserAgent chain and browser signatures.

The comparison is case-insensitive : the browser signatures must be in lower case
Parameters
NameTypeDescription
$deviceClassstring

Name of class against which a match will be attempted

Returns
TypeDescription
bool
methodprotected_matchUserAgent() : \Zend_Http_UserAgent_Result

Run the identification sequence to match the right browser type according to the user agent

Returns
TypeDescription
\Zend_Http_UserAgent_Result
methodprotected_validateLoaderType(string $type) : string

Validate a plugin loader type

Verifies that it is in {@link $_loaderTypes}, and returns a normalized version of the type.
Parameters
NameTypeDescription
$typestring
Returns
TypeDescription
string
Throws
ExceptionDescription
\Zend_Http_UserAgent_Exceptionon invalid type
methodpublicclearStorage(string $browser = null) : void

Clean the persistent storage

Parameters
NameTypeDescription
$browserstring

Browser identifier (User Agent chain)

methodpublicgetBrowserType() : string

Retrieve the browser type

Returns
TypeDescription
string$browserType
methodpublicgetConfig() : array

Get user configuration

Returns
TypeDescription
array
methodpublicgetDevice() : \Zend_Http_UserAgent_Device

Returns the device object

This is the object that will contain the various discovered device capabilities.
Returns
TypeDescription
\Zend_Http_UserAgent_Device$device
methodpublicgetHttpAccept(string $httpAccept = null) : string

Returns the HTTP Accept server param

Parameters
NameTypeDescription
$httpAcceptstring

(option) forced HTTP Accept chain

Returns
TypeDescription
string
methodpublicgetPluginLoader(string $type) : \Zend_Loader_PluginLoader

Get a plugin loader

Parameters
NameTypeDescription
$typestring

A valid plugin loader type; see {@link $_loaderTypes}

Returns
TypeDescription
\Zend_Loader_PluginLoader
methodpublicgetServer() : array

Retrieve the "$_SERVER" array

Basically, the $_SERVER array or an equivalent container storing the data that will be introspected. If the value has not been previously set, it sets itself from the $_SERVER superglobal.
Returns
TypeDescription
array
methodpublicgetServerValue(string $key) : mixed

Retrieve a server value

Parameters
NameTypeDescription
$keystring
Returns
TypeDescription
mixed
methodpublicgetStorage(string $browser = null) : \Zend_Http_UserAgent_Storage

Returns the persistent storage handler

Session storage is used by default unless a different storage adapter has been set via the "persistent_storage_adapter" key. That key should contain either a fully qualified class name, or a short name that resolves via the plugin loader.
Parameters
NameTypeDescription
$browserstring

Browser identifier (User Agent chain)

Returns
TypeDescription
\Zend_Http_UserAgent_Storage
methodpublicgetUserAgent() : string

Returns the User Agent value

If $userAgent param is null, the value of $_server['HTTP_USER_AGENT'] is returned.
Returns
TypeDescription
string
methodpublicserialize() : string

Serialized representation of the object

Returns
TypeDescription
string
methodpublicsetBrowserType(string $browserType) : \Zend_Http_UserAgent

Set the browser "type"

Parameters
NameTypeDescription
$browserTypestring
Returns
TypeDescription
\Zend_Http_UserAgent
methodpublicsetConfig(mixed $config = array()) : \Zend_Http_UserAgent

Config parameters is an Array or a Zend_Config object

The allowed parameters are : - the identification sequence (can be empty) => desktop browser type is the default browser type returned $config['identification_sequence'] : ',' separated browser types - the persistent storage adapter $config['persistent_storage_adapter'] = "Session" or "NonPersistent" - to add or replace a browser type device $config[(type)]['device']['path'] $config[(type)]['device']['classname'] - to add or replace a browser type features adapter $config[(type)]['features']['path'] $config[(type)]['features']['classname']
Parameters
NameTypeDescription
$configmixed

(option) Config array

Returns
TypeDescription
\Zend_Http_UserAgent
methodpublicsetHttpAccept(string $httpAccept) : \Zend_Http_UserAgent

Force or replace the HTTP_ACCEPT chain in self::$_server variable

Parameters
NameTypeDescription
$httpAcceptstring

Forced HTTP Accept chain

Returns
TypeDescription
\Zend_Http_UserAgent
methodpublicsetOptions(array | \Zend_Config | \ArrayAccess $options) : \Zend_Http_UserAgent

Configure instance

Parameters
NameTypeDescription
$optionsarray | \Zend_Config | \ArrayAccess
Returns
TypeDescription
\Zend_Http_UserAgent
methodpublicsetPluginLoader(string $type, string | \Zend_Loader_PluginLoader $loader) : \Zend_Http_UserAgent

Set plugin loader

Parameters
NameTypeDescription
$typestring

Type of plugin loader; one of 'storage', (?)

$loaderstring | \Zend_Loader_PluginLoader
Returns
TypeDescription
\Zend_Http_UserAgent
methodpublicsetServer(array | \ArrayAccess $server) : void

Set the "$_SERVER" array

Basically, the $_SERVER array or an equivalent container storing the data that will be introspected.
Parameters
NameTypeDescription
$serverarray | \ArrayAccess
Throws
ExceptionDescription
\Zend_Http_UserAgent_Exceptionon invalid parameter
methodpublicsetServerValue(string | int | float $key, mixed $value) : void

Set a server value

Parameters
NameTypeDescription
$keystring | int | float
$valuemixed
methodpublicsetStorage(\Zend_Http_UserAgent_Storage $storage) : \Zend_Http_UserAgent

Sets the persistent storage handler

Parameters
NameTypeDescription
$storage\Zend_Http_UserAgent_Storage
Returns
TypeDescription
\Zend_Http_UserAgent
methodpublicsetUserAgent(string $userAgent) : \Zend_Http_UserAgent

Force or replace the UA chain in $_server variable

Parameters
NameTypeDescription
$userAgentstring

Forced UserAgent chain

Returns
TypeDescription
\Zend_Http_UserAgent
methodpublicunserialize(string $serialized) : void

Unserialize a previous representation of the object

Parameters
NameTypeDescription
$serializedstring
Documentation was generated by phpDocumentor 2.2.0 .