PageRenderTime 41ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/concreteOLD/libraries/3rdparty/Zend/Http/UserAgent/Features/Adapter/DeviceAtlas.php

https://bitbucket.org/selfeky/xclusivescardwebsite
PHP | 78 lines | 29 code | 9 blank | 40 comment | 5 complexity | b462a913aeba7eb7ea1f346fca42dc4c MD5 | raw file
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Http
  17. * @subpackage UserAgent
  18. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * Zend_Http_UserAgent_Features_Adapter_Interface
  23. */
  24. require_once 'Zend/Http/UserAgent/Features/Adapter.php';
  25. /**
  26. * Features adapter build with the Tera Wurfl Api
  27. * See installation instruction here : http://deviceatlas.com/licences
  28. * Download : http://deviceatlas.com/getAPI/php
  29. *
  30. * @package Zend_Http
  31. * @subpackage UserAgent
  32. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  33. * @license http://framework.zend.com/license/new-bsd New BSD License
  34. */
  35. class Zend_Http_UserAgent_Features_Adapter_DeviceAtlas implements Zend_Http_UserAgent_Features_Adapter
  36. {
  37. /**
  38. * Get features from request
  39. *
  40. * @param array $request $_SERVER variable
  41. * @return array
  42. */
  43. public static function getFromRequest($request, array $config)
  44. {
  45. if (!class_exists('Mobi_Mtld_DA_Api')) {
  46. if (!isset($config['deviceatlas'])) {
  47. require_once 'Zend/Http/UserAgent/Features/Exception.php';
  48. throw new Zend_Http_UserAgent_Features_Exception('"DeviceAtlas" configuration is not defined');
  49. }
  50. }
  51. $config = $config['deviceatlas'];
  52. if (!class_exists('Mobi_Mtld_DA_Api')) {
  53. if (empty($config['deviceatlas_lib_dir'])) {
  54. require_once 'Zend/Http/UserAgent/Features/Exception.php';
  55. throw new Zend_Http_UserAgent_Features_Exception('The "deviceatlas_lib_dir" parameter is not defined');
  56. }
  57. // Include the Device Atlas file from the specified lib_dir
  58. require_once ($config['deviceatlas_lib_dir'] . '/Mobi/Mtld/DA/Api.php');
  59. }
  60. if (empty($config['deviceatlas_data'])) {
  61. require_once 'Zend/Http/UserAgent/Features/Exception.php';
  62. throw new Zend_Http_UserAgent_Features_Exception('The "deviceatlas_data" parameter is not defined');
  63. }
  64. //load the device data-tree : e.g. 'json/DeviceAtlas.json
  65. $tree = Mobi_Mtld_DA_Api::getTreeFromFile($config['deviceatlas_data']);
  66. $properties = Mobi_Mtld_DA_Api::getProperties($tree, $request['http_user_agent']);
  67. return $properties;
  68. }
  69. }