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 */ public function getSiteLinks(): Group { return BuilderUtil::getSiteLinks( $this->definitions ); } /** * Builds the anonymous settings group. * * @inheritDoc */ public function getSettingsGroup(): Group { $group = new Group( 'pt-preferences' ); // Show settings group for anon and temp users $userIdentityUtils = MediaWikiServices::getInstance()->getUserIdentityUtils(); $isTemp = $userIdentityUtils->isTemp( $this->user ); if ( $this->showMobileOptions && ( !$this->user->isRegistered() || $isTemp ) ) { $this->definitions->insertMobileOptionsItem( $group ); } return $group; } /** * 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' ); $excludeKeyList = [ 'betafeatures', 'mytalk', 'sandbox' ]; // For anonymous users exclude all links except login. if ( !$this->user->isRegistered() ) { $excludeKeyList = array_diff( array_keys( $personalTools ), [ 'login' ] ); } $userIdentityUtils = MediaWikiServices::getInstance()->getUserIdentityUtils(); $isTemp = $userIdentityUtils->isTemp( $this->user ); if ( $isTemp ) { $excludeKeyList[] = 'mycontris'; } foreach ( $personalTools as $key => $item ) { $href = $item['href'] ?? null; if ( $href && !in_array( $key, $excludeKeyList ) ) { // 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'], $href, $item['class'] ?? '', $icon ); $entry->trackClicks( $key ); $group->insertEntry( $entry ); } } } return $group; } }