MediaWiki
REL1_23
|
00001 <?php 00028 class RollbackAction extends FormlessAction { 00029 00030 public function getName() { 00031 return 'rollback'; 00032 } 00033 00034 public function getRestriction() { 00035 return 'rollback'; 00036 } 00037 00038 public function onView() { 00039 $details = null; 00040 00041 $request = $this->getRequest(); 00042 00043 $result = $this->page->doRollback( 00044 $request->getVal( 'from' ), 00045 $request->getText( 'summary' ), 00046 $request->getVal( 'token' ), 00047 $request->getBool( 'bot' ), 00048 $details, 00049 $this->getUser() 00050 ); 00051 00052 if ( in_array( array( 'actionthrottledtext' ), $result ) ) { 00053 throw new ThrottledError; 00054 } 00055 00056 if ( isset( $result[0][0] ) && 00057 ( $result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback' ) 00058 ) { 00059 $this->getOutput()->setPageTitle( $this->msg( 'rollbackfailed' ) ); 00060 $errArray = $result[0]; 00061 $errMsg = array_shift( $errArray ); 00062 $this->getOutput()->addWikiMsgArray( $errMsg, $errArray ); 00063 00064 if ( isset( $details['current'] ) ) { 00066 $current = $details['current']; 00067 00068 if ( $current->getComment() != '' ) { 00069 $this->getOutput()->addHTML( $this->msg( 'editcomment' )->rawParams( 00070 Linker::formatComment( $current->getComment() ) )->parse() ); 00071 } 00072 } 00073 00074 return; 00075 } 00076 00077 #NOTE: Permission errors already handled by Action::checkExecute. 00078 00079 if ( $result == array( array( 'readonlytext' ) ) ) { 00080 throw new ReadOnlyError; 00081 } 00082 00083 #XXX: Would be nice if ErrorPageError could take multiple errors, and/or a status object. 00084 # Right now, we only show the first error 00085 foreach ( $result as $error ) { 00086 throw new ErrorPageError( 'rollbackfailed', $error[0], array_slice( $error, 1 ) ); 00087 } 00088 00090 $current = $details['current']; 00091 $target = $details['target']; 00092 $newId = $details['newid']; 00093 $this->getOutput()->setPageTitle( $this->msg( 'actioncomplete' ) ); 00094 $this->getOutput()->setRobotPolicy( 'noindex,nofollow' ); 00095 00096 $old = Linker::revUserTools( $current ); 00097 $new = Linker::revUserTools( $target ); 00098 $this->getOutput()->addHTML( $this->msg( 'rollback-success' )->rawParams( $old, $new ) 00099 ->parseAsBlock() ); 00100 $this->getOutput()->returnToMain( false, $this->getTitle() ); 00101 00102 if ( !$request->getBool( 'hidediff', false ) && 00103 !$this->getUser()->getBoolOption( 'norollbackdiff', false ) 00104 ) { 00105 $contentHandler = $current->getContentHandler(); 00106 $de = $contentHandler->createDifferenceEngine( 00107 $this->getContext(), 00108 $current->getId(), 00109 $newId, 00110 false, 00111 true 00112 ); 00113 $de->showDiff( '', '' ); 00114 } 00115 } 00116 00117 protected function getDescription() { 00118 return ''; 00119 } 00120 }