本文整理汇总了PHP中Mobile_Detect::getTabletDevices方法的典型用法代码示例。如果您正苦于以下问题:PHP Mobile_Detect::getTabletDevices方法的具体用法?PHP Mobile_Detect::getTabletDevices怎么用?PHP Mobile_Detect::getTabletDevices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mobile_Detect
的用法示例。
在下文中一共展示了Mobile_Detect::getTabletDevices方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DetectOperatingSystem
function DetectOperatingSystem($_host = "")
{
$OSYSTEMS = array("debian" => "Debian", "freebsd" => "Free BSD", "iphoneos%" => "IPhone iOS%", "blackberry%" => "Blackberry %", "ipad" => "IPad", "macosx100" => "MAC OS X 10.0 (Cheetah)", "macosx101" => "MAC OS X 10.1 (Puma)", "macosx102" => "MAC OS X 10.2 (Jaguar)", "macosx103" => "MAC OS X 10.3 (Panther)", "macosx104" => "MAC OS X 10.4 (Tiger)", "macosx105" => "MAC OS X 10.5 (Leopard)", "macosx106" => "MAC OS X 10.6 (Snow Leopard)", "macosx107" => "MAC OS X 10.7 (Lion)", "macosx108" => "MAC OS X 10.8 (Mountain Lion)", "macosx109" => "MAC OS X 10.9 (Mavericks)", "macos%" => "Mac OS %", "ubuntu" => "Ubuntu (Linux)", "windows98" => "Windows 98", "windowsme" => "Windows ME", "windowsnt31" => "Windows NT 3.1", "windowsnt35" => "Windows NT 3.5", "windowsnt351" => "Windows NT 3.51", "windowsnt40" => "Windows NT 4.0", "windowsnt50" => "Windows 2000", "windowsnt51" => "Windows XP", "windowsnt52" => "Windows XP", "windowsxp" => "Windows XP", "windowsnt60" => "Windows Vista", "windowsnt61" => "Windows 7", "windowsnt62" => "Windows 8", "windowsnt63" => "Windows 8.1", "mediacenterpc%" => "Windows Media Center %", "fedora%" => "Fedora %", "symbianos%" => "Symbian %", "dangerhiptop%" => "Danger Hiptop %", "linux" => "Linux", "opensuse" => "openSUSE Linux", "windows" => "Windows CE / Mobile", "nintendodsi" => "Nintendo DSi", "nexiannxg911" => "Nexian NX-G911", "lglg" => "LG Smartphone", "samsung" => "Samsung Smartphone", "htc" => "HTC Smartphone", "nokia" => "Nokia Smartphone", "sony" => "Sony Smartphone", "playstation" => "Sony PlayStation", "playstationport" => "PlayStation Portable");
$MOBILEDEVICES = array("midp");
$this->OperatingSystemUnknown = true;
require_once LIVEZILLA_PATH . "_lib/trdp/mobde.php";
$MobileDetect = new Mobile_Detect();
$mlist = array_merge($MobileDetect->getPhoneDevices(), $MobileDetect->getTabletDevices(), $MobileDetect->getOperatingSystems());
$this->IsMobile = $MobileDetect->isMobile();
if ($this->IsMobile) {
foreach ($mlist as $name => $regex) {
if ($check = $MobileDetect->{'is' . $name}()) {
$this->OperatingSystemUnknown = false;
$this->OperatingSystem .= empty($this->OperatingSystem) ? $name : " / " . $name;
}
}
}
if (!$this->IsMobile || $this->OperatingSystemUnknown) {
$os = $_host;
if (!empty($_SERVER["HTTP_USER_AGENT"])) {
$os .= strtolower($_SERVER["HTTP_USER_AGENT"]);
}
$os = !empty($_SERVER["HTTP_USER_AGENT"]) ? str_replace(array(".", " ", "/", "_", "-", "["), array("", "", "", "", "", ""), $os) : "";
$lists = array($OSYSTEMS, $MOBILEDEVICES);
foreach ($lists as $index => $list) {
foreach ($list as $oskey => $osname) {
$fixkey = str_replace("%", "", $oskey);
if (strpos($os, $fixkey) !== false) {
if ($index == 0) {
$mversion = @substr($os, strpos($os, $fixkey) + strlen($fixkey), 1);
if (is_numeric($mversion) && $mversion > 0) {
$this->OperatingSystem = str_replace("%", $mversion, $osname);
} else {
$this->OperatingSystem = str_replace(" %", "", $osname);
if (strpos($oskey, "%") !== false) {
$this->OperatingSystemVersionUnknown = true;
}
}
} else {
$this->OperatingSystem = "Unknown Smartphone";
}
$this->OperatingSystemUnknown = false;
return $MobileDetect;
}
}
}
}
return $MobileDetect;
}
示例2: matchTabletType
/**
* Can we match the Tablet Device Type in the route to the device
*
* @param string $routeValue type option in the route
* @param \Mobile_Detect $device device object from the WebRequest
*
* @return bool|string matched OS
*/
protected function matchTabletType($routeValue, \Mobile_Detect $device)
{
$routeValue = strtolower($routeValue);
$aParameters = $this->rejiggerMobileParameterArray($device->getTabletDevices());
if (isset($aParameters[$routeValue])) {
$isType = 'is' . $aParameters[$routeValue];
if ($device->{$isType}()) {
return $aParameters[$routeValue];
}
}
return false;
}
示例3: testRulesExtended
/**
* @covers Mobile_Detect::getMobileDetectionRulesExtended
*/
public function testRulesExtended()
{
$md = new Mobile_Detect();
$count = array_sum(array(count(Mobile_Detect::getPhoneDevices()), count(Mobile_Detect::getTabletDevices()), count(Mobile_Detect::getOperatingSystems()), count(Mobile_Detect::getBrowsers()), count(Mobile_Detect::getUtilities())));
$md->setDetectionType(Mobile_Detect::DETECTION_TYPE_EXTENDED);
$rules = $md->getRules();
$this->assertEquals($count, count($rules));
}
示例4: dirname
* Use the resulting JSON export file in other languages
* other than PHP. Always check for 'version' key because
* new major versions can modify the structure of the JSON file.
*
* The result of running this script is the export.json file.
*
* @license Code and contributions have 'MIT License'
* More details: https://github.com/serbanghita/Mobile-Detect/blob/master/LICENSE.txt
*
*/
// Included nicejson function to beautify the result JSON file.
// This library is not mandatory.
if (file_exists(dirname(__FILE__) . '/nicejson/nicejson.php')) {
include_once dirname(__FILE__) . '/nicejson/nicejson.php';
}
// Include Mobile Detect.
require_once dirname(__FILE__) . '/../Mobile_Detect.php';
$detect = new Mobile_Detect();
$json = array('version' => $detect->getScriptVersion(), 'headerMatch' => $detect->getMobileHeaders(), 'uaHttpHeaders' => $detect->getUaHttpHeaders(), 'uaMatch' => array('phones' => $detect->getPhoneDevices(), 'tablets' => $detect->getTabletDevices(), 'browsers' => $detect->getBrowsers(), 'os' => $detect->getOperatingSystems(), 'utilities' => $detect->getUtilities()));
$jsonString = function_exists('json_format') ? json_format($json) : json_encode($json);
// Write the JSON file to disk.
// You can import this file in your app.
$fileName = dirname(__FILE__) . '/../Mobile_Detect.json';
$handle = fopen($fileName, 'w');
$fwrite = fwrite($handle, $jsonString);
fclose($handle);
if ($fwrite) {
echo 'Done. Check ' . realpath($fileName) . ' file.';
} else {
echo 'Failed to write ' . realpath($fileName) . ' to disk.';
}
示例5: initAfterCache
/**
* Executed once or never. Sets all the information that is required for parsing the user agent string.
*
* If all the user agents are taken from cache, this method is not called
*/
protected static function initAfterCache()
{
if (null !== self::$uaparser) {
return;
}
require_once UserAgentInfoConfig::$base_dir . UserAgentInfoConfig::DIR_IMPORTS . DIRECTORY_SEPARATOR . 'uaparser.php';
self::$browscap_wrapper = new BrowscapWrapper(self::$browscap_source_file);
self::$uaparser = new UAParser(self::$uaparser_source_file);
self::$md_browsers = array_keys(self::$mobile_detect->getBrowsers());
$md_os_list = self::$mobile_detect->getOperatingSystems();
self::$md_os_list = array_keys($md_os_list);
self::$md_devices = array_keys(self::$mobile_detect->getPhoneDevices() + self::$mobile_detect->getTabletDevices());
self::$md_devices_generic = array();
foreach (self::$md_devices as $device) {
if (!in_array($device, self::$generic_devices)) {
self::$md_devices_generic[] = str_replace(self::MOBILE_DETECT_TABLET_SUFFIX, '', $device);
}
}
self::$md_devices_generic[] = 'Nokia';
self::$md_devices_generic = array_unique(self::$md_devices_generic);
}