Exemple #1
0
 /**
  * Get features from request
  *
  * @param  array $request $_SERVER variable
  * @return array
  */
 public static function getFromRequest($request, array $config)
 {
     if (!class_exists('TeraWurfl')) {
         // If TeraWurfl class not found, see if we can load it from
         // configuration
         //
         if (!isset($config['terawurfl'])) {
             // No configuration
             require_once 'Zend/Http/UserAgent/Features/Exception.php';
             throw new Zend_Http_UserAgent_Features_Exception('"TeraWurfl" configuration is not defined');
         }
         $config = $config['terawurfl'];
         if (empty($config['terawurfl_lib_dir'])) {
             // No lib_dir given
             require_once 'Zend/Http/UserAgent/Features/Exception.php';
             throw new Zend_Http_UserAgent_Features_Exception('The "terawurfl_lib_dir" parameter is not defined');
         }
         // Include the Tera-WURFL file
         require_once $config['terawurfl_lib_dir'] . '/TeraWurfl.php';
     }
     // instantiate the Tera-WURFL object
     $wurflObj = new TeraWurfl();
     // Get the capabilities of the current client.
     $matched = $wurflObj->getDeviceCapabilitiesFromRequest(array_change_key_case($request, CASE_UPPER));
     return self::getAllCapabilities($wurflObj);
 }
 protected function actionRequest()
 {
     $this->wurfl->getDeviceCapabilitiesFromRequest($this->http_headers);
     $this->response['id'] = $this->wurfl->capabilities['id'];
     $this->response['user_agent'] = $this->wurfl->httpRequest->user_agent->original;
     if (!empty($this->capabilities)) {
         $this->response['capabilities'] = array();
         foreach ($this->capabilities as $capability) {
             $this->response['capabilities'][$capability] = $this->wurfl->getDeviceCapability($capability);
         }
     }
     if ($this->matcher_history) {
         $this->response['matcher_history'] = $this->wurfl->getDeviceCapability('matcher_history');
     }
     $this->response['success'] = true;
     $this->sendResponse();
 }
<?php

/**
 * Copyright (c) 2011 ScientiaMobile, Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * Refer to the COPYING.txt file distributed with this package.
 *
 * @package    WURFL
 * @copyright  ScientiaMobile, Inc.
 * @author     Steve Kamerman <steve AT scientiamobile.com>
 * @license    GNU Affero General Public License
 * @version    $id$
 */
// Include the Tera-WURFL file
require_once realpath(dirname(__FILE__) . '/TeraWurfl.php');
// Instantiate the Tera-WURFL object
$wurflObj = new TeraWurfl();
// Get the capabilities from the object
$wurflObj->getDeviceCapabilitiesFromRequest();
// Print the capabilities array
echo "<pre>" . htmlspecialchars(var_export($wurflObj->capabilities, true)) . "</pre>";