Skip to content

Commit

Permalink
Adds support for Tizen
Browse files Browse the repository at this point in the history
  • Loading branch information
donatj committed Feb 20, 2015
1 parent ea239f0 commit 4c6f77b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Source/UserAgentParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ function parse_user_agent( $u_agent = null ) {

if( preg_match('/\((.*?)\)/im', $u_agent, $parent_matches) ) {

preg_match_all('/(?P<platform>BB\d+;|Android|CrOS|iPhone|iPad|Linux|Macintosh|Windows(\ Phone)?|Silk|linux-gnu|BlackBerry|PlayBook|(New\ )?Nintendo\ (WiiU?|3DS)|Xbox(\ One)?)
preg_match_all('/(?P<platform>BB\d+;|Android|CrOS|Tizen|iPhone|iPad|Linux|Macintosh|Windows(\ Phone)?|Silk|linux-gnu|BlackBerry|PlayBook|(New\ )?Nintendo\ (WiiU?|3DS)|Xbox(\ One)?)
(?:\ [^;]*)?
(?:;|$)/imx', $parent_matches[1], $result, PREG_PATTERN_ORDER);

$priority = array( 'Android', 'Xbox One', 'Xbox' );
$priority = array( 'Android', 'Xbox One', 'Xbox', 'Tizen' );
$result['platform'] = array_unique($result['platform']);
if( count($result['platform']) > 1 ) {
if( $keys = array_intersect($priority, $result['platform']) ) {
Expand All @@ -52,7 +52,7 @@ function parse_user_agent( $u_agent = null ) {
$platform = 'Chrome OS';
}

preg_match_all('%(?P<browser>Camino|Kindle(\ Fire\ Build)?|Firefox|Iceweasel|Safari|MSIE|Trident|AppleWebKit|Chrome|
preg_match_all('%(?P<browser>Camino|Kindle(\ Fire\ Build)?|Firefox|Iceweasel|Safari|MSIE|Trident|AppleWebKit|TizenBrowser|Chrome|
Vivaldi|IEMobile|Opera|OPR|Silk|Midori|Edge|
Baiduspider|Googlebot|YandexBot|bingbot|Lynx|Version|Wget|curl|
NintendoBrowser|PLAYSTATION\ (\d|Vita)+)
Expand Down Expand Up @@ -144,6 +144,8 @@ function parse_user_agent( $u_agent = null ) {
$browser = 'BlackBerry Browser';
} elseif( $find('Safari', $key) ) {
$browser = 'Safari';
} elseif( $find('TizenBrowser', $key) ) {
$browser = 'TizenBrowser';
}

$find('Version', $key);
Expand All @@ -157,5 +159,4 @@ function parse_user_agent( $u_agent = null ) {
}

return array( 'platform' => $platform ?: null, 'browser' => $browser ?: null, 'version' => $version ?: null );

}

0 comments on commit 4c6f77b

Please sign in to comment.