From bdf9431795aa7f403f93775b73492e7839f34ce3 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Thu, 20 Mar 2008 21:49:22 +0000 Subject: [PATCH] Remove the functionality allowing users to change the default direction; this is basically redundant with first/last. Uncomment the multiple-ordering stuff in Pager.php, since it works fine, but comment it out in SpecialCategories.php, since the index is not unique and it won't sort correctly. IndexPager needs to support multiple-column sort, and the index should be extended to (cat_pages, cat_title). --- RELEASE-NOTES | 4 --- includes/Pager.php | 56 +++++++------------------------ includes/SpecialCategories.php | 19 +++++++---- languages/messages/MessagesEn.php | 2 -- maintenance/language/messages.inc | 2 -- 5 files changed, 25 insertions(+), 58 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index a64df70708..cfa8208c55 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -49,11 +49,7 @@ 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 * (bug 1459) Search for duplicate files by hash: Special:FileDuplicateSearch -* Allow the user to choose whether to use a descending or ascending sort in - AlphabeticPager-based special pages (Categories, Listusers, Protectedpages/ - titles). === Bug fixes in 1.13 === diff --git a/includes/Pager.php b/includes/Pager.php index 422121bec8..189bd955a2 100644 --- a/includes/Pager.php +++ b/includes/Pager.php @@ -75,9 +75,8 @@ abstract class IndexPager implements Pager { * going backwards, we'll display the last page of results, but the last * result will be at the bottom, not the top. * - * "Default" is really a misnomer here, since now it's possible for the - * user to directly modify this with query parameters. TODO: rename that - * to $mDescending, maybe set this to that by reference for compatibility. + * Like $mIndexField, $mDefaultDirection will be a single value even if the + * class supports multiple default directions for different order types. */ public $mDefaultDirection; public $mIsBackwards; @@ -119,20 +118,11 @@ abstract class IndexPager implements Pager { } if( !isset( $this->mDefaultDirection ) ) { - $dir = $this->getDefaultDirection(); + $dir = $this->getDefaultDirections(); $this->mDefaultDirection = is_array( $dir ) ? $dir[$this->mOrderType] : $dir; } - - # FIXME: Can we figure out a less confusing convention than using a - # "direction" parameter when we already have "dir" and "order"? - if( $this->mRequest->getVal( 'direction' ) == 'asc' ) { - $this->mDefaultDirection = false; - } - if( $this->mRequest->getVal( 'direction' ) == 'desc' ) { - $this->mDefaultDirection = true; - } } /** @@ -345,7 +335,6 @@ abstract class IndexPager implements Pager { unset( $this->mDefaultQuery['dir'] ); unset( $this->mDefaultQuery['offset'] ); unset( $this->mDefaultQuery['limit'] ); - unset( $this->mDefaultQuery['direction'] ); unset( $this->mDefaultQuery['order'] ); } return $this->mDefaultQuery; @@ -362,7 +351,7 @@ abstract class IndexPager implements Pager { } /** - * Get a query array for the prev, next, first and last links. + * Get a URL query array for the prev, next, first and last links. */ function getPagingQueries() { if ( !$this->mQueryDone ) { @@ -449,6 +438,9 @@ abstract class IndexPager implements Pager { * 'querykey' => 'indexfield' pairs, so that a request with &count=querykey * will use indexfield to sort. In this case, the first returned key is * the default. + * + * Needless to say, it's really not a good idea to use a non-unique index + * for this! That won't page right. */ abstract function getIndexField(); @@ -464,12 +456,12 @@ abstract class IndexPager implements Pager { * called, for instance if it's statically initialized. In that case the * value of that variable (which must be a boolean) will be used. * - * Note that despite its name, this does not return the value of the now- - * misnamed $this->mDefaultDirection member variable. That is not a - * default, it's the actual direction used. This is just the default and - * can be overridden by user input. + * Note that despite its name, this does not return the value of the + * $this->mDefaultDirection member variable. That's the default for this + * particular instantiation, which is a single value. This is the set of + * all defaults for the class. */ - protected function getDefaultDirection() { return false; } + protected function getDefaultDirections() { return false; } } @@ -483,7 +475,7 @@ abstract class AlphabeticPager extends IndexPager { } /** - * Shamelessly stolen bits from ReverseChronologicalPager, d + * Shamelessly stolen bits from ReverseChronologicalPager, * didn't want to do class magic as may be still revamped */ function getNavigationBar() { @@ -509,27 +501,6 @@ abstract class AlphabeticPager extends IndexPager { wfMsgHtml( 'viewprevnext', $pagingLinks['prev'], $pagingLinks['next'], $limits ); - /* - $dirlinks = array(); - # Note for grep: uses pager-sort-asc, pager-sort-desc (each in two - # places) - foreach( array( 'asc', 'desc' ) as $dir ) { - if( ($this->mDefaultDirection ? 'desc' : 'asc' ) == $dir ) { - # Don't print a link, just some text - $dirlinks[$dir] = wfMsgHTML( "pager-sort-$dir" ); - } else { - $query = array( 'direction' => $dir ); - if( $this->mOrderType !== null ) { - $query['order'] = $this->mOrderType; - } - $dirlinks[$dir] = $this->makeLink( - wfMsgHTML( "pager-sort-$dir" ), - $query - ); - } - } - $this->mNavigationBar .= ' (' . implode( ' | ', $dirlinks ) . ')'; - if( !is_array( $this->getIndexField() ) ) { # Early return to avoid undue nesting return $this->mNavigationBar; @@ -558,7 +529,6 @@ abstract class AlphabeticPager extends IndexPager { if( $extra !== '' ) { $this->mNavigationBar .= " ($extra)"; } - */ return $this->mNavigationBar; } diff --git a/includes/SpecialCategories.php b/includes/SpecialCategories.php index 38996dcd4a..a653d2a0b9 100644 --- a/includes/SpecialCategories.php +++ b/includes/SpecialCategories.php @@ -17,6 +17,9 @@ function wfSpecialCategories() { } /** + * TODO: Allow sorting by count. We need to have a unique index to do this + * properly. + * * @addtogroup SpecialPage * @addtogroup Pager */ @@ -31,16 +34,18 @@ class CategoryPager extends AlphabeticPager { } function getIndexField() { - return array( 'abc' => 'cat_title', 'count' => 'cat_pages' ); +# return array( 'abc' => 'cat_title', 'count' => 'cat_pages' ); + return 'cat_title'; } - protected function getOrderTypeMessages() { - return array( 'abc' => 'special-categories-sort-abc', - 'count' => 'special-categories-sort-count' ); - } +# protected function getOrderTypeMessages() { +# return array( 'abc' => 'special-categories-sort-abc', +# 'count' => 'special-categories-sort-count' ); +# } - protected function getDefaultDirection() { - return array( 'abc' => false, 'count' => true ); + protected function getDefaultDirections() { +# return array( 'abc' => false, 'count' => true ); + return false; } /* Override getBody to apply LinksBatch on resultset before actually outputting anything. */ diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 45cb2aecc2..4adff06405 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -1729,8 +1729,6 @@ The [http://meta.wikimedia.org/wiki/Help:Job_queue job queue] length is '''\$7'' 'notargettext' => 'You have not specified a target page or user to perform this function on.', 'pager-newer-n' => '{{PLURAL:$1|newer 1|newer $1}}', 'pager-older-n' => '{{PLURAL:$1|older 1|older $1}}', -'pager-sort-asc' => 'ascending', -'pager-sort-desc' => 'descending', # Book sources 'booksources' => 'Book sources', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index ef7f956068..0c57380688 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -1133,8 +1133,6 @@ $wgMessageStructure = array( 'notargettext', 'pager-newer-n', 'pager-older-n', - 'pager-sort-asc', - 'pager-sort-desc', ), 'booksources' => array( 'booksources', -- 2.20.1