MediaWiki
REL1_34
MoveLogFormatter.php
Go to the documentation of this file.
1
<?php
26
use
MediaWiki\MediaWikiServices
;
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
|| !MediaWikiServices::getInstance()
66
->getPermissionManager()
67
->userHasRight( $this->context->getUser(),
'move'
)
68
) {
69
return
''
;
70
}
71
72
$params = $this->
extractParameters
();
73
$destTitle = Title::newFromText( $params[3] );
74
if
( !$destTitle ) {
75
return
''
;
76
}
77
78
$revert = $this->
getLinkRenderer
()->makeKnownLink(
79
SpecialPage::getTitleFor(
'Movepage'
),
80
$this->
msg
(
'revertmove'
)->text(),
81
[],
82
[
83
'wpOldTitle'
=> $destTitle->getPrefixedDBkey(),
84
'wpNewTitle'
=> $this->entry->getTarget()->getPrefixedDBkey(),
85
'wpReason'
=> $this->msg(
'revertmove'
)->inContentLanguage()->text(),
86
'wpMovetalk'
=> 0
87
]
88
);
89
90
return
$this->
msg
(
'parentheses'
)->rawParams( $revert )->escaped();
91
}
92
93
protected
function
getParametersForApi
() {
94
$entry
=
$this->entry
;
95
$params =
$entry
->
getParameters
();
96
97
static
$map = [
98
'4:title:target'
,
99
'5:bool:suppressredirect'
,
100
'4::target'
=>
'4:title:target'
,
101
'5::noredir'
=>
'5:bool:suppressredirect'
,
102
];
103
foreach
( $map as $index => $key ) {
104
if
( isset( $params[$index] ) ) {
105
$params[$key] = $params[$index];
106
unset( $params[$index] );
107
}
108
}
109
110
if
( !isset( $params[
'5:bool:suppressredirect'
] ) ) {
111
$params[
'5:bool:suppressredirect'
] =
false
;
112
}
113
114
return
$params;
115
}
116
117
}
LogFormatter
Implements the default log formatting.
Definition
LogFormatter.php:38
LogFormatter\$entry
LogEntryBase $entry
Definition
LogFormatter.php:77
LogFormatter\getLinkRenderer
getLinkRenderer()
Definition
LogFormatter.php:136
LogFormatter\msg
msg( $key,... $params)
Shortcut for wfMessage which honors local context.
Definition
LogFormatter.php:761
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:665
LogFormatter\extractParameters
extractParameters()
Extracts the optional extra parameters for use in action messages.
Definition
LogFormatter.php:514
LogPage\DELETED_ACTION
const DELETED_ACTION
Definition
LogPage.php:34
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition
MediaWikiServices.php:117
Message\rawParam
static rawParam( $raw)
Definition
Message.php:1027
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 intented 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:93
MoveLogFormatter\getActionLinks
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
Definition
MoveLogFormatter.php:62
LogEntry\getParameters
getParameters()
Get the extra parameters stored for this message.
includes
logging
MoveLogFormatter.php
Generated on Fri Apr 5 2024 23:10:14 for MediaWiki by
1.9.8