MediaWiki  1.34.0
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 }
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:316
MoveLogFormatter
This class formats move log entries.
Definition: MoveLogFormatter.php:33
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:117
LogEntry\getParameters
getParameters()
Get the extra parameters stored for this message.
LogFormatter\$entry
LogEntryBase $entry
Definition: LogFormatter.php:77
SpecialPage\getTitleFor
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,...
Definition: SpecialPage.php:83
MoveLogFormatter\getPreloadTitles
getPreloadTitles()
Definition: MoveLogFormatter.php:34
MoveLogFormatter\getParametersForApi
getParametersForApi()
Get the array of parameters, converted from legacy format if necessary.
Definition: MoveLogFormatter.php:93
LogPage\DELETED_ACTION
const DELETED_ACTION
Definition: LogPage.php:34
MoveLogFormatter\getActionLinks
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
Definition: MoveLogFormatter.php:62
MoveLogFormatter\getMessageKey
getMessageKey()
Returns a key to be used for formatting the action sentence.
Definition: MoveLogFormatter.php:40
LogFormatter
Implements the default log formatting.
Definition: LogFormatter.php:38
LogFormatter\msg
msg( $key,... $params)
Shortcut for wfMessage which honors local context.
Definition: LogFormatter.php:761
LogFormatter\getLinkRenderer
getLinkRenderer()
Definition: LogFormatter.php:136
LogFormatter\extractParameters
extractParameters()
Extracts the optional extra parameters for use in action messages.
Definition: LogFormatter.php:514
LogFormatter\makePageLink
makePageLink(Title $title=null, $parameters=[], $html=null)
Helper to make a link to the page, taking the plaintext value in consideration.
Definition: LogFormatter.php:665
MoveLogFormatter\getMessageParameters
getMessageParameters()
Formats parameters intented for action message from array of all parameters.
Definition: MoveLogFormatter.php:51