There are three menus in Piwik, the main menu, the top menu and the admin menu. Each menu has a class that manages the menu's content. Each class invokes a different event to allow plugins to add new menu items.
Inheritance: extends Piwik\Singleton
示例#1
0
 /**
  * Triggers the Menu.MenuAdmin.addItems hook and returns the admin menu.
  *
  * @return Array
  */
 public function getMenu()
 {
     if (!$this->menu) {
         /**
          * Triggered when collecting all available admin menu items. Subscribe to this event if you want
          * to add one or more items to the Piwik admin menu.
          *
          * Menu items should be added via the {@link add()} method.
          *
          * **Example**
          * 
          *     use Piwik\Menu\MenuAdmin;
          * 
          *     public function addMenuItems()
          *     {
          *         MenuAdmin::getInstance()->add(
          *             'MenuName',
          *             'SubmenuName',
          *             array('module' => 'MyPlugin', 'action' => 'index'),
          *             $showOnlyIf = Piwik::isUserIsSuperUser(),
          *             $order = 6
          *         );
          *     }
          */
         Piwik::postEvent('Menu.Admin.addItems');
     }
     return parent::getMenu();
 }
示例#2
0
文件: MenuTop.php 项目: piwik/piwik
 /**
  * Triggers the Menu.Top.addItems hook and returns the menu.
  *
  * @return Array
  */
 public function getMenu()
 {
     if (!$this->menu) {
         foreach ($this->getAllMenus() as $menu) {
             $menu->configureTopMenu($this);
         }
     }
     return parent::getMenu();
 }
示例#3
0
 /**
  * Triggers the Menu.MenuAdmin.addItems hook and returns the admin menu.
  *
  * @return Array
  */
 public function getMenu()
 {
     if (!$this->menu) {
         /**
          * @ignore
          */
         Piwik::postEvent('Menu.Admin.addItems', array());
         foreach ($this->getAvailableMenus() as $menu) {
             $menu->configureAdminMenu($this);
         }
     }
     return parent::getMenu();
 }
示例#4
0
 /**
  * Triggers the Menu.Reporting.addItems hook and returns the menu.
  *
  * @return Array
  */
 public function getMenu()
 {
     if (!$this->menu) {
         /**
          * @ignore
          * @deprecated
          */
         Piwik::postEvent('Menu.Reporting.addItems', array());
         foreach ($this->getAvailableMenus() as $menu) {
             $menu->configureReportingMenu($this);
         }
     }
     return parent::getMenu();
 }
示例#5
0
 /**
  * Setup the database and create the base tables for all tests
  */
 public function setUp()
 {
     parent::setUp();
     static::$fixture->extraDefinitions = array_merge(static::provideContainerConfigBeforeClass(), $this->provideContainerConfig());
     static::$fixture->createEnvironmentInstance();
     Db::createDatabaseObject();
     Fixture::loadAllPlugins(new TestingEnvironmentVariables(), get_class($this), self::$fixture->extraPluginsToLoad);
     Access::getInstance()->setSuperUserAccess(true);
     if (!empty(self::$tableData)) {
         self::restoreDbTables(self::$tableData);
     }
     PiwikCache::getEagerCache()->flushAll();
     PiwikCache::getTransientCache()->flushAll();
     MenuAbstract::clearMenus();
 }
示例#6
0
 /**
  * Triggers the Menu.Top.addItems hook and returns the menu.
  *
  * @return Array
  */
 public function getMenu()
 {
     if (!$this->menu) {
         /**
          * Triggered when collecting all available menu items that are be displayed on the very top of every
          * page, next to the login/logout links.
          * 
          * Subscribe to this event if you want to add one or more items to the top menu.
          * 
          * Menu items should be added via the {@link addEntry()} method.
          *
          * **Example**
          * 
          *     use Piwik\Menu\MenuTop;
          *
          *     public function addMenuItems()
          *     {
          *         MenuTop::addEntry(
          *             'TopMenuName',
          *             array('module' => 'MyPlugin', 'action' => 'index'),
          *             $showOnlyIf = Piwik::isUserIsSuperUser(),
          *             $order = 6
          *         );
          *     }
          */
         Piwik::postEvent('Menu.Top.addItems');
     }
     return parent::getMenu();
 }