title = $title; $this->messageLocalizer = $msgLocalizer; $this->permissions = $permissions; $this->languagesHelper = $languagesHelper; } /** * @inheritDoc * @throws MWException */ public function getGroup( array $toolbox, array $actions ): Group { $group = new Group( 'p-tb' ); if ( $this->permissions->isAllowed( IMinervaPagePermissions::SWITCH_LANGUAGE ) ) { $group->insertEntry( new LanguageSelectorEntry( $this->title, $this->languagesHelper->doesTitleHasLanguagesOrVariants( $this->title ), $this->messageLocalizer, MinervaUI::iconClass( 'language-base20', 'before', 'minerva-page-actions-language-switcher', 'wikimedia' ), 'minerva-page-actions-language-switcher' ) ); } $possibleEntries = array_filter( [ $this->buildFromToolbox( 'user-groups', 'userGroup', 'userrights', $toolbox ), $this->buildFromToolbox( 'logs', 'listBullet', 'log', $toolbox ), $this->buildFromToolbox( 'info', 'infoFilled', 'info', $toolbox ), $this->buildFromToolbox( 'permalink', 'link', 'permalink', $toolbox ), $this->buildFromToolbox( 'backlinks', 'articleRedirect', 'whatlinkshere', $toolbox ) ] ); foreach ( $possibleEntries as $menuEntry ) { $group->insertEntry( $menuEntry ); } Hooks::run( 'MobileMenu', [ 'pageactions.overflow', &$group ] ); return $group; } /** * Build entry based on the $toolbox element * * @param string $name * @param string $icon Icon CSS class name. * @param string $toolboxIdx * @param array $toolbox An array of common toolbox items from the sidebar menu * @return IMenuEntry|null */ private function buildFromToolbox( $name, $icon, $toolboxIdx, array $toolbox ) { return $this->build( $name, $icon, $toolbox[$toolboxIdx]['href'] ?? null ); } /** * Build single Menu entry * * @param string $name * @param string $icon WikimediaUI icon name. * @param string|null $href * @return IMenuEntry|null */ private function build( $name, $icon, $href ) { return $href ? SingleMenuEntry::create( 'page-actions-overflow-' . $name, $this->messageLocalizer->msg( 'minerva-page-actions-' . $name )->text(), $href )->setIcon( $icon, 'before' ) ->trackClicks( $name ) : null; } }