قرینه از
https://github.com/matomo-org/matomo.git
synced 2025-08-21 22:47:43 +00:00

* [Coding Style] Enable rule PSR12.Files.FileHeader * Apply CS * Replace Piwik with Matomo in file headers * Unify file headers (position, no. of lines, https links) * Rebuild dist files * Apply CS * Fix system test that relies on line numbers in a file that had the file header updated --------- Co-authored-by: Stefan Giehl <stefan@matomo.org>
66 خطوط
1.9 KiB
PHP
66 خطوط
1.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Matomo - free/libre analytics platform
|
|
*
|
|
* @link https://matomo.org
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
|
*/
|
|
|
|
namespace Piwik\Plugins\API;
|
|
|
|
use Piwik\Container\StaticContainer;
|
|
use Piwik\Menu\MenuAdmin;
|
|
use Piwik\Menu\MenuTop;
|
|
use Piwik\Piwik;
|
|
use DeviceDetector\Parser\OperatingSystem;
|
|
use Piwik\Url;
|
|
|
|
class Menu extends \Piwik\Plugin\Menu
|
|
{
|
|
public const DD_SHORT_NAME_ANDROID = 'AND';
|
|
public const DD_SHORT_NAME_IOS = 'IOS';
|
|
|
|
public function configureTopMenu(MenuTop $menu)
|
|
{
|
|
$this->addTopMenuMobileApp($menu);
|
|
}
|
|
|
|
public function configureAdminMenu(MenuAdmin $menu)
|
|
{
|
|
$menu->addPlatformItem(
|
|
'General_API',
|
|
$this->urlForAction('listAllAPI', array('segment' => false)),
|
|
7,
|
|
Piwik::translate('API_TopLinkTooltip')
|
|
);
|
|
|
|
if (Piwik::isUserIsAnonymous()) {
|
|
$menu->addPlatformItem(
|
|
'API_Glossary',
|
|
$this->urlForAction('glossary', array('segment' => false)),
|
|
50
|
|
);
|
|
}
|
|
}
|
|
|
|
private function addTopMenuMobileApp(MenuTop $menu)
|
|
{
|
|
if (empty($_SERVER['HTTP_USER_AGENT'])) {
|
|
return;
|
|
}
|
|
|
|
if (!class_exists("DeviceDetector\\DeviceDetector")) {
|
|
throw new \Exception("DeviceDetector could not be found, maybe you are using Piwik from git and need to update Composer. Execute this command: php composer.phar update");
|
|
}
|
|
|
|
$ua = new OperatingSystem($_SERVER['HTTP_USER_AGENT']);
|
|
$ua->setCache(StaticContainer::get('DeviceDetector\Cache\Cache'));
|
|
$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->addItem('Mobile_MatomoMobile', null, Url::addCampaignParametersToMatomoLink('https://matomo.org/mobile/'), 4);
|
|
}
|
|
}
|
|
}
|