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