MediaWiki master
MergeLogFormatter.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 getMessageParameters() {
42 $params = parent::getMessageParameters();
43 $oldname = $this->makePageLink( $this->entry->getTarget(), [ 'redirect' => 'no' ] );
44 $newname = $this->makePageLink( Title::newFromText( $params[3] ) );
45 $params[2] = Message::rawParam( $oldname );
46 $params[3] = Message::rawParam( $newname );
47 $params[4] = $this->context->getLanguage()
48 ->userTimeAndDate( $params[4], $this->context->getUser() );
49 return $params;
50 }
51
52 public function getActionLinks() {
53 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) // Action is hidden
54 || !$this->context->getAuthority()->isAllowed( 'mergehistory' )
55 ) {
56 return '';
57 }
58
59 // Show unmerge link
60 $params = $this->extractParameters();
61 if ( isset( $params[5] ) ) {
62 $mergePoint = $params[4] . "|" . $params[5];
63 } else {
64 // This is an old log entry from before we recorded the revid separately
65 $mergePoint = $params[4];
66 }
67 $revert = $this->getLinkRenderer()->makeKnownLink(
68 SpecialPage::getTitleFor( 'MergeHistory' ),
69 $this->msg( 'revertmerge' )->text(),
70 [],
71 [
72 'target' => $params[3],
73 'dest' => $this->entry->getTarget()->getPrefixedDBkey(),
74 'mergepoint' => $mergePoint,
75 'submitted' => 1 // show the revisions immediately
76 ]
77 );
78
79 return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
80 }
81
82 protected function getParametersForApi() {
83 $entry = $this->entry;
85
86 static $map = [
87 '4:title:dest',
88 '5:timestamp:mergepoint',
89 '4::dest' => '4:title:dest',
90 '5::mergepoint' => '5:timestamp:mergepoint',
91 '6::mergerevid'
92 ];
93 foreach ( $map as $index => $key ) {
94 if ( isset( $params[$index] ) ) {
95 $params[$key] = $params[$index];
96 unset( $params[$index] );
97 }
98 }
99
100 return $params;
101 }
102}
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 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.
getParameters()
Get the extra parameters stored for this message.