messageLocalizer = $messageLocalizer; $this->permissions = $permissions; } /** * @inheritDoc */ public function getGroup( array $toolbox, array $actions ): Group { $group = new Group( 'p-tb' ); // T285567: Make sure admins can unprotect the page afterwards $permissionChangeAction = array_key_exists( 'unprotect', $actions ) ? $this->build( 'unprotect', 'unLock', 'unprotect', $actions ) : $this->build( 'protect', 'lock', 'protect', $actions ); $possibleEntries = array_filter( [ $this->build( 'info', 'infoFilled', 'info', $toolbox ), $this->build( 'permalink', 'link', 'permalink', $toolbox ), $this->build( 'backlinks', 'articleRedirect', 'whatlinkshere', $toolbox ), $this->build( 'wikibase', 'logoWikidata', 'wikibase', $toolbox ), $this->build( 'cite', 'quotes', 'citethispage', $toolbox ), $this->permissions->isAllowed( IMinervaPagePermissions::MOVE ) ? $this->build( 'move', 'move', 'move', $actions ) : null, $this->permissions->isAllowed( IMinervaPagePermissions::DELETE ) ? $this->build( 'delete', 'trash', 'delete', $actions ) : null, $this->permissions->isAllowed( IMinervaPagePermissions::PROTECT ) ? $permissionChangeAction : null ] ); foreach ( $possibleEntries as $menuEntry ) { $group->insertEntry( $menuEntry ); } return $group; } /** * Build the single menu entry * * @param string $name * @param string $icon WikimediaUI icon name. * @param string $toolboxIdx * @param array $toolbox An array of common toolbox items from the sidebar menu * @return IMenuEntry|null */ private function build( $name, $icon, $toolboxIdx, array $toolbox ) { $href = $toolbox[$toolboxIdx]['href'] ?? null; return $href ? SingleMenuEntry::create( 'page-actions-overflow-' . $name, $this->messageLocalizer->msg( 'minerva-page-actions-' . $name )->text(), $href )->setIcon( $icon, 'before' ) ->trackClicks( $name ) : null; } }