Definition at line 37 of file UserAgent.php.
◆ __construct()
__construct |
( |
|
$options = null | ) |
|
Constructor
- Parameters
-
- Returns
- void
Definition at line 160 of file UserAgent.php.
◆ _createDevice()
Creates device object instance
- Returns
- void
Definition at line 847 of file UserAgent.php.
_getUserAgentDevice($browserType)
◆ _getUserAgentDevice()
_getUserAgentDevice |
( |
|
$browserType | ) |
|
|
protected |
Loads class for a user agent device
- Parameters
-
string | $browserType | Browser type |
- Returns
- string
- Exceptions
-
Definition at line 312 of file UserAgent.php.
314 $browserType = strtolower($browserType);
315 if (isset($this->_browserTypeClass[$browserType])) {
316 return $this->_browserTypeClass[$browserType];
319 if (isset($this->_config[$browserType])
320 && isset($this->_config[$browserType][
'device'])
322 $deviceConfig = $this->_config[$browserType][
'device'];
323 if (is_array($deviceConfig) && isset($deviceConfig[
'classname'])) {
324 $device = (string) $deviceConfig[
'classname'];
326 #require_once 'Zend/Http/UserAgent/Exception.php'; 328 'Invalid classname "%s" provided in device configuration for browser type "%s"',
333 }
elseif (is_array($deviceConfig) && isset($deviceConfig[
'path'])) {
335 $path = $deviceConfig[
'path'];
336 $prefix = isset($deviceConfig[
'prefix']) ? $deviceConfig[
'prefix'] :
'Zend_Http_UserAgent';
339 $device =
$loader->load($browserType);
342 $device =
$loader->load($browserType);
346 $device =
$loader->load($browserType);
349 $this->_browserTypeClass[$browserType] = $device;
elseif(isset( $params[ 'redirect_parent']))
◆ _match()
Comparison of the UserAgent chain and browser signatures.
The comparison is case-insensitive : the browser signatures must be in lower case
- Parameters
-
string | $deviceClass | Name of class against which a match will be attempted |
- Returns
- bool
Definition at line 284 of file UserAgent.php.
287 $r =
new ReflectionClass($deviceClass);
288 if (!$r->implementsInterface(
'Zend_Http_UserAgent_Device')) {
290 'Invalid device class provided ("%s"); must implement Zend_Http_UserAgent_Device',
299 array($deviceClass,
'match'),
call_user_func($callable, $param)
◆ _matchUserAgent()
Run the identification sequence to match the right browser type according to the user agent
- Returns
- Zend_Http_UserAgent_Result
Definition at line 804 of file UserAgent.php.
809 if (empty($this->_config[
'identification_sequence'])) {
814 $sequence = explode(
',', $this->_config[
'identification_sequence']);
818 array_unshift($sequence, $browserType);
822 if (!in_array(
$type, $sequence)) {
827 foreach ($sequence as $browserType) {
828 $browserType = trim($browserType);
833 $type = $browserType;
_getUserAgentDevice($browserType)
const DEFAULT_BROWSER_TYPE
◆ _validateLoaderType()
_validateLoaderType |
( |
|
$type | ) |
|
|
protected |
Validate a plugin loader type
Verifies that it is in $_loaderTypes, and returns a normalized version of the type.
- Parameters
-
- Returns
- string
- Exceptions
-
Definition at line 782 of file UserAgent.php.
785 if (!in_array(
$type, $this->_loaderTypes)) {
786 $types = implode(
', ', $this->_loaderTypes);
788 #require_once 'Zend/Http/UserAgent/Exception.php'; 790 'Expected one of "%s" for plugin loader type; received "%s"',
◆ clearStorage()
clearStorage |
( |
|
$browser = null | ) |
|
Clean the persistent storage
- Parameters
-
string | $browser | Browser identifier (User Agent chain) |
- Returns
- void
Definition at line 469 of file UserAgent.php.
getStorage($browser=null)
◆ getBrowserType()
Retrieve the browser type
- Returns
- string $browserType
Definition at line 578 of file UserAgent.php.
◆ getConfig()
Get user configuration
- Returns
- array
Definition at line 479 of file UserAgent.php.
◆ getDevice()
Returns the device object
This is the object that will contain the various discovered device capabilities.
- Returns
- Zend_Http_UserAgent_Device $device
Definition at line 539 of file UserAgent.php.
541 if (
null !== $this->_device) {
550 if (!$storage->isEmpty()) {
553 $object = $storage->read();
567 $this->_immutable =
true;
getStorage($browser=null)
setBrowserType($browserType)
◆ getHttpAccept()
getHttpAccept |
( |
|
$httpAccept = null | ) |
|
Returns the HTTP Accept server param
- Parameters
-
string | $httpAccept | (option) forced HTTP Accept chain |
- Returns
- string
Definition at line 390 of file UserAgent.php.
setHttpAccept($httpAccept)
const DEFAULT_HTTP_ACCEPT
◆ getPluginLoader()
Get a plugin loader
- Parameters
-
- Returns
- Zend_Loader_PluginLoader
Definition at line 762 of file UserAgent.php.
765 if (!isset($this->_loaders[
$type])) {
766 #require_once 'Zend/Loader/PluginLoader.php'; 769 return $this->_loaders[
$type];
_validateLoaderType($type)
setPluginLoader($type, $loader)
◆ getServer()
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
- array
Definition at line 613 of file UserAgent.php.
615 if (
null === $this->_server) {
◆ getServerValue()
Retrieve a server value
- Parameters
-
- Returns
- mixed
Definition at line 673 of file UserAgent.php.
675 $key = strtolower($key);
678 if (isset($server[$key])) {
679 $return = $server[$key];
◆ getStorage()
getStorage |
( |
|
$browser = null | ) |
|
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
-
string | $browser | Browser identifier (User Agent chain) |
- Returns
- Zend_Http_UserAgent_Storage
Definition at line 422 of file UserAgent.php.
424 if (
null === $browser) {
427 if (
null === $this->_storage) {
428 $config = $this->_config[
'storage'];
435 $options = array(
'browser_type' => $browser);
436 if (isset(
$config[
'options'])) {
setStorage(Zend_Http_UserAgent_Storage $storage)
◆ getUserAgent()
Returns the User Agent value
If $userAgent param is null, the value of $_server['HTTP_USER_AGENT'] is returned.
- Returns
- string
Definition at line 362 of file UserAgent.php.
const DEFAULT_HTTP_USER_AGENT
◆ serialize()
Serialized representation of the object
- Returns
- string
Definition at line 172 of file UserAgent.php.
176 'browser_type' => $this->_browserType,
177 'config' => $this->_config,
178 'device_class' => get_class($device),
179 'device' => $device->serialize(),
◆ setBrowserType()
setBrowserType |
( |
|
$browserType | ) |
|
Set the browser "type"
- Parameters
-
- Returns
- Zend_Http_UserAgent
Definition at line 589 of file UserAgent.php.
591 if ($this->_immutable) {
592 #require_once 'Zend/Http/UserAgent/Exception.php'; 594 'The User-Agent device object has already been retrieved; the browser type is now immutable' 598 $this->_browserType = $browserType;
◆ setConfig()
setConfig |
( |
|
$config = array() | ) |
|
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
-
mixed | $config | (option) Config array |
- Returns
- Zend_Http_UserAgent
Definition at line 503 of file UserAgent.php.
511 #require_once 'Zend/Http/UserAgent/Exception.php'; 513 'Config parameters must be in an array or a Traversable object; received "%s"',
518 if (
$config instanceof Traversable) {
527 $this->_config = array_merge($this->_config,
$config);
◆ setHttpAccept()
setHttpAccept |
( |
|
$httpAccept | ) |
|
Force or replace the HTTP_ACCEPT chain in self::$_server variable
- Parameters
-
string | $httpAccept | Forced HTTP Accept chain |
- Returns
- Zend_Http_UserAgent
Definition at line 405 of file UserAgent.php.
setServerValue($key, $value)
◆ setOptions()
Configure instance
- Parameters
-
- Returns
- Zend_Http_UserAgent
Definition at line 217 of file UserAgent.php.
227 #require_once 'Zend/Http/UserAgent/Exception.php'; 229 'Invalid argument; expected array, Zend_Config object, or object implementing ArrayAccess and Traversable; received %s',
241 if (isset(
$options[
'plugin_loader'])) {
242 $plConfig =
$options[
'plugin_loader'];
243 if (is_array($plConfig) || $plConfig instanceof Traversable) {
248 unset($plConfig,
$options[
'plugin_loader']);
254 switch (strtolower($key)) {
setConfig($config=array())
setHttpAccept($httpAccept)
setPluginLoader($type, $loader)
$_option $_optionId $class
setBrowserType($browserType)
◆ setPluginLoader()
setPluginLoader |
( |
|
$type, |
|
|
|
$loader |
|
) |
| |
Set plugin loader
- Parameters
-
string | $type | Type of plugin loader; one of 'storage', (?) |
string | Zend_Loader_PluginLoader | $loader | |
- Returns
- Zend_Http_UserAgent
Definition at line 714 of file UserAgent.php.
720 #require_once 'Zend/Loader.php'; 725 #require_once 'Zend/Http/UserAgent/Exception.php'; 727 'Expected a plugin loader class or object; received %s',
731 if (!
$loader instanceof Zend_Loader_PluginLoader) {
732 #require_once 'Zend/Http/UserAgent/Exception.php'; 734 'Expected an object extending Zend_Loader_PluginLoader; received %s',
739 $basePrefix =
'Zend_Http_UserAgent_';
740 $basePath =
'Zend/Http/UserAgent/';
743 $prefix = $basePrefix .
'Storage';
744 $path = $basePath .
'Storage';
_validateLoaderType($type)
elseif(isset( $params[ 'redirect_parent']))
static loadClass($class, $dirs=null)
◆ setServer()
Set the "$_SERVER" array
Basically, the $_SERVER array or an equivalent container storing the data that will be introspected.
- Parameters
-
array | ArrayAccess | $server | |
- Returns
- void
- Exceptions
-
Definition at line 631 of file UserAgent.php.
633 if ($this->_immutable) {
634 #require_once 'Zend/Http/UserAgent/Exception.php'; 636 'The User-Agent device object has already been retrieved; the server array is now immutable' 640 if (!is_array($server) && !$server instanceof Traversable) {
641 #require_once 'Zend/Http/UserAgent/Exception.php'; 643 'Expected an array or object implementing Traversable; received %s',
644 (is_object($server) ? get_class($server) : gettype($server))
649 if ($server instanceof ArrayObject) {
650 $server = $server->getArrayCopy();
651 }
elseif ($server instanceof Traversable) {
653 foreach ($server as $key =>
$value) {
661 $server = array_change_key_case($server, CASE_LOWER);
663 $this->_server = $server;
elseif(isset( $params[ 'redirect_parent']))
◆ setServerValue()
setServerValue |
( |
|
$key, |
|
|
|
$value |
|
) |
| |
Set a server value
- Parameters
-
string | int | float | $key | |
mixed | $value | |
- Returns
- void
Definition at line 692 of file UserAgent.php.
694 if ($this->_immutable) {
695 #require_once 'Zend/Http/UserAgent/Exception.php'; 697 'The User-Agent device object has already been retrieved; the server array is now immutable' 702 $key = strtolower($key);
703 $this->_server[$key] =
$value;
◆ setStorage()
Sets the persistent storage handler
- Parameters
-
- Returns
- Zend_Http_UserAgent
Definition at line 450 of file UserAgent.php.
452 if ($this->_immutable) {
453 #require_once 'Zend/Http/UserAgent/Exception.php'; 455 'The User-Agent device object has already been retrieved; the storage object is now immutable' 459 $this->_storage = $storage;
◆ setUserAgent()
setUserAgent |
( |
|
$userAgent | ) |
|
Force or replace the UA chain in $_server variable
- Parameters
-
string | $userAgent | Forced UserAgent chain |
- Returns
- Zend_Http_UserAgent
Definition at line 378 of file UserAgent.php.
setServerValue($key, $value)
◆ unserialize()
unserialize |
( |
|
$serialized | ) |
|
Unserialize a previous representation of the object
- Parameters
-
- Returns
- void
Definition at line 192 of file UserAgent.php.
199 $deviceClass = $spec[
'device_class'];
206 $deviceSpec[
'_config'] = $this->
getConfig();
207 $deviceSpec[
'_server'] = $this->
getServer();
208 $this->_device =
new $deviceClass($deviceSpec);
_getUserAgentDevice($browserType)
◆ $_browserType
◆ $_browserTypeClass
$_browserTypeClass = array() |
|
protected |
◆ $_config
Initial value:= array(
'identification_sequence' => self::DEFAULT_IDENTIFICATION_SEQUENCE,
'storage' => array(
'adapter' => self::DEFAULT_PERSISTENT_STORAGE_ADAPTER,
),
)
Definition at line 93 of file UserAgent.php.
◆ $_device
◆ $_immutable
◆ $_loaders
◆ $_loaderTypes
$_loaderTypes = array('storage', 'device') |
|
protected |
◆ $_matchLog
◆ $_server
◆ $_storage
◆ DEFAULT_BROWSER_TYPE
const DEFAULT_BROWSER_TYPE = 'desktop' |
'desktop' by default if the sequence return false for each item
Definition at line 52 of file UserAgent.php.
◆ DEFAULT_HTTP_ACCEPT
const DEFAULT_HTTP_ACCEPT = "application/xhtml+xml" |
Default Http Accept param to prevent empty value
Definition at line 62 of file UserAgent.php.
◆ DEFAULT_HTTP_USER_AGENT
const DEFAULT_HTTP_USER_AGENT = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)' |
Default User Agent chain to prevent empty value
Definition at line 57 of file UserAgent.php.
◆ DEFAULT_IDENTIFICATION_SEQUENCE
const DEFAULT_IDENTIFICATION_SEQUENCE = 'mobile,desktop' |
'desktop' by default if the sequence return false for each item or is empty
Definition at line 42 of file UserAgent.php.
◆ DEFAULT_MARKUP_LANGUAGE
const DEFAULT_MARKUP_LANGUAGE = "xhtml" |
◆ DEFAULT_PERSISTENT_STORAGE_ADAPTER
const DEFAULT_PERSISTENT_STORAGE_ADAPTER = 'Session' |
Default persitent storage adapter : Session or NonPersitent
Definition at line 47 of file UserAgent.php.
The documentation for this class was generated from the following file: