From: Aryeh Gregor Date: Thu, 20 Mar 2008 01:49:33 +0000 (+0000) Subject: Nighttime commit when I'm tired and want to get this thing checked in and go to bed... X-Git-Tag: 1.31.0-rc.0~48960 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=f13cec37db8a04aa8115648b1a61023b34a5defd;p=lhc%2Fweb%2Fwiklou.git Nighttime commit when I'm tired and want to get this thing checked in and go to bed! Yay! Allow sorting by number of members on Special:Categories, and also allow descending sorts. Mostlinkedcategories should be killed and turned into a redirect to this. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index cd279b71e5..6e25693854 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/Pager.php b/includes/Pager.php index ed7086b44b..1e5b11cc7c 100644 --- a/includes/Pager.php +++ b/includes/Pager.php @@ -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() ) ); } /** diff --git a/includes/SpecialCategories.php b/includes/SpecialCategories.php index db6ed26ab7..6ffe65b453 100644 --- a/includes/SpecialCategories.php +++ b/includes/SpecialCategories.php @@ -13,7 +13,7 @@ function wfSpecialCategories() { $cap->getNavigationBar() . '' . $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; + } } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index f8d964862b..7d5f344bb0 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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:',