r32259 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32258‎ | r32259 | r32260 >
Date:21:49, 20 March 2008
Author:simetrical
Status:old
Tags:
Comment:
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).
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Pager.php (modified) (history)
  • /trunk/phase3/includes/SpecialCategories.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -1133,8 +1133,6 @@
11341134 'notargettext',
11351135 'pager-newer-n',
11361136 'pager-older-n',
1137 - 'pager-sort-asc',
1138 - 'pager-sort-desc',
11391137 ),
11401138 'booksources' => array(
11411139 'booksources',
Index: trunk/phase3/includes/SpecialCategories.php
@@ -17,6 +17,9 @@
1818 }
1919
2020 /**
 21+ * TODO: Allow sorting by count. We need to have a unique index to do this
 22+ * properly.
 23+ *
2124 * @addtogroup SpecialPage
2225 * @addtogroup Pager
2326 */
@@ -31,16 +34,18 @@
3235 }
3336
3437 function getIndexField() {
35 - return array( 'abc' => 'cat_title', 'count' => 'cat_pages' );
 38+# return array( 'abc' => 'cat_title', 'count' => 'cat_pages' );
 39+ return 'cat_title';
3640 }
3741
38 - protected function getOrderTypeMessages() {
39 - return array( 'abc' => 'special-categories-sort-abc',
40 - 'count' => 'special-categories-sort-count' );
41 - }
 42+# protected function getOrderTypeMessages() {
 43+# return array( 'abc' => 'special-categories-sort-abc',
 44+# 'count' => 'special-categories-sort-count' );
 45+# }
4246
43 - protected function getDefaultDirection() {
44 - return array( 'abc' => false, 'count' => true );
 47+ protected function getDefaultDirections() {
 48+# return array( 'abc' => false, 'count' => true );
 49+ return false;
4550 }
4651
4752 /* Override getBody to apply LinksBatch on resultset before actually outputting anything. */
Index: trunk/phase3/includes/Pager.php
@@ -75,9 +75,8 @@
7676 * going backwards, we'll display the last page of results, but the last
7777 * result will be at the bottom, not the top.
7878 *
79 - * "Default" is really a misnomer here, since now it's possible for the
80 - * user to directly modify this with query parameters. TODO: rename that
81 - * to $mDescending, maybe set this to that by reference for compatibility.
 79+ * Like $mIndexField, $mDefaultDirection will be a single value even if the
 80+ * class supports multiple default directions for different order types.
8281 */
8382 public $mDefaultDirection;
8483 public $mIsBackwards;
@@ -119,20 +118,11 @@
120119 }
121120
122121 if( !isset( $this->mDefaultDirection ) ) {
123 - $dir = $this->getDefaultDirection();
 122+ $dir = $this->getDefaultDirections();
124123 $this->mDefaultDirection = is_array( $dir )
125124 ? $dir[$this->mOrderType]
126125 : $dir;
127126 }
128 -
129 - # FIXME: Can we figure out a less confusing convention than using a
130 - # "direction" parameter when we already have "dir" and "order"?
131 - if( $this->mRequest->getVal( 'direction' ) == 'asc' ) {
132 - $this->mDefaultDirection = false;
133 - }
134 - if( $this->mRequest->getVal( 'direction' ) == 'desc' ) {
135 - $this->mDefaultDirection = true;
136 - }
137127 }
138128
139129 /**
@@ -345,7 +335,6 @@
346336 unset( $this->mDefaultQuery['dir'] );
347337 unset( $this->mDefaultQuery['offset'] );
348338 unset( $this->mDefaultQuery['limit'] );
349 - unset( $this->mDefaultQuery['direction'] );
350339 unset( $this->mDefaultQuery['order'] );
351340 }
352341 return $this->mDefaultQuery;
@@ -362,7 +351,7 @@
363352 }
364353
365354 /**
366 - * Get a query array for the prev, next, first and last links.
 355+ * Get a URL query array for the prev, next, first and last links.
367356 */
368357 function getPagingQueries() {
369358 if ( !$this->mQueryDone ) {
@@ -449,6 +438,9 @@
450439 * 'querykey' => 'indexfield' pairs, so that a request with &count=querykey
451440 * will use indexfield to sort. In this case, the first returned key is
452441 * the default.
 442+ *
 443+ * Needless to say, it's really not a good idea to use a non-unique index
 444+ * for this! That won't page right.
453445 */
454446 abstract function getIndexField();
455447
@@ -464,12 +456,12 @@
465457 * called, for instance if it's statically initialized. In that case the
466458 * value of that variable (which must be a boolean) will be used.
467459 *
468 - * Note that despite its name, this does not return the value of the now-
469 - * misnamed $this->mDefaultDirection member variable. That is not a
470 - * default, it's the actual direction used. This is just the default and
471 - * can be overridden by user input.
 460+ * Note that despite its name, this does not return the value of the
 461+ * $this->mDefaultDirection member variable. That's the default for this
 462+ * particular instantiation, which is a single value. This is the set of
 463+ * all defaults for the class.
472464 */
473 - protected function getDefaultDirection() { return false; }
 465+ protected function getDefaultDirections() { return false; }
474466 }
475467
476468
@@ -483,7 +475,7 @@
484476 }
485477
486478 /**
487 - * Shamelessly stolen bits from ReverseChronologicalPager, d
 479+ * Shamelessly stolen bits from ReverseChronologicalPager,
488480 * didn't want to do class magic as may be still revamped
489481 */
490482 function getNavigationBar() {
@@ -509,27 +501,6 @@
510502 wfMsgHtml( 'viewprevnext', $pagingLinks['prev'],
511503 $pagingLinks['next'], $limits );
512504
513 - /*
514 - $dirlinks = array();
515 - # Note for grep: uses pager-sort-asc, pager-sort-desc (each in two
516 - # places)
517 - foreach( array( 'asc', 'desc' ) as $dir ) {
518 - if( ($this->mDefaultDirection ? 'desc' : 'asc' ) == $dir ) {
519 - # Don't print a link, just some text
520 - $dirlinks[$dir] = wfMsgHTML( "pager-sort-$dir" );
521 - } else {
522 - $query = array( 'direction' => $dir );
523 - if( $this->mOrderType !== null ) {
524 - $query['order'] = $this->mOrderType;
525 - }
526 - $dirlinks[$dir] = $this->makeLink(
527 - wfMsgHTML( "pager-sort-$dir" ),
528 - $query
529 - );
530 - }
531 - }
532 - $this->mNavigationBar .= ' (' . implode( ' | ', $dirlinks ) . ')';
533 -
534505 if( !is_array( $this->getIndexField() ) ) {
535506 # Early return to avoid undue nesting
536507 return $this->mNavigationBar;
@@ -558,7 +529,6 @@
559530 if( $extra !== '' ) {
560531 $this->mNavigationBar .= " ($extra)";
561532 }
562 - */
563533
564534 return $this->mNavigationBar;
565535 }
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1729,8 +1729,6 @@
17301730 'notargettext' => 'You have not specified a target page or user to perform this function on.',
17311731 'pager-newer-n' => '{{PLURAL:$1|newer 1|newer $1}}',
17321732 'pager-older-n' => '{{PLURAL:$1|older 1|older $1}}',
1733 -'pager-sort-asc' => 'ascending',
1734 -'pager-sort-desc' => 'descending',
17351733
17361734 # Book sources
17371735 'booksources' => 'Book sources',
Index: trunk/phase3/RELEASE-NOTES
@@ -49,11 +49,7 @@
5050 * Add category table to allow better tracking of category membership counts
5151 ** (bug 1212) Give correct membership counts on the pages of large categories
5252 ** Use category table for more efficient display of Special:Categories
53 -** Allow sorting by number of members on Special:Categories
5453 * (bug 1459) Search for duplicate files by hash: Special:FileDuplicateSearch
55 -* Allow the user to choose whether to use a descending or ascending sort in
56 - AlphabeticPager-based special pages (Categories, Listusers, Protectedpages/
57 - titles).
5854
5955 === Bug fixes in 1.13 ===
6056

Status & tagging log