X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fpager%2FIndexPager.php;h=9398e30fff757cb84a55fc427ca79912c7739478;hb=64d5264dc58fbede0e971fd813b8ba90887d9ddb;hp=1d93c27f68a25bcd925b9d3143dc14f62ea65bcb;hpb=253dbff3224d38c7af0986f949f9b248a3d4e0dc;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/pager/IndexPager.php b/includes/pager/IndexPager.php index 1d93c27f68..9398e30fff 100644 --- a/includes/pager/IndexPager.php +++ b/includes/pager/IndexPager.php @@ -64,6 +64,14 @@ * @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; @@ -87,7 +95,7 @@ abstract class IndexPager extends ContextSource implements Pager { 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 @@ -190,6 +198,7 @@ abstract class IndexPager extends ContextSource implements Pager { $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; @@ -447,8 +456,8 @@ abstract class IndexPager extends ContextSource implements Pager { * * @param string $text Text displayed on the link * @param array $query Associative array of parameter to be in the query string - * @param string $type Value of the "rel" attribute - * + * @param string $type Link type used to create additional attributes, like "rel", "class" or + * "title". Valid values (non-exhaustive list): 'first', 'last', 'prev', 'next', 'asc', 'desc'. * @return string HTML fragment */ function makeLink( $text, array $query = null, $type = null ) { @@ -457,11 +466,14 @@ abstract class IndexPager extends ContextSource implements Pager { } $attrs = array(); - if ( in_array( $type, array( 'first', 'prev', 'next', 'last' ) ) ) { - # HTML5 rel attributes + if ( in_array( $type, array( 'prev', 'next' ) ) ) { $attrs['rel'] = $type; } + if ( in_array( $type, array( 'asc', 'desc' ) ) ) { + $attrs['title'] = wfMessage( $type == 'asc' ? 'sort-ascending' : 'sort-descending' )->text(); + } + if ( $type ) { $attrs['class'] = "mw-{$type}link"; } @@ -705,8 +717,8 @@ abstract class IndexPager extends ContextSource implements Pager { } /** - * 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. @@ -724,6 +736,6 @@ abstract class IndexPager extends ContextSource implements Pager { * @return bool */ protected function getDefaultDirections() { - return false; + return IndexPager::DIR_ASCENDING; } }