24use Wikimedia\Timestamp\TimestampFormat as TS;
40 parent::__construct(
$entry );
41 $this->titleParser = $titleParser;
42 $this->namespaceInfo = $namespaceInfo;
47 $params = parent::getMessageParameters();
49 $title = $this->entry->getTarget();
50 if ( str_starts_with( $title->getText(),
'#' ) ) {
52 $params[2] = $title->getText();
56 $username = $title->getText();
59 $targetUser = User::newFromName( $username,
false );
61 $params[3] = $username;
64 $subtype = $this->entry->getSubtype();
65 if ( $subtype ===
'block' || $subtype ===
'reblock' ) {
66 if ( !isset( $params[4] ) ) {
68 $params[4] =
'infinity';
75 $durationTooltip =
'‎' . htmlspecialchars( $params[4] );
76 $blockExpiry = $this->context->getLanguage()->translateBlockExpiry(
78 $this->context->getUser(),
79 (
int)
wfTimestamp( TS::UNIX, $this->entry->getTimestamp() )
81 if ( $this->plaintext ) {
86 "<span class=\"blockExpiry\" title=\"$durationTooltip\">" .
88 htmlspecialchars( $blockExpiry ) .
92 $params[5] = isset( $params[5] ) ?
96 if ( isset( $params[6] ) ) {
97 $pages = $params[6][
'pages'] ?? [];
99 foreach ( $pages as $page ) {
100 $pageLinks[] = $this->
makePageLink( Title::newFromText( $page ) );
103 $rawNamespaces = $params[6][
'namespaces'] ?? [];
105 foreach ( $rawNamespaces as $ns ) {
107 ? $this->
msg(
'blanknamespace' )->escaped()
108 : htmlspecialchars( $this->context->getLanguage()->getFormattedNsText( $ns ) );
109 if ( $this->plaintext ) {
113 $namespaces[] = $text;
117 [
'namespace' => $ns ],
123 $rawActions = $params[6][
'actions'] ?? [];
125 foreach ( $rawActions as $action ) {
126 $actions[] = $this->
msg(
'ipb-action-' . $action )->escaped();
131 $restrictions[] = $this->
msg(
'logentry-partialblock-block-page' )
132 ->numParams( count( $pageLinks ) )
133 ->rawParams( $this->context->getLanguage()->listToText( $pageLinks ) )->escaped();
137 $restrictions[] = $this->
msg(
'logentry-partialblock-block-ns' )
138 ->numParams( count( $namespaces ) )
139 ->rawParams( $this->context->getLanguage()->listToText( $namespaces ) )->escaped();
142 $restrictions[] = $this->
msg(
'logentry-partialblock-block-action' )
143 ->numParams( count( $actions ) )
144 ->rawParams( $this->context->getLanguage()->listToText( $actions ) )->escaped();
147 $params[6] =
Message::rawParam( $this->context->getLanguage()->listToText( $restrictions ) );
156 $params = parent::extractParameters();
158 if ( $this->entry->isLegacy() && isset( $params[3] ) ) {
159 if ( isset( $params[4] ) ) {
160 $params[5] = $params[4];
162 $params[4] = $params[3];
170 $title = $this->entry->getTarget();
173 if ( substr( $title->getText(), 0, 1 ) !==
'#' && $title->canExist() ) {
174 $preload[] = $this->namespaceInfo->getTalkPage( $title );
178 if ( isset( $params[6][
'pages'] ) ) {
179 foreach ( $params[6][
'pages'] as $page ) {
181 $preload[] = $this->titleParser->parseTitle( $page );
191 $subtype = $this->entry->getSubtype();
196 || !( $subtype ===
'block' || $subtype ===
'reblock' )
197 || !$this->context->getAuthority()->isAllowed(
'block' )
202 $title = $this->entry->getTarget();
204 $params = $this->entry->getParameters();
205 if ( isset( $params[
'blockId'] ) ) {
207 $query = isset( $params[
'blockId'] ) ? [
'id' => $params[
'blockId'] ] : [];
209 $linkRenderer->makeKnownLink(
211 $this->msg(
'remove-blocklink' )->text(),
213 $query + [
'remove' =>
'1' ]
215 $linkRenderer->makeKnownLink(
217 $this->msg(
'change-blocklink' )->text(),
226 $linkRenderer->makeKnownLink(
228 $this->msg(
'manage-blocklink' )->text(),
235 $linkRenderer->makeKnownLink(
237 $this->msg(
'unblocklink' )->text()
239 $linkRenderer->makeKnownLink(
241 $this->msg(
'change-blocklink' )->text()
246 return $this->
msg(
'parentheses' )->rawParams(
247 $this->context->getLanguage()->pipeList( $links ) )->escaped();
259 $flags = trim( $flags );
260 if ( $flags ===
'' ) {
263 $flags = explode(
',', $flags );
264 $flagsCount = count( $flags );
266 for ( $i = 0; $i < $flagsCount; $i++ ) {
270 return wfMessage(
'parentheses' )->inLanguage( $lang )
271 ->rawParams( $lang->
commaList( $flags ) )->escaped();
282 static $messages = [];
284 if ( !isset( $messages[$flag] ) ) {
285 $messages[$flag] = htmlspecialchars( $flag );
295 $msg =
wfMessage(
'block-log-flags-' . $flag )->inLanguage( $lang );
297 if ( $msg->exists() ) {
298 $messages[$flag] = $msg->escaped();
302 return $messages[$flag];
315 '6::flags' =>
'6:array:flags',
318 foreach ( $map as $index => $key ) {
319 if ( isset( $params[$index] ) ) {
320 $params[$key] = $params[$index];
321 unset( $params[$index] );
328 if ( $subtype ===
'block' || $subtype ===
'reblock' ) {
331 '5::duration' =>
'infinity',
332 '6:array:flags' => [],
335 if ( !is_array( $params[
'6:array:flags'] ) ) {
336 $params[
'6:array:flags'] = $params[
'6:array:flags'] ===
''
338 : explode(
',', $params[
'6:array:flags'] );
343 $params[
'5::duration'] =
'infinity';
344 $params[
':plain:duration-l10n'] = $this->
msg(
'infiniteblock' )->plain();
347 $expiry = strtotime( $params[
'5::duration'], $ts );
348 if ( $expiry !==
false && $expiry > 0 ) {
349 $params[
':timestamp:expiry'] = $expiry;
351 $params[
':plain:duration-l10n'] = $this->context->getLanguage()
352 ->formatDurationBetweenTimestamps( $ts, $expiry );
364 $ret = parent::formatParametersForApi();
365 if ( isset( $ret[
'flags'] ) ) {
366 ApiResult::setIndexedTagName( $ret[
'flags'],
'f' );
369 if ( isset( $ret[
'restrictions'][
'pages'] ) ) {
370 $ret[
'restrictions'][
'pages'] = array_map(
function ( $title ) {
372 }, $ret[
'restrictions'][
'pages'] );
373 ApiResult::setIndexedTagName( $ret[
'restrictions'][
'pages'],
'p' );
376 if ( isset( $ret[
'restrictions'][
'namespaces'] ) ) {
378 ApiResult::setIndexedTagName( $ret[
'restrictions'][
'namespaces'],
'ns' );
386 $type = $this->entry->getType();
387 $subtype = $this->entry->getSubtype();
388 $params = $this->entry->getParameters();
389 $sitewide = $params[
'sitewide'] ??
true;
390 $count = $params[
'finalTargetCount'] ?? 0;
392 $key =
"logentry-$type-$subtype";
393 if ( ( $subtype ===
'block' || $subtype ===
'reblock' ) && !$sitewide ) {
397 $params = parent::getMessageParameters();
400 if ( isset( $params[6] ) ) {
401 $key =
"logentry-partial$type-$subtype";
403 $key =
"logentry-non-editing-$type-$subtype";
406 if ( $subtype ===
'block' && $count > 1 ) {
417class_alias( BlockLogFormatter::class,
'BlockLogFormatter' );
wfTimestamp( $outputtype=TS::UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfIsInfinity( $str)
Determine input string is represents as infinity.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
A class containing constants representing the names of configuration variables.
const UseCodexSpecialBlock
Name constant for the UseCodexSpecialBlock setting, for use with Config::get()
Parent class for all special pages.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
getTimestamp()
Get the timestamp when the action was executed.
getParameters()
Get the extra parameters stored for this message.
getSubtype()
The log subtype.