* 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 ===
/**
* 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() ) );
}
/**
$cap->getNavigationBar()
. '<ul>' . $cap->getBody() . '</ul>' .
$cap->getNavigationBar()
- );
+ );
}
/**
* @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();
}
$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;
+ }
}
'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:',