From c6a96b4bd560304166248abb406247b87f80718d Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Wed, 21 Nov 2018 15:15:19 -0800 Subject: [PATCH] Separate content parts of mw-usertoollinks from presentation 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 | 21 ++++++++++++++++----- includes/changes/ChangesList.php | 8 +++++++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/includes/Linker.php b/includes/Linker.php index b605acd894..89a41dce84 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -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() - . '' - . wfMessage( 'parentheses' )->rawParams( $wgLang->pipeList( $items ) )->escaped() - . ''; + if ( $useParentheses ) { + return wfMessage( 'word-separator' )->escaped() + . '' + . wfMessage( 'parentheses' )->rawParams( $wgLang->pipeList( $items ) )->escaped() + . ''; + } else { + $tools = []; + foreach ( $items as $tool ) { + $tools[] = Html::rawElement( 'span', [], $tool ); + } + return ' ' . + implode( ' ', $tools ) . ''; + } } else { return ''; } diff --git a/includes/changes/ChangesList.php b/includes/changes/ChangesList.php index 6a8bd6d83f..7a54f9521c 100644 --- a/includes/changes/ChangesList.php +++ b/includes/changes/ChangesList.php @@ -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 + ); } } -- 2.20.1