Feature #24443 » getBrowserInfo.diff
t3lib/utility/class.t3lib_utility_client.php | ||
---|---|---|
}
|
||
// system
|
||
// Microsoft Documentation about Platform tokens: http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx
|
||
$browserInfo['system'] = '';
|
||
if (strstr($userAgent, 'Win')) {
|
||
// windows
|
||
... | ... | |
$browserInfo['system'] = 'win98';
|
||
} elseif (strstr($userAgent, 'Win95') || strstr($userAgent, 'Windows 95')) {
|
||
$browserInfo['system'] = 'win95';
|
||
} elseif (strstr($userAgent, 'Windows NT 6.1')) {
|
||
$browserInfo['system'] = 'win7';
|
||
} elseif (strstr($userAgent, 'Windows NT 6.0')) {
|
||
$browserInfo['system'] = 'winVista';
|
||
} elseif (strstr($userAgent, 'Windows NT 5.1')) {
|
||
$browserInfo['system'] = 'winXP';
|
||
} elseif (strstr($userAgent, 'Windows NT 5.0') || strstr($userAgent, 'Windows NT 5.01')) {
|
||
$browserInfo['system'] = 'win2k';
|
||
} elseif (strstr($userAgent, 'WinNT') || strstr($userAgent, 'Windows NT')) {
|
||
$browserInfo['system'] = 'winNT';
|
||
} elseif (strstr($userAgent, 'Win16') || strstr($userAgent, 'Windows 311')) {
|
||
$browserInfo['system'] = 'win311';
|
||
}
|
||
} elseif (strstr($userAgent, 'Mac')) {
|
||
$browserInfo['system'] = 'mac';
|
||
if (strstr($userAgent, 'iPad') || strstr($userAgent, 'iPhone') || strstr($userAgent, 'iPod')) {
|
||
$browserInfo['system'] = 'iOS';
|
||
} else {
|
||
$browserInfo['system'] = 'mac';
|
||
}
|
||
// unixes
|
||
} elseif (strstr($userAgent, 'Linux')) {
|
||
$browserInfo['system'] = 'linux';
|
||
if (strstr($userAgent, 'Android')) {
|
||
$browserInfo['system'] = 'android';
|
||
} else {
|
||
$browserInfo['system'] = 'linux';
|
||
}
|
||
} elseif (strstr($userAgent, 'SGI') && strstr($userAgent, ' IRIX ')) {
|
||
$browserInfo['system'] = 'unix_sgi';
|
||
} elseif (strstr($userAgent, ' SunOS ')) {
|
||
... | ... | |
}
|
||
}
|
||
?>
|
||
?>
|
tests/t3lib/utility/t3lib_utility_clientTest.php | ||
---|---|---|
$infoArray['all']['gecko']
|
||
);
|
||
}
|
||
/**
|
||
* @test
|
||
*/
|
||
public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows7() {
|
||
$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(
|
||
'win7',
|
||
$infoArray['system']
|
||
);
|
||
}
|
||
/**
|
||
* @test
|
||
*/
|
||
public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsVista() {
|
||
$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(
|
||
'winVista',
|
||
$infoArray['system']
|
||
);
|
||
}
|
||
/**
|
||
* @test
|
||
*/
|
||
public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsXp() {
|
||
$userAgentString = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)';
|
||
$infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
|
||
$this->assertSame(
|
||
'winXP',
|
||
$infoArray['system']
|
||
);
|
||
}
|
||
/**
|
||
* @test
|
||
*/
|
||
public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows2k() {
|
||
$userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; SV1)';
|
||
$infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
|
||
$this->assertSame(
|
||
'win2k',
|
||
$infoArray['system']
|
||
);
|
||
}
|
||
/**
|
||
* @test
|
||
*/
|
||
public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindows2kServicePack1() {
|
||
$userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.01; SV1)';
|
||
$infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
|
||
$this->assertSame(
|
||
'win2k',
|
||
$infoArray['system']
|
||
);
|
||
}
|
||
/**
|
||
* @test
|
||
*/
|
||
public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfWindowsNt() {
|
||
$userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 4.0)';
|
||
$infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
|
||
$this->assertSame(
|
||
'winNT',
|
||
$infoArray['system']
|
||
);
|
||
}
|
||
/**
|
||
* @test
|
||
*/
|
||
public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringContainingNtAsFallback() {
|
||
$userAgentString = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT)';
|
||
$infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
|
||
$this->assertSame(
|
||
'winNT',
|
||
$infoArray['system']
|
||
);
|
||
}
|
||
/**
|
||
* @test
|
||
*/
|
||
public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIpad() {
|
||
$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(
|
||
'iOS',
|
||
$infoArray['system']
|
||
);
|
||
}
|
||
/**
|
||
* @test
|
||
*/
|
||
public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIphone() {
|
||
$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(
|
||
'iOS',
|
||
$infoArray['system']
|
||
);
|
||
}
|
||
/**
|
||
* @test
|
||
*/
|
||
public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfIpod() {
|
||
$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(
|
||
'iOS',
|
||
$infoArray['system']
|
||
);
|
||
}
|
||
/**
|
||
* @test
|
||
*/
|
||
public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfMacOsX() {
|
||
$userAgentString = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-us) AppleWebKit/534.15+ (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4';
|
||
$infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
|
||
$this->assertSame(
|
||
'mac',
|
||
$infoArray['system']
|
||
);
|
||
}
|
||
/**
|
||
* @test
|
||
*/
|
||
public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfLinux() {
|
||
$userAgentString = 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.8) Gecko/20100723 Ubuntu/10.04 (lucid) Firefox/3.6.8';
|
||
$infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
|
||
$this->assertSame(
|
||
'linux',
|
||
$infoArray['system']
|
||
);
|
||
}
|
||
/**
|
||
* @test
|
||
*/
|
||
public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfSolaris() {
|
||
$userAgentString = 'Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.1.9) Gecko/20100525 Firefox/3.5.9';
|
||
$infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString);
|
||
$this->assertSame(
|
||
'unix_sun',
|
||
$infoArray['system']
|
||
);
|
||
}
|
||
/**
|
||
* @test
|
||
*/
|
||
public function getBrowserInfoReturnsCorrectSystemValueForUserAgentStringOfAndroid() {
|
||
$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(
|
||
'android',
|
||
$infoArray['system']
|
||
);
|
||
}
|
||
}
|
||
?>
|
||
?>
|