Skip to content

Commit

Permalink
refs matomo-org#3962 use UserAgentParserEnhanced instead of UserAgent…
Browse files Browse the repository at this point in the history
…Parser to detect android & ios devices
  • Loading branch information
sgiehl committed Jan 30, 2014
1 parent 94256e4 commit 3149eb8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions plugins/API/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -700,9 +700,11 @@ protected function addTopMenuMobileApp()
if (empty($_SERVER['HTTP_USER_AGENT'])) {
return;
}
require_once PIWIK_INCLUDE_PATH . '/libs/UserAgentParser/UserAgentParser.php';
$os = \UserAgentParser::getOperatingSystem($_SERVER['HTTP_USER_AGENT']);
if ($os && in_array($os['id'], array('AND', 'IPD', 'IPA', 'IPH'))) {
require_once PIWIK_INCLUDE_PATH . '/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php';
$ua = new \UserAgentParserEnhanced($_SERVER['HTTP_USER_AGENT']);
$ua->parse();
$os = $ua->getOs('short_name');
if ($os && in_array($os, array('AND', 'IOS'))) {
MenuTop::addEntry('Piwik Mobile App', array('module' => 'Proxy', 'action' => 'redirect', 'url' => 'http://piwik.org/mobile/'), true, 4);
}
}
Expand All @@ -711,4 +713,4 @@ public function getStylesheetFiles(&$stylesheets)
{
$stylesheets[] = "plugins/API/stylesheets/listAllAPI.less";
}
}
}

0 comments on commit 3149eb8

Please sign in to comment.