MediaWiki master
MoveLogFormatter.php
Go to the documentation of this file.
1<?php
29
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;
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}
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:150
Parent class for all special pages.
Represents a title within MediaWiki.
Definition Title.php:78
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.