Add CSS classes for userlinks on SpecialPages
authorEddie Greiner-Petter <git@eddie-sh.de>
Fri, 17 Feb 2017 12:59:16 +0000 (13:59 +0100)
committerEddie Greiner-Petter <git@eddie-sh.de>
Thu, 23 Feb 2017 01:51:23 +0000 (02:51 +0100)
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

includes/Linker.php

index 94b145e..05e3abb 100644 (file)
@@ -933,13 +933,14 @@ class Linker {
                if ( $userId ) {
                        // check if the user has an edit
                        $attribs = [];
+                       $attribs['class'] = 'mw-usertoollinks-contribs';
                        if ( $redContribsWhenNoEdits ) {
                                if ( intval( $edits ) === 0 && $edits !== 0 ) {
                                        $user = User::newFromId( $userId );
                                        $edits = $user->getEditCount();
                                }
                                if ( $edits === 0 ) {
-                                       $attribs['class'] = 'new';
+                                       $attribs['class'] .= ' new';
                                }
                        }
                        $contribsPage = SpecialPage::getTitleFor( 'Contributions', $userText );
@@ -986,7 +987,10 @@ class Linker {
         */
        public static function userTalkLink( $userId, $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;
        }
 
@@ -998,7 +1002,10 @@ class Linker {
         */
        public static function blockLink( $userId, $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;
        }
 
@@ -1009,7 +1016,10 @@ class Linker {
         */
        public static function emailLink( $userId, $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;
        }