Skip to content
This repository

Consider iPad and iPod in two separate cases (for issue #1122) #1123

Merged
merged 2 commits into from about 2 years ago

3 participants

Buddhima Wijeweera elinw Louis Landry
Buddhima Wijeweera

File: joomla-platform / libraries / joomla / application / web / client.php
Method: detectPlatform()

For issue #1122 : Mobile detection is wrong

Fixed by: adding 2 separate else if clauses to consider iPad and iPod seperately

Signed-off-by: Buddhima Wijeweera buddhimawijeweera@yahoo.com

Buddhima Wijeweera Add 2 elseif cases for iPad and iPod
Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
1ecbcfe
elinw

Yes, newer UA strings look like that.
Please also add these examples to the test.

Thanks Elin , I have done that :)
joomla#1125

Buddhima Wijeweera Buddhima referenced this pull request from a commit in Buddhima/joomla-platform April 06, 2012
Buddhima Wijeweera unit test enhancement for iPad and iPod for pull request #1123, issue #…
…1122

Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
fe1e0da
Buddhima Wijeweera Changed tests/suites/unit/joomla/application/web/JApplicationWebClien…
…tTest.php by adding iPod,iPad to array

Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
81d3bf0
Louis Landry LouisLandry merged commit bc2de19 into from April 06, 2012
Louis Landry LouisLandry closed this April 06, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Apr 06, 2012
Buddhima Wijeweera Add 2 elseif cases for iPad and iPod
Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
1ecbcfe
Apr 07, 2012
Buddhima Wijeweera Changed tests/suites/unit/joomla/application/web/JApplicationWebClien…
…tTest.php by adding iPod,iPad to array

Signed-off-by: Buddhima Wijeweera <buddhimawijeweera@yahoo.com>
81d3bf0
This page is out of date. Refresh to see the latest.
12  libraries/joomla/application/web/client.php
@@ -417,6 +417,18 @@ protected function detectPlatform($userAgent)
417 417
 				$this->platform = self::IPOD;
418 418
 			}
419 419
 		}
  420
+			// In case where iPhone is not mentioed in iPad user agent string
  421
+			elseif (stripos($userAgent, 'iPad') !== false)
  422
+			{
  423
+				$this->mobile = true;
  424
+				$this->platform = self::IPAD;
  425
+			}
  426
+			// In case where iPhone is not mentioed in iPod user agent string
  427
+			elseif (stripos($userAgent, 'iPod') !== false)
  428
+			{
  429
+				$this->mobile = true;
  430
+				$this->platform = self::IPOD;
  431
+			}
420 432
 		// This has to come after the iPhone check because mac strings are also present in iOS devices.
421 433
 		elseif (preg_match('/macintosh|mac os x/i', $userAgent))
422 434
 		{
2  tests/suites/unit/joomla/application/web/JApplicationWebClientTest.php
@@ -54,6 +54,8 @@ public static function getUserAgentData()
54 54
 			array(JApplicationWebClient::ANDROID, true, JApplicationWebClient::WEBKIT, JApplicationWebClient::SAFARI, '4', 'Mozilla/5.0 (Linux; U; Android 2.2.1; en-ca; LG-P505R Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'),
55 55
 			array(JApplicationWebClient::IPAD, true, JApplicationWebClient::WEBKIT, JApplicationWebClient::SAFARI, '4.0.4', 'Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10gin_lib.cc'),
56 56
 			array(JApplicationWebClient::IPHONE, true, JApplicationWebClient::WEBKIT, JApplicationWebClient::SAFARI, '4.0.5', 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B5097d Safari/6531.22.7'),
  57
+			array(JApplicationWebClient::IPAD, true, JApplicationWebClient::WEBKIT, JApplicationWebClient::SAFARI, '4.0.4', 'Mozilla/5.0(iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10gin_lib.cc'),
  58
+			array(JApplicationWebClient::IPOD, true, JApplicationWebClient::WEBKIT, JApplicationWebClient::SAFARI, '4.0.4', 'Mozilla/5.0(iPod; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10gin_lib.cc'),
57 59
 			array(JApplicationWebClient::WINDOWS, false, JApplicationWebClient::WEBKIT, JApplicationWebClient::SAFARI, '5.0.4', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27'),
58 60
 			array(JApplicationWebClient::MAC, false, JApplicationWebClient::WEBKIT, JApplicationWebClient::SAFARI, '5.0.3', 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; ar) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4'),
59 61
 			array(JApplicationWebClient::WINDOWS, false, JApplicationWebClient::GECKO, JApplicationWebClient::FIREFOX, '3.6.9', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.2.9) Gecko/20100824 Firefox/3.6.9 ( .NET CLR 3.5.30729; .NET CLR 4.0.20506)'),
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.