MediaWiki REL1_30
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 $text = htmlspecialchars( $text );
50 $link = Linker::link( $title, $text );
51 } else {
52 if ( !$title instanceof Title ) {
53 $link = "[[User:$text]]";
54 } else {
55 $link = '[[' . $title->getPrefixedText() . ']]';
56 }
57 }
58
59 return $link;
60 }
61
62 public function getMessageKey() {
63 $key = parent::getMessageKey();
64 $params = $this->extractParameters();
65
66 // Very old log format, everything in comment
67 if ( !isset( $params[3] ) ) {
68 return "$key-legaciest";
69 } elseif ( !isset( $params[5] ) ) {
70 return "$key-legacier";
71 }
72
73 return $key;
74 }
75
76 public function getPreloadTitles() {
77 $params = $this->extractParameters();
78 if ( !isset( $params[3] ) ) {
79 // Very old log format, everything in comment - legaciest
80 return [];
81 }
82 if ( !isset( $params[4] ) ) {
83 // Old log format - legacier
84 $newUserName = $params[3];
85 } else {
86 $newUserName = $params[4];
87 }
88
89 $title = Title::makeTitleSafe( NS_USER, $newUserName );
90 if ( $title ) {
91 return [ $title ];
92 }
93
94 return [];
95 }
96}
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
Definition Linker.php:107
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:962
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:2989
$params