/**
  * Return a device the given WURFL_Request_GenericRequest request(user-agent..)
  *
  * @param WURFL_Request_GenericRequest $request
  * @return WURFL_CustomDevice device
  * @throws Exception if the $request parameter is not set
  */
 public function getDeviceForRequest(WURFL_Request_GenericRequest $request)
 {
     if (!isset($request)) {
         throw new Exception("The request parameter must be set.");
     }
     WURFL_Handlers_Utils::reset();
     if (WURFL_Configuration_ConfigHolder::getWURFLConfig()->isHighPerformance() && WURFL_Handlers_Utils::isDesktopBrowserHeavyDutyAnalysis($request->userAgent)) {
         // This device has been identified as a web browser programatically, so no call to WURFL is necessary
         return $this->_wurflService->getDevice(WURFL_Constants::GENERIC_WEB_BROWSER);
     }
     return $this->_wurflService->getDeviceForRequest($request);
 }
Exemple #2
0
 /**
  * Applies Catch-All match
  * @param string $userAgent
  * @return string WURFL deviceID
  */
 public function applyRecoveryCatchAllMatch($userAgent)
 {
     if (WURFL_Handlers_Utils::isDesktopBrowserHeavyDutyAnalysis($userAgent)) {
         return WURFL_Constants::GENERIC_WEB_BROWSER;
     }
     $mobile = WURFL_Handlers_Utils::isMobileBrowser($userAgent);
     $desktop = WURFL_Handlers_Utils::isDesktopBrowser($userAgent);
     if (!$desktop) {
         $deviceId = WURFL_Handlers_Utils::getMobileCatchAllId($userAgent);
         if ($deviceId !== WURFL_Constants::NO_MATCH) {
             return $deviceId;
         }
     }
     if ($mobile) {
         return WURFL_Constants::GENERIC_MOBILE;
     }
     if ($desktop) {
         return WURFL_Constants::GENERIC_WEB_BROWSER;
     }
     return WURFL_Constants::GENERIC;
 }
Exemple #3
0
 /**
  * Returns the device id for the device that matches the $request
  * @param WURFL_Request_GenericRequest $request WURFL Request object
  * @return string WURFL device id
  */
 private function deviceIdForRequest($request)
 {
     $deviceId = $this->_cacheProvider->load($request->id);
     if (empty($deviceId)) {
         $generic_normalizer = WURFL_UserAgentHandlerChainFactory::createGenericNormalizers();
         $request->userAgentNormalized = $generic_normalizer->normalize($request->userAgent);
         if (WURFL_Configuration_ConfigHolder::getWURFLConfig()->isHighPerformance() && WURFL_Handlers_Utils::isDesktopBrowserHeavyDutyAnalysis($request->userAgentNormalized)) {
             // This device has been identified as a web browser programatically, so no call to WURFL is necessary
             return WURFL_Constants::GENERIC_WEB_BROWSER;
         }
         $deviceId = $this->_userAgentHandlerChain->match($request);
         // save it in cache
         $this->_cacheProvider->save($request->id, $deviceId);
     } else {
         $request->matchInfo->from_cache = true;
         $request->matchInfo->lookup_time = 0.0;
     }
     return $deviceId;
 }
Exemple #4
0
 /**
  * Applies Catch-All match
  * @param string $userAgent
  * @return string WURFL deviceID
  */
 public function applyRecoveryCatchAllMatch($userAgent)
 {
     if (WURFL_Handlers_Utils::isDesktopBrowserHeavyDutyAnalysis($userAgent)) {
         return WURFL_Constants::GENERIC_WEB_BROWSER;
     }
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'CoreMedia')) {
         return 'apple_iphone_coremedia_ver1';
     }
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Windows CE')) {
         return 'generic_ms_mobile';
     }
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/7.2')) {
         return 'opwv_v72_generic';
     }
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/7')) {
         return 'opwv_v7_generic';
     }
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/6.2')) {
         return 'opwv_v62_generic';
     }
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/6')) {
         return 'opwv_v6_generic';
     }
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/5')) {
         return 'upgui_generic';
     }
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/4')) {
         return 'uptext_generic';
     }
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'UP.Browser/3')) {
         return 'uptext_generic';
     }
     // Series 60
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'Series60')) {
         return 'nokia_generic_series60';
     }
     // Access/Net Front
     if (WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.0', 'ACS-NF/3.0'))) {
         return 'generic_netfront_ver3';
     }
     if (WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.1', 'ACS-NF/3.1'))) {
         return 'generic_netfront_ver3_1';
     }
     if (WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.2', 'ACS-NF/3.2'))) {
         return 'generic_netfront_ver3_2';
     }
     if (WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.3', 'ACS-NF/3.3'))) {
         return 'generic_netfront_ver3_3';
     }
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'NetFront/3.4')) {
         return 'generic_netfront_ver3_4';
     }
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'NetFront/3.5')) {
         return 'generic_netfront_ver3_5';
     }
     if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'NetFront/4.0')) {
         return 'generic_netfront_ver4_0';
     }
     // Contains Mozilla/, but not at the beginning of the UA
     // ie: MOTORAZR V8/R601_G_80.41.17R Mozilla/4.0 (compatible; MSIE 6.0 Linux; MOTORAZR V88.50) Profile/MIDP-2.0 Configuration/CLDC-1.1 Opera 8.50[zh]
     if (strpos($userAgent, 'Mozilla/') > 0) {
         return WURFL_Constants::GENERIC_XHTML;
     }
     if (WURFL_Handlers_Utils::checkIfContainsAnyOf($userAgent, array('Obigo', 'AU-MIC/2', 'AU-MIC-', 'AU-OBIGO/', 'Teleca Q03B1'))) {
         return WURFL_Constants::GENERIC_XHTML;
     }
     // DoCoMo
     if (WURFL_Handlers_Utils::checkIfStartsWithAnyOf($userAgent, array('DoCoMo', 'KDDI'))) {
         return 'docomo_generic_jap_ver1';
     }
     if (WURFL_Handlers_Utils::isMobileBrowser($userAgent)) {
         return WURFL_Constants::GENERIC_MOBILE;
     }
     return WURFL_Constants::GENERIC;
 }