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