web/lib/Zend/Http/UserAgent/Features/Adapter/DeviceAtlas.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    13  * to license@zend.com so we can send you a copy immediately.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Http
    16  * @package    Zend_Http
    17  * @subpackage UserAgent
    17  * @subpackage UserAgent
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  */
    20  */
    21 
    21 
    22 /**
    22 /**
    23  * Zend_Http_UserAgent_Features_Adapter_Interface
    23  * Zend_Http_UserAgent_Features_Adapter_Interface
    24  */
    24  */
    25 require_once 'Zend/Http/UserAgent/Features/Adapter.php';
    25 require_once 'Zend/Http/UserAgent/Features/Adapter.php';
    26 
    26 
    27 /**
    27 /**
    28  * Features adapter build with the Tera Wurfl Api
    28  * Features adapter build with the Tera Wurfl Api
    29  * See installation instruction here : http://deviceatlas.com/licences 
    29  * See installation instruction here : http://deviceatlas.com/licences
    30  * Download : http://deviceatlas.com/getAPI/php
    30  * Download : http://deviceatlas.com/getAPI/php
    31  *
    31  *
    32  * @package    Zend_Http
    32  * @package    Zend_Http
    33  * @subpackage UserAgent
    33  * @subpackage UserAgent
    34  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    34  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    35  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    35  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    36  */
    36  */
    37 class Zend_Http_UserAgent_Features_Adapter_DeviceAtlas implements Zend_Http_UserAgent_Features_Adapter
    37 class Zend_Http_UserAgent_Features_Adapter_DeviceAtlas implements Zend_Http_UserAgent_Features_Adapter
    38 {
    38 {
    39     /**
    39     /**
    48             if (!isset($config['deviceatlas'])) {
    48             if (!isset($config['deviceatlas'])) {
    49                 require_once 'Zend/Http/UserAgent/Features/Exception.php';
    49                 require_once 'Zend/Http/UserAgent/Features/Exception.php';
    50                 throw new Zend_Http_UserAgent_Features_Exception('"DeviceAtlas" configuration is not defined');
    50                 throw new Zend_Http_UserAgent_Features_Exception('"DeviceAtlas" configuration is not defined');
    51             }
    51             }
    52         }
    52         }
    53         
    53 
    54         $config = $config['deviceatlas'];
    54         $config = $config['deviceatlas'];
    55         
    55 
    56         if (!class_exists('Mobi_Mtld_DA_Api')) {
    56         if (!class_exists('Mobi_Mtld_DA_Api')) {
    57             if (empty($config['deviceatlas_lib_dir'])) {
    57             if (empty($config['deviceatlas_lib_dir'])) {
    58                 require_once 'Zend/Http/UserAgent/Features/Exception.php';
    58                 require_once 'Zend/Http/UserAgent/Features/Exception.php';
    59                 throw new Zend_Http_UserAgent_Features_Exception('The "deviceatlas_lib_dir" parameter is not defined');
    59                 throw new Zend_Http_UserAgent_Features_Exception('The "deviceatlas_lib_dir" parameter is not defined');
    60             }
    60             }
    61 
    61 
    62             // Include the Device Atlas file from the specified lib_dir
    62             // Include the Device Atlas file from the specified lib_dir
    63             require_once ($config['deviceatlas_lib_dir'] . '/Mobi/Mtld/DA/Api.php');
    63             require_once ($config['deviceatlas_lib_dir'] . '/Mobi/Mtld/DA/Api.php');
    64         }
    64         }
    65         
    65 
    66         if (empty($config['deviceatlas_data'])) {
    66         if (empty($config['deviceatlas_data'])) {
    67             require_once 'Zend/Http/UserAgent/Features/Exception.php';
    67             require_once 'Zend/Http/UserAgent/Features/Exception.php';
    68             throw new Zend_Http_UserAgent_Features_Exception('The "deviceatlas_data" parameter is not defined');
    68             throw new Zend_Http_UserAgent_Features_Exception('The "deviceatlas_data" parameter is not defined');
    69         }
    69         }
    70         
    70 
    71         //load the device data-tree : e.g. 'json/DeviceAtlas.json
    71         //load the device data-tree : e.g. 'json/DeviceAtlas.json
    72         $tree = Mobi_Mtld_DA_Api::getTreeFromFile($config['deviceatlas_data']);
    72         $tree = Mobi_Mtld_DA_Api::getTreeFromFile($config['deviceatlas_data']);
    73         
    73 
    74         $properties = Mobi_Mtld_DA_Api::getProperties($tree, $request['http_user_agent']);
    74         $properties = Mobi_Mtld_DA_Api::getProperties($tree, $request['http_user_agent']);
    75         
    75 
    76         return $properties;
    76         return $properties;
    77     }
    77     }
    78 }
    78 }