MediaWiki  master
MergeLogFormatter.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 getMessageParameters() {
41  $params = parent::getMessageParameters();
42  $oldname = $this->makePageLink( $this->entry->getTarget(), [ 'redirect' => 'no' ] );
43  $newname = $this->makePageLink( Title::newFromText( $params[3] ) );
44  $params[2] = Message::rawParam( $oldname );
45  $params[3] = Message::rawParam( $newname );
46  $params[4] = $this->context->getLanguage()
47  ->userTimeAndDate( $params[4], $this->context->getUser() );
48  return $params;
49  }
50 
51  public function getActionLinks() {
52  if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) // Action is hidden
53  || !$this->context->getAuthority()->isAllowed( 'mergehistory' )
54  ) {
55  return '';
56  }
57 
58  // Show unmerge link
59  $params = $this->extractParameters();
60  $revert = $this->getLinkRenderer()->makeKnownLink(
61  SpecialPage::getTitleFor( 'MergeHistory' ),
62  $this->msg( 'revertmerge' )->text(),
63  [],
64  [
65  'target' => $params[3],
66  'dest' => $this->entry->getTarget()->getPrefixedDBkey(),
67  'mergepoint' => $params[4],
68  'submitted' => 1 // show the revisions immediately
69  ]
70  );
71 
72  return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
73  }
74 
75  protected function getParametersForApi() {
77  $params = $entry->getParameters();
78 
79  static $map = [
80  '4:title:dest',
81  '5:timestamp:mergepoint',
82  '4::dest' => '4:title:dest',
83  '5::mergepoint' => '5:timestamp:mergepoint',
84  ];
85  foreach ( $map as $index => $key ) {
86  if ( isset( $params[$index] ) ) {
87  $params[$key] = $params[$index];
88  unset( $params[$index] );
89  }
90  }
91 
92  return $params;
93  }
94 }
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.
const DELETED_ACTION
Definition: LogPage.php:44
Parent class for all special pages.
Definition: SpecialPage.php:66
Represents a title within MediaWiki.
Definition: Title.php:76
This class formats merge log entries.
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
getMessageParameters()
Formats parameters intended for action message from array of all parameters.
getParametersForApi()
Get the array of parameters, converted from legacy format if necessary.
static rawParam( $raw)
Definition: Message.php:1136
getParameters()
Get the extra parameters stored for this message.