MediaWiki REL1_40
MergeLogFormatter.php
Go to the documentation of this file.
1<?php
26
33 public function getPreloadTitles() {
34 $params = $this->extractParameters();
35
36 return [ Title::newFromText( $params[3] ) ];
37 }
38
39 protected function getMessageParameters() {
40 $params = parent::getMessageParameters();
41 $oldname = $this->makePageLink( $this->entry->getTarget(), [ 'redirect' => 'no' ] );
42 $newname = $this->makePageLink( Title::newFromText( $params[3] ) );
43 $params[2] = Message::rawParam( $oldname );
44 $params[3] = Message::rawParam( $newname );
45 $params[4] = $this->context->getLanguage()
46 ->userTimeAndDate( $params[4], $this->context->getUser() );
47 return $params;
48 }
49
50 public function getActionLinks() {
51 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) // Action is hidden
52 || !$this->context->getAuthority()->isAllowed( 'mergehistory' )
53 ) {
54 return '';
55 }
56
57 // Show unmerge link
58 $params = $this->extractParameters();
59 $revert = $this->getLinkRenderer()->makeKnownLink(
60 SpecialPage::getTitleFor( 'MergeHistory' ),
61 $this->msg( 'revertmerge' )->text(),
62 [],
63 [
64 'target' => $params[3],
65 'dest' => $this->entry->getTarget()->getPrefixedDBkey(),
66 'mergepoint' => $params[4],
67 'submitted' => 1 // show the revisions immediately
68 ]
69 );
70
71 return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
72 }
73
74 protected function getParametersForApi() {
75 $entry = $this->entry;
76 $params = $entry->getParameters();
77
78 static $map = [
79 '4:title:dest',
80 '5:timestamp:mergepoint',
81 '4::dest' => '4:title:dest',
82 '5::mergepoint' => '5:timestamp:mergepoint',
83 ];
84 foreach ( $map as $index => $key ) {
85 if ( isset( $params[$index] ) ) {
86 $params[$key] = $params[$index];
87 unset( $params[$index] );
88 }
89 }
90
91 return $params;
92 }
93}
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
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:1135
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.