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\Message\Message
;
26 use MediaWiki\SpecialPage\SpecialPage
;
27 use MediaWiki\Title\Title
;
30 * This class formats merge log entries.
34 class MergeLogFormatter
extends LogFormatter
{
35 public function getPreloadTitles() {
36 $params = $this->extractParameters();
38 return [ Title
::newFromText( $params[3] ) ];
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() );
52 public function getActionLinks() {
53 if ( $this->entry
->isDeleted( LogPage
::DELETED_ACTION
) // Action is hidden
54 ||
!$this->context
->getAuthority()->isAllowed( 'mergehistory' )
60 $params = $this->extractParameters();
61 if ( isset( $params[5] ) ) {
62 $mergePoint = $params[4] . "|" . $params[5];
64 // This is an old log entry from before we recorded the revid separately
65 $mergePoint = $params[4];
67 $revert = $this->getLinkRenderer()->makeKnownLink(
68 SpecialPage
::getTitleFor( 'MergeHistory' ),
69 $this->msg( 'revertmerge' )->text(),
72 'target' => $params[3],
73 'dest' => $this->entry
->getTarget()->getPrefixedDBkey(),
74 'mergepoint' => $mergePoint,
75 'submitted' => 1 // show the revisions immediately
79 return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
82 protected function getParametersForApi() {
83 $entry = $this->entry
;
84 $params = $entry->getParameters();
88 '5:timestamp:mergepoint',
89 '4::dest' => '4:title:dest',
90 '5::mergepoint' => '5:timestamp:mergepoint',
93 foreach ( $map as $index => $key ) {
94 if ( isset( $params[$index] ) ) {
95 $params[$key] = $params[$index];
96 unset( $params[$index] );