]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Removing home stub if empty
authorbuttle <chris@gatopelao.org>
Fri, 13 Feb 2015 15:26:41 +0000 (16:26 +0100)
committerbuttle <chris@gatopelao.org>
Fri, 13 Feb 2015 15:26:41 +0000 (16:26 +0100)
Added an Event HomeStubNavItems
menu->subMenu() returns false if empty

EVENTS.txt
lib/homestubnav.php
lib/menu.php

index 197b8afe6fa8a4f033fccb06369018507fabd318..66a86652e96e243e13eb6202aa99c09f3b2a0153 100644 (file)
@@ -1463,3 +1463,12 @@ StartNotifyMentioned: During notice distribution, we send notifications (email,
 EndNotifyMentioned: During notice distribution, we send notifications (email, im...) to the profiles who were somehow mentioned.
 - $stored:         Notice object that is being distributed.
 - $mentioned_ids:  Array of profile IDs (not just for local users) who got mentioned by the notice.
+
+StartHomeStubNavItems: Go back Home nav items. Default includes just one item 'home'
+- $action: action being executed (for output and params)
+- $items: array of items in the nav
+
+EndHomeStubNavItems:
+- $action: action being executed (for output and params)
+- $items: array of items in the nav
+
index d22d1fd16c71b4c557362ac43fc4d575ecceff45..64212f18aaf3c596d8cbe0dd63b21b719361cb3b 100644 (file)
@@ -49,17 +49,18 @@ class HomeStubNav extends Menu
 {
     function getItems()
     {
-        if (Event::handle('StartHomeStubNav', array(&$this->action))) {
-            return array(array('top',
-                               array(),
-                               // TRANS: Menu item in personal group navigation menu.
-                               _m('MENU','Home'),
-                               // TRANS: Menu item title in personal group navigation menu.
-                               // TRANS: %s is a username.
-                               _('Back to top'),
-                               'nav_return_top'));
-            Event::handle('EndHomeStubNav', array(&$this->action));
+        $items = array();
+        if (Event::handle('StartHomeStubNavItems', array($this->action, &$items))) {
+            $items[] = array('top',
+                            array(),
+                            // TRANS: Menu item in personal group navigation menu.
+                            _m('MENU','Home'),
+                            // TRANS: Menu item title in personal group navigation menu.
+                            // TRANS: %s is a username.
+                            _('Back to top'),
+                            'nav_return_top');
+            Event::handle('EndHomeStubNavItems', array($this->action, &$items));
         }
-        return Null;
+        return $items;
     }
 }
index 3d22ff49241c0101a10794041baee0c2cde75e60..4baeb70d2fba6f6667a36ddadf5d3655923bb32f 100644 (file)
@@ -150,8 +150,9 @@ class Menu extends Widget
 
     function submenu($label, $menu)
     {
-        if(!$menu->getItems())
-            return;
+        if (empty($menu->getItems())){
+            return false;
+        }
         $this->action->elementStart('li');
         $this->action->element('h3', null, $label);
         $menu->show();