Merge "Special:Upload should not crash on failing previews"
[mediawiki.git] / includes / logging / MergeLogFormatter.php
blobb0edd4c07f653ed997bf50b8703ab6dadb952cfe
1 <?php
2 /**
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
20 * @file
21 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
22 * @since 1.25
25 /**
26 * This class formats merge log entries.
28 * @since 1.25
30 class MergeLogFormatter extends LogFormatter {
31 public function getPreloadTitles() {
32 $params = $this->extractParameters();
34 return [ Title::newFromText( $params[3] ) ];
37 protected function getMessageParameters() {
38 $params = parent::getMessageParameters();
39 $oldname = $this->makePageLink( $this->entry->getTarget(), [ 'redirect' => 'no' ] );
40 $newname = $this->makePageLink( Title::newFromText( $params[3] ) );
41 $params[2] = Message::rawParam( $oldname );
42 $params[3] = Message::rawParam( $newname );
43 $params[4] = $this->context->getLanguage()
44 ->userTimeAndDate( $params[4], $this->context->getUser() );
45 return $params;
48 public function getActionLinks() {
49 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) // Action is hidden
50 || !$this->context->getUser()->isAllowed( 'mergehistory' )
51 ) {
52 return '';
55 // Show unmerge link
56 $params = $this->extractParameters();
57 $revert = Linker::linkKnown(
58 SpecialPage::getTitleFor( 'MergeHistory' ),
59 $this->msg( 'revertmerge' )->escaped(),
60 [],
62 'target' => $params[3],
63 'dest' => $this->entry->getTarget()->getPrefixedDBkey(),
64 'mergepoint' => $params[4],
65 'submitted' => 1 // show the revisions immediately
69 return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
72 protected function getParametersForApi() {
73 $entry = $this->entry;
74 $params = $entry->getParameters();
76 static $map = [
77 '4:title:dest',
78 '5:timestamp:mergepoint',
79 '4::dest' => '4:title:dest',
80 '5::mergepoint' => '5:timestamp:mergepoint',
82 foreach ( $map as $index => $key ) {
83 if ( isset( $params[$index] ) ) {
84 $params[$key] = $params[$index];
85 unset( $params[$index] );
89 return $params;