[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/actions/ -> PurgeAction.php (source)

   1  <?php
   2  /**
   3   * User-requested page cache purging.
   4   *
   5   * This program is free software; you can redistribute it and/or modify
   6   * it under the terms of the GNU General Public License as published by
   7   * the Free Software Foundation; either version 2 of the License, or
   8   * (at your option) any later version.
   9   *
  10   * This program is distributed in the hope that it will be useful,
  11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13   * GNU General Public License for more details.
  14   *
  15   * You should have received a copy of the GNU General Public License
  16   * along with this program; if not, write to the Free Software
  17   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  18   *
  19   * @file
  20   * @ingroup Actions
  21   */
  22  
  23  /**
  24   * User-requested page cache purging.
  25   *
  26   * For users with 'purge', this will directly trigger the cache purging and
  27   * for users without that right, it will show a confirmation form.
  28   *
  29   * @ingroup Actions
  30   */
  31  class PurgeAction extends FormAction {
  32  
  33      private $redirectParams;
  34  
  35  	public function getName() {
  36          return 'purge';
  37      }
  38  
  39  	public function requiresUnblock() {
  40          return false;
  41      }
  42  
  43  	public function getDescription() {
  44          return '';
  45      }
  46  
  47      /**
  48       * Just get an empty form with a single submit button
  49       * @return array
  50       */
  51  	protected function getFormFields() {
  52          return array();
  53      }
  54  
  55  	public function onSubmit( $data ) {
  56          return $this->page->doPurge();
  57      }
  58  
  59      /**
  60       * purge is slightly weird because it can be either formed or formless depending
  61       * on user permissions
  62       */
  63  	public function show() {
  64          $this->setHeaders();
  65  
  66          // This will throw exceptions if there's a problem
  67          $this->checkCanExecute( $this->getUser() );
  68  
  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              if ( $this->onSubmit( array() ) ) {
  75                  $this->onSuccess();
  76              }
  77          } else {
  78              $this->redirectParams = $this->getRequest()->getVal( 'redirectparams', '' );
  79              $form = $this->getForm();
  80              if ( $form->show() ) {
  81                  $this->onSuccess();
  82              }
  83          }
  84      }
  85  
  86  	protected function alterForm( HTMLForm $form ) {
  87          $form->setSubmitTextMsg( 'confirm_purge_button' );
  88      }
  89  
  90  	protected function preText() {
  91          return $this->msg( 'confirm-purge-top' )->parse();
  92      }
  93  
  94  	protected function postText() {
  95          return $this->msg( 'confirm-purge-bottom' )->parse();
  96      }
  97  
  98  	public function onSuccess() {
  99          $this->getOutput()->redirect( $this->getTitle()->getFullURL( $this->redirectParams ) );
 100      }
 101  }


Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1