title = $title; $this->messageLocalizer = $msgLocalizer; $this->pageUser = $userPageHelper->getPageUser(); $this->permissions = $permissions; $this->languagesHelper = $languagesHelper; } /** * @inheritDoc * @throws MWException */ public function getGroup( array $toolbox ): Group { $group = new Group(); if ( $this->permissions->isAllowed( IMinervaPagePermissions::SWITCH_LANGUAGE ) ) { $group->insertEntry( new LanguageSelectorEntry( $this->title, $this->languagesHelper->doesTitleHasLanguagesOrVariants( $this->title ), $this->messageLocalizer, MinervaUI::iconClass( 'language-switcher-base20', 'before', 'minerva-page-actions-language-switcher' ), 'minerva-page-actions-language-switcher' ) ); } $group->insertEntry( $this->build( 'uploads', 'upload', SpecialPage::getTitleFor( 'Uploads', $this->pageUser )->getLocalURL() ) ); $possibleEntries = array_filter( [ $this->buildFromToolbox( 'user-rights', 'userAvatar', '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 PageActionMenuEntry|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 Wikimedia UI icon name. * @param string|null $href * @return PageActionMenuEntry|null */ private function build( $name, $icon, $href ) { return $href ? new PageActionMenuEntry( 'page-actions-overflow-' . $name, $href, MinervaUI::iconClass( '', 'before', 'wikimedia-ui-' . $icon . '-base20' ), $this->messageLocalizer->msg( 'minerva-page-actions-' . $name ), $name ) : null; } }