From 7a98becbec6bf32038549c879b4f6cfda3a7b77d Mon Sep 17 00:00:00 2001 From: sgiehl Date: Thu, 3 Apr 2014 13:54:40 +0200 Subject: [PATCH] use DeviceDetector instead of old UserAgentParser --- core/Tracker/Visit.php | 14 ++++++++------ plugins/UserSettings/API.php | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php index 470ec3eb4cd..cfca27271a6 100644 --- a/core/Tracker/Visit.php +++ b/core/Tracker/Visit.php @@ -14,7 +14,7 @@ use Piwik\IP; use Piwik\Piwik; use Piwik\Tracker; -use UserAgentParser; +use DeviceDetector; /** * Class used to handle a Visit. @@ -592,20 +592,22 @@ protected function getUserSettingsInformation() if (is_array($this->userSettingsInformation)) { return $this->userSettingsInformation; } - require_once PIWIK_INCLUDE_PATH . '/libs/UserAgentParser/UserAgentParser.php'; list($plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie) = $this->request->getPlugins(); $resolution = $this->request->getParam('res'); $userAgent = $this->request->getUserAgent(); - $aBrowserInfo = UserAgentParser::getBrowser($userAgent); - $browserName = ($aBrowserInfo !== false && $aBrowserInfo['id'] !== false) ? $aBrowserInfo['id'] : 'UNK'; + $deviceDetector = new DeviceDetector($userAgent); + $deviceDetector->parse(); + $aBrowserInfo = $deviceDetector->getBrowser(); + + $browserName = ($aBrowserInfo !== false && $aBrowserInfo['short_name'] !== false) ? $aBrowserInfo['short_name'] : 'UNK'; $browserVersion = ($aBrowserInfo !== false && $aBrowserInfo['version'] !== false) ? $aBrowserInfo['version'] : ''; - $os = UserAgentParser::getOperatingSystem($userAgent); - $os = $os === false ? 'UNK' : $os['id']; + $os = $deviceDetector->getOS(); + $os = empty($os['short_name']) ? 'UNK' : $os['short_name']; $browserLang = substr($this->request->getBrowserLanguage(), 0, 20); // limit the length of this string to match db $configurationHash = $this->getConfigHash( diff --git a/plugins/UserSettings/API.php b/plugins/UserSettings/API.php index 036e4d14c0f..432863c1ed7 100644 --- a/plugins/UserSettings/API.php +++ b/plugins/UserSettings/API.php @@ -65,7 +65,7 @@ public function getOS($idSite, $period, $date, $segment = false, $addShortLabel /** * Gets a DataTable displaying number of visits by operating system family. The operating - * system families are listed in /libs/UserAgentParser/UserAgentParser.php. + * system families are listed in vendor piwik/device-detector. */ public function getOSFamily($idSite, $period, $date, $segment = false) {