3 * Edit rollback user interface
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 * User interface for the rollback action
28 class RollbackAction
extends FormlessAction
{
30 public function getName() {
34 public function getRestriction() {
38 public function onView() {
41 $request = $this->getRequest();
43 $result = $this->page
->doRollback(
44 $request->getVal( 'from' ),
45 $request->getText( 'summary' ),
46 $request->getVal( 'token' ),
47 $request->getBool( 'bot' ),
52 if ( in_array( array( 'actionthrottledtext' ), $result ) ) {
53 throw new ThrottledError
;
56 if ( isset( $result[0][0] ) && ( $result[0][0] == 'alreadyrolled' ||
$result[0][0] == 'cantrollback' ) ) {
57 $this->getOutput()->setPageTitle( $this->msg( 'rollbackfailed' ) );
58 $errArray = $result[0];
59 $errMsg = array_shift( $errArray );
60 $this->getOutput()->addWikiMsgArray( $errMsg, $errArray );
62 if ( isset( $details['current'] ) ) {
63 $current = $details['current'];
65 if ( $current->getComment() != '' ) {
66 $this->getOutput()->addHTML( $this->msg( 'editcomment' )->rawParams(
67 Linker
::formatComment( $current->getComment() ) )->parse() );
74 #NOTE: Permission errors already handled by Action::checkExecute.
76 if ( $result == array( array( 'readonlytext' ) ) ) {
77 throw new ReadOnlyError
;
80 #XXX: Would be nice if ErrorPageError could take multiple errors, and/or a status object.
81 # Right now, we only show the first error
82 foreach ( $result as $error ) {
83 throw new ErrorPageError( 'rollbackfailed', $error[0], array_slice( $error, 1 ) );
86 $current = $details['current'];
87 $target = $details['target'];
88 $newId = $details['newid'];
89 $this->getOutput()->setPageTitle( $this->msg( 'actioncomplete' ) );
90 $this->getOutput()->setRobotPolicy( 'noindex,nofollow' );
92 $old = Linker
::revUserTools( $current );
93 $new = Linker
::revUserTools( $target );
94 $this->getOutput()->addHTML( $this->msg( 'rollback-success' )->rawParams( $old, $new )->parseAsBlock() );
95 $this->getOutput()->returnToMain( false, $this->getTitle() );
97 if ( !$request->getBool( 'hidediff', false ) && !$this->getUser()->getBoolOption( 'norollbackdiff', false ) ) {
98 $contentHandler = $current->getContentHandler();
99 $de = $contentHandler->createDifferenceEngine( $this->getContext(), $current->getId(), $newId, false, true );
100 $de->showDiff( '', '' );
104 protected function getDescription() {