File indexing completed on 2025-01-19 05:21:14
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Http 0017 * @subpackage UserAgent 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 */ 0021 0022 /** 0023 * Zend_Http_UserAgent_Features_Adapter_Interface 0024 */ 0025 // require_once 'Zend/Http/UserAgent/Features/Adapter.php'; 0026 0027 /** 0028 * Features adapter build with the Tera Wurfl Api 0029 * See installation instruction here : http://deviceatlas.com/licences 0030 * Download : http://deviceatlas.com/getAPI/php 0031 * 0032 * @package Zend_Http 0033 * @subpackage UserAgent 0034 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0035 * @license http://framework.zend.com/license/new-bsd New BSD License 0036 */ 0037 class Zend_Http_UserAgent_Features_Adapter_DeviceAtlas implements Zend_Http_UserAgent_Features_Adapter 0038 { 0039 /** 0040 * Get features from request 0041 * 0042 * @param array $request $_SERVER variable 0043 * @return array 0044 */ 0045 public static function getFromRequest($request, array $config) 0046 { 0047 if (!class_exists('Mobi_Mtld_DA_Api')) { 0048 if (!isset($config['deviceatlas'])) { 0049 // require_once 'Zend/Http/UserAgent/Features/Exception.php'; 0050 throw new Zend_Http_UserAgent_Features_Exception('"DeviceAtlas" configuration is not defined'); 0051 } 0052 } 0053 0054 $config = $config['deviceatlas']; 0055 0056 if (!class_exists('Mobi_Mtld_DA_Api')) { 0057 if (empty($config['deviceatlas_lib_dir'])) { 0058 // require_once 'Zend/Http/UserAgent/Features/Exception.php'; 0059 throw new Zend_Http_UserAgent_Features_Exception('The "deviceatlas_lib_dir" parameter is not defined'); 0060 } 0061 0062 // Include the Device Atlas file from the specified lib_dir 0063 // require_once ($config['deviceatlas_lib_dir'] . '/Mobi/Mtld/DA/Api.php'); 0064 } 0065 0066 if (empty($config['deviceatlas_data'])) { 0067 // require_once 'Zend/Http/UserAgent/Features/Exception.php'; 0068 throw new Zend_Http_UserAgent_Features_Exception('The "deviceatlas_data" parameter is not defined'); 0069 } 0070 0071 //load the device data-tree : e.g. 'json/DeviceAtlas.json 0072 $tree = Mobi_Mtld_DA_Api::getTreeFromFile($config['deviceatlas_data']); 0073 0074 $properties = Mobi_Mtld_DA_Api::getProperties($tree, $request['http_user_agent']); 0075 0076 return $properties; 0077 } 0078 }