From 693b5de895b7430974adb5fbfa7a9f30310d1501 Mon Sep 17 00:00:00 2001 From: Glaisher Date: Mon, 19 Oct 2015 23:00:44 +0500 Subject: [PATCH] Cleanup on Special:AllPages and Special:PrefixIndex * Move pagination links to the left (on LTR) and below the form * Drop a few HTML classes * Minor code cleanups * Remove Allpages link from Special:Allpages pagination links Follows up I720d34e21950c18de3c6e0b1d6d8a4461db495cb Bug: T32965 Change-Id: I19018d87b769320761a95410bb3198b31f16544d --- includes/specials/SpecialAllPages.php | 50 ++++------- includes/specials/SpecialPrefixindex.php | 85 ++++++++++--------- .../mediawiki.special/mediawiki.special.css | 24 ------ 3 files changed, 61 insertions(+), 98 deletions(-) diff --git a/includes/specials/SpecialAllPages.php b/includes/specials/SpecialAllPages.php index 4348b14fbb..0c1a941a9a 100644 --- a/includes/specials/SpecialAllPages.php +++ b/includes/specials/SpecialAllPages.php @@ -100,7 +100,6 @@ class SpecialAllPages extends IncludableSpecialPage { */ function namespaceForm( $namespace = NS_MAIN, $from = '', $to = '', $hideredirects = false ) { $t = $this->getPageTitle(); - $out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) ); $out .= Xml::openElement( 'form', @@ -148,7 +147,6 @@ class SpecialAllPages extends IncludableSpecialPage { $out .= Xml::closeElement( 'fieldset' ); $out .= Xml::closeElement( 'form' ); $out .= Xml::closeElement( 'div' ); - return $out; } @@ -273,14 +271,10 @@ class SpecialAllPages extends IncludableSpecialPage { return; } + $navLinks = array(); $self = $this->getPageTitle(); - $topLinks = array( - Linker::link( $self, $this->msg( 'allpages' )->escaped() ) - ); - $bottomLinks = array(); - - # Do we put a previous link ? + // Generate a "previous page" link if needed if ( $prevTitle ) { $query = array( 'from' => $prevTitle->getText() ); @@ -292,16 +286,16 @@ class SpecialAllPages extends IncludableSpecialPage { $query['hideredirects'] = $hideredirects; } - $prevLink = Linker::linkKnown( + $navLinks[] = Linker::linkKnown( $self, $this->msg( 'prevpage', $prevTitle->getText() )->escaped(), array(), $query ); - $topLinks[] = $prevLink; - $bottomLinks[] = $prevLink; + } + // Generate a "next page" link if needed if ( $n == $this->maxPerPage && $s = $res->fetchObject() ) { # $s is the first link of the next chunk $t = Title::makeTitle( $namespace, $s->page_title ); @@ -315,36 +309,28 @@ class SpecialAllPages extends IncludableSpecialPage { $query['hideredirects'] = $hideredirects; } - $nextLink = Linker::linkKnown( + $navLinks[] = Linker::linkKnown( $self, $this->msg( 'nextpage', $t->getText() )->escaped(), array(), $query ); - $topLinks[] = $nextLink; - $bottomLinks[] = $nextLink; } - $nsForm = $this->namespaceForm( $namespace, $from, $to, $hideredirects ); - $out2 = Xml::openElement( 'table', array( 'class' => 'mw-allpages-table-form' ) ) . - ' - ' . - $nsForm . - ' - ' . - $this->getLanguage()->pipeList( $topLinks ) . - ''; - - $output->addHTML( $out2 . $out ); - - if ( count( $bottomLinks ) ) { - $output->addHTML( - Html::element( 'hr' ) . - Html::rawElement( 'div', array( 'class' => 'mw-allpages-nav' ), - $this->getLanguage()->pipeList( $bottomLinks ) - ) + $topOut = $this->namespaceForm( $namespace, $from, $to, $hideredirects ); + + if ( count( $navLinks ) ) { + // Add pagination links + $pagination = Html::rawElement( 'div', + array( 'class' => 'mw-allpages-nav' ), + $this->getLanguage()->pipeList( $navLinks ) ); + + $topOut .= $pagination; + $out .= Html::element( 'hr' ) . $pagination; // Footer } + + $output->addHTML( $topOut . $out ); } /** diff --git a/includes/specials/SpecialPrefixindex.php b/includes/specials/SpecialPrefixindex.php index bc5dfd0805..fbe5ab39ea 100644 --- a/includes/specials/SpecialPrefixindex.php +++ b/includes/specials/SpecialPrefixindex.php @@ -201,7 +201,7 @@ class SpecialPrefixindex extends SpecialAllPages { ) ); - # ## @todo FIXME: Side link to previous + // @todo FIXME: Side link to previous $n = 0; if ( $res->numRows() > 0 ) { @@ -239,54 +239,55 @@ class SpecialPrefixindex extends SpecialAllPages { } } - $footer = ''; - if ( $this->including() ) { - $out2 = ''; - } else { - $nsForm = $this->namespacePrefixForm( $namespace, $prefix ); - $self = $this->getPageTitle(); - $out2 = Xml::openElement( 'table', array( 'id' => 'mw-prefixindex-nav-table' ) ) . - ' - ' . - $nsForm . - ' - '; - - if ( $res && ( $n == $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) { - $query = array( - 'from' => $s->page_title, - 'prefix' => $prefix, - 'hideredirects' => $this->hideRedirects, - 'stripprefix' => $this->stripPrefix, - ); + $output = $this->getOutput(); - if ( $namespace || $prefix == '' ) { - // Keep the namespace even if it's 0 for empty prefixes. - // This tells us we're not just a holdover from old links. - $query['namespace'] = $namespace; - } + if ( $this->including() ) { + // We don't show the nav-links and the form when included into other + // pages so let's just finish here. + $output->addHTML( $out ); + return; + } - $nextLink = Linker::linkKnown( - $self, - $this->msg( 'nextpage', str_replace( '_', ' ', $s->page_title ) )->escaped(), - array(), - $query - ); + $topOut = $this->namespacePrefixForm( $namespace, $prefix ); - $out2 .= $nextLink; + if ( $res && ( $n == $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) { + $query = array( + 'from' => $s->page_title, + 'prefix' => $prefix, + 'hideredirects' => $this->hideRedirects, + 'stripprefix' => $this->stripPrefix, + ); - $footer = "\n" . Html::element( 'hr' ) . - Html::rawElement( - 'div', - array( 'class' => 'mw-prefixindex-nav' ), - $nextLink - ); + if ( $namespace || $prefix == '' ) { + // Keep the namespace even if it's 0 for empty prefixes. + // This tells us we're not just a holdover from old links. + $query['namespace'] = $namespace; } - $out2 .= "" . - Xml::closeElement( 'table' ); + + $nextLink = Linker::linkKnown( + $this->getPageTitle(), + $this->msg( 'nextpage', str_replace( '_', ' ', $s->page_title ) )->escaped(), + array(), + $query + ); + + // Link shown at the top of the page below the form + $topOut .= Html::rawElement( 'div', + array( 'class' => 'mw-prefixindex-nav' ), + $nextLink + ); + + // Link shown at the footer + $out .= "\n" . Html::element( 'hr' ) . + Html::rawElement( + 'div', + array( 'class' => 'mw-prefixindex-nav' ), + $nextLink + ); + } - $this->getOutput()->addHTML( $out2 . $out . $footer ); + $output->addHTML( $topOut . $out ); } protected function getGroupName() { diff --git a/resources/src/mediawiki.special/mediawiki.special.css b/resources/src/mediawiki.special/mediawiki.special.css index 2b028ae8bb..15f4e4d3d4 100644 --- a/resources/src/mediawiki.special/mediawiki.special.css +++ b/resources/src/mediawiki.special/mediawiki.special.css @@ -28,30 +28,6 @@ font-style: italic; } -/* Special:Allpages */ -.mw-allpages-nav { - text-align: right; - margin-bottom: 1em; -} -table.mw-allpages-table-form { - width: 100%; -} -table.mw-allpages-table-form tr { - vertical-align: top; -} - -/* Special:Prefixindex */ -.mw-prefixindex-nav { - text-align: right; -} -table#mw-prefixindex-nav-table { - width: 100%; -} -td#mw-prefixindex-nav-form { - margin-bottom: 1em; - vertical-align: top; -} - /* Special:Block */ p.mw-ipb-conveniencelinks { font-size: 90%; -- 2.20.1