MediaWiki master
McrRestoreAction.php
Go to the documentation of this file.
1<?php
8namespace MediaWiki\Actions;
9
12
23
25 public function getName() {
26 return 'mcrrestore';
27 }
28
30 public function getDescription() {
31 return '';
32 }
33
34 protected function initFromParameters() {
35 $curRev = $this->getWikiPage()->getRevisionRecord();
36 if ( !$curRev ) {
37 throw new ErrorPageError( 'mcrundofailed', 'nopagetext' );
38 }
39 $this->curRev = $curRev;
40 $this->cur = $this->getRequest()->getInt( 'cur', $this->curRev->getId() );
41
42 $this->undo = $this->cur;
43 $this->undoafter = $this->getRequest()->getInt( 'restore' );
44
45 if ( $this->undo == 0 || $this->undoafter == 0 ) {
46 throw new ErrorPageError( 'mcrundofailed', 'mcrundo-missingparam' );
47 }
48 }
49
50 protected function addStatePropagationFields( HTMLForm $form ) {
51 $form->addHiddenField( 'restore', $this->undoafter );
52 $form->addHiddenField( 'cur', $this->curRev->getId() );
53 }
54
55 protected function alterForm( HTMLForm $form ) {
56 parent::alterForm( $form );
57
58 $form->setWrapperLegendMsg( 'confirm-mcrrestore-title' );
59 }
60
61}
62
64class_alias( McrRestoreAction::class, 'McrRestoreAction' );
getWikiPage()
Get a WikiPage object.
Definition Action.php:192
getRequest()
Get the WebRequest being used for this instance.
Definition Action.php:133
Temporary action for restoring multi-content revisions.
getName()
Return the name of the action this object responds to.1.17string Lowercase name
alterForm(HTMLForm $form)
Play with the HTMLForm if you need to more substantially.
getDescription()
Returns the description that goes below the <h1> element.1.17 to override string HTML
Temporary action for MCR undos.
An error page which can definitely be safely rendered using the OutputPage.
Object handling generic submission, CSRF protection, layout and other logic for UI forms in a reusabl...
Definition HTMLForm.php:195
setWrapperLegendMsg( $msg)
Prompt the whole form to be wrapped in a "<fieldset>", with this message as its "<legend>" element.
addHiddenField( $name, $value, array $attribs=[])
Add a hidden field to the output Array values are discarded for security reasons (per WebRequest::get...