diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2018-04-30 22:15:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-30 22:15:22 +0300 |
commit | 8d9d5ed8667f9b39560be9bc1db8d09cfe373fba (patch) | |
tree | 32b526dccb3bd91d0e8f19a6134a31517f6b6c9b /core/Menu/MenuAbstract.php | |
parent | 8a76f44f2670921029d6733c9560c1863c99dba6 (diff) |
Add possibility to specify an icon and onclick handler for submenu items (#12791)
Diffstat (limited to 'core/Menu/MenuAbstract.php')
-rw-r--r-- | core/Menu/MenuAbstract.php | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/core/Menu/MenuAbstract.php b/core/Menu/MenuAbstract.php index ca30c02cc7..6ec8d3bcee 100644 --- a/core/Menu/MenuAbstract.php +++ b/core/Menu/MenuAbstract.php @@ -101,10 +101,12 @@ abstract class MenuAbstract extends Singleton * that can be used to build the URL. * @param int $order The order hint. * @param bool|string $tooltip An optional tooltip to display or false to display the tooltip. + * @param bool|string $icon An icon classname, such as "icon-add". Only supported by admin menu + * @param bool|string $onclick Will execute the on click handler instead of executing the link. Only supported by admin menu. * @since 2.7.0 * @api */ - public function addItem($menuName, $subMenuName, $url, $order = 50, $tooltip = false) + public function addItem($menuName, $subMenuName, $url, $order = 50, $tooltip = false, $icon = false, $onclick = false) { // make sure the idSite value used is numeric (hack-y fix for #3426) if (isset($url['idSite']) && !is_numeric($url['idSite'])) { @@ -117,7 +119,9 @@ abstract class MenuAbstract extends Singleton $subMenuName, $url, $order, - $tooltip + $tooltip, + $icon, + $onclick ); } @@ -145,7 +149,7 @@ abstract class MenuAbstract extends Singleton * @param int $order * @param bool|string $tooltip Tooltip to display. */ - private function buildMenuItem($menuName, $subMenuName, $url, $order = 50, $tooltip = false) + private function buildMenuItem($menuName, $subMenuName, $url, $order = 50, $tooltip = false, $icon = false, $onclick = false) { if (!isset($this->menu[$menuName])) { $this->menu[$menuName] = array( @@ -170,6 +174,8 @@ abstract class MenuAbstract extends Singleton $this->menu[$menuName][$subMenuName]['_order'] = $order; $this->menu[$menuName][$subMenuName]['_name'] = $subMenuName; $this->menu[$menuName][$subMenuName]['_tooltip'] = $tooltip; + $this->menu[$menuName][$subMenuName]['_icon'] = $icon; + $this->menu[$menuName][$subMenuName]['_onclick'] = $onclick; $this->menu[$menuName]['_hasSubmenu'] = true; if (!array_key_exists('_tooltip', $this->menu[$menuName])) { @@ -184,7 +190,7 @@ abstract class MenuAbstract extends Singleton private function buildMenu() { foreach ($this->menuEntries as $menuEntry) { - $this->buildMenuItem($menuEntry[0], $menuEntry[1], $menuEntry[2], $menuEntry[3], $menuEntry[4]); + $this->buildMenuItem($menuEntry[0], $menuEntry[1], $menuEntry[2], $menuEntry[3], $menuEntry[4], $menuEntry[5], $menuEntry[6]); } } |