/** * Applies Catch-All match * * @param string $userAgent * * @return string WURFL deviceID */ public function applyRecoveryCatchAllMatch($userAgent) { if (Utils::isDesktopBrowserHeavyDutyAnalysis($userAgent)) { return WurflConstants::GENERIC_WEB_BROWSER; } if (Utils::checkIfContains($userAgent, 'CoreMedia')) { return 'apple_iphone_coremedia_ver1'; } if (Utils::checkIfContains($userAgent, 'Windows CE')) { return 'generic_ms_mobile'; } if (Utils::checkIfContains($userAgent, 'UP.Browser/7.2')) { return 'opwv_v72_generic'; } if (Utils::checkIfContains($userAgent, 'UP.Browser/7')) { return 'opwv_v7_generic'; } if (Utils::checkIfContains($userAgent, 'UP.Browser/6.2')) { return 'opwv_v62_generic'; } if (Utils::checkIfContains($userAgent, 'UP.Browser/6')) { return 'opwv_v6_generic'; } if (Utils::checkIfContains($userAgent, 'UP.Browser/5')) { return 'upgui_generic'; } if (Utils::checkIfContains($userAgent, 'UP.Browser/4')) { return 'uptext_generic'; } if (Utils::checkIfContains($userAgent, 'UP.Browser/3')) { return 'uptext_generic'; } // Series 60 if (Utils::checkIfContains($userAgent, 'Series60')) { return 'nokia_generic_series60'; } // Access/Net Front if (Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.0', 'ACS-NF/3.0'))) { return 'generic_netfront_ver3'; } if (Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.1', 'ACS-NF/3.1'))) { return 'generic_netfront_ver3_1'; } if (Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.2', 'ACS-NF/3.2'))) { return 'generic_netfront_ver3_2'; } if (Utils::checkIfContainsAnyOf($userAgent, array('NetFront/3.3', 'ACS-NF/3.3'))) { return 'generic_netfront_ver3_3'; } if (Utils::checkIfContains($userAgent, 'NetFront/3.4')) { return 'generic_netfront_ver3_4'; } if (Utils::checkIfContains($userAgent, 'NetFront/3.5')) { return 'generic_netfront_ver3_5'; } if (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 WurflConstants::GENERIC_XHTML; } if (Utils::checkIfContainsAnyOf($userAgent, array('Obigo', 'AU-MIC/2', 'AU-MIC-', 'AU-OBIGO/', 'Teleca Q03B1'))) { return WurflConstants::GENERIC_XHTML; } // DoCoMo if (Utils::checkIfStartsWithAnyOf($userAgent, array('DoCoMo', 'KDDI'))) { return 'docomo_generic_jap_ver1'; } if (Utils::isMobileBrowser($userAgent)) { return WurflConstants::GENERIC_MOBILE; } return WurflConstants::GENERIC; }
/** * 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\GenericRequest $request) { $userAgent = $request->getUserAgent(); if (!$userAgent) { // $request->id is not set // -> do not try to get info from cache nor try to save to the cache $request->getMatchInfo()->fromCache = 'invalid id'; $request->getMatchInfo()->lookupTime = 0.0; return $this->getUserAgentHandlerChain()->match($request); } $deviceId = $this->getCacheStorage()->load($userAgent); if (empty($deviceId)) { $genericNormalizer = UserAgentHandlerChainFactory::createGenericNormalizers(); $request->setUserAgentNormalized($genericNormalizer->normalize($userAgent)); if ($this->getWurflConfig()->isHighPerformance() && Handlers\Utils::isDesktopBrowserHeavyDutyAnalysis($request->getUserAgentNormalized())) { // This device has been identified as a web browser programatically, // so no call to WURFL is necessary $deviceId = WurflConstants::GENERIC_WEB_BROWSER; } else { $deviceId = $this->getUserAgentHandlerChain()->match($request); } // save it in cache $this->getCacheStorage()->save($userAgent, $deviceId); } else { $request->getMatchInfo()->fromCache = true; $request->getMatchInfo()->lookupTime = 0.0; } return $deviceId; }