[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Edit rollback user interface
   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 interface for the rollback action
  25   *
  26   * @ingroup Actions
  27   */
  28  class RollbackAction extends FormlessAction {
  29  
  30  	public function getName() {
  31          return 'rollback';
  32      }
  33  
  34  	public function getRestriction() {
  35          return 'rollback';
  36      }
  37  
  38  	public function onView() {
  39          $details = null;
  40  
  41          $request = $this->getRequest();
  42          $user = $this->getUser();
  43  
  44          $result = $this->page->doRollback(
  45              $request->getVal( 'from' ),
  46              $request->getText( 'summary' ),
  47              $request->getVal( 'token' ),
  48              $request->getBool( 'bot' ),
  49              $details,
  50              $this->getUser()
  51          );
  52  
  53          if ( in_array( array( 'actionthrottledtext' ), $result ) ) {
  54              throw new ThrottledError;
  55          }
  56  
  57          if ( isset( $result[0][0] ) &&
  58              ( $result[0][0] == 'alreadyrolled' || $result[0][0] == 'cantrollback' )
  59          ) {
  60              $this->getOutput()->setPageTitle( $this->msg( 'rollbackfailed' ) );
  61              $errArray = $result[0];
  62              $errMsg = array_shift( $errArray );
  63              $this->getOutput()->addWikiMsgArray( $errMsg, $errArray );
  64  
  65              if ( isset( $details['current'] ) ) {
  66                  /** @var Revision $current */
  67                  $current = $details['current'];
  68  
  69                  if ( $current->getComment() != '' ) {
  70                      $this->getOutput()->addHTML( $this->msg( 'editcomment' )->rawParams(
  71                          Linker::formatComment( $current->getComment() ) )->parse() );
  72                  }
  73              }
  74  
  75              return;
  76          }
  77  
  78          #NOTE: Permission errors already handled by Action::checkExecute.
  79  
  80          if ( $result == array( array( 'readonlytext' ) ) ) {
  81              throw new ReadOnlyError;
  82          }
  83  
  84          #XXX: Would be nice if ErrorPageError could take multiple errors, and/or a status object.
  85          #     Right now, we only show the first error
  86          foreach ( $result as $error ) {
  87              throw new ErrorPageError( 'rollbackfailed', $error[0], array_slice( $error, 1 ) );
  88          }
  89  
  90          /** @var Revision $current */
  91          $current = $details['current'];
  92          $target = $details['target'];
  93          $newId = $details['newid'];
  94          $this->getOutput()->setPageTitle( $this->msg( 'actioncomplete' ) );
  95          $this->getOutput()->setRobotPolicy( 'noindex,nofollow' );
  96  
  97          $old = Linker::revUserTools( $current );
  98          $new = Linker::revUserTools( $target );
  99          $this->getOutput()->addHTML( $this->msg( 'rollback-success' )->rawParams( $old, $new )
 100              ->parseAsBlock() );
 101  
 102          if ( $user->getBoolOption( 'watchrollback' ) ) {
 103              $user->addWatch( $this->page->getTitle(), WatchedItem::IGNORE_USER_RIGHTS );
 104          }
 105  
 106          $this->getOutput()->returnToMain( false, $this->getTitle() );
 107  
 108          if ( !$request->getBool( 'hidediff', false ) &&
 109              !$this->getUser()->getBoolOption( 'norollbackdiff', false )
 110          ) {
 111              $contentHandler = $current->getContentHandler();
 112              $de = $contentHandler->createDifferenceEngine(
 113                  $this->getContext(),
 114                  $current->getId(),
 115                  $newId,
 116                  false,
 117                  true
 118              );
 119              $de->showDiff( '', '' );
 120          }
 121      }
 122  
 123  	protected function getDescription() {
 124          return '';
 125      }
 126  }


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