insertDonateItem( $group ); } return $group; } /** * Prepares a list of links that have the purpose of discovery in the main navigation menu * @param Definitions $definitions A menu items definitions set * @param array $navigationTools * @return Group * @throws FatalError * @throws MWException */ public static function getDiscoveryTools( Definitions $definitions, array $navigationTools ): Group { $group = new Group( 'p-navigation' ); $entryDefinitions = [ 'n-mainpage-description' => [ 'name' => 'home', 'text' => $definitions->msg( 'mobile-frontend-home-button' ), 'icon' => 'home', 'class' => '', 'href' => Title::newMainPage()->getLocalURL(), ], 'n-randompage' => [ 'name' => 'random', 'text' => $definitions->msg( 'mobile-frontend-random-button' ), 'icon' => 'die', 'class' => '', 'href' => SpecialPage::getTitleFor( 'Randompage' )->getLocalURL(), ], ]; // Run through navigation tools and update if needed. foreach ( $navigationTools as $item ) { $id = $item['id'] ?? null; if ( $id && isset( $entryDefinitions[ $id ] ) ) { foreach ( [ 'icon', 'class', 'href', 'msg' ] as $overridableKey ) { $override = $item[ $overridableKey ] ?? null; if ( $override ) { $entryDefinitions[$id][$overridableKey] = $override; } } } } // Build the menu foreach ( $entryDefinitions as $definition ) { $msgKey = $definition['msg'] ?? null; $text = null; if ( $msgKey ) { $msg = $definitions->msg( $msgKey ); $text = $msg->exists() ? $msg->text() : null; } if ( !$text ) { $text = $definition['text']; } $entry = SingleMenuEntry::create( $definition['name'], $text, $definition['href'], $definition['class'], $definition['icon'] ); $group->insertEntry( $entry ); } $definitions->insertNearbyIfSupported( $group ); // Allow other extensions to add or override tools Hooks::run( 'MobileMenu', [ 'discovery', &$group ] ); return $group; } /** * Like SkinMinerva#getDiscoveryTools and #getPersonalTools, create * a group of configuration-related menu items. Currently, only the Settings menu item is in the * group. * @param Definitions $definitions A menu items definitions set * @param bool $showMobileOptions Show MobileOptions instead of Preferences * @return Group * @throws MWException */ public static function getConfigurationTools( Definitions $definitions, $showMobileOptions ): Group { $group = new Group( 'pt-preferences' ); $showMobileOptions ? $definitions->insertMobileOptionsItem( $group ) : $definitions->insertPreferencesItem( $group ); return $group; } /** * Returns an array of sitelinks to add into the main menu footer. * @param Definitions $definitions A menu items definitions set * @return Group Collection of site links * @throws MWException */ public static function getSiteLinks( Definitions $definitions ): Group { $group = new Group( 'p-minerva-sitelinks' ); $definitions->insertAboutItem( $group ); $definitions->insertDisclaimersItem( $group ); // Allow other extensions to add or override tools Hooks::run( 'MobileMenu', [ 'sitelinks', &$group ] ); return $group; } }