MediaWiki REL1_34
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 || !MediaWikiServices::getInstance()
53 ->getPermissionManager()
54 ->userHasRight( $this->context->getUser(), 'mergehistory' )
55 ) {
56 return '';
57 }
58
59 // Show unmerge link
60 $params = $this->extractParameters();
61 $revert = $this->getLinkRenderer()->makeKnownLink(
62 SpecialPage::getTitleFor( 'MergeHistory' ),
63 $this->msg( 'revertmerge' )->text(),
64 [],
65 [
66 'target' => $params[3],
67 'dest' => $this->entry->getTarget()->getPrefixedDBkey(),
68 'mergepoint' => $params[4],
69 'submitted' => 1 // show the revisions immediately
70 ]
71 );
72
73 return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
74 }
75
76 protected function getParametersForApi() {
78 $params = $entry->getParameters();
79
80 static $map = [
81 '4:title:dest',
82 '5:timestamp:mergepoint',
83 '4::dest' => '4:title:dest',
84 '5::mergepoint' => '5:timestamp:mergepoint',
85 ];
86 foreach ( $map as $index => $key ) {
87 if ( isset( $params[$index] ) ) {
88 $params[$key] = $params[$index];
89 unset( $params[$index] );
90 }
91 }
92
93 return $params;
94 }
95}
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:34
MediaWikiServices is the service locator for the application scope of MediaWiki.
This class formats merge log entries.
getActionLinks()
Returns extra links that comes after the action text, like "revert", etc.
getMessageParameters()
Formats parameters intented 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:1027
getParameters()
Get the extra parameters stored for this message.