MediaWiki REL1_35
MoveLogFormatter.php
Go to the documentation of this file.
1<?php
27
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() {
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}
Implements the default log formatting.
LogEntryBase $entry
msg( $key,... $params)
Shortcut for wfMessage which honors local context.
makePageLink(Title $title=null, $parameters=[], $html=null)
Helper to make a link to the page, taking the plaintext value in consideration.
extractParameters()
Extracts the optional extra parameters for use in action messages.
const DELETED_ACTION
Definition LogPage.php:38
MediaWikiServices is the service locator for the application scope of MediaWiki.
static rawParam( $raw)
Definition Message.php:1053
This class formats move log entries.
getMessageKey()
Returns a key to be used for formatting the action sentence.
getPreloadTitles()
Stable to override.
getMessageParameters()
Formats parameters intented for action message from array of all parameters.
getParametersForApi()
Get the array of parameters, converted from legacy format if necessary.
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
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,...
getParameters()
Get the extra parameters stored for this message.