MediaWiki master
NewUsersLogFormatter.php
Go to the documentation of this file.
1<?php
26namespace MediaWiki\Logging;
27
31
38 private NamespaceInfo $namespaceInfo;
39
40 public function __construct(
42 NamespaceInfo $namespaceInfo
43 ) {
44 parent::__construct( $entry );
45 $this->namespaceInfo = $namespaceInfo;
46 }
47
48 protected function getMessageParameters() {
49 $params = parent::getMessageParameters();
50 $subtype = $this->entry->getSubtype();
51 if ( $subtype === 'create2' || $subtype === 'byemail' ) {
52 if ( isset( $params[3] ) ) {
53 $target = User::newFromId( $params[3] );
54 } else {
55 $target = User::newFromName( $this->entry->getTarget()->getText(), false );
56 }
57 $params[2] = Message::rawParam( $this->makeUserLink( $target ) );
58 $params[3] = $target->getName();
59 }
60
61 return $params;
62 }
63
64 public function getComment() {
65 $timestamp = wfTimestamp( TS_MW, $this->entry->getTimestamp() );
66 if ( $timestamp < '20080129000000' ) {
67 # Suppress $comment from old entries (before 2008-01-29),
68 # not needed and can contain incorrect links
69 return '';
70 }
71
72 return parent::getComment();
73 }
74
75 public function getPreloadTitles() {
76 $subtype = $this->entry->getSubtype();
77 if ( $subtype === 'create2' || $subtype === 'byemail' ) {
78 // add the user talk to LinkBatch for the userLink
79 return [ $this->namespaceInfo->getTalkPage( $this->entry->getTarget() ) ];
80 }
81
82 return [];
83 }
84}
85
87class_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.
__construct(LogEntry $entry, NamespaceInfo $namespaceInfo)
getMessageParameters()
Formats parameters intended for action message from array of all parameters.
getComment()
Gets the user provided comment.
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:157
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:123
An individual log entry.
Definition LogEntry.php:37
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...