MediaWiki  1.33.0
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
34  $link = $this->myPageLink( $title, $params[3],
35  [ 'redirect' => 'no' ] );
36  $params[3] = Message::rawParam( $link );
37 
38  // Nice link to new user page
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 }
RenameuserLogFormatter\getMessageParameters
getMessageParameters()
Formats parameters intented for action message from array of all parameters.
Definition: RenameuserLogFormatter.php:8
RenameuserLogFormatter
LogFormatter for renameuser/renameuser logs.
Definition: RenameuserLogFormatter.php:6
$params
$params
Definition: styleTest.css.php:44
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
$query
null for the wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1588
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:925
RenameuserLogFormatter\getMessageKey
getMessageKey()
Returns a key to be used for formatting the action sentence.
Definition: RenameuserLogFormatter.php:73
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:604
RenameuserLogFormatter\myPageLink
myPageLink(Title $title=null, $text, $query=[])
Definition: RenameuserLogFormatter.php:55
RenameuserLogFormatter\getPreloadTitles
getPreloadTitles()
Definition: RenameuserLogFormatter.php:87
LogFormatter
Implements the default log formatting.
Definition: LogFormatter.php:38
Title
Represents a title within MediaWiki.
Definition: Title.php:40
NS_USER
const NS_USER
Definition: Defines.php:66
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:3053
LogFormatter\getLinkRenderer
getLinkRenderer()
Definition: LogFormatter.php:136
LogFormatter\extractParameters
extractParameters()
Extracts the optional extra parameters for use in action messages.
Definition: LogFormatter.php:498