MediaWiki
master
MoveLogFormatter.php
Go to the documentation of this file.
1
<?php
26
use
MediaWiki\Message\Message
;
27
use
MediaWiki\SpecialPage\SpecialPage
;
28
use
MediaWiki\Title\MalformedTitleException
;
29
use
MediaWiki\Title\Title
;
30
use
MediaWiki\Title\TitleParser
;
31
37
class
MoveLogFormatter
extends
LogFormatter
{
38
private
TitleParser
$titleParser;
39
40
public
function
__construct
(
41
LogEntry
$entry,
42
TitleParser
$titleParser
43
) {
44
parent::__construct( $entry );
45
$this->titleParser = $titleParser;
46
}
47
48
public
function
getPreloadTitles
() {
49
$params
= $this->
extractParameters
();
50
51
try
{
52
return
[ $this->titleParser->parseTitle(
$params
[3] ) ];
53
}
catch
(
MalformedTitleException
$_ ) {
54
// namespace configuration may have changed to make $params[3] invalid (T370396);
55
// nothing to preload in this case
56
return
[];
57
}
58
}
59
60
protected
function
getMessageKey
() {
61
$key = parent::getMessageKey();
62
$params
= $this->
extractParameters
();
63
if
( isset(
$params
[4] ) &&
$params
[4] ===
'1'
) {
64
// Messages: logentry-move-move-noredirect, logentry-move-move_redir-noredirect
65
$key .=
'-noredirect'
;
66
}
67
68
return
$key;
69
}
70
71
protected
function
getMessageParameters
() {
72
$params
= parent::getMessageParameters();
73
$oldname = $this->
makePageLink
( $this->entry->getTarget(), [
'redirect'
=>
'no'
] );
74
$newname = $this->
makePageLink
( Title::newFromText(
$params
[3] ) );
75
$params
[2] = Message::rawParam( $oldname );
76
$params
[3] = Message::rawParam( $newname );
77
unset(
$params
[4] );
// handled in getMessageKey
78
79
return
$params
;
80
}
81
82
public
function
getActionLinks
() {
83
if
( $this->entry->isDeleted( LogPage::DELETED_ACTION )
// Action is hidden
84
|| $this->entry->getSubtype() !==
'move'
85
|| !$this->context->getAuthority()->isAllowed(
'move'
)
86
) {
87
return
''
;
88
}
89
90
$params
= $this->
extractParameters
();
91
$destTitle = Title::newFromText(
$params
[3] );
92
if
( !$destTitle || !$destTitle->exists() ) {
93
return
''
;
94
}
95
96
$revert = $this->
getLinkRenderer
()->makeKnownLink(
97
SpecialPage::getTitleFor(
'Movepage'
),
98
$this->
msg
(
'revertmove'
)->text(),
99
[],
100
[
101
'wpOldTitle'
=> $destTitle->getPrefixedDBkey(),
102
'wpNewTitle'
=> $this->entry->getTarget()->getPrefixedDBkey(),
103
'wpReason'
=> $this->msg(
'revertmove-summary'
)->inContentLanguage()->text(),
104
'wpMovetalk'
=> 0
105
]
106
);
107
108
return
$this->
msg
(
'parentheses'
)->rawParams( $revert )->escaped();
109
}
110
111
protected
function
getParametersForApi
() {
112
$entry
= $this->entry;
113
$params
=
$entry
->
getParameters
();
114
115
static
$map = [
116
'4:title:target'
,
117
'5:bool:suppressredirect'
,
118
'4::target'
=>
'4:title:target'
,
119
'5::noredir'
=>
'5:bool:suppressredirect'
,
120
];
121
foreach
( $map as $index => $key ) {
122
if
( isset(
$params
[$index] ) ) {
123
$params
[$key] =
$params
[$index];
124
unset(
$params
[$index] );
125
}
126
}
127
128
if
( !isset(
$params
[
'5:bool:suppressredirect'
] ) ) {
129
$params
[
'5:bool:suppressredirect'
] =
false
;
130
}
131
132
return
$params
;
133
}
134
135
}
$params
array $params
The job parameters.
Definition
UploadJobTrait.php:46
LogFormatter
Implements the default log formatting.
Definition
LogFormatter.php:59
LogFormatter\$entry
LogEntryBase $entry
Definition
LogFormatter.php:93
LogFormatter\getLinkRenderer
getLinkRenderer()
Definition
LogFormatter.php:163
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:766
LogFormatter\msg
msg( $key,... $params)
Shortcut for wfMessage which honors local context.
Definition
LogFormatter.php:866
LogFormatter\extractParameters
extractParameters()
Extracts the optional extra parameters for use in action messages.
Definition
LogFormatter.php:605
MediaWiki\Message\Message
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition
Message.php:155
MediaWiki\SpecialPage\SpecialPage
Parent class for all special pages.
Definition
SpecialPage.php:67
MediaWiki\Title\MalformedTitleException
MalformedTitleException is thrown when a TitleParser is unable to parse a title string.
Definition
MalformedTitleException.php:32
MediaWiki\Title\Title
Represents a title within MediaWiki.
Definition
Title.php:78
MoveLogFormatter
This class formats move log entries.
Definition
MoveLogFormatter.php:37
MoveLogFormatter\getMessageKey
getMessageKey()
Returns a key to be used for formatting the action sentence.
Definition
MoveLogFormatter.php:60
MoveLogFormatter\getPreloadTitles
getPreloadTitles()
Definition
MoveLogFormatter.php:48
MoveLogFormatter\getMessageParameters
getMessageParameters()
Formats parameters intended for action message from array of all parameters.
Definition
MoveLogFormatter.php:71
MoveLogFormatter\getParametersForApi
getParametersForApi()
Get the array of parameters, converted from legacy format if necessary.
Definition
MoveLogFormatter.php:111
MoveLogFormatter\getActionLinks
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
Definition
MoveLogFormatter.php:82
MoveLogFormatter\__construct
__construct(LogEntry $entry, TitleParser $titleParser)
Definition
MoveLogFormatter.php:40
LogEntry
An individual log entry.
Definition
LogEntry.php:35
LogEntry\getParameters
getParameters()
Get the extra parameters stored for this message.
MediaWiki\Title\TitleParser
A title parser service for MediaWiki.
Definition
TitleParser.php:35
includes
logging
MoveLogFormatter.php
Generated on Sat Feb 15 2025 13:24:07 for MediaWiki by
1.10.0