예제 #1
0
 public function reload($wurflConfigurationPath)
 {
     $wurflConfig = WURFL_Configuration_ConfigFactory::create($wurflConfigurationPath);
     WURFL_Configuration_ConfigHolder::setWURFLConfig($wurflConfig);
     $cacheProvider = WURFL_Cache_CacheProviderFactory::getCacheProvider();
     $cacheProvider->clear();
     $persistenceProvider = WURFL_Xml_PersistenceProvider_PersistenceProviderManager::getPersistenceProvider();
     $persistenceProvider->setWURFLLoaded(FALSE);
     WURFL_WURFLManagerProvider::getWURFLManager($wurflConfigurationPath);
 }
예제 #2
0
 function Wurfl()
 {
     $providerPath = 'libraries/WURFL/WURFLManagerProvider.php';
     if (is_file(APPPATH . $providerPath)) {
         require_once APPPATH . $providerPath;
     } else {
         if (is_file(BASEPATH . $providerPath)) {
             require_once BASEPATH . $providerPath;
         } else {
             return false;
         }
     }
     $this->wurflManager = WURFL_WURFLManagerProvider::getWURFLManager(APPPATH . 'config/wurfl-config.xml');
 }
예제 #3
0
 /**
  * Initiaizes the actual WURFLManager
  *
  * @param string $configurationFilePath Absolute path to the wurfl configuration file
  */
 private static function _init($configurationFilePath)
 {
     $wurflConfig = WURFL_Configuration_ConfigFactory::create($configurationFilePath);
     WURFL_Configuration_ConfigHolder::setWURFLConfig($wurflConfig);
     $wurflFileParser = new WURFL_Xml_WURFLFileParser();
     $wurflPatchFileParser = new WURFL_Xml_WURFLPatchFileParser();
     $wurflPatchManager = new WURFL_Xml_PatchManager();
     // Persistence and Cache Providers
     $persistenceProvider = WURFL_Xml_PersistenceProvider_PersistenceProviderManager::getPersistenceProvider();
     $cacheProvider = WURFL_Cache_CacheProviderFactory::getCacheProvider();
     $xmlResourceManager = new WURFL_Xml_XMLResourceManager($persistenceProvider, $wurflPatchManager, $wurflFileParser, $wurflPatchFileParser);
     $userAgentHandlerChain = WURFL_UserAgentHandlerChainFactory::create();
     $deviceRepository = new WURFL_DeviceRepository($xmlResourceManager, $userAgentHandlerChain, $persistenceProvider);
     $wurflService = new WURFL_WURFLService($deviceRepository, $userAgentHandlerChain, $cacheProvider);
     $userAgentNormalizer = new WURFL_Request_UserAgentNormalizer();
     $requestFactory = new WURFL_Request_GenericRequestFactory($userAgentNormalizer);
     self::$wurflManager = new WURFL_WURFLManager($wurflService, $requestFactory);
 }
 /**
  * Get features from request
  *
  * @param  array $request $_SERVER variable
  * @return array
  */
 public static function getFromRequest($request, array $config)
 {
     if (!isset($config['wurflapi'])) {
         #require_once 'Zend/Http/UserAgent/Features/Exception.php';
         throw new Zend_Http_UserAgent_Features_Exception('"wurflapi" configuration is not defined');
     }
     $config = $config['wurflapi'];
     if (empty($config['wurfl_lib_dir'])) {
         #require_once 'Zend/Http/UserAgent/Features/Exception.php';
         throw new Zend_Http_UserAgent_Features_Exception('The "wurfl_lib_dir" parameter is not defined');
     }
     if (empty($config['wurfl_config_file']) && empty($config['wurfl_config_array'])) {
         #require_once 'Zend/Http/UserAgent/Features/Exception.php';
         throw new Zend_Http_UserAgent_Features_Exception('The "wurfl_config_file" parameter is not defined');
     }
     if (empty($config['wurfl_api_version'])) {
         $config['wurfl_api_version'] = self::DEFAULT_API_VERSION;
     }
     switch ($config['wurfl_api_version']) {
         case '1.0':
             // Zend_Http_UserAgent::$config['wurfl_config_file'] must be an XML file
             #require_once ($config['wurfl_lib_dir'] . 'WURFLManagerProvider.php');
             $wurflManager = WURFL_WURFLManagerProvider::getWURFLManager(Zend_Http_UserAgent::$config['wurfl_config_file']);
             break;
         case '1.1':
             #require_once ($config['wurfl_lib_dir'] . 'Application.php');
             if (!empty($config['wurfl_config_file'])) {
                 $wurflConfig = WURFL_Configuration_ConfigFactory::create($config['wurfl_config_file']);
             } elseif (!empty($config['wurfl_config_array'])) {
                 $c = $config['wurfl_config_array'];
                 $wurflConfig = new WURFL_Configuration_InMemoryConfig();
                 $wurflConfig->wurflFile($c['wurfl']['main-file'])->wurflPatch($c['wurfl']['patches'])->persistence($c['persistence']['provider'], $c['persistence']['dir']);
             }
             $wurflManagerFactory = new WURFL_WURFLManagerFactory($wurflConfig);
             $wurflManager = $wurflManagerFactory->create();
             break;
         default:
             #require_once 'Zend/Http/UserAgent/Features/Exception.php';
             throw new Zend_Http_UserAgent_Features_Exception(sprintf('Unknown API version "%s"', $config['wurfl_api_version']));
     }
     $device = $wurflManager->getDeviceForHttpRequest(array_change_key_case($request, CASE_UPPER));
     $features = $device->getAllCapabilities();
     return $features;
 }
예제 #5
0
 public static function getDevice()
 {
     if (!is_null(self::$device)) {
         return self::$device;
     }
     if (RESOURCES_DIR && class_exists('WURFL_WURFLManagerProvider')) {
         $wurflConfigFile = RESOURCES_DIR . 'wurfl-config.xml';
         try {
             $wurflManager = WURFL_WURFLManagerProvider::getWURFLManager($wurflConfigFile);
             self::$device = $wurflManager->getDeviceForHttpRequest($_SERVER);
         } catch (Exception $e) {
             if (Controller::$debug) {
                 Backend::addError('Wurfl Error: ' . $e->getMessage());
             }
             return false;
         }
         return self::$device ? self::$device : false;
     } else {
         Backend::addError('Could not find WURFL resources');
         return false;
     }
 }
예제 #6
0
 protected function setUp()
 {
     $configFilePath = dirname(__FILE__) . DIRECTORY_SEPARATOR . self::WURFL_CONFIG_FILE;
     $this->wurflManager = WURFL_WURFLManagerProvider::getWURFLManager($configFilePath);
 }
예제 #7
0
 public function detectByWurfl()
 {
     App::import('Vendor', 'WURFL', array('file' => 'WURFLManagerProvider.php'));
     $wurflConfigFile = APP . 'Config' . DS . 'wurfl ' . DS . 'config.xml';
     $wurflManager = WURFL_WURFLManagerProvider::getWURFLManager($wurflConfigFile);
     $requestingDevice = $wurflManager->getDeviceForHttpRequest($_SERVER);
     if ($requestingDevice->getCapability('is_wireless_device') == 'true') {
         return true;
     }
     return false;
 }
예제 #8
0
파일: index.php 프로젝트: eusholli/drupal
<?php

define("WURFL_DIR", dirname(__FILE__) . '/../../WURFL/');
define("RESOURCES_DIR", dirname(__FILE__) . "/../resources/");
require_once WURFL_DIR . 'WURFLManagerProvider.php';
$wurflConfigFile = RESOURCES_DIR . 'wurfl-config.xml';
$wurflManager = WURFL_WURFLManagerProvider::getWURFLManager($wurflConfigFile);
define("XHTML_ADVANCED", "xhtml_advanced.php");
define("XHTML_SIMPLE", "xhtml_simple.php");
define("WML", "wml.php");
define("XHTML_SUPPORT_LEVEL", "xhtml_support_level");
define("XHTMLMP_PREFERRED_MIME_TYPE", "xhtmlmp_preferred_mime_type");
$device = $wurflManager->getDeviceForHttpRequest($_SERVER);
$markUp = $device->getCapability(XHTML_SUPPORT_LEVEL);
$contentType = $device->getCapability(XHTMLMP_PREFERRED_MIME_TYPE);
$page = getPage($markUp);
redirectToPage($page, $contentType);
function getPage($markUp)
{
    $page = WML;
    switch ($markUp) {
        case 1:
        case 2:
            $page = XHTML_SIMPLE;
            break;
        case 3:
        case 4:
            $page = XHTML_ADVANCED;
            break;
        default:
            $page = WML;