MediaWiki master
NewUsersLogFormatter.php
Go to the documentation of this file.
1<?php
12namespace MediaWiki\Logging;
13
17use Wikimedia\Timestamp\TimestampFormat as TS;
18
25 private NamespaceInfo $namespaceInfo;
26
27 public function __construct(
29 NamespaceInfo $namespaceInfo
30 ) {
31 parent::__construct( $entry );
32 $this->namespaceInfo = $namespaceInfo;
33 }
34
36 protected function getMessageParameters() {
37 $params = parent::getMessageParameters();
38 $subtype = $this->entry->getSubtype();
39 if ( $subtype === 'create2' || $subtype === 'byemail' ) {
40 if ( isset( $params[3] ) ) {
41 $target = User::newFromId( $params[3] );
42 } else {
43 $target = User::newFromName( $this->entry->getTarget()->getText(), false );
44 }
45 $params[2] = Message::rawParam( $this->makeUserLink( $target ) );
46 $params[3] = $target->getName();
47 }
48
49 return $params;
50 }
51
53 public function getComment() {
54 $timestamp = wfTimestamp( TS::MW, $this->entry->getTimestamp() );
55 if ( $timestamp < '20080129000000' ) {
56 # Suppress $comment from old entries (before 2008-01-29),
57 # not needed and can contain incorrect links
58 return '';
59 }
60
61 return parent::getComment();
62 }
63
65 public function getPreloadTitles() {
66 $subtype = $this->entry->getSubtype();
67 if ( $subtype === 'create2' || $subtype === 'byemail' ) {
68 // add the user talk to LinkBatch for the userLink
69 return [ $this->namespaceInfo->getTalkPage( $this->entry->getTarget() ) ];
70 }
71
72 return [];
73 }
74}
75
77class_alias( NewUsersLogFormatter::class, 'NewUsersLogFormatter' );
wfTimestamp( $outputtype=TS::UNIX, $ts=0)
Get a timestamp string in one of various formats.
Implements the default log formatting.
makeUserLink(UserIdentity $user, $toolFlags=0)
This class formats new user log entries.
getPreloadTitles()
to override LinkTarget[] Array of titles that should be preloaded with LinkBatch
__construct(LogEntry $entry, NamespaceInfo $namespaceInfo)
getMessageParameters()
Formats parameters intended for action message from array of all parameters.There are three hardcoded...
getComment()
Gets the user provided comment.to override string HTML
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:144
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
User class for the MediaWiki software.
Definition User.php:110
An individual log entry.
Definition LogEntry.php:23