Revert r101492, broken, see CR. Also revert followup r101496.
[mediawiki.git] / includes / actions / PurgeAction.php
blob29cbf3ae5b26be909675a5068c8d1279fbba39c5
1 <?php
2 /**
3 * Formats credits for articles
5 * Copyright 2004, Evan Prodromou <evan@wikitravel.org>.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 * @file
22 * @ingroup Actions
23 * @author <evan@wikitravel.org>
26 class PurgeAction extends FormAction {
28 private $redirectParams;
30 public function getName() {
31 return 'purge';
34 public function getRestriction() {
35 return null;
38 public function requiresUnblock() {
39 return false;
42 public function getDescription() {
43 return '';
46 /**
47 * Just get an empty form with a single submit button
48 * @return array
50 protected function getFormFields() {
51 return array();
54 public function onSubmit( $data ) {
55 $this->page->doPurge();
56 return true;
59 /**
60 * purge is slightly weird because it can be either formed or formless depending
61 * on user permissions
63 public function show() {
64 $this->setHeaders();
66 // This will throw exceptions if there's a problem
67 $this->checkCanExecute( $this->getUser() );
69 if ( $this->getUser()->isAllowed( 'purge' ) ) {
70 $this->redirectParams = wfArrayToCGI( array_diff_key(
71 $this->getRequest()->getQueryValues(),
72 array( 'title' => null, 'action' => null )
73 ) );
74 $this->onSubmit( array() );
75 $this->onSuccess();
76 } else {
77 $this->redirectParams = $this->getRequest()->getVal( 'redirectparams', '' );
78 $form = $this->getForm();
79 if ( $form->show() ) {
80 $this->onSuccess();
85 protected function alterForm( HTMLForm $form ) {
86 $form->setSubmitText( wfMsg( 'confirm_purge_button' ) );
89 protected function preText() {
90 return wfMessage( 'confirm-purge-top' )->parse();
93 protected function postText() {
94 return wfMessage( 'confirm-purge-bottom' )->parse();
97 public function onSuccess() {
98 $this->getOutput()->redirect( $this->getTitle()->getFullUrl( $this->redirectParams ) );