1 | <?php |
||
4 | class Browsers extends AbstractProvider |
||
5 | { |
||
6 | /** |
||
7 | * List of browsers. |
||
8 | * |
||
9 | * The order inside a browser family is _important_. |
||
10 | * |
||
11 | * Eg. When checking for isChrome() we will first check for 'mobile' |
||
12 | * and at last the 'desktop' version. |
||
13 | * This way we don't need to keep accurate two regexes. |
||
14 | * The last 'desktop' regex is a fallback. |
||
15 | * At the last step we already know what happened before. |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | protected $data = array( |
||
20 | /** |
||
21 | * Microsoft Internet Explorer family |
||
22 | * |
||
23 | * @docs http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx |
||
24 | */ |
||
25 | 'IE' => array( |
||
26 | 'IE Mobile' => array( |
||
27 | 'vendor' => 'Microsoft', |
||
28 | 'model' => 'IE Mobile', |
||
29 | 'isMobile' => true, |
||
30 | 'identityMatches' => 'IEMobile|MSIEMobile|Trident/[0-9.]+; Touch; rv:[0-9.]+;', |
||
31 | 'versionMatches' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];', 'Trident.*rv.[VER]'), |
||
32 | ), |
||
33 | 'IE Desktop' => array( |
||
34 | 'vendor' => 'Microsoft', |
||
35 | 'model' => 'IE Desktop', |
||
36 | 'isMobile' => false, |
||
37 | 'identityMatches' => 'MSIE [0-9.]+;|Trident.*rv.[0-9.]+', |
||
38 | 'versionMatches' => array('MSIE [VER];', 'Trident.*rv.[VER]'), |
||
39 | ), |
||
40 | ), |
||
41 | /** |
||
42 | * Opera family |
||
43 | */ |
||
44 | 'Opera' => array( |
||
45 | 'Opera Mini' => array( |
||
46 | 'vendor' => 'Opera', |
||
47 | 'model' => 'Opera Mini', |
||
48 | 'isMobile' => true, |
||
49 | 'identityMatches' => 'Opera.*Mini', |
||
50 | 'versionMatches' => array('Opera Mini/[VER]'), |
||
51 | ), |
||
52 | 'Opera Mobi' => array( |
||
53 | 'vendor' => 'Opera', |
||
54 | 'model' => 'Opera Mobi', |
||
55 | 'isMobile' => true, |
||
56 | 'identityMatches' => 'Opera.*Mobi|Android.*Opera|Mobile.*OPR/[0-9.]+', |
||
57 | 'versionMatches' => array('Opera Mobi/[VER]', ' OPR/[VER]', 'Version/[VER]'), |
||
58 | ), |
||
59 | 'Opera Coast' => array( |
||
60 | 'vendor' => 'Opera', |
||
61 | 'model' => 'Opera Coast', |
||
62 | 'isMobile' => true, |
||
63 | 'identityMatches' => 'Coast/[0-9.]+', |
||
64 | 'versionMatches' => array('Coast/[VER]'), |
||
65 | ), |
||
66 | 'Opera Desktop' => array( |
||
67 | 'vendor' => 'Opera', |
||
68 | 'model' => 'Opera Desktop', |
||
69 | 'isMobile' => false, |
||
70 | 'identityMatches' => '\bOpera\b| OPR/', |
||
71 | 'versionMatches' => array('Opera/[VER]', ' OPR/[VER]', 'Version/[VER]' ), |
||
72 | ), |
||
73 | ), |
||
74 | /** |
||
75 | * Google Chrome browser family |
||
76 | * |
||
77 | * @docs https://developers.google.com/chrome/mobile/docs/user-agent |
||
78 | */ |
||
79 | 'Chrome' => array( |
||
80 | 'Chrome Mobile' => array( |
||
81 | 'vendor' => 'Google', |
||
82 | 'model' => 'Chrome Mobile', |
||
83 | 'isMobile' => true, |
||
84 | 'identityMatches' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?', |
||
85 | 'versionMatches' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'), |
||
86 | ), |
||
87 | 'Chrome Desktop' => array( |
||
88 | 'vendor' => 'Google', |
||
89 | 'model' => 'Chrome Desktop', |
||
90 | 'isMobile' => false, |
||
91 | 'identityMatches' => '\bChrome\b/[.0-9]*', |
||
92 | 'versionMatches' => array('Chrome/[VER]'), |
||
93 | ), |
||
94 | ), |
||
95 | |||
96 | /** |
||
97 | * NetFront browsers family. |
||
98 | * @todo (Serban) Should we split this into NetFront and NetFrontLife? Mobile/Desktop |
||
99 | * @docs http://en.wikipedia.org/wiki/NetFront |
||
100 | */ |
||
101 | 'NetFront' => array( |
||
102 | 'NetFront Mobile' => array( |
||
103 | 'vendor' => 'NetFront', |
||
104 | 'model' => 'NetFront Mobile', |
||
105 | 'isMobile' => true, |
||
106 | 'identityMatches' => 'NetFront/[.0-9]+|NetFrontLifeBrowser|NF-Browser', |
||
107 | 'versionMatches' => array('NetFront/[VER]', 'NetFrontLifeBrowser/[VER]', 'Version/[VER]'), |
||
108 | ) |
||
109 | ), |
||
110 | |||
111 | 'Generic' => array( |
||
112 | /** |
||
113 | * Dolfin family has only mobile browsers. |
||
114 | * @docs https://en.wikipedia.org/wiki/Dolphin_Browser |
||
115 | */ |
||
116 | 'Dolfin' => array( |
||
117 | 'vendor' => 'Dolfin', |
||
118 | 'model' => 'Dolfin', |
||
119 | 'isMobile' => true, |
||
120 | 'identityMatches' => '\bDolfin\b', |
||
121 | 'versionMatches' => array('Dolfin/[VER]') |
||
122 | ), |
||
123 | /** |
||
124 | * @docs http://www.ucweb.com/ |
||
125 | */ |
||
126 | 'UCBrowser' => array( |
||
127 | 'vendor' => 'UCWeb', |
||
128 | 'model' => 'UCBrowser', |
||
129 | 'isMobile' => true, |
||
130 | 'identityMatches' => 'UC.*Browser|UCWEB', |
||
131 | 'versionMatches' => array('UCWEB[VER]', 'UCBrowser/[VER]') |
||
132 | ), |
||
133 | 'Silk' => array( |
||
134 | 'vendor' => 'Amazon', |
||
135 | 'model' => 'Silk', |
||
136 | 'isMobile' => true, |
||
137 | 'identityMatches' => '\bSilk\b', |
||
138 | 'versionMatches' => 'Silk\[VER]' |
||
139 | ), |
||
140 | 'Generic Mobile' => array( |
||
141 | 'vendor' => 'Generic', |
||
142 | 'model' => 'Generic Mobile', |
||
143 | 'isMobile' => true, |
||
144 | 'identityMatches' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|UP.Browser|ObigoInternetBrowser', |
||
145 | // @todo If this grows, then split into multiple generic browsers as they become important. |
||
146 | 'versionMatches' => array('Version/[VER]', 'Safari/[VER]', 'Browser/[VER]'), |
||
147 | ) |
||
148 | ), |
||
149 | |||
150 | /** |
||
151 | * Apple Safari family |
||
152 | * |
||
153 | * @docs http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/OptimizingforSafarioniPhone.html#//apple_ref/doc/uid/TP40006517-SW3 |
||
154 | * @note Safari 7534.48.3 is actually Version 5.1. |
||
155 | * @note On BlackBerry the Version is overwritten by the OS. |
||
156 | */ |
||
157 | 'Safari' => array( |
||
158 | 'Safari Mobile' => array( |
||
159 | 'vendor' => 'Apple', |
||
160 | 'model' => 'Safari Mobile', |
||
161 | 'isMobile' => true, |
||
162 | 'identityMatches' => 'Version.*Mobile.*Safari|Safari.*Mobile|MobileSafari|Android.*Safari', |
||
163 | // @note: Safari 7534.48.3 is actually Version 5.1. |
||
164 | // On BlackBerry the Version is overwritten by the OS. |
||
165 | 'versionMatches' => array('Safari/[VER]', 'Version/[VER]'), |
||
166 | 'versionHelper' => 'getSafariVersion' |
||
167 | |||
168 | ), |
||
169 | 'Safari Desktop' => array( |
||
170 | 'vendor' => 'Apple', |
||
171 | 'model' => 'Safari Desktop', |
||
172 | 'isMobile' => false, |
||
173 | 'identityMatches' => 'Safari/[0-9.]+', |
||
174 | 'versionMatches' => array('Version/[VER]', 'Safari/[VER]'), |
||
175 | 'versionHelper' => 'getSafariVersion' |
||
176 | ), |
||
177 | ), |
||
178 | |||
179 | ); |
||
180 | |||
181 | public function getSafariVersion($versionMatch) |
||
190 | |||
191 | // Updated from https://en.wikipedia.org/wiki/Safari_version_history |
||
192 | public function getSafariVersions() |
||
304 | |||
305 | |||
306 | public function getFamily($familyName) |
||
310 | } |