3 * Formatter for merge log entries.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
21 * @license GPL-2.0-or-later
25 use MediaWiki\MediaWikiServices
;
28 * This class formats merge log entries.
32 class MergeLogFormatter
extends LogFormatter
{
33 public function getPreloadTitles() {
34 $params = $this->extractParameters();
36 return [ Title
::newFromText( $params[3] ) ];
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() );
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' )
60 $params = $this->extractParameters();
61 $revert = $this->getLinkRenderer()->makeKnownLink(
62 SpecialPage
::getTitleFor( 'MergeHistory' ),
63 $this->msg( 'revertmerge' )->text(),
66 'target' => $params[3],
67 'dest' => $this->entry
->getTarget()->getPrefixedDBkey(),
68 'mergepoint' => $params[4],
69 'submitted' => 1 // show the revisions immediately
73 return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
76 protected function getParametersForApi() {
77 $entry = $this->entry
;
78 $params = $entry->getParameters();
82 '5:timestamp:mergepoint',
83 '4::dest' => '4:title:dest',
84 '5::mergepoint' => '5:timestamp:mergepoint',
86 foreach ( $map as $index => $key ) {
87 if ( isset( $params[$index] ) ) {
88 $params[$key] = $params[$index];
89 unset( $params[$index] );