1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\API;
use Piwik\Menu\MenuTop;
use Piwik\Menu\MenuUser;
use Piwik\Piwik;
class Menu extends \Piwik\Plugin\Menu
{
public function configureTopMenu(MenuTop $menu)
{
$this->addTopMenuMobileApp($menu);
}
public function configureUserMenu(MenuUser $menu)
{
$apiUrlParams = array('module' => 'API', 'action' => 'listAllAPI', 'segment' => false);
$tooltip = Piwik::translate('API_TopLinkTooltip');
$menu->add('CorePluginsAdmin_MenuPlatform', 'General_API', $apiUrlParams, true, 6, $tooltip);
}
private function addTopMenuMobileApp(MenuTop $menu)
{
if (empty($_SERVER['HTTP_USER_AGENT'])) {
return;
}
if (!class_exists("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'))) {
$menu->add('Piwik Mobile App', null, array('module' => 'Proxy', 'action' => 'redirect', 'url' => 'http://piwik.org/mobile/'), true, 4);
}
}
}
|