Follow-up to issue #16878: Keep t3lib_utility_Client::getBrowserInfo backwards compat...
authorErnesto Baschny <ernst@cron-it.de>
Fri, 21 Jan 2011 18:08:15 +0000 (18:08 +0000)
committerErnesto Baschny <ernst@cron-it.de>
Fri, 21 Jan 2011 18:08:15 +0000 (18:08 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@10220 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/matchcondition/class.t3lib_matchcondition_abstract.php
t3lib/utility/class.t3lib_utility_client.php
tests/t3lib/utility/t3lib_utility_clientTest.php

index 1f65ce8..877fbba 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,7 @@
 
 2011-01-21  Ernesto Baschny  <ernst@cron-it.de>
 
+       * Follow-up to issue #16878: Keep t3lib_utility_Client::getBrowserInfo backwards compatible, deprecate 'system' and only use 'all_systems' from now on
        * Fixed bug #16994: ExtDirect in frontend generates php warnings (Thanks to Stefan Galinski)
        * Fixed issue #17198: Introduce setting "defaultMailFromName" and move defaultMailFromAddress to [MAIL] section (Thanks to Jigal van Hemert)
        * Fixed issue #17175: t3lib_compressor should write .htaccess to set Expires headers for .js/.css files (Thanks to Steffen Gebert)
index d872a78..57511f7 100644 (file)
@@ -259,10 +259,7 @@ abstract class t3lib_matchCondition_abstract {
                                $values = t3lib_div::trimExplode(',', $value, TRUE);
                                        // Take all identified systems into account, e.g. mac for iOS, Linux
                                        // for android and Windows NT for Windows XP
-                               $allSystems = $browserInfo['system'];
-                               if (!empty($browserInfo['all_systems'])) {
-                                       $allSystems .= ' ' . implode(' ', $browserInfo['all_systems']);
-                               }
+                               $allSystems .= ' ' . implode(' ', $browserInfo['all_systems']);
                                foreach ($values as $test) {
                                        if (stripos($allSystems, $test) !== FALSE) {
                                                return TRUE;
index 3679ebb..d433d39 100644 (file)
@@ -103,58 +103,75 @@ final class t3lib_utility_Client {
                        }
                }
 
-                       // system
                        // Microsoft Documentation about Platform tokens: http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
+                       // 'system' is deprecated, use 'all_systems' (array) in future!
                $browserInfo['system'] = '';
                $browserInfo['all_systems'] = '';
                if (strstr($userAgent, 'Win')) {
                                // windows
                        if (strstr($userAgent, 'Windows NT 6.1')) {
-                               $browserInfo['system'] = 'win7';
+                               $browserInfo['system'] = 'winNT'; // backwards compatible
+                               $browserInfo['all_systems'][] = 'win7';
                                $browserInfo['all_systems'][] = 'winNT';
                        } elseif (strstr($userAgent, 'Windows NT 6.0')) {
-                               $browserInfo['system'] = 'winVista';
+                               $browserInfo['system'] = 'winNT'; // backwards compatible
+                               $browserInfo['all_systems'][] = 'winVista';
                                $browserInfo['all_systems'][] = 'winNT';
                        } elseif (strstr($userAgent, 'Windows NT 5.1')) {
-                               $browserInfo['system'] = 'winXP';
+                               $browserInfo['system'] = 'winNT'; // backwards compatible
+                               $browserInfo['all_systems'][] = 'winXP';
                                $browserInfo['all_systems'][] = 'winNT';
                        } elseif (strstr($userAgent, 'Windows NT 5.0')) {
-                               $browserInfo['system'] = 'win2k';
+                               $browserInfo['system'] = 'winNT'; // backwards compatible
+                               $browserInfo['all_systems'][] = 'win2k';
                                $browserInfo['all_systems'][] = 'winNT';
                        } elseif (strstr($userAgent, 'Win98') || strstr($userAgent, 'Windows 98')) {
                                $browserInfo['system'] = 'win98';
+                               $browserInfo['all_systems'][] = 'win98';
                        } elseif (strstr($userAgent, 'Win95') || strstr($userAgent, 'Windows 95')) {
                                $browserInfo['system'] = 'win95';
+                               $browserInfo['all_systems'][] = 'win95';
                        } elseif (strstr($userAgent, 'WinNT') || strstr($userAgent, 'Windows NT')) {
                                $browserInfo['system'] = 'winNT';
+                               $browserInfo['all_systems'][] = 'winNT';
                        } elseif (strstr($userAgent, 'Win16') || strstr($userAgent, 'Windows 311')) {
                                $browserInfo['system'] = 'win311';
+                               $browserInfo['all_systems'][] = 'win311';
                        }
                } elseif (strstr($userAgent, 'Mac')) {
                        if (strstr($userAgent, 'iPad') || strstr($userAgent, 'iPhone') || strstr($userAgent, 'iPod')) {
-                               $browserInfo['system'] = 'iOS';
+                               $browserInfo['system'] = 'mac'; // backwards compatible
+                               $browserInfo['all_systems'][] = 'iOS';
                                $browserInfo['all_systems'][] = 'mac';
                        } else {
                                $browserInfo['system'] = 'mac';
+                               $browserInfo['all_systems'][] = 'mac';
                        }
                                // unixes
                } elseif (strstr($userAgent, 'Linux')) {
                        if (strstr($userAgent, 'Android')) {
-                               $browserInfo['system'] = 'android';
+                               $browserInfo['system'] = 'linux'; // backwards compatible
+                               $browserInfo['all_systems'][] = 'android';
                                $browserInfo['all_systems'][] = 'linux';
                        } else {
                                $browserInfo['system'] = 'linux';
+                               $browserInfo['all_systems'][] = 'linux';
                        }
                } elseif (strstr($userAgent, 'BSD')) {
                        $browserInfo['system'] = 'unix_bsd';
+                       $browserInfo['all_systems'][] = 'unix_bsd';
                } elseif (strstr($userAgent, 'SGI') && strstr($userAgent, ' IRIX ')) {
                        $browserInfo['system'] = 'unix_sgi';
+                       $browserInfo['all_systems'][] = 'unix_sgi';
                } elseif (strstr($userAgent, ' SunOS ')) {
                        $browserInfo['system'] = 'unix_sun';
+                       $browserInfo['all_systems'][] = 'unix_sun';
                } elseif (strstr($userAgent, ' HP-UX ')) {
                        $browserInfo['system'] = 'unix_hp';
+                       $browserInfo['all_systems'][] = 'unix_hp';
                } elseif (strstr($userAgent, 'CrOS')) {
-                       $browserInfo['system'] = 'chrome';
+                       $browserInfo['system'] = 'linux';
+                       $browserInfo['all_systems'][] = 'chrome';
                        $browserInfo['all_systems'][] = 'linux';
                }
 
index fce3928..30a2767 100644 (file)
@@ -209,8 +209,13 @@ class t3lib_utility_clientTest extends tx_phpunit_testcase {
                $userAgentString = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)';
                $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
 
-               $this->assertSame(
+               $this->assertContains(
                        'win7',
+                       $infoArray['all_systems']
+               );
+                       // Check for backwards compatibility (deprecated since 4.5)
+               $this->assertEquals(
+                       'winNT',
                        $infoArray['system']
                );
        }
@@ -222,8 +227,13 @@ class t3lib_utility_clientTest extends tx_phpunit_testcase {
                $userAgentString = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506)';
                $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
 
-               $this->assertSame(
+               $this->assertContains(
                        'winVista',
+                       $infoArray['all_systems']
+               );
+                       // Check for backwards compatibility (deprecated since 4.5)
+               $this->assertSame(
+                       'winNT',
                        $infoArray['system']
                );
        }
@@ -235,8 +245,13 @@ class t3lib_utility_clientTest extends tx_phpunit_testcase {
                $userAgentString = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)';
                $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
 
-               $this->assertSame(
+               $this->assertContains(
                        'winXP',
+                       $infoArray['all_systems']
+               );
+                       // Check for backwards compatibility (deprecated since 4.5)
+               $this->assertSame(
+                       'winNT',
                        $infoArray['system']
                );
        }
@@ -248,8 +263,13 @@ class t3lib_utility_clientTest extends tx_phpunit_testcase {
                $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; SV1)';
                $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
 
-               $this->assertSame(
+               $this->assertContains(
                        'win2k',
+                       $infoArray['all_systems']
+               );
+                       // Check for backwards compatibility (deprecated since 4.5)
+               $this->assertSame(
+                       'winNT',
                        $infoArray['system']
                );
        }
@@ -261,8 +281,13 @@ class t3lib_utility_clientTest extends tx_phpunit_testcase {
                $userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.01; SV1)';
                $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
 
-               $this->assertSame(
+               $this->assertContains(
                        'win2k',
+                       $infoArray['all_systems']
+               );
+                       // Check for backwards compatibility (deprecated since 4.5)
+               $this->assertSame(
+                       'winNT',
                        $infoArray['system']
                );
        }
@@ -300,8 +325,13 @@ class t3lib_utility_clientTest extends tx_phpunit_testcase {
                $userAgentString = '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/7W367a Safari/531.21.10';
                $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
 
-               $this->assertSame(
+               $this->assertContains(
                        'iOS',
+                       $infoArray['all_systems']
+               );
+                       // Check for backwards compatibility (deprecated since 4.5)
+               $this->assertSame(
+                       'mac',
                        $infoArray['system']
                );
        }
@@ -313,8 +343,13 @@ class t3lib_utility_clientTest extends tx_phpunit_testcase {
                $userAgentString = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7';
                $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
 
-               $this->assertSame(
+               $this->assertContains(
                        'iOS',
+                       $infoArray['all_systems']
+               );
+                       // Check for backwards compatibility (deprecated since 4.5)
+               $this->assertSame(
+                       'mac',
                        $infoArray['system']
                );
        }
@@ -326,8 +361,13 @@ class t3lib_utility_clientTest extends tx_phpunit_testcase {
                $userAgentString = 'Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Geckto) Version/3.0 Mobile/3A101a Safari/419.3';
                $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
 
-               $this->assertSame(
+               $this->assertContains(
                        'iOS',
+                       $infoArray['all_systems']
+               );
+                       // Check for backwards compatibility (deprecated since 4.5)
+               $this->assertSame(
+                       'mac',
                        $infoArray['system']
                );
        }
@@ -378,8 +418,13 @@ class t3lib_utility_clientTest extends tx_phpunit_testcase {
                $userAgentString = 'Mozilla/5.0 (Linux; U; Android 2.3; en-US; sdk Build/GRH55) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1';
                $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
 
-               $this->assertSame(
+               $this->assertContains(
                        'android',
+                       $infoArray['all_systems']
+               );
+                       // Check for backwards compatibility (deprecated since 4.5)
+               $this->assertSame(
+                       'linux',
                        $infoArray['system']
                );
        }
@@ -391,9 +436,9 @@ class t3lib_utility_clientTest extends tx_phpunit_testcase {
                $userAgentString = 'Links (1.00pre20; OpenBSD 4.8 i386; 80x25)';
                $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
 
-               $this->assertSame(
+               $this->assertContains(
                        'unix_bsd',
-                       $infoArray['system']
+                       $infoArray['all_systems']
                );
        }
 
@@ -404,9 +449,9 @@ class t3lib_utility_clientTest extends tx_phpunit_testcase {
                $userAgentString = 'Links (2.2; NetBSD 5.1 amd64; 80x25)';
                $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
 
-               $this->assertSame(
+               $this->assertContains(
                        'unix_bsd',
-                       $infoArray['system']
+                       $infoArray['all_systems']
                );
        }
 
@@ -417,9 +462,9 @@ class t3lib_utility_clientTest extends tx_phpunit_testcase {
                $userAgentString = 'Mozilla/5.0 (X11; U; FreeBSD amd64; c) AppleWebKit/531.2+ (KHTML, like Gecko) Safari 531.2+ Epiphany/230.2';
                $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
 
-               $this->assertSame(
+               $this->assertContains(
                        'unix_bsd',
-                       $infoArray['system']
+                       $infoArray['all_systems']
                );
        }
 
@@ -430,9 +475,9 @@ class t3lib_utility_clientTest extends tx_phpunit_testcase {
                $userAgentString = 'Mozilla/5.0 (X11; U; CrOS i686  9.10.0; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.253.0 Safari 532.5';
                $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
 
-               $this->assertSame(
+               $this->assertContains(
                        'chrome',
-                       $infoArray['system']
+                       $infoArray['all_systems']
                );
        }