| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
m |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
use MediaWiki\Message\Message; |
| 27 |
use MediaWiki\SpecialPage\SpecialPage; |
| 28 |
use MediaWiki\Title\Title; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
class MoveLogFormatter extends LogFormatter { |
| 36 |
public function getPreloadTitles() { |
| 37 |
$params = $this->extractParameters(); |
| 38 |
$title = Title::newFromText( $params[3] ); |
| 39 |
|
| 40 |
if ( $title !== null ) { |
| 41 |
return [ $title ]; |
| 42 |
} else { |
| 43 |
|
| 44 |
|
| 45 |
return []; |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
protected function getMessageKey() { |
| 50 |
$key = parent::getMessageKey(); |
| 51 |
$params = $this->extractParameters(); |
| 52 |
if ( isset( $params[4] ) && $params[4] === '1' ) { |
| 53 |
|
| 54 |
$key .= '-noredirect'; |
| 55 |
} |
| 56 |
|
| 57 |
return $key; |
| 58 |
} |
| 59 |
|
| 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] ); |
| 67 |
|
| 68 |
return $params; |
| 69 |
} |
| 70 |
|
| 71 |
public function getActionLinks() { |
| 72 |
if ( $this->entry->isDeleted( LogPage::DELETED_ACTION ) |
| 73 |
|| $this->entry->getSubtype() !== 'move' |
| 74 |
|| !$this->context->getAuthority()->isAllowed( 'move' ) |
| 75 |
) { |
| 76 |
return ''; |
| 77 |
} |
| 78 |
|
| 79 |
$params = $this->extractParameters(); |
| 80 |
$destTitle = Title::newFromText( $params[3] ); |
| 81 |
if ( !$destTitle || !$destTitle->exists() ) { |
| 82 |
return ''; |
| 83 |
} |
| 84 |
|
| 85 |
$revert = $this->getLinkRenderer()->makeKnownLink( |
| 86 |
SpecialPage::getTitleFor( 'Movepage' ), |
| 87 |
$this->msg( 'revertmove' )->text(), |
| 88 |
[], |
| 89 |
[ |
| 90 |
'wpOldTitle' => $destTitle->getPrefixedDBkey(), |
| 91 |
'wpNewTitle' => $this->entry->getTarget()->getPrefixedDBkey(), |
| 92 |
'wpReason' => $this->msg( 'revertmove-summary' )->inContentLanguage()->text(), |
| 93 |
'wpMovetalk' => 0 |
| 94 |
] |
| 95 |
); |
| 96 |
|
| 97 |
return $this->msg( 'parentheses' )->rawParams( $revert )->escaped(); |
| 98 |
} |
| 99 |
|
| 100 |
protected function getParametersForApi() { |
| 101 |
$entry = $this->entry; |
| 102 |
$params = $entry->getParameters(); |
| 103 |
|
| 104 |
static $map = [ |
| 105 |
'4:title:target', |
| 106 |
'5:bool:suppressredirect', |
| 107 |
'4::target' => '4:title:target', |
| 108 |
'5::noredir' => '5:bool:suppressredirect', |
| 109 |
]; |
| 110 |
foreach ( $map as $index => $key ) { |
| 111 |
if ( isset( $params[$index] ) ) { |
| 112 |
$params[$key] = $params[$index]; |
| 113 |
unset( $params[$index] ); |
| 114 |
} |
| 115 |
} |
| 116 |
|
| 117 |
if ( !isset( $params['5:bool:suppressredirect'] ) ) { |
| 118 |
$params['5:bool:suppressredirect'] = false; |
| 119 |
} |
| 120 |
|
| 121 |
return $params; |
| 122 |
} |
| 123 |
|
| 124 |
} |