| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
use MediaWiki\HTMLForm\HTMLForm; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
class McrRestoreAction extends McrUndoAction { |
| 20 |
|
| 21 |
public function getName() { |
| 22 |
return 'mcrrestore'; |
| 23 |
} |
| 24 |
|
| 25 |
public function getDescription() { |
| 26 |
return ''; |
| 27 |
} |
| 28 |
|
| 29 |
protected function initFromParameters() { |
| 30 |
$curRev = $this->getWikiPage()->getRevisionRecord(); |
| 31 |
if ( !$curRev ) { |
| 32 |
throw new ErrorPageError( 'mcrundofailed', 'nopagetext' ); |
| 33 |
} |
| 34 |
$this->curRev = $curRev; |
| 35 |
$this->cur = $this->getRequest()->getInt( 'cur', $this->curRev->getId() ); |
| 36 |
|
| 37 |
$this->undo = $this->cur; |
| 38 |
$this->undoafter = $this->getRequest()->getInt( 'restore' ); |
| 39 |
|
| 40 |
if ( $this->undo == 0 || $this->undoafter == 0 ) { |
| 41 |
throw new ErrorPageError( 'mcrundofailed', 'mcrundo-missingparam' ); |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
protected function addStatePropagationFields( HTMLForm $form ) { |
| 46 |
$form->addHiddenField( 'restore', $this->undoafter ); |
| 47 |
$form->addHiddenField( 'cur', $this->curRev->getId() ); |
| 48 |
} |
| 49 |
|
| 50 |
protected function alterForm( HTMLForm $form ) { |
| 51 |
parent::alterForm( $form ); |
| 52 |
|
| 53 |
$form->setWrapperLegendMsg( 'confirm-mcrrestore-title' ); |
| 54 |
} |
| 55 |
|
| 56 |
} |