MenuTop.php
59 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Matomo - free/libre analytics platform |
| 5 | * |
| 6 | * @link https://matomo.org |
| 7 | * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 8 | */ |
| 9 | namespace Piwik\Menu; |
| 10 | |
| 11 | /** |
| 12 | * Contains menu entries for the Top menu (the menu at the very top of the page). |
| 13 | * Plugins can implement the `configureTopMenu()` method of the `Menu` plugin class to add, rename of remove |
| 14 | * items. If your plugin does not have a `Menu` class yet you can create one using `./console generate:menu`. |
| 15 | * |
| 16 | * @method static \Piwik\Menu\MenuTop getInstance() |
| 17 | */ |
| 18 | class MenuTop extends \Piwik\Menu\MenuAbstract |
| 19 | { |
| 20 | /** |
| 21 | * Directly adds a menu entry containing html. |
| 22 | * |
| 23 | * @param string $menuName |
| 24 | * @param string $data |
| 25 | * @param boolean $displayedForCurrentUser |
| 26 | * @param int $order |
| 27 | * @param string $tooltip Tooltip to display. |
| 28 | * @api |
| 29 | */ |
| 30 | public function addHtml($menuName, $data, $displayedForCurrentUser, $order, $tooltip) |
| 31 | { |
| 32 | if ($displayedForCurrentUser) { |
| 33 | if (!isset($this->menu[$menuName])) { |
| 34 | $this->menu[$menuName]['_name'] = $menuName; |
| 35 | $this->menu[$menuName]['_html'] = $data; |
| 36 | $this->menu[$menuName]['_order'] = $order; |
| 37 | $this->menu[$menuName]['_url'] = null; |
| 38 | $this->menu[$menuName]['_icon'] = ''; |
| 39 | $this->menu[$menuName]['_hasSubmenu'] = \false; |
| 40 | $this->menu[$menuName]['_tooltip'] = $tooltip; |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | /** |
| 45 | * Triggers the Menu.Top.addItems hook and returns the menu. |
| 46 | * |
| 47 | * @return array |
| 48 | */ |
| 49 | public function getMenu() |
| 50 | { |
| 51 | if (!$this->menu) { |
| 52 | foreach ($this->getAllMenus() as $menu) { |
| 53 | $menu->configureTopMenu($this); |
| 54 | } |
| 55 | } |
| 56 | return parent::getMenu(); |
| 57 | } |
| 58 | } |
| 59 |