OperaMini.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace WhichBrowser\Analyser\Header;
  3. use WhichBrowser\Data;
  4. use WhichBrowser\Constants;
  5. class OperaMini
  6. {
  7. public function __construct($header, &$data)
  8. {
  9. $this->data =& $data;
  10. $parts = explode(' # ', $header);
  11. $manufacturer = isset($parts[0]) ? $parts[0] : '';
  12. $model = isset($parts[1]) ? $parts[1] : '';
  13. if ($manufacturer != '?' && $model != '?') {
  14. if ($this->data->device->identified < Constants\Id::PATTERN) {
  15. if ($this->identifyBasedOnModel($model)) {
  16. return;
  17. }
  18. $this->data->device->manufacturer = $manufacturer;
  19. $this->data->device->model = $model;
  20. $this->data->device->identified = true;
  21. }
  22. }
  23. }
  24. private function identifyBasedOnModel($model)
  25. {
  26. $device = Data\DeviceModels::identify('bada', $model);
  27. if ($device->identified) {
  28. $device->identified |= $this->data->device->identified;
  29. $this->data->device = $device;
  30. if (!isset($this->data->os->name) || $this->data->os->name != 'Bada') {
  31. $this->data->os->name = 'Bada';
  32. $this->data->os->version = null;
  33. }
  34. return true;
  35. }
  36. $device = Data\DeviceModels::identify('blackberry', $model);
  37. if ($device->identified) {
  38. $device->identified |= $this->data->device->identified;
  39. $this->data->device = $device;
  40. if (!isset($this->data->os->name) || $this->data->os->name != 'BlackBerry OS') {
  41. $this->data->os->name = 'BlackBerry OS';
  42. $this->data->os->version = null;
  43. }
  44. return true;
  45. }
  46. $device = Data\DeviceModels::identify('wm', $model);
  47. if ($device->identified) {
  48. $device->identified |= $this->data->device->identified;
  49. $this->data->device = $device;
  50. if (!isset($this->data->os->name) || $this->data->os->name != 'Windows Mobile') {
  51. $this->data->os->name = 'Windows Mobile';
  52. $this->data->os->version = null;
  53. }
  54. return true;
  55. }
  56. }
  57. }