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 if ( isset( $params[5] ) ) {
61 $mergePoint = $params[4] . "|" . $params[5];
62 } else {
63 // This is an old log entry from before we recorded the revid separately
64 $mergePoint = $params[4];
65 }
66 $revert = $this->getLinkRenderer()->makeKnownLink(
67 SpecialPage::getTitleFor( 'MergeHistory' ),
68 $this->msg( 'revertmerge' )->text(),
69 [],
70 [
71 'target' => $params[3],
72 'dest' => $this->entry->getTarget()->getPrefixedDBkey(),
73 'mergepoint' => $mergePoint,
74 'submitted' => 1 // show the revisions immediately
75 ]
76 );
77
78 return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
79 }
80
81 protected function getParametersForApi() {
82 $entry = $this->entry;
83 $params = $entry->getParameters();
84
85 static $map = [
86 '4:title:dest',
87 '5:timestamp:mergepoint',
88 '4::dest' => '4:title:dest',
89 '5::mergepoint' => '5:timestamp:mergepoint',
90 '6::mergerevid'
91 ];
92 foreach ( $map as $index => $key ) {
93 if ( isset( $params[$index] ) ) {
94 $params[$key] = $params[$index];
95 unset( $params[$index] );
96 }
97 }
98
99 return $params;
100 }
101}
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 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.