| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- /**
- * 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
- * @package Zend_Http
- * @subpackage UserAgent
- * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
- /**
- * Zend_Http_UserAgent_Features_Adapter_Interface
- */
- require_once 'Zend/Http/UserAgent/Features/Adapter.php';
- /**
- * Features adapter build with the Tera Wurfl Api
- * See installation instruction here : http://deviceatlas.com/licences
- * Download : http://deviceatlas.com/getAPI/php
- *
- * @package Zend_Http
- * @subpackage UserAgent
- * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
- class Zend_Http_UserAgent_Features_Adapter_DeviceAtlas implements Zend_Http_UserAgent_Features_Adapter
- {
- /**
- * Get features from request
- *
- * @param array $request $_SERVER variable
- * @return array
- */
- public static function getFromRequest($request, array $config)
- {
- if (!isset($config['deviceatlas'])) {
- require_once 'Zend/Http/UserAgent/Features/Exception.php';
- throw new Zend_Http_UserAgent_Features_Exception('"DeviceAtlas" configuration is not defined');
- }
-
- $config = $config['deviceatlas'];
-
- if (empty($config['deviceatlas_lib_dir'])) {
- require_once 'Zend/Http/UserAgent/Features/Exception.php';
- throw new Zend_Http_UserAgent_Features_Exception('The "deviceatlas_lib_dir" parameter is not defined');
- }
-
- if (empty($config['deviceatlas_data'])) {
- require_once 'Zend/Http/UserAgent/Features/Exception.php';
- throw new Zend_Http_UserAgent_Features_Exception('The "deviceatlas_data" parameter is not defined');
- }
-
- // Include the Device Atlas file
- require_once ($config['deviceatlas_lib_dir'] . '/Mobi/Mtld/DA/Api.php');
-
- //load the device data-tree : e.g. 'json/DeviceAtlas.json
- $tree = Mobi_Mtld_DA_Api::getTreeFromFile($config['deviceatlas_data']);
-
- $properties = Mobi_Mtld_DA_Api::getProperties($tree, $request['http_user_agent']);
-
- return $properties;
- }
- }
|