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
21 * @author Niklas Laxström
22 * @license GPL-2.0-or-later
26 use MediaWiki\MediaWikiServices
;
29 * This class formats move log entries.
33 class MoveLogFormatter
extends LogFormatter
{
34 public function getPreloadTitles() {
35 $params = $this->extractParameters();
37 return [ Title
::newFromText( $params[3] ) ];
40 protected function getMessageKey() {
41 $key = parent
::getMessageKey();
42 $params = $this->extractParameters();
43 if ( isset( $params[4] ) && $params[4] === '1' ) {
44 // Messages: logentry-move-move-noredirect, logentry-move-move_redir-noredirect
45 $key .= '-noredirect';
51 protected function getMessageParameters() {
52 $params = parent
::getMessageParameters();
53 $oldname = $this->makePageLink( $this->entry
->getTarget(), [ 'redirect' => 'no' ] );
54 $newname = $this->makePageLink( Title
::newFromText( $params[3] ) );
55 $params[2] = Message
::rawParam( $oldname );
56 $params[3] = Message
::rawParam( $newname );
57 unset( $params[4] ); // handled in getMessageKey
62 public function getActionLinks() {
63 if ( $this->entry
->isDeleted( LogPage
::DELETED_ACTION
) // Action is hidden
64 ||
$this->entry
->getSubtype() !== 'move'
65 ||
!MediaWikiServices
::getInstance()
66 ->getPermissionManager()
67 ->userHasRight( $this->context
->getUser(), 'move' )
72 $params = $this->extractParameters();
73 $destTitle = Title
::newFromText( $params[3] );
78 $revert = $this->getLinkRenderer()->makeKnownLink(
79 SpecialPage
::getTitleFor( 'Movepage' ),
80 $this->msg( 'revertmove' )->text(),
83 'wpOldTitle' => $destTitle->getPrefixedDBkey(),
84 'wpNewTitle' => $this->entry
->getTarget()->getPrefixedDBkey(),
85 'wpReason' => $this->msg( 'revertmove' )->inContentLanguage()->text(),
90 return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
93 protected function getParametersForApi() {
94 $entry = $this->entry
;
95 $params = $entry->getParameters();
99 '5:bool:suppressredirect',
100 '4::target' => '4:title:target',
101 '5::noredir' => '5:bool:suppressredirect',
103 foreach ( $map as $index => $key ) {
104 if ( isset( $params[$index] ) ) {
105 $params[$key] = $params[$index];
106 unset( $params[$index] );
110 if ( !isset( $params['5:bool:suppressredirect'] ) ) {
111 $params['5:bool:suppressredirect'] = false;