From ca32f08966f1b51fcb19460f0996bb0c4048e6fe Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 3 Dec 2011 13:29:22 +0100 Subject: Update to MediaWiki 1.18.0 * also update ArchLinux skin to chagnes in MonoBook * Use only css to hide our menu bar when printing --- includes/actions/RollbackAction.php | 122 ++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 includes/actions/RollbackAction.php (limited to 'includes/actions/RollbackAction.php') diff --git a/includes/actions/RollbackAction.php b/includes/actions/RollbackAction.php new file mode 100644 index 00000000..9036ebf5 --- /dev/null +++ b/includes/actions/RollbackAction.php @@ -0,0 +1,122 @@ +getRequest(); + + $result = $this->page->doRollback( + $request->getVal( 'from' ), + $request->getText( 'summary' ), + $request->getVal( 'token' ), + $request->getBool( 'bot' ), + $details, + $this->getUser() + ); + + if ( in_array( array( 'actionthrottledtext' ), $result ) ) { + throw new ThrottledError; + } + + if ( isset( $result[0][0] ) && ( $result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback' ) ) { + $this->getOutput()->setPageTitle( wfMsg( 'rollbackfailed' ) ); + $errArray = $result[0]; + $errMsg = array_shift( $errArray ); + $this->getOutput()->addWikiMsgArray( $errMsg, $errArray ); + + if ( isset( $details['current'] ) ) { + $current = $details['current']; + + if ( $current->getComment() != '' ) { + $this->getOutput()->addHTML( wfMessage( 'editcomment' )->rawParams( + Linker::formatComment( $current->getComment() ) )->parse() ); + } + } + + return; + } + + # Display permissions errors before read-only message -- there's no + # point in misleading the user into thinking the inability to rollback + # is only temporary. + if ( !empty( $result ) && $result !== array( array( 'readonlytext' ) ) ) { + # array_diff is completely broken for arrays of arrays, sigh. + # Remove any 'readonlytext' error manually. + $out = array(); + foreach ( $result as $error ) { + if ( $error != array( 'readonlytext' ) ) { + $out [] = $error; + } + } + $this->getOutput()->showPermissionsErrorPage( $out ); + + return; + } + + if ( $result == array( array( 'readonlytext' ) ) ) { + throw new ReadOnlyError; + } + + $current = $details['current']; + $target = $details['target']; + $newId = $details['newid']; + $this->getOutput()->setPageTitle( wfMsg( 'actioncomplete' ) ); + $this->getOutput()->setRobotPolicy( 'noindex,nofollow' ); + + if ( $current->getUserText() === '' ) { + $old = wfMsg( 'rev-deleted-user' ); + } else { + $old = Linker::userLink( $current->getUser(), $current->getUserText() ) + . Linker::userToolLinks( $current->getUser(), $current->getUserText() ); + } + + $new = Linker::userLink( $target->getUser(), $target->getUserText() ) + . Linker::userToolLinks( $target->getUser(), $target->getUserText() ); + $this->getOutput()->addHTML( wfMsgExt( 'rollback-success', array( 'parse', 'replaceafter' ), $old, $new ) ); + $this->getOutput()->returnToMain( false, $this->getTitle() ); + + if ( !$request->getBool( 'hidediff', false ) && !$this->getUser()->getBoolOption( 'norollbackdiff', false ) ) { + $de = new DifferenceEngine( $this->getTitle(), $current->getId(), $newId, false, true ); + $de->showDiff( '', '' ); + } + } + + protected function getDescription() { + return ''; + } +} -- cgit v1.2.3-54-g00ecf