showMobileOptions = $showMobileOptions; $this->showDonateLink = $showDonateLink; $this->user = $user; $this->definitions = $definitions; } /** * @inheritDoc */ public function getDiscoveryGroup( array $navigationTools ): Group { return BuilderUtil::getDiscoveryTools( $this->definitions, $navigationTools ); } /** * @inheritDoc */ public function getDonateGroup(): Group { return BuilderUtil::getDonateGroup( $this->definitions, $this->showDonateLink ); } /** * @inheritDoc */ public function getInteractionToolsGroup(): Group { return new Group( 'p-interaction' ); } /** * @inheritDoc * @throws MWException */ public function getSiteLinks(): Group { return BuilderUtil::getSiteLinks( $this->definitions ); } /** * Builds the personal tools menu item group. * * ... by adding the Watchlist, Settings, and Log{in,out} menu items in the given order. * * @inheritDoc */ public function getPersonalToolsGroup( array $personalTools ): Group { $group = new Group( 'p-personal' ); // special casing for now to support Extension:GrowthExperiments $userpage = $personalTools[ 'userpage' ] ?? null; // Check if it exists. In future Extension:GrowthExperiments can unset // this and replace it with homepage key. if ( $userpage ) { $this->definitions->insertAuthMenuItem( $group ); } // Note `homepage` is reserved for Extension:GrowthExperiments usage $include = [ 'homepage', 'login', 'watchlist', 'mycontris', 'preferences', 'logout' ]; $trackingKeyOverrides = [ 'watchlist' => 'unStar', 'mycontris' => 'contributions', ]; foreach ( $include as $key ) { $item = $personalTools[ $key ] ?? null; if ( $item ) { // Substitute preference if $showMobileOptions is set. if ( $this->showMobileOptions && $key === 'preferences' ) { $this->definitions->insertMobileOptionsItem( $group ); } else { $icon = $item['icon'] ?? null; $entry = SingleMenuEntry::create( $key, $item['text'], $item['href'], $item['class'] ?? '', $icon ); // override tracking key where key mismatch if ( array_key_exists( $key, $trackingKeyOverrides ) ) { $entry->trackClicks( $trackingKeyOverrides[ $key ] ); } $group->insertEntry( $entry ); } } } // Allow other extensions to add or override tools Hooks::run( 'MobileMenu', [ 'personal', &$group ] ); return $group; } }