From ea3c2daa4c6b793030ba49b53a04d118a70d25bd Mon Sep 17 00:00:00 2001 From: "H. C. Kruse" <6594492+octfx@users.noreply.github.com> Date: Wed, 27 Jan 2021 22:53:01 +0100 Subject: [PATCH] feat: move some toolbox links into the drawer (#241) * feat: Move some toolbox links into the drawer * ci: lint code to MediaWiki standards Check commit and GitHub actions for more details Co-authored-by: github-actions --- includes/SkinCitizen.php | 44 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/includes/SkinCitizen.php b/includes/SkinCitizen.php index 2edccfe6..239ab057 100644 --- a/includes/SkinCitizen.php +++ b/includes/SkinCitizen.php @@ -334,7 +334,6 @@ class SkinCitizen extends SkinMustache { switch ( $name ) { case 'SEARCH': - break; case 'TOOLBOX': break; case 'LANGUAGES': @@ -371,10 +370,15 @@ class SkinCitizen extends SkinMustache { } $firstPortal = $props[0] ?? null; + if ( $firstPortal ) { $firstPortal[ 'class' ] .= ' portal-first'; // Hide label for first portal $firstPortal[ 'label-class' ] .= 'screen-reader-text'; + + if ( isset( $firstPortal['html-items'] ) ) { + $this->addToolboxLinksToDrawer( $firstPortal['html-items'] ); + } } return [ @@ -385,6 +389,44 @@ class SkinCitizen extends SkinMustache { ]; } + /** + * @inheritDoc + * + * Manually disable links to upload and speacial pages + * as they are moved from the toolbox to the drawer + * + * @return array + */ + protected function buildNavUrls() { + $urls = parent::buildNavUrls(); + + $urls['upload'] = false; + $urls['specialpages'] = false; + + return $urls; + } + + /** + * Add a link to special pages and the upload form to the first portal in the drawer + * + * @param string &$htmlItems + * + * @return void + */ + private function addToolboxLinksToDrawer( &$htmlItems ) { + // First add a link to special pages + $htmlItems .= $this->makeListItem( 'specialpages', [ + 'href' => self::makeSpecialUrl( 'specialpages' ), + 'id' => 't-specialpages' + ] ); + + // Then add a link to the upload form + $htmlItems .= $this->makeListItem( 'upload', [ + 'href' => self::makeSpecialUrl( 'upload' ), + 'id' => 't-upload' + ] ); + } + /** * Build Personal Tools menu *