From: <jon...@us...> - 2011-09-30 11:19:39
|
Revision: 37809 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=37809&view=rev Author: jonnybradley Date: 2011-09-30 11:19:32 +0000 (Fri, 30 Sep 2011) Log Message: ----------- [FIX] mobile: Update mobile esp library Modified Paths: -------------- third_party/mobileESP/mdetect.php Modified: third_party/mobileESP/mdetect.php =================================================================== --- third_party/mobileESP/mdetect.php 2011-09-30 11:12:20 UTC (rev 37808) +++ third_party/mobileESP/mdetect.php 2011-09-30 11:19:32 UTC (rev 37809) @@ -3,41 +3,30 @@ /* ******************************************* // Copyright 2010-2011, Anthony Hand // -// File version date: June 04, 2011 +// File version date: August 22, 2011 // Update: -// - Updated DetectTierIphone() for a BlackBerry issue. Now it checks for both BB WebKit *and* BB Touch. +// - Updated DetectAndroidTablet() to fix a bug introduced in the last fix! The true/false returns were mixed up. // -// File version date: May 30, 2011 -// Updates: -// - Added a global variable: isAndroidPhone. -// - Updated the Constructor to always call InitDeviceScan(). -// See notes if you don't need some or all of the InitDeviceScan() feature. -// - Added the DetectIos() detection method to better reflect parity with the other OS detection methods. -// - Refactored the Android detection methods to better reflect parity with the iOS methods. -// - Note the meaning of the DetectAndroid() has changed. Now, it's ANY Android device. -// - Note the new DetectAndroidPhone() method. It detects both Android phones and multi-media players. -// Now, it also follows Google's best practice of any Android device that DOES have the word 'mobile' in it. -// - Added a check for the HTC Flyer 7" tablet to the DetectAndroid and DetectAndroidPhone methods. -// It doesn't always report itself as small Android device. -// - Note the DetectAndroidTablet() has changed. -// Now, it follows Google's best practice of any Android device that does NOT have the word 'mobile' in it. -// - Revised the BlackBerry method descriptions to clarify which include or exclude the Playbook. -// - Removed the detection of third-party Android WebKit browsers from DetectTierIphone(). It was redundant. +// File version date: August 16, 2011 +// Update: +// - Updated DetectAndroidTablet() to exclude Opera Mini, which was falsely reporting as running on a tablet device when on a phone. // -// File version date: March 28, 2011 -// Updates: -// - Bug Fix: In DetectMobileQuick(), the DetectIpad() function was misspelled. +// File version date: August 7, 2011 +// Update: +// - The Opera for Android browser doesn't follow Google's recommended useragent string guidelines, so some fixes were needed. +// - Updated DetectAndroidPhone() and DetectAndroidTablet() to properly detect devices running Opera Mobile. +// - Created 2 new methods: DetectOperaAndroidPhone() and DetectOperaAndroidTablet(). +// - Updated DetectTierIphone(). Removed the call to DetectMaemoTablet(), an obsolete mobile OS. // -// File version date: March 14, 2011 -// Updates: -// - In uagent_info(), added null test case when initializing variables. -// - Added a stored variable 'isTierTablet' which is initialized in InitDeviceScan(). -// - Added a variable to support the new DetectBlackBerryTablet() function. -// - Added a variable to support the new DetectAndroidTablet() function. This is a first draft! -// - Added the new DetectTierTablet() function. Use this to detect any of the new -// larger-screen HTML5 capable tablets. (The 7 inch Galaxy Tab doesn't quality right now.) -// - Moved Windows Phone 7 from iPhone Tier to Rich CSS Tier. Sorry, Microsoft, but IE 7 isn't good enough. +// File version date: July 15, 2011 +// Update: +// - Refactored the variable called maemoTablet. Its new name is the more generic deviceTablet. +// - Created the variable deviceWebOShp for HP's line of WebOS devices starting with the TouchPad tablet. +// - Created the DetectWebOSTablet() method for HP's line of WebOS tablets starting with the TouchPad tablet. +// - Updated the DetectTierTablet() method to also search for WebOS tablets. +// - Updated the DetectMaemoTablet() method to disambiguate against WebOS tablets which share some signature traits. // +// // LICENSE INFORMATION // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -127,7 +116,9 @@ var $deviceBBPlaybook = 'playbook'; //PlayBook tablet var $devicePalm = 'palm'; - var $deviceWebOS = 'webos'; //For Palm's new WebOS devices + var $deviceWebOS = 'webos'; //For Palm's line of WebOS devices + var $deviceWebOShp = 'hpwos'; //For HP's line of WebOS devices + var $engineBlazer = 'blazer'; //Old Palm browser var $engineXiino = 'xiino'; //Another old Palm @@ -138,6 +129,7 @@ var $wml = 'wml'; //Initialize variables for other random devices and mobile browsers. + var $deviceTablet = 'tablet'; //Generic term for slate and tablet devices var $deviceBrew = 'brew'; var $deviceDanger = 'danger'; var $deviceHiptop = 'hiptop'; @@ -163,7 +155,6 @@ //Use Maemo, Tablet, and Linux to test for Nokia's Internet Tablets. var $maemo = 'maemo'; - var $maemoTablet = 'tablet'; var $linux = 'linux'; var $qtembedded = 'qt embedded'; //for Sony Mylo and others var $mylocom2 = 'com2'; //for Sony Mylo also @@ -316,6 +307,9 @@ if (($this->DetectAndroid() == $this->true) && (stripos($this->useragent, $this->mobile) > -1)) return $this->true; + //Special check for Android phones with Opera Mobile. They should report here. + if (($this->DetectOperaAndroidPhone() == $this->true)) + return $this->true; //Special check for the HTC Flyer 7" tablet. It should report here. if ((stripos($this->useragent, $this->deviceHtcFlyer) > -1)) return $this->true; @@ -328,14 +322,22 @@ // Google says these devices will have 'Android' and NOT 'mobile' in their user agent. function DetectAndroidTablet() { + //First, let's make sure we're on an Android device. + if ($this->DetectAndroid() == $this->false) + return $this->false; + + //Special check for Opera Android Phones. They should NOT report here. + if ($this->DetectOperaMobile() == $this->true) + return $this->false; //Special check for the HTC Flyer 7" tablet. It should NOT report here. if ((stripos($this->useragent, $this->deviceHtcFlyer) > -1)) return $this->false; - if (($this->DetectAndroid() == $this->true) && - !(stripos($this->useragent, $this->mobile) > -1)) + + //Otherwise, if it's Android and does NOT have 'mobile' in it, Google says it's a tablet. + if (stripos($this->useragent, $this->mobile) > -1) + return $this->false; + else return $this->true; - else - return $this->false; } //************************** @@ -571,6 +573,17 @@ } //************************** + // Detects if the current browser is on an HP tablet running WebOS. + function DetectWebOSTablet() + { + if ((stripos($this->useragent, $this->deviceWebOShp) > -1) + && (stripos($this->useragent, $this->deviceTablet) > -1)) + return $this->true; + else + return $this->false; + } + + //************************** // Detects if the current browser is a // Garmin Nuvifone. function DetectGarminNuvifone() @@ -644,6 +657,32 @@ } //************************** + // Detects if the current browser is Opera Mobile + // running on an Android phone. + function DetectOperaAndroidPhone() + { + if ((stripos($this->useragent, $this->engineOpera) > -1) && + (stripos($this->useragent, $this->deviceAndroid) > -1) && + (stripos($this->useragent, $this->mobi) > -1)) + return $this->true; + else + return $this->false; + } + + //************************** + // Detects if the current browser is Opera Mobile + // running on an Android tablet. + function DetectOperaAndroidTablet() + { + if ((stripos($this->useragent, $this->engineOpera) > -1) && + (stripos($this->useragent, $this->deviceAndroid) > -1) && + (stripos($this->useragent, $this->deviceTablet) > -1)) + return $this->true; + else + return $this->false; + } + + //************************** // Detects whether the device supports WAP or WML. function DetectWapWml() { @@ -768,9 +807,11 @@ { if (stripos($this->useragent, $this->maemo) > -1) return $this->true; - //Must be Linux + Tablet, or else it could be something else. - if (stripos($this->useragent, $this->maemoTablet) > -1 && - stripos($this->useragent, $this->linux) > -1) + //For Nokia N810, must be Linux + Tablet, or else it could be something else. + if ((stripos($this->useragent, $this->linux) > -1) + && (stripos($this->useragent, $this->deviceTablet) > -1) + && ($this->DetectWebOSTablet() == $this->false) + && ($this->DetectAndroid() == $this->false)) return $this->true; else return $this->false; @@ -852,15 +893,14 @@ // The quick way to detect for a tier of devices. // This method detects for the new generation of // HTML 5 capable, larger screen tablets. - // Includes iPad, Android (e.g., Xoom), BB Playbook, etc. + // Includes iPad, Android (e.g., Xoom), BB Playbook, WebOS, etc. function DetectTierTablet() { - if ($this->DetectIpad() == $this->true) + if (($this->DetectIpad() == $this->true) + || ($this->DetectAndroidTablet() == $this->true) + || ($this->DetectBlackBerryTablet() == $this->true) + || ($this->DetectWebOSTablet() == $this->true)) return $this->true; - if ($this->DetectAndroidTablet() == $this->true) - return $this->true; - if ($this->DetectBlackBerryTablet() == $this->true) - return $this->true; else return $this->false; } @@ -884,8 +924,6 @@ return $this->true; if ($this->DetectGarminNuvifone() == $this->true) return $this->true; - if ($this->DetectMaemoTablet() == $this->true) - return $this->true; else return $this->false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |