Nighttime commit when I'm tired and want to get this thing checked in and go to bed...
authorAryeh Gregor <simetrical@users.mediawiki.org>
Thu, 20 Mar 2008 01:49:33 +0000 (01:49 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Thu, 20 Mar 2008 01:49:33 +0000 (01:49 +0000)
RELEASE-NOTES
includes/Pager.php
includes/SpecialCategories.php
languages/messages/MessagesEn.php

index cd279b7..6e25693 100644 (file)
@@ -49,6 +49,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Add category table to allow better tracking of category membership counts
 ** (bug 1212) Give correct membership counts on the pages of large categories
 ** Use category table for more efficient display of Special:Categories
+** Allow sorting by number of members on Special:Categories, and also allow
+   descending sorts
 * (bug 1459) Search for duplicate files by hash: Special:FileDuplicateSearch
 
 === Bug fixes in 1.13 ===
index ed7086b..1e5b11c 100644 (file)
@@ -238,13 +238,12 @@ abstract class IndexPager implements Pager {
        /**
         * Make a self-link
         */
-       function makeLink($text, $query = NULL) {
+       function makeLink($text, $query = null) {
                if ( $query === null ) {
                        return $text;
-               } else {
-                       return $this->getSkin()->makeKnownLinkObj( $this->getTitle(), $text,
-                               wfArrayToCGI( $query, $this->getDefaultQuery() ) );
                }
+               return $this->getSkin()->makeKnownLinkObj( $this->getTitle(), $text,
+                               wfArrayToCGI( $query, $this->getDefaultQuery() ) );
        }
 
        /**
index db6ed26..6ffe65b 100644 (file)
@@ -13,7 +13,7 @@ function wfSpecialCategories() {
                $cap->getNavigationBar()
                . '<ul>' . $cap->getBody() . '</ul>' .
                $cap->getNavigationBar()
-               );
+       );
 }
 
 /**
@@ -21,20 +21,42 @@ function wfSpecialCategories() {
  * @addtogroup Pager
  */
 class CategoryPager extends AlphabeticPager {
+       private $mOrderType = 'abc';
+
+       public function __construct() {
+               parent::__construct();
+               if( $this->mRequest->getText( 'order' ) == 'count' ) {
+                       $this->mOrderType = 'count';
+               }
+               if( $this->mRequest->getText( 'direction' ) == 'asc' ) {
+                       $this->mDefaultDirection = false;
+               } elseif( $this->mRequest->getText( 'direction' ) == 'desc'
+               || $this->mOrderType == 'count' ) {
+                       $this->mDefaultDirection = true;
+               }
+       }
+
        function getQueryInfo() {
                global $wgRequest;
                return array(
-                       'tables' => array('category'),
-                       'fields' => array('cat_title','cat_pages')
+                       'tables' => array( 'category' ),
+                       'fields' => array( 'cat_title','cat_pages' ),
+                       'conds' => array( 'cat_pages > 0' )
                );
        }
        
        function getIndexField() {
-               return "cat_title";
+               # We can't use mOrderType here, since this is called from the parent
+               # constructor.  Hmm.
+               if( $this->mRequest->getText( 'order' ) == 'count' ) {
+                       return 'cat_pages';
+               } else {
+                       return "cat_title";
+               }
        }
        
        /* Override getBody to apply LinksBatch on resultset before actually outputting anything. */
-       function getBody() {
+       public function getBody() {
                if (!$this->mQueryDone) {
                        $this->doQuery();
                }
@@ -58,6 +80,39 @@ class CategoryPager extends AlphabeticPager {
                                $wgLang->formatNum( $result->cat_pages ) );
                return Xml::tags('li', null, "$titleText ($count)" ) . "\n";
        }
+
+       /** Override this to order by count */
+       public function getNavigationBar() {
+               $nav = parent::getNavigationBar() . ' (';
+               if( $this->mOrderType == 'abc' ) {
+                       $nav .= $this->makeLink(
+                               wfMsgHTML( 'special-categories-sort-count' ),
+                               array( 'order' => 'count' )
+                       );
+               } else {
+                       $nav .= $this->makeLink(
+                               wfMsgHTML( 'special-categories-sort-abc' ),
+                               array( 'order' => 'abc' )
+                       );
+               }
+               $nav .= ') (';
+               # FIXME, these are stupid query names.  "order" and "dir" are already
+               # used.
+               if( $this->mDefaultDirection ) {
+                       # Descending
+                       $nav .= $this->makeLink(
+                               wfMsgHTML( 'special-categories-sort-asc' ),
+                               array( 'direction' => 'asc' )
+                       );
+               } else {
+                       $nav .= $this->makeLink(
+                               wfMsgHTML( 'special-categories-sort-desc' ),
+                               array( 'direction' => 'desc' )
+                       );
+               }
+               $nav .= ')';
+               return $nav;
+       }
 }
 
 
index f8d9648..7d5f344 100644 (file)
@@ -1738,16 +1738,20 @@ The [http://meta.wikimedia.org/wiki/Help:Job_queue job queue] length is '''\$7''
 'booksources-go'            => 'Go',
 'booksources-text'          => 'Below is a list of links to other sites that sell new and used books, and may also have further information about books you are looking for:',
 
-'categoriespagetext' => 'The following categories contain pages or media.',
-'data'               => 'Data',
-'userrights'         => 'User rights management',
-'userrights-summary' => '', # only translate this message to other languages if you have to change it
-'groups'             => 'User groups',
-'isbn'               => 'ISBN', # only translate this message to other languages if you have to change it
-'rfcurl'             => 'http://tools.ietf.org/html/rfc$1', # don't translate or duplicate this message to other languages
-'pubmedurl'          => 'http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=$1', # don't translate or duplicate this message to other languages
-'alphaindexline'     => '$1 to $2',
-'version'            => 'Version',
+'categoriespagetext'            => 'The following categories contain pages or media.',
+'special-categories-sort-count' => 'sort by count',
+'special-categories-sort-abc'   => 'sort alphabetically',
+'special-categories-sort-asc'   => 'ascending',
+'special-categories-sort-desc'  => 'descending',
+'data'                          => 'Data',
+'userrights'                    => 'User rights management',
+'userrights-summary'            => '', # only translate this message to other languages if you have to change it
+'groups'                        => 'User groups',
+'isbn'                          => 'ISBN', # only translate this message to other languages if you have to change it
+'rfcurl'                        => 'http://tools.ietf.org/html/rfc$1', # don't translate or duplicate this message to other languages
+'pubmedurl'                     => 'http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids=$1', # don't translate or duplicate this message to other languages
+'alphaindexline'                => '$1 to $2',
+'version'                       => 'Version',
 
 # Special:Log
 'specialloguserlabel'  => 'User:',