当前位置: 首页>>代码示例>>PHP>>正文


PHP UserAgentMatcher::applyConclusiveMatch方法代码示例

本文整理汇总了PHP中UserAgentMatcher::applyConclusiveMatch方法的典型用法代码示例。如果您正苦于以下问题:PHP UserAgentMatcher::applyConclusiveMatch方法的具体用法?PHP UserAgentMatcher::applyConclusiveMatch怎么用?PHP UserAgentMatcher::applyConclusiveMatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserAgentMatcher的用法示例。


在下文中一共展示了UserAgentMatcher::applyConclusiveMatch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getDeviceIDFromUALoose

 /**
  * Returns the matching WURFL ID for a given User Agent
  * @return String WURFL ID
  */
 protected function getDeviceIDFromUALoose()
 {
     $this->matcherHistory = array();
     // Return generic UA if userAgent is empty
     if (strlen($this->userAgent) == 0) {
         $this->matchData['matcher'] = "none";
         $this->matchData['match_type'] = "none";
         $this->matchData['match'] = false;
         $this->setMatcherHistory();
         return WurflConstants::$GENERIC;
     }
     // Check for exact match
     if (TeraWurflConfig::$SIMPLE_DESKTOP_ENGINE_ENABLE && $this->userAgent == WurflConstants::$SIMPLE_DESKTOP_UA) {
         // SimpleDesktop UA Matching avoids querying the database here
         $deviceID = WurflConstants::$GENERIC_WEB_BROWSER;
     } else {
         $deviceID = $this->db->getDeviceFromUA($this->userAgent);
     }
     $this->matcherHistory[] = $this->userAgentMatcher->matcherName() . "(exact)";
     if ($deviceID !== false) {
         $this->matchData['matcher'] = $this->userAgentMatcher->matcherName();
         $this->matchData['match_type'] = "exact";
         $this->matchData['match'] = true;
         $this->setMatcherHistory();
         return $deviceID;
     }
     // Check for a conclusive match
     $deviceID = $this->userAgentMatcher->applyConclusiveMatch($this->userAgent);
     $this->matcherHistory[] = $this->userAgentMatcher->matcherName() . "(conclusive)";
     if ($deviceID != WurflConstants::$GENERIC) {
         $this->matchData['matcher'] = $this->userAgentMatcher->matcherName();
         $this->matchData['match_type'] = "conclusive";
         $this->matchData['match'] = true;
         $this->setMatcherHistory();
         return $deviceID;
     }
     // Check for Vodafone magic
     if ($this->userAgentMatcher->matcherName() != "VodafoneUserAgentMatcher" && UserAgentMatcher::contains($this->userAgent, "Vodafone")) {
         @(require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/VodafoneUserAgentMatcher.php'));
         $vodafoneUserAgentMatcher = new VodafoneUserAgentMatcher($this);
         $this->matcherHistory[] = $vodafoneUserAgentMatcher->matcherName() . "(conclusive)";
         $deviceID = $vodafoneUserAgentMatcher->applyConclusiveMatch($this->userAgent);
         if ($deviceID != WurflConstants::$GENERIC) {
             $this->matchData['matcher'] = $vodafoneUserAgentMatcher->matcherName();
             $this->matchData['match_type'] = "conclusive";
             $this->matchData['match'] = true;
             $this->setMatcherHistory();
             return $deviceID;
         }
     }
     // Check for recovery match
     $deviceID = $this->userAgentMatcher->applyRecoveryMatch($this->userAgent);
     $this->matcherHistory[] = $this->userAgentMatcher->matcherName() . "(recovery)";
     if ($deviceID != WurflConstants::$GENERIC) {
         $this->matchData['matcher'] = $this->userAgentMatcher->matcherName();
         $this->matchData['match_type'] = "recovery";
         $this->matchData['match'] = false;
         $this->setMatcherHistory();
         return $deviceID;
     }
     // Check CatchAll if it's not already in use
     if ($this->userAgentMatcher->matcherName() != "CatchAllUserAgentMatcher") {
         $catchAllUserAgentMatcher = new CatchAllUserAgentMatcher($this);
         $this->matcherHistory[] = $catchAllUserAgentMatcher->matcherName() . "(recovery)";
         $deviceID = $catchAllUserAgentMatcher->applyRecoveryMatch($this->userAgent);
         if ($deviceID != WurflConstants::$GENERIC) {
             // The CatchAll matcher is intelligent enough to determine the match properties
             $this->matchData['matcher'] = $catchAllUserAgentMatcher->matcher;
             $this->matchData['match_type'] = $catchAllUserAgentMatcher->match_type;
             $this->matchData['match'] = $catchAllUserAgentMatcher->match;
             $this->setMatcherHistory();
             return $deviceID;
         }
     }
     // A matching device still hasn't been found - check HTTP ACCEPT headers
     if (strlen($this->httpAccept) > 0) {
         $this->matcherHistory[] = "http_accept";
         if (UserAgentMatcher::contains($this->httpAccept, array(WurflConstants::$ACCEPT_HEADER_VND_WAP_XHTML_XML, WurflConstants::$ACCEPT_HEADER_XHTML_XML, WurflConstants::$ACCEPT_HEADER_TEXT_HTML))) {
             $this->matchData['matcher'] = "http_accept";
             $this->matchData['match_type'] = "recovery";
             // This isn't really a match, it's a suggestion
             $this->matchData['match'] = false;
             $this->setMatcherHistory();
             return WurflConstants::$GENERIC_XHTML;
         }
     }
     $this->matchData['matcher'] = "none";
     $this->matchData['match_type'] = "none";
     $this->matchData['match'] = false;
     $this->setMatcherHistory();
     if (UserAgentUtils::isMobileBrowser($this->userAgent)) {
         return WurflConstants::$GENERIC_XHTML;
     }
     return WurflConstants::$GENERIC_WEB_BROWSER;
 }
开发者ID:vuong93st,项目名称:w-game,代码行数:99,代码来源:TeraWurfl.php

示例2: getDeviceIDFromRequestLoose

 /**
  * Returns the matching WURFL ID for a given User Agent
  * @return string WURFL ID
  */
 protected function getDeviceIDFromRequestLoose()
 {
     $this->matcherHistory = array();
     // Return generic UA if userAgent is empty
     if (strlen($this->httpRequest->user_agent) == 0) {
         $this->matchData['matcher'] = "none";
         $this->matchData['match_type'] = "none";
         $this->matchData['match'] = false;
         $this->setMatcherHistory();
         if ($this->httpRequest->uaprof instanceof TeraWurflUserAgentProfile && $this->httpRequest->uaprof->containsValidUrl()) {
             return WurflConstants::GENERIC_MOBILE;
         } else {
             return WurflConstants::NO_MATCH;
         }
     }
     // Check for exact match
     if (TeraWurflConfig::$SIMPLE_DESKTOP_ENGINE_ENABLE && $this->httpRequest->user_agent == WurflConstants::SIMPLE_DESKTOP_UA) {
         // SimpleDesktop UA Matching avoids querying the database here
         $this->matchData['matcher'] = $this->userAgentMatcher->matcherName();
         $this->matchData['match_type'] = "high_performance";
         $this->matchData['match'] = true;
         $this->matcherHistory[] = $this->matchData['matcher'] . "(high_performance)";
         $this->setMatcherHistory();
         return WurflConstants::GENERIC_WEB_BROWSER;
     } else {
         $deviceID = $this->db->getDeviceFromUA($this->httpRequest->user_agent->normalized);
     }
     $this->matcherHistory[] = $this->userAgentMatcher->matcherName() . "(exact)";
     if ($deviceID !== false) {
         $this->matchData['matcher'] = $this->userAgentMatcher->matcherName();
         $this->matchData['match_type'] = "exact";
         $this->matchData['match'] = true;
         $this->setMatcherHistory();
         return $deviceID;
     }
     // Check for a conclusive match
     $deviceID = $this->userAgentMatcher->applyConclusiveMatch($this->httpRequest);
     $this->matcherHistory[] = $this->userAgentMatcher->matcherName() . "(conclusive)";
     if ($deviceID != WurflConstants::NO_MATCH) {
         $this->matchData['matcher'] = $this->userAgentMatcher->matcherName();
         $this->matchData['match_type'] = "conclusive";
         $this->matchData['match'] = true;
         $this->setMatcherHistory();
         return $deviceID;
     }
     /*
     // Check for Vodafone magic
     if ($this->userAgentMatcher->matcherName()!="VodafoneUserAgentMatcher" && $this->httpRequest->user_agent->contains("Vodafone")) {
     	@require_once realpath(dirname(__FILE__).'/UserAgentMatchers/VodafoneUserAgentMatcher.php');
     	$vodafoneUserAgentMatcher = new VodafoneUserAgentMatcher($this);
     	$this->matcherHistory[] = $vodafoneUserAgentMatcher->matcherName() . "(conclusive)";
     	$deviceID = $vodafoneUserAgentMatcher->applyConclusiveMatch($this->httpRequest);
     	if ($deviceID != WurflConstants::NO_MATCH) {
     		$this->matchData['matcher'] = $vodafoneUserAgentMatcher->matcherName();
     		$this->matchData['match_type'] = "conclusive";
     		$this->matchData['match'] = true;
     		$this->setMatcherHistory();
     		return $deviceID;
     	}
     }
     */
     // Check for recovery match
     $deviceID = $this->userAgentMatcher->applyRecoveryMatch($this->httpRequest);
     $this->matcherHistory[] = $this->userAgentMatcher->matcherName() . "(recovery)";
     if ($deviceID != WurflConstants::NO_MATCH) {
         $this->matchData['matcher'] = $this->userAgentMatcher->matcherName();
         $this->matchData['match_type'] = "recovery";
         $this->matchData['match'] = false;
         $this->setMatcherHistory();
         return $deviceID;
     }
     // Check CatchAll if it's not already in use
     if ($this->userAgentMatcher->matcherName() != "CatchAllUserAgentMatcher") {
         $catchAllUserAgentMatcher = new CatchAllUserAgentMatcher($this);
         $this->matcherHistory[] = $catchAllUserAgentMatcher->matcherName() . "(recovery)";
         $deviceID = $catchAllUserAgentMatcher->applyRecoveryMatch($this->httpRequest);
         if ($deviceID != WurflConstants::NO_MATCH) {
             // The CatchAll matcher is intelligent enough to determine the match properties
             $this->matchData['matcher'] = $catchAllUserAgentMatcher->matcher;
             $this->matchData['match_type'] = $catchAllUserAgentMatcher->match_type;
             $this->matchData['match'] = $catchAllUserAgentMatcher->match;
             $this->setMatcherHistory();
             return $deviceID;
         }
     }
     // A matching device still hasn't been found - check HTTP ACCEPT headers
     if ($this->httpRequest->accept->length() > 0) {
         $this->matcherHistory[] = 'http_accept';
         if ($this->httpRequest->accept->contains('application/vnd.wap.xhtml+xml')) {
             $this->matchData['matcher'] = 'http_accept';
             $this->matchData['match_type'] = 'recovery';
             // This isn't really a match, it's a suggestion
             $this->matchData['match'] = false;
             $this->setMatcherHistory();
             return WurflConstants::GENERIC_MOBILE;
         }
//.........这里部分代码省略.........
开发者ID:pwodaniilea,项目名称:t3x-contexts_wurfl,代码行数:101,代码来源:TeraWurfl.php


注:本文中的UserAgentMatcher::applyConclusiveMatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。