Add CSS classes for userlinks on SpecialPages

On Special:Watchlist, Special:Contributions, Special:Recentchanges etc.
there are links to (talk | contribs | block) for the user who did the
contribution. Add CSS class for them. Introduce the following css
classes:
- mw-usertoollinks-contribs
- mw-usertoollinks-talk
- mw-usertoollinks-block
- mw-usertoollinks-mail

Bug: T156879
Change-Id: I85a3b0987a016ff25026f1c047214a31170b0452
This commit is contained in:
Eddie Greiner-Petter 2017-02-17 13:59:16 +01:00
parent 1978dc538a
commit 83e616a152

View file

@ -933,13 +933,14 @@ class Linker {
if ( $userId ) { if ( $userId ) {
// check if the user has an edit // check if the user has an edit
$attribs = []; $attribs = [];
$attribs['class'] = 'mw-usertoollinks-contribs';
if ( $redContribsWhenNoEdits ) { if ( $redContribsWhenNoEdits ) {
if ( intval( $edits ) === 0 && $edits !== 0 ) { if ( intval( $edits ) === 0 && $edits !== 0 ) {
$user = User::newFromId( $userId ); $user = User::newFromId( $userId );
$edits = $user->getEditCount(); $edits = $user->getEditCount();
} }
if ( $edits === 0 ) { if ( $edits === 0 ) {
$attribs['class'] = 'new'; $attribs['class'] .= ' new';
} }
} }
$contribsPage = SpecialPage::getTitleFor( 'Contributions', $userText ); $contribsPage = SpecialPage::getTitleFor( 'Contributions', $userText );
@ -986,7 +987,10 @@ class Linker {
*/ */
public static function userTalkLink( $userId, $userText ) { public static function userTalkLink( $userId, $userText ) {
$userTalkPage = Title::makeTitle( NS_USER_TALK, $userText ); $userTalkPage = Title::makeTitle( NS_USER_TALK, $userText );
$userTalkLink = self::link( $userTalkPage, wfMessage( 'talkpagelinktext' )->escaped() ); $moreLinkAttribs['class'] = 'mw-usertoollinks-talk';
$userTalkLink = self::link( $userTalkPage,
wfMessage( 'talkpagelinktext' )->escaped(),
$moreLinkAttribs );
return $userTalkLink; return $userTalkLink;
} }
@ -998,7 +1002,10 @@ class Linker {
*/ */
public static function blockLink( $userId, $userText ) { public static function blockLink( $userId, $userText ) {
$blockPage = SpecialPage::getTitleFor( 'Block', $userText ); $blockPage = SpecialPage::getTitleFor( 'Block', $userText );
$blockLink = self::link( $blockPage, wfMessage( 'blocklink' )->escaped() ); $moreLinkAttribs['class'] = 'mw-usertoollinks-block';
$blockLink = self::link( $blockPage,
wfMessage( 'blocklink' )->escaped(),
$moreLinkAttribs );
return $blockLink; return $blockLink;
} }
@ -1009,7 +1016,10 @@ class Linker {
*/ */
public static function emailLink( $userId, $userText ) { public static function emailLink( $userId, $userText ) {
$emailPage = SpecialPage::getTitleFor( 'Emailuser', $userText ); $emailPage = SpecialPage::getTitleFor( 'Emailuser', $userText );
$emailLink = self::link( $emailPage, wfMessage( 'emaillink' )->escaped() ); $moreLinkAttribs['class'] = 'mw-usertoollinks-mail';
$emailLink = self::link( $emailPage,
wfMessage( 'emaillink' )->escaped(),
$moreLinkAttribs );
return $emailLink; return $emailLink;
} }