MediaWiki  REL1_19
PurgeAction.php
Go to the documentation of this file.
00001 <?php
00026 class PurgeAction extends FormAction {
00027 
00028         private $redirectParams;
00029 
00030         public function getName() {
00031                 return 'purge';
00032         }
00033 
00034         public function requiresUnblock() {
00035                 return false;
00036         }
00037 
00038         public function getDescription() {
00039                 return '';
00040         }
00041 
00046         protected function getFormFields() {
00047                 return array();
00048         }
00049 
00050         public function onSubmit( $data ) {
00051                 return $this->page->doPurge();
00052         }
00053 
00058         public function show() {
00059                 $this->setHeaders();
00060 
00061                 // This will throw exceptions if there's a problem
00062                 $this->checkCanExecute( $this->getUser() );
00063 
00064                 if ( $this->getUser()->isAllowed( 'purge' ) ) {
00065                         $this->redirectParams = wfArrayToCGI( array_diff_key(
00066                                 $this->getRequest()->getQueryValues(),
00067                                 array( 'title' => null, 'action' => null )
00068                         ) );
00069                         if( $this->onSubmit( array() ) ) {
00070                                 $this->onSuccess();
00071                         }
00072                 } else {
00073                         $this->redirectParams = $this->getRequest()->getVal( 'redirectparams', '' );
00074                         $form = $this->getForm();
00075                         if ( $form->show() ) {
00076                                 $this->onSuccess();
00077                         }
00078                 }
00079         }
00080 
00081         protected function alterForm( HTMLForm $form ) {
00082                 $form->setSubmitText( wfMsg( 'confirm_purge_button' ) );
00083         }
00084 
00085         protected function preText() {
00086                 return wfMessage( 'confirm-purge-top' )->parse();
00087         }
00088 
00089         protected function postText() {
00090                 return wfMessage( 'confirm-purge-bottom' )->parse();
00091         }
00092 
00093         public function onSuccess() {
00094                 $this->getOutput()->redirect( $this->getTitle()->getFullUrl( $this->redirectParams ) );
00095         }
00096 }