Log entries can be rendered with parentheses in HTML
authorjdlrobson <jdlrobson@gmail.com>
Tue, 26 Mar 2019 23:58:19 +0000 (16:58 -0700)
committerVolkerE <volker.e@wikimedia.org>
Thu, 19 Sep 2019 03:58:51 +0000 (03:58 +0000)
Entries such as "User creation log" on Special:RecentChanges can
be wrapped or not wrapped in parentheses

Bug: T219348
Change-Id: Ic764081497dbe8d6d9e5bff6f8a1ceeac4b306e2

includes/changes/ChangesList.php
includes/changes/OldChangesList.php

index a48e191..e649201 100644 (file)
@@ -455,13 +455,21 @@ class ChangesList extends ContextSource {
         * @param string &$s HTML to update
         * @param Title $title
         * @param string $logtype
+        * @param bool $useParentheses (optional) Wrap log entry in parentheses where needed
         */
-       public function insertLog( &$s, $title, $logtype ) {
+       public function insertLog( &$s, $title, $logtype, $useParentheses = true ) {
                $page = new LogPage( $logtype );
                $logname = $page->getName()->setContext( $this->getContext() )->text();
-               $s .= Html::rawElement( 'span', [
-                       'class' => 'mw-changeslist-links'
-               ], $this->linkRenderer->makeKnownLink( $title, $logname ) );
+               $link = $this->linkRenderer->makeKnownLink( $title, $logname, [
+                       'class' => $useParentheses ? '' : 'mw-changeslist-links'
+               ] );
+               if ( $useParentheses ) {
+                       $s .= $this->msg( 'parentheses' )->rawParams(
+                               $link
+                       )->escaped();
+               } else {
+                       $s .= $link;
+               }
        }
 
        /**
index c15701b..8228bae 100644 (file)
@@ -87,7 +87,7 @@ class OldChangesList extends ChangesList {
 
                if ( $rc->mAttribs['rc_log_type'] ) {
                        $logtitle = SpecialPage::getTitleFor( 'Log', $rc->mAttribs['rc_log_type'] );
-                       $this->insertLog( $html, $logtitle, $rc->mAttribs['rc_log_type'] );
+                       $this->insertLog( $html, $logtitle, $rc->mAttribs['rc_log_type'], false );
                        $flags = $this->recentChangesFlags( [ 'unpatrolled' => $unpatrolled,
                                'bot' => $rc->mAttribs['rc_bot'] ], '' );
                        if ( $flags !== '' ) {
@@ -98,7 +98,7 @@ class OldChangesList extends ChangesList {
                        list( $name, $htmlubpage ) = MediaWikiServices::getInstance()->getSpecialPageFactory()->
                                resolveAlias( $rc->mAttribs['rc_title'] );
                        if ( $name == 'Log' ) {
-                               $this->insertLog( $html, $rc->getTitle(), $htmlubpage );
+                               $this->insertLog( $html, $rc->getTitle(), $htmlubpage, false );
                        }
                // Regular entries
                } else {