MediaWiki master
MoveLogFormatter.php
Go to the documentation of this file.
1<?php
28
35 public function getPreloadTitles() {
36 $params = $this->extractParameters();
37
38 return [ Title::newFromText( $params[3] ) ];
39 }
40
41 protected function getMessageKey() {
42 $key = parent::getMessageKey();
43 $params = $this->extractParameters();
44 if ( isset( $params[4] ) && $params[4] === '1' ) {
45 // Messages: logentry-move-move-noredirect, logentry-move-move_redir-noredirect
46 $key .= '-noredirect';
47 }
48
49 return $key;
50 }
51
52 protected function getMessageParameters() {
53 $params = parent::getMessageParameters();
54 $oldname = $this->makePageLink( $this->entry->getTarget(), [ 'redirect' => 'no' ] );
55 $newname = $this->makePageLink( Title::newFromText( $params[3] ) );
56 $params[2] = Message::rawParam( $oldname );
57 $params[3] = Message::rawParam( $newname );
58 unset( $params[4] ); // handled in getMessageKey
59
60 return $params;
61 }
62
63 public function getActionLinks() {
64 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) // Action is hidden
65 || $this->entry->getSubtype() !== 'move'
66 || !$this->context->getAuthority()->isAllowed( 'move' )
67 ) {
68 return '';
69 }
70
71 $params = $this->extractParameters();
72 $destTitle = Title::newFromText( $params[3] );
73 if ( !$destTitle ) {
74 return '';
75 }
76
77 $revert = $this->getLinkRenderer()->makeKnownLink(
78 SpecialPage::getTitleFor( 'Movepage' ),
79 $this->msg( 'revertmove' )->text(),
80 [],
81 [
82 'wpOldTitle' => $destTitle->getPrefixedDBkey(),
83 'wpNewTitle' => $this->entry->getTarget()->getPrefixedDBkey(),
84 'wpReason' => $this->msg( 'revertmove' )->inContentLanguage()->text(),
85 'wpMovetalk' => 0
86 ]
87 );
88
89 return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
90 }
91
92 protected function getParametersForApi() {
93 $entry = $this->entry;
94 $params = $entry->getParameters();
95
96 static $map = [
97 '4:title:target',
98 '5:bool:suppressredirect',
99 '4::target' => '4:title:target',
100 '5::noredir' => '5:bool:suppressredirect',
101 ];
102 foreach ( $map as $index => $key ) {
103 if ( isset( $params[$index] ) ) {
104 $params[$key] = $params[$index];
105 unset( $params[$index] );
106 }
107 }
108
109 if ( !isset( $params['5:bool:suppressredirect'] ) ) {
110 $params['5:bool:suppressredirect'] = false;
111 }
112
113 return $params;
114 }
115
116}
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.
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.