MediaWiki master
RenameuserLogFormatter.php
Go to the documentation of this file.
1<?php
2
5
10
14 protected function getMessageParameters() {
15 $params = parent::getMessageParameters();
16 /* Current format:
17 * 1,2,3: normal logformatter params
18 * 4: old username (linked)
19 * (legaciest doesn't have this at all, all in comment)
20 * (legacier uses this as new name and stores old name in target)
21 * 5: new username (linked)
22 * 6: number of edits the user had at the time
23 * (not available except in newest log entries)
24 * 7: new username (raw format for GENDER)
25 * Note that the arrays are zero-indexed, while message parameters
26 * start from 1, so substract one to get array entries below.
27 */
28
29 if ( !isset( $params[3] ) ) {
30 // The oldest format
31 return $params;
32 } elseif ( !isset( $params[4] ) ) {
33 // See comments above
34 $params[4] = $params[3];
35 $params[3] = $this->entry->getTarget()->getText();
36 }
37
38 if ( isset( $params[5] ) ) {
39 // Make sure number of edits is formatted
40 $params[5] = Message::numParam( $params[5] );
41 }
42
43 // Nice link to old user page
44 $title = Title::makeTitleSafe( NS_USER, $params[3] );
45 // @phan-suppress-next-line SecurityCheck-DoubleEscaped
46 $link = $this->myPageLink( $title, $params[3],
47 [ 'redirect' => 'no' ] );
48 // @phan-suppress-next-line SecurityCheck-XSS
49 $params[3] = Message::rawParam( $link );
50
51 // Nice link to new user page
52 $title = Title::makeTitleSafe( NS_USER, $params[4] );
53 // @phan-suppress-next-line SecurityCheck-DoubleEscaped
54 $link = $this->myPageLink( $title, $params[4] );
55 // @phan-suppress-next-line SecurityCheck-XSS
56 $params[4] = Message::rawParam( $link );
57 // GENDER support (using new user page)
58 $params[6] = $title->getText();
59
60 return $params;
61 }
62
70 protected function myPageLink( ?Title $title, $text, $query = [] ) {
71 if ( !$this->plaintext ) {
72 if ( !$title instanceof Title ) {
73 $link = htmlspecialchars( $text );
74 } else {
75 $link = $this->getLinkRenderer()->makeLink( $title, $text, [], $query );
76 }
77 } else {
78 if ( !$title instanceof Title ) {
79 $link = "[[User:$text]]";
80 } else {
81 $link = '[[' . $title->getPrefixedText() . ']]';
82 }
83 }
84
85 return $link;
86 }
87
88 public function getMessageKey() {
89 $key = parent::getMessageKey();
90 $params = $this->extractParameters();
91
92 // Very old log format, everything in comment
93 if ( !isset( $params[3] ) ) {
94 // Message: logentry-renameuser-renameuser-legaciest
95 return "$key-legaciest";
96 } elseif ( !isset( $params[5] ) ) {
97 // Message: logentry-renameuser-renameuser-legacier
98 return "$key-legacier";
99 }
100
101 // Message: logentry-renameuser-renameuser
102 return $key;
103 }
104
105 public function getPreloadTitles() {
106 $params = $this->extractParameters();
107 if ( !isset( $params[3] ) ) {
108 // Very old log format, everything in comment - legaciest
109 return [];
110 }
111 if ( !isset( $params[4] ) ) {
112 // Old log format - legacier
113 $newUserName = $params[3];
114 } else {
115 $newUserName = $params[4];
116 }
117
118 $title = Title::makeTitleSafe( NS_USER, $newUserName );
119 if ( $title ) {
120 return [ $title ];
121 }
122
123 return [];
124 }
125}
const NS_USER
Definition Defines.php:67
array $params
The job parameters.
Implements the default log formatting.
extractParameters()
Extracts the optional extra parameters for use in action messages.
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:150
Represents a title within MediaWiki.
Definition Title.php:78
getPrefixedText()
Get the prefixed title with spaces.
Definition Title.php:1858
LogFormatter for renameuser/renameuser logs.
getMessageKey()
Returns a key to be used for formatting the action sentence.
myPageLink(?Title $title, $text, $query=[])
getMessageParameters()
Formats parameters intended for action message from array of all parameters.There are three hardcoded...