Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / logging / MoveLogFormatter.php
blob7f5e9efab71d1ff6ac42facdf8b0f57b855fb769
1 <?php
2 /**
3 * Formatter for move 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 * @author Niklas Laxström
22 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
23 * @since 1.22
26 /**
27 * This class formats move log entries.
29 * @since 1.19
31 class MoveLogFormatter extends LogFormatter {
32 public function getPreloadTitles() {
33 $params = $this->extractParameters();
35 return array( Title::newFromText( $params[3] ) );
38 protected function getMessageKey() {
39 $key = parent::getMessageKey();
40 $params = $this->extractParameters();
41 if ( isset( $params[4] ) && $params[4] === '1' ) {
42 // Messages: logentry-move-move-noredirect, logentry-move-move_redir-noredirect
43 $key .= '-noredirect';
46 return $key;
49 protected function getMessageParameters() {
50 $params = parent::getMessageParameters();
51 $oldname = $this->makePageLink( $this->entry->getTarget(), array( 'redirect' => 'no' ) );
52 $newname = $this->makePageLink( Title::newFromText( $params[3] ) );
53 $params[2] = Message::rawParam( $oldname );
54 $params[3] = Message::rawParam( $newname );
55 unset( $params[4] ); // handled in getMessageKey
57 return $params;
60 public function getActionLinks() {
61 if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) // Action is hidden
62 || $this->entry->getSubtype() !== 'move'
63 || !$this->context->getUser()->isAllowed( 'move' )
64 ) {
65 return '';
68 $params = $this->extractParameters();
69 $destTitle = Title::newFromText( $params[3] );
70 if ( !$destTitle ) {
71 return '';
74 $revert = Linker::linkKnown(
75 SpecialPage::getTitleFor( 'Movepage' ),
76 $this->msg( 'revertmove' )->escaped(),
77 array(),
78 array(
79 'wpOldTitle' => $destTitle->getPrefixedDBkey(),
80 'wpNewTitle' => $this->entry->getTarget()->getPrefixedDBkey(),
81 'wpReason' => $this->msg( 'revertmove' )->inContentLanguage()->text(),
82 'wpMovetalk' => 0
86 return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
89 protected function getParametersForApi() {
90 $entry = $this->entry;
91 $params = $entry->getParameters();
93 static $map = array(
94 '4:title:target',
95 '5:bool:suppressredirect',
96 '4::target' => '4:title:target',
97 '5::noredir' => '5:bool:suppressredirect',
99 foreach ( $map as $index => $key ) {
100 if ( isset( $params[$index] ) ) {
101 $params[$key] = $params[$index];
102 unset( $params[$index] );
106 if ( !isset( $params['5:bool:suppressredirect'] ) ) {
107 $params['5:bool:suppressredirect'] = false;
110 return $params;