Cleanup on Special:AllPages and Special:PrefixIndex
authorGlaisher <glaisher.wiki@gmail.com>
Mon, 19 Oct 2015 18:00:44 +0000 (23:00 +0500)
committerGlaisher <glaisher.wiki@gmail.com>
Thu, 22 Oct 2015 17:28:47 +0000 (22:28 +0500)
* 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
includes/specials/SpecialPrefixindex.php
resources/src/mediawiki.special/mediawiki.special.css

index 4348b14..0c1a941 100644 (file)
@@ -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' ) ) .
-                       '<tr>
-                                               <td>' .
-                       $nsForm .
-                       '</td>
-                                               <td class="mw-allpages-nav">' .
-                       $this->getLanguage()->pipeList( $topLinks ) .
-                       '</td></tr></table>';
-
-               $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 );
        }
 
        /**
index bc5dfd0..fbe5ab3 100644 (file)
@@ -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' ) ) .
-                               '<tr>
-                                       <td>' .
-                               $nsForm .
-                               '</td>
-                               <td id="mw-prefixindex-nav-form" class="mw-prefixindex-nav">';
-
-                       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 .= "</td></tr>" .
-                               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() {
index 2b028ae..15f4e4d 100644 (file)
        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%;