Separate content parts of mw-usertoollinks from presentation
authorjdlrobson <jdlrobson@gmail.com>
Wed, 21 Nov 2018 23:15:19 +0000 (15:15 -0800)
committerJdlrobson <jrobson@wikimedia.org>
Wed, 9 Jan 2019 00:56:40 +0000 (00:56 +0000)
Use the existing class mw-changeslist-links to visually separate
the user tools in CSS rather than in the HTML.

Bug: T205581
Change-Id: I024c8298ca5da753d96ec392be05d4530bb3ffa9

includes/Linker.php
includes/changes/ChangesList.php

index b605acd..89a41dc 100644 (file)
@@ -910,10 +910,12 @@ class Linker {
         * @param int $flags Customisation flags (e.g. Linker::TOOL_LINKS_NOBLOCK
         *   and Linker::TOOL_LINKS_EMAIL).
         * @param int|null $edits User edit count (optional, for performance)
+        * @param bool $useParentheses (optional) Wrap comments in parentheses where needed
         * @return string HTML fragment
         */
        public static function userToolLinks(
-               $userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null
+               $userId, $userText, $redContribsWhenNoEdits = false, $flags = 0, $edits = null,
+               $useParentheses = true
        ) {
                global $wgUser, $wgDisableAnonTalk, $wgLang;
                $talkable = !( $wgDisableAnonTalk && $userId == 0 );
@@ -957,10 +959,19 @@ class Linker {
                Hooks::run( 'UserToolLinksEdit', [ $userId, $userText, &$items ] );
 
                if ( $items ) {
-                       return wfMessage( 'word-separator' )->escaped()
-                               . '<span class="mw-usertoollinks">'
-                               . wfMessage( 'parentheses' )->rawParams( $wgLang->pipeList( $items ) )->escaped()
-                               . '</span>';
+                       if ( $useParentheses ) {
+                               return wfMessage( 'word-separator' )->escaped()
+                                       . '<span class="mw-usertoollinks">'
+                                       . wfMessage( 'parentheses' )->rawParams( $wgLang->pipeList( $items ) )->escaped()
+                                       . '</span>';
+                       } else {
+                               $tools = [];
+                               foreach ( $items as $tool ) {
+                                       $tools[] = Html::rawElement( 'span', [], $tool );
+                               }
+                               return ' <span class="mw-usertoollinks mw-changeslist-links">' .
+                                       implode( ' ', $tools ) . '</span>';
+                       }
                } else {
                        return '';
                }
index 6a8bd6d..7a54f95 100644 (file)
@@ -559,7 +559,13 @@ class ChangesList extends ContextSource {
                } else {
                        $s .= $this->getLanguage()->getDirMark() . Linker::userLink( $rc->mAttribs['rc_user'],
                                $rc->mAttribs['rc_user_text'] );
-                       $s .= Linker::userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
+                       $s .= Linker::userToolLinks(
+                               $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'],
+                               false, 0, null,
+                               // The text content of tools is not wrapped with parenthesises or "piped".
+                               // This will be handled in CSS (T205581).
+                               false
+                       );
                }
        }