MediaWiki  master
McrRestoreAction.php
Go to the documentation of this file.
1 <?php
18 
19  public function getName() {
20  return 'mcrrestore';
21  }
22 
23  public function getDescription() {
24  return '';
25  }
26 
27  protected function initFromParameters() {
28  $curRev = $this->getWikiPage()->getRevisionRecord();
29  if ( !$curRev ) {
30  throw new ErrorPageError( 'mcrundofailed', 'nopagetext' );
31  }
32  $this->curRev = $curRev;
33  $this->cur = $this->getRequest()->getInt( 'cur', $this->curRev->getId() );
34 
35  $this->undo = $this->cur;
36  $this->undoafter = $this->getRequest()->getInt( 'restore' );
37 
38  if ( $this->undo == 0 || $this->undoafter == 0 ) {
39  throw new ErrorPageError( 'mcrundofailed', 'mcrundo-missingparam' );
40  }
41  }
42 
43  protected function addStatePropagationFields( HTMLForm $form ) {
44  $form->addHiddenField( 'restore', $this->undoafter );
45  $form->addHiddenField( 'cur', $this->curRev->getId() );
46  }
47 
48  protected function alterForm( HTMLForm $form ) {
49  parent::alterForm( $form );
50 
51  $form->setWrapperLegendMsg( 'confirm-mcrrestore-title' );
52  }
53 
54 }
getWikiPage()
Get a WikiPage object.
Definition: Action.php:200
getRequest()
Get the WebRequest being used for this instance.
Definition: Action.php:141
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:155
setWrapperLegendMsg( $msg)
Prompt the whole form to be wrapped in a "<fieldset>", with this message as its "<legend>" element.
Definition: HTMLForm.php:1842
addHiddenField( $name, $value, array $attribs=[])
Add a hidden field to the output Array values are discarded for security reasons (per WebRequest::get...
Definition: HTMLForm.php:1152
Temporary action for restoring multi-content revisions.
alterForm(HTMLForm $form)
Play with the HTMLForm if you need to more substantially.
getName()
Return the name of the action this object responds to.
addStatePropagationFields(HTMLForm $form)
getDescription()
Returns the description that goes below the <h1> element.
Temporary action for MCR undos.
RevisionRecord null $curRev