MediaWiki REL1_40
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 || !$this->context->getAuthority()->isAllowed( 'move' )
66 ) {
67 return '';
68 }
69
70 $params = $this->extractParameters();
71 $destTitle = Title::newFromText( $params[3] );
72 if ( !$destTitle ) {
73 return '';
74 }
75
76 $revert = $this->getLinkRenderer()->makeKnownLink(
77 SpecialPage::getTitleFor( 'Movepage' ),
78 $this->msg( 'revertmove' )->text(),
79 [],
80 [
81 'wpOldTitle' => $destTitle->getPrefixedDBkey(),
82 'wpNewTitle' => $this->entry->getTarget()->getPrefixedDBkey(),
83 'wpReason' => $this->msg( 'revertmove' )->inContentLanguage()->text(),
84 'wpMovetalk' => 0
85 ]
86 );
87
88 return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
89 }
90
91 protected function getParametersForApi() {
92 $entry = $this->entry;
93 $params = $entry->getParameters();
94
95 static $map = [
96 '4:title:target',
97 '5:bool:suppressredirect',
98 '4::target' => '4:title:target',
99 '5::noredir' => '5:bool:suppressredirect',
100 ];
101 foreach ( $map as $index => $key ) {
102 if ( isset( $params[$index] ) ) {
103 $params[$key] = $params[$index];
104 unset( $params[$index] );
105 }
106 }
107
108 if ( !isset( $params['5:bool:suppressredirect'] ) ) {
109 $params['5:bool:suppressredirect'] = false;
110 }
111
112 return $params;
113 }
114
115}
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.
Represents a title within MediaWiki.
Definition Title.php:82
static rawParam( $raw)
Definition Message.php:1135
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.
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.