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\Message\Message
;
27 use MediaWiki\SpecialPage\SpecialPage
;
28 use MediaWiki\Title\Title
;
31 * This class formats move log entries.
35 class MoveLogFormatter
extends LogFormatter
{
36 public function getPreloadTitles() {
37 $params = $this->extractParameters();
38 $title = Title
::newFromText( $params[3] );
40 if ( $title !== null ) {
43 // namespace configuration may have changed to make $params[3] invalid (T370396);
44 // nothing to preload in this case
49 protected function getMessageKey() {
50 $key = parent
::getMessageKey();
51 $params = $this->extractParameters();
52 if ( isset( $params[4] ) && $params[4] === '1' ) {
53 // Messages: logentry-move-move-noredirect, logentry-move-move_redir-noredirect
54 $key .= '-noredirect';
60 protected function getMessageParameters() {
61 $params = parent
::getMessageParameters();
62 $oldname = $this->makePageLink( $this->entry
->getTarget(), [ 'redirect' => 'no' ] );
63 $newname = $this->makePageLink( Title
::newFromText( $params[3] ) );
64 $params[2] = Message
::rawParam( $oldname );
65 $params[3] = Message
::rawParam( $newname );
66 unset( $params[4] ); // handled in getMessageKey
71 public function getActionLinks() {
72 if ( $this->entry
->isDeleted( LogPage
::DELETED_ACTION
) // Action is hidden
73 ||
$this->entry
->getSubtype() !== 'move'
74 ||
!$this->context
->getAuthority()->isAllowed( 'move' )
79 $params = $this->extractParameters();
80 $destTitle = Title
::newFromText( $params[3] );
81 if ( !$destTitle ||
!$destTitle->exists() ) {
85 $revert = $this->getLinkRenderer()->makeKnownLink(
86 SpecialPage
::getTitleFor( 'Movepage' ),
87 $this->msg( 'revertmove' )->text(),
90 'wpOldTitle' => $destTitle->getPrefixedDBkey(),
91 'wpNewTitle' => $this->entry
->getTarget()->getPrefixedDBkey(),
92 'wpReason' => $this->msg( 'revertmove-summary' )->inContentLanguage()->text(),
97 return $this->msg( 'parentheses' )->rawParams( $revert )->escaped();
100 protected function getParametersForApi() {
101 $entry = $this->entry
;
102 $params = $entry->getParameters();
106 '5:bool:suppressredirect',
107 '4::target' => '4:title:target',
108 '5::noredir' => '5:bool:suppressredirect',
110 foreach ( $map as $index => $key ) {
111 if ( isset( $params[$index] ) ) {
112 $params[$key] = $params[$index];
113 unset( $params[$index] );
117 if ( !isset( $params['5:bool:suppressredirect'] ) ) {
118 $params['5:bool:suppressredirect'] = false;