本文整理汇总了PHP中UserAgentUtils::isDesktopBrowser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserAgentUtils::isDesktopBrowser方法的具体用法?PHP UserAgentUtils::isDesktopBrowser怎么用?PHP UserAgentUtils::isDesktopBrowser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserAgentUtils
的用法示例。
在下文中一共展示了UserAgentUtils::isDesktopBrowser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isDesktopBrowser
/**
* Is the given user agent very likely to be a desktop browser
* @param String User agent
* @return Bool
*/
public static function isDesktopBrowser($ua)
{
if (UserAgentUtils::isMobileBrowser($ua)) {
return false;
}
if (self::contains($ua, array('HTC', 'PPC', 'Nintendo'))) {
return false;
}
// Firefox
if (self::contains($ua, "Firefox") && !self::contains($ua, 'Tablet')) {
return true;
}
if (UserAgentUtils::isDesktopBrowser($ua)) {
return true;
}
if (self::startsWith($ua, 'Opera/')) {
return true;
}
if (self::regexContains($ua, array('/^Mozilla\\/5\\.0 \\(compatible; MSIE 9\\.0; Windows NT \\d\\.\\d/', '/^Mozilla\\/4\\.0 \\(compatible; MSIE \\d\\.\\d; Windows NT \\d\\.\\d/'))) {
return true;
}
if (self::contains($ua, array("Chrome", "yahoo.com", "google.com", "Comcast"))) {
return true;
}
return false;
}
示例2: createUserAgentMatcher
/**
* Determines which UserAgentMatcher is the best fit for the incoming user agent and returns it
* @param TeraWurfl $wurfl
* @param String $userAgent
* @return UserAgentMatcher
*/
public static function createUserAgentMatcher(TeraWurfl $wurfl, $userAgent)
{
// $isMobile means it IS MOBILE, $isDesktop means it IS DESKTOP
// $isMobile does NOT mean it IS DESKTOP and vica-versa
$isMobile = UserAgentUtils::isMobileBrowser($userAgent);
$isDesktop = UserAgentUtils::isDesktopBrowser($userAgent);
$userAgent_lcase = strtolower($userAgent);
// Process exceptions
if (TeraWurflConfig::$SIMPLE_DESKTOP_ENGINE_ENABLE && $userAgent == WurflConstants::$SIMPLE_DESKTOP_UA) {
// SimpleDesktopUserAgentMatcher is included via require_once realpath(dirname(__FILE__).'/in TeraWurfl.php
return new SimpleDesktopUserAgentMatcher($wurfl);
}
// Process MOBILE user agents
if (!$isDesktop) {
// High workload UAMs go first
// Nokia
if (UserAgentMatcher::contains($userAgent_lcase, 'nokia')) {
require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/NokiaUserAgentMatcher.php');
return new NokiaUserAgentMatcher($wurfl);
}
// Samsung
if (UserAgentMatcher::contains($userAgent, array("Samsung/SGH", "SAMSUNG-SGH")) || UserAgentMatcher::startsWith($userAgent, array("SEC-", "Samsung", "SAMSUNG", "SPH", "SGH", "SCH")) || stripos($userAgent, 'samsung') !== false) {
require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/SamsungUserAgentMatcher.php');
return new SamsungUserAgentMatcher($wurfl);
}
// Blackberry
if (stripos($userAgent, "blackberry") !== false) {
require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/BlackBerryUserAgentMatcher.php');
return new BlackBerryUserAgentMatcher($wurfl);
}
// SonyEricsson
if (UserAgentMatcher::contains($userAgent, 'Sony')) {
require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/SonyEricssonUserAgentMatcher.php');
return new SonyEricssonUserAgentMatcher($wurfl);
}
// Motorola
if (UserAgentMatcher::startsWith($userAgent, array('Mot-', 'MOT-', 'MOTO', 'moto')) || UserAgentMatcher::contains($userAgent, 'Motorola')) {
require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/MotorolaUserAgentMatcher.php');
return new MotorolaUserAgentMatcher($wurfl);
}
// Continue processing UAMs in alphabetical order
// Alcatel
if (UserAgentMatcher::startsWith($userAgent_lcase, "alcatel")) {
require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/AlcatelUserAgentMatcher.php');
return new AlcatelUserAgentMatcher($wurfl);
}
// Apple
if (UserAgentMatcher::contains($userAgent, array("iPhone", "iPod", "iPad", "(iphone"))) {
require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/AppleUserAgentMatcher.php');
return new AppleUserAgentMatcher($wurfl);
}
// BenQ
if (UserAgentMatcher::startsWith($userAgent_lcase, "benq")) {
require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/BenQUserAgentMatcher.php');
return new BenQUserAgentMatcher($wurfl);
}
// DoCoMo
if (UserAgentMatcher::startsWith($userAgent, "DoCoMo")) {
require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/DoCoMoUserAgentMatcher.php');
return new DoCoMoUserAgentMatcher($wurfl);
}
// Grundig
if (UserAgentMatcher::startsWith($userAgent_lcase, "grundig")) {
require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/GrundigUserAgentMatcher.php');
return new GrundigUserAgentMatcher($wurfl);
}
// HTC
if (UserAgentMatcher::contains($userAgent, array("HTC", "XV6875"))) {
require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/HTCUserAgentMatcher.php');
return new HTCUserAgentMatcher($wurfl);
}
// KDDI
if (UserAgentMatcher::contains($userAgent, "KDDI-")) {
require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/KddiUserAgentMatcher.php');
return new KddiUserAgentMatcher($wurfl);
}
// Kyocera
if (UserAgentMatcher::startsWith($userAgent, array("kyocera", "QC-", "KWC-"))) {
require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/KyoceraUserAgentMatcher.php');
return new KyoceraUserAgentMatcher($wurfl);
}
// LG
if (UserAgentMatcher::startsWith($userAgent_lcase, "lg")) {
require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/LGUserAgentMatcher.php');
return new LGUserAgentMatcher($wurfl);
}
// Mitsubishi
if (UserAgentMatcher::startsWith($userAgent, "Mitsu")) {
require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/MitsubishiUserAgentMatcher.php');
return new MitsubishiUserAgentMatcher($wurfl);
}
// NEC
if (UserAgentMatcher::startsWith($userAgent, array("NEC-", "KGT"))) {
require_once realpath(dirname(__FILE__) . '/UserAgentMatchers/NecUserAgentMatcher.php');
//.........这里部分代码省略.........