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