MediaWiki
REL1_40
MoveLogFormatter.php
Go to the documentation of this file.
1
<?php
26
use
MediaWiki\Title\Title
;
27
33
class
MoveLogFormatter
extends
LogFormatter
{
34
public
function
getPreloadTitles
() {
35
$params = $this->
extractParameters
();
36
37
return
[ Title::newFromText( $params[3] ) ];
38
}
39
40
protected
function
getMessageKey
() {
41
$key = parent::getMessageKey();
42
$params = $this->
extractParameters
();
43
if
( isset( $params[4] ) && $params[4] ===
'1'
) {
44
// Messages: logentry-move-move-noredirect, logentry-move-move_redir-noredirect
45
$key .=
'-noredirect'
;
46
}
47
48
return
$key;
49
}
50
51
protected
function
getMessageParameters
() {
52
$params = parent::getMessageParameters();
53
$oldname = $this->
makePageLink
( $this->entry->getTarget(), [
'redirect'
=>
'no'
] );
54
$newname = $this->
makePageLink
( Title::newFromText( $params[3] ) );
55
$params[2] =
Message::rawParam
( $oldname );
56
$params[3] =
Message::rawParam
( $newname );
57
unset( $params[4] );
// handled in getMessageKey
58
59
return
$params;
60
}
61
62
public
function
getActionLinks
() {
63
if
( $this->entry->isDeleted( LogPage::DELETED_ACTION )
// Action is hidden
64
|| $this->entry->getSubtype() !==
'move'
65
|| !$this->context->getAuthority()->isAllowed(
'move'
)
66
) {
67
return
''
;
68
}
69
70
$params = $this->
extractParameters
();
71
$destTitle = Title::newFromText( $params[3] );
72
if
( !$destTitle ) {
73
return
''
;
74
}
75
76
$revert = $this->
getLinkRenderer
()->makeKnownLink(
77
SpecialPage::getTitleFor
(
'Movepage'
),
78
$this->
msg
(
'revertmove'
)->text(),
79
[],
80
[
81
'wpOldTitle'
=> $destTitle->getPrefixedDBkey(),
82
'wpNewTitle'
=> $this->entry->getTarget()->getPrefixedDBkey(),
83
'wpReason'
=> $this->msg(
'revertmove'
)->inContentLanguage()->text(),
84
'wpMovetalk'
=> 0
85
]
86
);
87
88
return
$this->
msg
(
'parentheses'
)->rawParams( $revert )->escaped();
89
}
90
91
protected
function
getParametersForApi
() {
92
$entry
= $this->entry;
93
$params =
$entry
->
getParameters
();
94
95
static
$map = [
96
'4:title:target'
,
97
'5:bool:suppressredirect'
,
98
'4::target'
=>
'4:title:target'
,
99
'5::noredir'
=>
'5:bool:suppressredirect'
,
100
];
101
foreach
( $map as $index => $key ) {
102
if
( isset( $params[$index] ) ) {
103
$params[$key] = $params[$index];
104
unset( $params[$index] );
105
}
106
}
107
108
if
( !isset( $params[
'5:bool:suppressredirect'
] ) ) {
109
$params[
'5:bool:suppressredirect'
] =
false
;
110
}
111
112
return
$params;
113
}
114
115
}
LogFormatter
Implements the default log formatting.
Definition
LogFormatter.php:47
LogFormatter\$entry
LogEntryBase $entry
Definition
LogFormatter.php:87
LogFormatter\getLinkRenderer
getLinkRenderer()
Definition
LogFormatter.php:151
LogFormatter\msg
msg( $key,... $params)
Shortcut for wfMessage which honors local context.
Definition
LogFormatter.php:781
LogFormatter\makePageLink
makePageLink(Title $title=null, $parameters=[], $html=null)
Helper to make a link to the page, taking the plaintext value in consideration.
Definition
LogFormatter.php:683
LogFormatter\extractParameters
extractParameters()
Extracts the optional extra parameters for use in action messages.
Definition
LogFormatter.php:529
MediaWiki\Title\Title
Represents a title within MediaWiki.
Definition
Title.php:82
Message\rawParam
static rawParam( $raw)
Definition
Message.php:1135
MoveLogFormatter
This class formats move log entries.
Definition
MoveLogFormatter.php:33
MoveLogFormatter\getMessageKey
getMessageKey()
Returns a key to be used for formatting the action sentence.
Definition
MoveLogFormatter.php:40
MoveLogFormatter\getPreloadTitles
getPreloadTitles()
Definition
MoveLogFormatter.php:34
MoveLogFormatter\getMessageParameters
getMessageParameters()
Formats parameters intended for action message from array of all parameters.
Definition
MoveLogFormatter.php:51
MoveLogFormatter\getParametersForApi
getParametersForApi()
Get the array of parameters, converted from legacy format if necessary.
Definition
MoveLogFormatter.php:91
MoveLogFormatter\getActionLinks
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
Definition
MoveLogFormatter.php:62
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Definition
SpecialPage.php:132
LogEntry\getParameters
getParameters()
Get the extra parameters stored for this message.
includes
logging
MoveLogFormatter.php
Generated on Thu Jun 27 2024 14:03:23 for MediaWiki by
1.10.0