IndexPager: Wrap inactive paging links in <span class="…">
Bug: T308364 Change-Id: Icf3597604ea100b2fce2f47fe5057cbfd12b96ed
This commit is contained in:
parent
94553a1bcb
commit
b95d208340
1 changed files with 21 additions and 22 deletions
|
|
@ -669,18 +669,15 @@ abstract class IndexPager extends ContextSource implements Pager {
|
|||
* @stable to override
|
||||
*
|
||||
* @param string $text Text displayed on the link
|
||||
* @param array|null $query Associative array of parameter to be in the query string
|
||||
* @param array|null $query Associative array of parameter to be in the query string.
|
||||
* If null, no link is generated.
|
||||
* @param string|null $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
|
||||
*/
|
||||
protected function makeLink( $text, array $query = null, $type = null ) {
|
||||
if ( $query === null ) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
$attrs = [];
|
||||
if ( in_array( $type, [ 'prev', 'next' ] ) ) {
|
||||
if ( $query !== null && in_array( $type, [ 'prev', 'next' ] ) ) {
|
||||
$attrs['rel'] = $type;
|
||||
}
|
||||
|
||||
|
|
@ -692,12 +689,16 @@ abstract class IndexPager extends ContextSource implements Pager {
|
|||
$attrs['class'] = "mw-{$type}link";
|
||||
}
|
||||
|
||||
return $this->getLinkRenderer()->makeKnownLink(
|
||||
$this->getTitle(),
|
||||
new HtmlArmor( $text ),
|
||||
$attrs,
|
||||
$query + $this->getDefaultQuery()
|
||||
);
|
||||
if ( $query !== null ) {
|
||||
return $this->getLinkRenderer()->makeKnownLink(
|
||||
$this->getTitle(),
|
||||
new HtmlArmor( $text ),
|
||||
$attrs,
|
||||
$query + $this->getDefaultQuery()
|
||||
);
|
||||
} else {
|
||||
return Html::rawElement( 'span', $attrs, $text );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -851,17 +852,15 @@ abstract class IndexPager extends ContextSource implements Pager {
|
|||
$links = [];
|
||||
|
||||
foreach ( $queries as $type => $query ) {
|
||||
if ( $query !== false ) {
|
||||
$links[$type] = $this->makeLink(
|
||||
$linkTexts[$type],
|
||||
$query,
|
||||
$type
|
||||
);
|
||||
} elseif ( isset( $disabledTexts[$type] ) ) {
|
||||
$links[$type] = $disabledTexts[$type];
|
||||
} else {
|
||||
$links[$type] = $linkTexts[$type];
|
||||
$linkText = $linkTexts[$type];
|
||||
if ( !$query && isset( $disabledTexts[$type] ) ) {
|
||||
$linkText = $disabledTexts[$type];
|
||||
}
|
||||
$links[$type] = $this->makeLink(
|
||||
$linkText,
|
||||
$query ?: null,
|
||||
$type
|
||||
);
|
||||
}
|
||||
|
||||
return $links;
|
||||
|
|
|
|||
Loading…
Reference in a new issue