X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2Flogging%2FBlockLogFormatter.php;h=6bc3f3969a88233332d9ba2217f0373489c23cef;hb=6196eaf08ce62962b9466435f33dddab65e6775b;hp=3762d6278760eaa5057e054da1ecf9c5029c1acf;hpb=a0b490bbe7a87b54de49f075c59befa8232b2237;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/logging/BlockLogFormatter.php b/includes/logging/BlockLogFormatter.php index 3762d62787..6bc3f3969a 100644 --- a/includes/logging/BlockLogFormatter.php +++ b/includes/logging/BlockLogFormatter.php @@ -57,17 +57,33 @@ class BlockLogFormatter extends LogFormatter { // The lrm is needed to make sure that the number // is shown on the correct side of the tooltip text. $durationTooltip = '‎' . htmlspecialchars( $params[4] ); - $params[4] = Message::rawParam( - "" . - $this->context->getLanguage()->translateBlockExpiry( - $params[4], - $this->context->getUser(), - wfTimestamp( TS_UNIX, $this->entry->getTimestamp() ) - ) . - '' + $blockExpiry = $this->context->getLanguage()->translateBlockExpiry( + $params[4], + $this->context->getUser(), + wfTimestamp( TS_UNIX, $this->entry->getTimestamp() ) ); + if ( $this->plaintext ) { + $params[4] = Message::rawParam( $blockExpiry ); + } else { + $params[4] = Message::rawParam( + "" . + $blockExpiry . + '' + ); + } $params[5] = isset( $params[5] ) ? self::formatBlockFlags( $params[5], $this->context->getLanguage() ) : ''; + + // block restrictions + if ( isset( $params[6] ) ) { + $pages = $params[6]['pages'] ?? []; + $pages = array_map( function ( $page ){ + return $this->makePageLink( Title::newFromText( ( $page ) ) ); + }, $pages ); + + $params[6] = Message::rawParam( $this->context->getLanguage()->listToText( $pages ) ); + $params[7] = count( $pages ); + } } return $params; @@ -188,6 +204,7 @@ class BlockLogFormatter extends LogFormatter { '6:array:flags', '6::flags' => '6:array:flags', ]; + foreach ( $map as $index => $key ) { if ( isset( $params[$index] ) ) { $params[$key] = $params[$index]; @@ -195,6 +212,8 @@ class BlockLogFormatter extends LogFormatter { } } + ksort( $params ); + $subtype = $entry->getSubtype(); if ( $subtype === 'block' || $subtype === 'reblock' ) { // Defaults for old log entries missing some fields @@ -226,7 +245,37 @@ class BlockLogFormatter extends LogFormatter { if ( isset( $ret['flags'] ) ) { ApiResult::setIndexedTagName( $ret['flags'], 'f' ); } + + if ( isset( $ret['restrictions']['pages'] ) ) { + $ret['restrictions']['pages'] = array_map( function ( $title ) { + return $this->formatParameterValueForApi( 'page', 'title-link', $title ); + }, $ret['restrictions']['pages'] ); + ApiResult::setIndexedTagName( $ret['restrictions']['pages'], 'p' ); + } + return $ret; } + protected function getMessageKey() { + $type = $this->entry->getType(); + $subtype = $this->entry->getSubtype(); + $sitewide = $this->entry->getParameters()['sitewide'] ?? true; + + $key = "logentry-$type-$subtype"; + if ( ( $subtype === 'block' || $subtype === 'reblock' ) && !$sitewide ) { + // $this->getMessageParameters is doing too much. We just need + // to check the presence of restrictions ($param[6]) and calling + // on parent gives us that + $params = parent::getMessageParameters(); + + // message changes depending on whether there are editing restrictions or not + if ( isset( $params[6] ) ) { + $key = "logentry-partial$type-$subtype"; + } else { + $key = "logentry-non-editing-$type-$subtype"; + } + } + + return $key; + } }