MediaWiki master
MoveLogFormatter.php
Go to the documentation of this file.
1<?php
29
36 public function getPreloadTitles() {
37 $params = $this->extractParameters();
38
39 return [ Title::newFromText( $params[3] ) ];
40 }
41
42 protected function getMessageKey() {
43 $key = parent::getMessageKey();
44 $params = $this->extractParameters();
45 if ( isset( $params[4] ) && $params[4] === '1' ) {
46 // Messages: logentry-move-move-noredirect, logentry-move-move_redir-noredirect
47 $key .= '-noredirect';
48 }
49
50 return $key;
51 }
52
53 protected function getMessageParameters() {
54 $params = parent::getMessageParameters();
55 $oldname = $this->makePageLink( $this->entry->getTarget(), [ 'redirect' => 'no' ] );
56 $newname = $this->makePageLink( Title::newFromText( $params[3] ) );
57 $params[2] = Message::rawParam( $oldname );
58 $params[3] = Message::rawParam( $newname );
59 unset( $params[4] ); // handled in getMessageKey
60
61 return $params;
62 }
63
64 public function getActionLinks() {
65 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) // Action is hidden
66 || $this->entry->getSubtype() !== 'move'
67 || !$this->context->getAuthority()->isAllowed( 'move' )
68 ) {
69 return '';
70 }
71
72 $params = $this->extractParameters();
73 $destTitle = Title::newFromText( $params[3] );
74 if ( !$destTitle || !$destTitle->exists() ) {
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-summary' )->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;
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}
array $params
The job parameters.
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.
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:158
Parent class for all special pages.
Represents a title within MediaWiki.
Definition Title.php:79
This class formats move log entries.
getMessageKey()
Returns a key to be used for formatting the action sentence.
getMessageParameters()
Formats parameters intended 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.
getParameters()
Get the extra parameters stored for this message.