Remove "Random" page in mobile menu.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Tue, 20 Nov 2018 21:39:42 +0000 (21:39 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Tue, 20 Nov 2018 21:39:42 +0000 (21:39 +0000)
git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/mediawiki_extensions/wrreport/trunk@2786 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wrreport_body.php

index 73cc8083b93c46818f33cc40d3f54fdb3d6968ae..43db28768415aca9d66d32d2524e90a006e4e4ee 100644 (file)
@@ -70,6 +70,8 @@
 //             Just include the sledrun(s) if the condition is fulfilled.
 //
 
+use MobileFrontend\MenuBuilder;
+
 
 // Constants
 // ---------
@@ -1113,6 +1115,25 @@ class WrReport {
 
        public static function MobileMenuHook($name, \MobileFrontend\MenuBuilder &$menu) {
                if ($name === 'discovery') {
+                       // delete "Random page". As a removeEntry function is missing,
+                       // a new menu is built here without the random page.
+                       $new_menu = new MenuBuilder();
+                       foreach ($menu->getEntries() as $menuEntryRepresentation) {
+                               $new_entry_name = $menuEntryRepresentation['name'];
+                               if ($new_entry_name == 'random') continue;
+                               $new_entry_components = $menuEntryRepresentation['components'];
+                               $new_entry_isjsonly = isset($menuEntryRepresentation['class']) and $menuEntryRepresentation['class'] === 'jsonly';
+                               $new_entry = $new_menu->insert($new_entry_name, $new_entry_isjsonly);
+                               foreach ($new_entry_components as $new_entry_component) {
+                                       $label = $new_entry_component['text'];
+                                       $url = $new_entry_component['href'];
+                                       $className = $new_entry_component['class'];
+                                       $new_entry->addComponent($label, $url, $className, $new_entry_components);
+                               }
+                       }
+                       $menu = $new_menu;
+
+                       // add region menu entry
                        $icon = MobileUI::iconClass('random', 'before');
                        $title = Title::newFromText('Region', NS_CATEGORY);
                        $menu->insert('region')->addComponent('Regionen', $title->getLocalURL(), $icon, array('id' => 'regionButton', 'data-event-name' => 'region'));