* @ingroup Pager
*/
abstract class IndexPager extends ContextSource implements Pager {
+ /**
+ * Constants for the $mDefaultDirection field.
+ *
+ * These are boolean for historical reasons and should stay boolean for backwards-compatibility.
+ */
+ const DIR_ASCENDING = false;
+ const DIR_DESCENDING = true;
+
public $mRequest;
public $mLimitsShown = array( 20, 50, 100, 250, 500 );
public $mDefaultLimit = 50;
protected $mOrderType;
/**
* $mDefaultDirection gives the direction to use when sorting results:
- * false for ascending, true for descending. If $mIsBackwards is set, we
+ * DIR_ASCENDING or DIR_DESCENDING. If $mIsBackwards is set, we
* start from the opposite end, but we still sort the page itself according
* to $mDefaultDirection. E.g., if $mDefaultDirection is false but we're
* going backwards, we'll display the last page of results, but the last
$fname = __METHOD__ . ' (' . get_class( $this ) . ')';
wfProfileIn( $fname );
+ // @todo This should probably compare to DIR_DESCENDING and DIR_ASCENDING constants
$descending = ( $this->mIsBackwards == $this->mDefaultDirection );
# Plus an extra row so that we can tell the "next" link should be shown
$queryLimit = $this->mLimit + 1;
}
/**
- * Return the default sorting direction: false for ascending, true for
- * descending. You can also have an associative array of ordertype => dir,
+ * Return the default sorting direction: DIR_ASCENDING or DIR_DESCENDING.
+ * You can also have an associative array of ordertype => dir,
* if multiple order types are supported. In this case getIndexField()
* must return an array, and the keys of that must exactly match the keys
* of this.
* @return bool
*/
protected function getDefaultDirections() {
- return false;
+ return IndexPager::DIR_ASCENDING;
}
}
* @ingroup Pager
*/
abstract class ReverseChronologicalPager extends IndexPager {
- public $mDefaultDirection = true;
+ public $mDefaultDirection = IndexPager::DIR_DESCENDING;
public $mYear;
public $mMonth;
$this->mSort = $this->getDefaultSort();
}
if ( $this->getRequest()->getBool( 'asc' ) ) {
- $this->mDefaultDirection = false;
+ $this->mDefaultDirection = IndexPager::DIR_ASCENDING;
} elseif ( $this->getRequest()->getBool( 'desc' ) ) {
- $this->mDefaultDirection = true;
+ $this->mDefaultDirection = IndexPager::DIR_DESCENDING;
} /* Else leave it at whatever the class default is */
parent::__construct();
if ( $this->mSort == $field ) {
// The table is sorted by this field already, make a link to sort in the other direction
// We don't actually know in which direction other fields will be sorted by default…
- if ( $this->mDefaultDirection ) {
+ if ( $this->mDefaultDirection == IndexPager::DIR_DESCENDING ) {
$linkType = 'asc';
$class = "$sortClass TablePager_sort-descending";
$query['asc'] = '1';
$this->mIndexField = 'am_title';
$this->mPage = $page;
$this->mConds = $conds;
- $this->mDefaultDirection = true; // always sort ascending
+ $this->mDefaultDirection = IndexPager::DIR_ASCENDING;
$this->mLimitsShown = array( 20, 50, 100, 250, 500, 5000 );
global $wgContLang;
function __construct( $page, $conds ) {
$this->page = $page;
$this->conds = $conds;
- $this->mDefaultDirection = true;
+ $this->mDefaultDirection = IndexPager::DIR_ASCENDING;
parent::__construct( $page->getContext() );
}
* @ingroup SpecialPage Pager
*/
class ContribsPager extends ReverseChronologicalPager {
- public $mDefaultDirection = true;
+ public $mDefaultDirection = IndexPager::DIR_ASCENDING;
public $messages;
public $target;
public $namespace = '';
* @ingroup SpecialPage
*/
class DeletedContribsPager extends IndexPager {
- public $mDefaultDirection = true;
+ public $mDefaultDirection = IndexPager::DIR_ASCENDING;
public $messages;
public $target;
public $namespace = '';
if ( !$including ) {
if ( $context->getRequest()->getText( 'sort', 'img_date' ) == 'img_date' ) {
- $this->mDefaultDirection = true;
+ $this->mDefaultDirection = IndexPager::DIR_ASCENDING;
} else {
- $this->mDefaultDirection = false;
+ $this->mDefaultDirection = IndexPager::DIR_DESCENDING;
}
} else {
- $this->mDefaultDirection = true;
+ $this->mDefaultDirection = IndexPager::DIR_ASCENDING;
}
parent::__construct( $context );
$this->editsOnly = $request->getBool( 'editsOnly' );
$this->creationSort = $request->getBool( 'creationSort' );
$this->including = $including;
- $this->mDefaultDirection = $request->getBool( 'desc' );
+ $this->mDefaultDirection = $request->getBool( 'desc' )
+ ? IndexPager::DIR_DESCENDING
+ : IndexPager::DIR_ASCENDING;
$this->requestedUser = '';