McrRestoreAction.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * Temporary action for restoring multi-content revisions
  4. * @file
  5. * @ingroup Actions
  6. */
  7. /**
  8. * Temporary action for restoring multi-content revisions.
  9. *
  10. * This is intended to go away when real MCR support is added to EditPage and
  11. * the standard revert-by-edit behavior can be implemented there instead.
  12. *
  13. * @ingroup Actions
  14. * @since 1.32
  15. * @deprecated since 1.32
  16. */
  17. class McrRestoreAction extends McrUndoAction {
  18. public function getName() {
  19. return 'mcrrestore';
  20. }
  21. public function getDescription() {
  22. return '';
  23. }
  24. protected function initFromParameters() {
  25. $curRev = $this->page->getRevision();
  26. if ( !$curRev ) {
  27. throw new ErrorPageError( 'mcrundofailed', 'nopagetext' );
  28. }
  29. $this->curRev = $curRev->getRevisionRecord();
  30. $this->cur = $this->getRequest()->getInt( 'cur', $this->curRev->getId() );
  31. $this->undo = $this->cur;
  32. $this->undoafter = $this->getRequest()->getInt( 'restore' );
  33. if ( $this->undo == 0 || $this->undoafter == 0 ) {
  34. throw new ErrorPageError( 'mcrundofailed', 'mcrundo-missingparam' );
  35. }
  36. }
  37. protected function addStatePropagationFields( HTMLForm $form ) {
  38. $form->addHiddenField( 'restore', $this->undoafter );
  39. $form->addHiddenField( 'cur', $this->curRev->getId() );
  40. }
  41. protected function alterForm( HTMLForm $form ) {
  42. parent::alterForm( $form );
  43. $form->setWrapperLegendMsg( 'confirm-mcrrestore-title' );
  44. }
  45. }