diff options
Diffstat (limited to 'plugins/API/Menu.php')
-rw-r--r-- | plugins/API/Menu.php | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/plugins/API/Menu.php b/plugins/API/Menu.php index d9048617ed..a76f87ee0e 100644 --- a/plugins/API/Menu.php +++ b/plugins/API/Menu.php @@ -11,9 +11,12 @@ namespace Piwik\Plugins\API; use Piwik\Menu\MenuTop; use Piwik\Menu\MenuUser; use Piwik\Piwik; +use DeviceDetector\Parser\OperatingSystem; class Menu extends \Piwik\Plugin\Menu { + const DD_SHORT_NAME_ANDROID = 'AND'; + const DD_SHORT_NAME_IOS = 'IOS'; public function configureTopMenu(MenuTop $menu) { @@ -34,14 +37,13 @@ class Menu extends \Piwik\Plugin\Menu return; } - if (!class_exists("DeviceDetector")) { + if (!class_exists("DeviceDetector\\DeviceDetector")) { throw new \Exception("DeviceDetector could not be found, maybe you are using Piwik from git and need to have update Composer. <br>php composer.phar update"); } - $ua = new \DeviceDetector($_SERVER['HTTP_USER_AGENT']); - $ua->parse(); - $os = $ua->getOs('short_name'); - if ($os && in_array($os, array('AND', 'IOS'))) { + $ua = new OperatingSystem($_SERVER['HTTP_USER_AGENT']); + $parsedOS = $ua->parse(); + if (!empty($parsedOS['short_name']) && in_array($parsedOS['short_name'], array(self::DD_SHORT_NAME_ANDROID, self::DD_SHORT_NAME_IOS))) { $menu->add('Piwik Mobile App', null, array('module' => 'Proxy', 'action' => 'redirect', 'url' => 'http://piwik.org/mobile/'), true, 4); } } |