nice debug msg for Title::getRestrictionTypes
[mediawiki.git] / includes / actions / PurgeAction.php
blobe288785f3d081323fd8a63f44caa6735dd8878f8
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 return $this->page->doPurge();
58 /**
59 * purge is slightly weird because it can be either formed or formless depending
60 * on user permissions
62 public function show() {
63 $this->setHeaders();
65 // This will throw exceptions if there's a problem
66 $this->checkCanExecute( $this->getUser() );
68 if ( $this->getUser()->isAllowed( 'purge' ) ) {
69 $this->redirectParams = wfArrayToCGI( array_diff_key(
70 $this->getRequest()->getQueryValues(),
71 array( 'title' => null, 'action' => null )
72 ) );
73 if( $this->onSubmit( array() ) ) {
74 $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 ) );