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';
74 $durationTooltip =
'‎' . htmlspecialchars( $params[4] );
75 $blockExpiry = $this->context->getLanguage()->translateBlockExpiry(
77 $this->context->getUser(),
78 (
int)
wfTimestamp( TS::UNIX, $this->entry->getTimestamp() )
80 if ( $this->plaintext ) {
81 $params[4] = $blockExpiry;
84 "<span class=\"blockExpiry\" title=\"$durationTooltip\">" .
85 htmlspecialchars( $blockExpiry ) .
89 $params[5] = isset( $params[5] ) ?
93 if ( isset( $params[6] ) ) {
94 $pages = $params[6][
'pages'] ?? [];
96 foreach ( $pages as $page ) {
97 $pageLinks[] = $this->
makePageLink( Title::newFromText( $page ) );
100 $rawNamespaces = $params[6][
'namespaces'] ?? [];
102 foreach ( $rawNamespaces as $ns ) {
104 ? $this->
msg(
'blanknamespace' )->escaped()
105 : htmlspecialchars( $this->context->getLanguage()->getFormattedNsText( $ns ) );
106 if ( $this->plaintext ) {
110 $namespaces[] = $text;
114 [
'namespace' => $ns ],
120 $rawActions = $params[6][
'actions'] ?? [];
122 foreach ( $rawActions as $action ) {
123 $actions[] = $this->
msg(
'ipb-action-' . $action )->escaped();
128 $restrictions[] = $this->
msg(
'logentry-partialblock-block-page' )
129 ->numParams( count( $pageLinks ) )
130 ->rawParams( $this->context->getLanguage()->listToText( $pageLinks ) )->escaped();
134 $restrictions[] = $this->
msg(
'logentry-partialblock-block-ns' )
135 ->numParams( count( $namespaces ) )
136 ->rawParams( $this->context->getLanguage()->listToText( $namespaces ) )->escaped();
139 $restrictions[] = $this->
msg(
'logentry-partialblock-block-action' )
140 ->numParams( count( $actions ) )
141 ->rawParams( $this->context->getLanguage()->listToText( $actions ) )->escaped();
144 $params[6] =
Message::rawParam( $this->context->getLanguage()->listToText( $restrictions ) );
153 $params = parent::extractParameters();
155 if ( $this->entry->isLegacy() && isset( $params[3] ) ) {
156 if ( isset( $params[4] ) ) {
157 $params[5] = $params[4];
159 $params[4] = $params[3];
167 $title = $this->entry->getTarget();
170 if ( substr( $title->getText(), 0, 1 ) !==
'#' && $title->canExist() ) {
171 $preload[] = $this->namespaceInfo->getTalkPage( $title );
175 if ( isset( $params[6][
'pages'] ) ) {
176 foreach ( $params[6][
'pages'] as $page ) {
178 $preload[] = $this->titleParser->parseTitle( $page );
188 $subtype = $this->entry->getSubtype();
193 || !( $subtype ===
'block' || $subtype ===
'reblock' )
194 || !$this->context->getAuthority()->isAllowed(
'block' )
199 $title = $this->entry->getTarget();
201 $params = $this->entry->getParameters();
202 if ( isset( $params[
'blockId'] ) ) {
204 $query = isset( $params[
'blockId'] ) ? [
'id' => $params[
'blockId'] ] : [];
206 $linkRenderer->makeKnownLink(
208 $this->msg(
'remove-blocklink' )->text(),
210 $query + [
'remove' =>
'1' ]
212 $linkRenderer->makeKnownLink(
214 $this->msg(
'change-blocklink' )->text(),
223 $linkRenderer->makeKnownLink(
225 $this->msg(
'manage-blocklink' )->text(),
232 $linkRenderer->makeKnownLink(
234 $this->msg(
'unblocklink' )->text()
236 $linkRenderer->makeKnownLink(
238 $this->msg(
'change-blocklink' )->text()
243 return $this->
msg(
'parentheses' )->rawParams(
244 $this->context->getLanguage()->pipeList( $links ) )->escaped();
256 $flags = trim( $flags );
257 if ( $flags ===
'' ) {
260 $flags = explode(
',', $flags );
261 $flagsCount = count( $flags );
263 for ( $i = 0; $i < $flagsCount; $i++ ) {
267 return wfMessage(
'parentheses' )->inLanguage( $lang )
268 ->rawParams( $lang->
commaList( $flags ) )->escaped();
279 static $messages = [];
281 if ( !isset( $messages[$flag] ) ) {
282 $messages[$flag] = htmlspecialchars( $flag );
292 $msg =
wfMessage(
'block-log-flags-' . $flag )->inLanguage( $lang );
294 if ( $msg->exists() ) {
295 $messages[$flag] = $msg->escaped();
299 return $messages[$flag];
312 '6::flags' =>
'6:array:flags',
315 foreach ( $map as $index => $key ) {
316 if ( isset( $params[$index] ) ) {
317 $params[$key] = $params[$index];
318 unset( $params[$index] );
325 if ( $subtype ===
'block' || $subtype ===
'reblock' ) {
328 '5::duration' =>
'infinity',
329 '6:array:flags' => [],
332 if ( !is_array( $params[
'6:array:flags'] ) ) {
333 $params[
'6:array:flags'] = $params[
'6:array:flags'] ===
''
335 : explode(
',', $params[
'6:array:flags'] );
340 $params[
'5::duration'] =
'infinity';
341 $params[
':plain:duration-l10n'] = $this->
msg(
'infiniteblock' )->plain();
344 $expiry = strtotime( $params[
'5::duration'], $ts );
345 if ( $expiry !==
false && $expiry > 0 ) {
346 $params[
':timestamp:expiry'] = $expiry;
348 $params[
':plain:duration-l10n'] = $this->context->getLanguage()
349 ->formatDurationBetweenTimestamps( $ts, $expiry );
361 $ret = parent::formatParametersForApi();
362 if ( isset( $ret[
'flags'] ) ) {
363 ApiResult::setIndexedTagName( $ret[
'flags'],
'f' );
366 if ( isset( $ret[
'restrictions'][
'pages'] ) ) {
367 $ret[
'restrictions'][
'pages'] = array_map(
function ( $title ) {
369 }, $ret[
'restrictions'][
'pages'] );
370 ApiResult::setIndexedTagName( $ret[
'restrictions'][
'pages'],
'p' );
373 if ( isset( $ret[
'restrictions'][
'namespaces'] ) ) {
375 ApiResult::setIndexedTagName( $ret[
'restrictions'][
'namespaces'],
'ns' );
383 $type = $this->entry->getType();
384 $subtype = $this->entry->getSubtype();
385 $params = $this->entry->getParameters();
386 $sitewide = $params[
'sitewide'] ??
true;
387 $count = $params[
'finalTargetCount'] ?? 0;
389 $key =
"logentry-$type-$subtype";
390 if ( ( $subtype ===
'block' || $subtype ===
'reblock' ) && !$sitewide ) {
394 $params = parent::getMessageParameters();
397 if ( isset( $params[6] ) ) {
398 $key =
"logentry-partial$type-$subtype";
400 $key =
"logentry-non-editing-$type-$subtype";
403 if ( $subtype ===
'block' && $count > 1 ) {
414class_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.