MediaWiki REL1_31
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 $params[3] = Message::rawParam( $link );
36
37 // Nice link to new user page
38 $title = Title::makeTitleSafe( NS_USER, $params[4] );
39 $link = $this->myPageLink( $title, $params[4] );
40 $params[4] = Message::rawParam( $link );
41 // GENDER support (using new user page)
42 $params[6] = $title->getText();
43
44 return $params;
45 }
46
47 protected function myPageLink( Title $title = null, $text ) {
48 if ( !$this->plaintext ) {
49 if ( !$title instanceof Title ) {
50 $link = htmlspecialchars( $text );
51 } else {
52 $link = $this->getLinkRenderer()->makeLink( $title, $text );
53 }
54 } else {
55 if ( !$title instanceof Title ) {
56 $link = "[[User:$text]]";
57 } else {
58 $link = '[[' . $title->getPrefixedText() . ']]';
59 }
60 }
61
62 return $link;
63 }
64
65 public function getMessageKey() {
66 $key = parent::getMessageKey();
67 $params = $this->extractParameters();
68
69 // Very old log format, everything in comment
70 if ( !isset( $params[3] ) ) {
71 return "$key-legaciest";
72 } elseif ( !isset( $params[5] ) ) {
73 return "$key-legacier";
74 }
75
76 return $key;
77 }
78
79 public function getPreloadTitles() {
80 $params = $this->extractParameters();
81 if ( !isset( $params[3] ) ) {
82 // Very old log format, everything in comment - legaciest
83 return [];
84 }
85 if ( !isset( $params[4] ) ) {
86 // Old log format - legacier
87 $newUserName = $params[3];
88 } else {
89 $newUserName = $params[4];
90 }
91
92 $title = Title::makeTitleSafe( NS_USER, $newUserName );
93 if ( $title ) {
94 return [ $title ];
95 }
96
97 return [];
98 }
99}
Implements the default log formatting.
extractParameters()
Extracts the optional extra parameters for use in action messages.
LogFormatter for renameuser/renameuser logs.
getMessageKey()
Returns a key to be used for formatting the action sentence.
myPageLink(Title $title=null, $text)
getMessageParameters()
Formats parameters intented for action message from array of all parameters.
Represents a title within MediaWiki.
Definition Title.php:39
namespace and then decline to actually register it file or subcat img or subcat $title
Definition hooks.txt:964
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:3021
$params