MediaWiki  1.32.5
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 
48  protected function myPageLink( Title $title = null, $text, $query = [] ) {
49  if ( !$this->plaintext ) {
50  if ( !$title instanceof Title ) {
51  $link = htmlspecialchars( $text );
52  } else {
53  $link = $this->getLinkRenderer()->makeLink( $title, $text, [], $query );
54  }
55  } else {
56  if ( !$title instanceof Title ) {
57  $link = "[[User:$text]]";
58  } else {
59  $link = '[[' . $title->getPrefixedText() . ']]';
60  }
61  }
62 
63  return $link;
64  }
65 
66  public function getMessageKey() {
67  $key = parent::getMessageKey();
68  $params = $this->extractParameters();
69 
70  // Very old log format, everything in comment
71  if ( !isset( $params[3] ) ) {
72  return "$key-legaciest";
73  } elseif ( !isset( $params[5] ) ) {
74  return "$key-legacier";
75  }
76 
77  return $key;
78  }
79 
80  public function getPreloadTitles() {
81  $params = $this->extractParameters();
82  if ( !isset( $params[3] ) ) {
83  // Very old log format, everything in comment - legaciest
84  return [];
85  }
86  if ( !isset( $params[4] ) ) {
87  // Old log format - legacier
88  $newUserName = $params[3];
89  } else {
90  $newUserName = $params[4];
91  }
92 
93  $title = Title::makeTitleSafe( NS_USER, $newUserName );
94  if ( $title ) {
95  return [ $title ];
96  }
97 
98  return [];
99  }
100 }
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:1627
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:964
RenameuserLogFormatter\getMessageKey
getMessageKey()
Returns a key to be used for formatting the action sentence.
Definition: RenameuserLogFormatter.php:66
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:573
RenameuserLogFormatter\myPageLink
myPageLink(Title $title=null, $text, $query=[])
Definition: RenameuserLogFormatter.php:48
RenameuserLogFormatter\getPreloadTitles
getPreloadTitles()
Definition: RenameuserLogFormatter.php:80
LogFormatter
Implements the default log formatting.
Definition: LogFormatter.php:38
Title
Represents a title within MediaWiki.
Definition: Title.php:39
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:3098
LogFormatter\getLinkRenderer
getLinkRenderer()
Definition: LogFormatter.php:142
LogFormatter\extractParameters
extractParameters()
Extracts the optional extra parameters for use in action messages.
Definition: LogFormatter.php:503