Newer
Older
mattpiwik
a validé
<?php
/**
* Piwik - Open source web analytics
mattpiwik
a validé
* @link http://piwik.org
mattpiwik
a validé
* @category Piwik
* @package Piwik_Menu
*/
namespace Piwik\Menu;
use Piwik\Piwik;
mattpiwik
a validé
/**
* @package Piwik_Menu
*/
class MenuMain extends MenuAbstract
mattpiwik
a validé
{
static private $instance = null;
/**
* @return MenuAbstract
*/
static public function getInstance()
{
if (self::$instance == null) {
self::$instance = new self;
}
return self::$instance;
}
/**
* Returns if the URL was found in the menu.
*
* @param string $url
* @return boolean
*/
public function isUrlFound($url)
{
$menu = MenuMain::getInstance()->getMenu();
mattpiwik
a validé
foreach ($menu as $subMenus) {
foreach ($subMenus as $subMenuName => $menuUrl) {
if (strpos($subMenuName, '_') !== 0 && $menuUrl['_url'] == $url) {
return true;
}
}
}
return false;
}
/**
Thomas Steur
a validé
* Triggers the Menu.Reporting.addItems hook and returns the menu.
*
* @return Array
*/
{
// We trigger the Event only once!
if (!$this->menu) {
/**
* This event is triggered to collect all available reporting menu items. Subscribe to this event if you
* want to add one or more items to the Piwik reporting menu. Just define the name of your menu item as
* well as a controller and an action that should be executed once a user selects your menu item. It is
* also possible to display the item only for users having a specific role.
*
* Example:
* ```
* public function addMenuItems()
* {
* \Piwik\Menu\Main::getInstance()->add(
* 'CustomMenuName',
* 'CustomSubmenuName',
* array('module' => 'MyPlugin', 'action' => 'index'),
* Piwik::isUserIsSuperUser(),
* $order = 6
* );
* }
* ```
*/
Piwik::postEvent('Menu.Reporting.addItems');