<?php
-
/**
- * Created on Oct 31, 2007
* API for MediaWiki 1.8+
*
+ * Created on Oct 31, 2007
+ *
* Copyright © 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl
*
* This program is free software; you can redistribute it and/or modify
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
*/
if ( !defined( 'MEDIAWIKI' ) ) {
}
/**
+ * API Module to move pages
* @ingroup API
*/
class ApiMove extends ApiBase {
}
$this->requireOnlyOneParameter( $params, 'from', 'fromid' );
- if ( !isset( $params['to'] ) ) {
- $this->dieUsageMsg( array( 'missingparam', 'to' ) );
- }
if ( isset( $params['from'] ) ) {
$fromTitle = Title::newFromText( $params['from'] );
}
// Move the page
- $hookErr = null;
$retval = $fromTitle->moveTo( $toTitle, true, $params['reason'], !$params['noredirect'] );
if ( $retval !== true ) {
$this->dieUsageMsg( reset( $retval ) );
}
$r = array( 'from' => $fromTitle->getPrefixedText(), 'to' => $toTitle->getPrefixedText(), 'reason' => $params['reason'] );
- if ( !$params['noredirect'] || !$wgUser->isAllowed( 'suppressredirect' ) )
- {
+ if ( !$params['noredirect'] || !$wgUser->isAllowed( 'suppressredirect' ) ) {
$r['redirectcreated'] = '';
}
// Move the talk page
- if ( $params['movetalk'] && $fromTalk->exists() && !$fromTitle->isTalkPage() )
- {
+ if ( $params['movetalk'] && $fromTalk->exists() && !$fromTitle->isTalkPage() ) {
$retval = $fromTalk->moveTo( $toTalk, true, $params['reason'], !$params['noredirect'] );
if ( $retval === true ) {
$r['talkfrom'] = $fromTalk->getPrefixedText();
$watch = "preferences";
if ( isset( $params['watchlist'] ) ) {
$watch = $params['watchlist'];
- } elseif ( $wgUser->getOption( 'watchmoves' ) || $params['watch'] ) {
+ } elseif ( $params['watch'] ) {
$watch = 'watch';
} elseif ( $params['unwatch'] ) {
$watch = 'unwatch';
}
// Watch pages
- $this->setWatch( $watch, $fromTitle );
- $this->setWatch( $watch, $toTitle );
+ $this->setWatch( $watch, $fromTitle, 'watchmoves' );
+ $this->setWatch( $watch, $toTitle, 'watchmoves' );
$this->getResult()->addValue( null, $this->getModuleName(), $r );
}
'fromid' => array(
ApiBase::PARAM_TYPE => 'integer'
),
- 'to' => null,
+ 'to' => array(
+ ApiBase::PARAM_TYPE => 'string',
+ ApiBase::PARAM_REQUIRED => true
+ ),
'token' => null,
'reason' => null,
'movetalk' => false,
}
public function getParamDescription() {
+ $p = $this->getModulePrefix();
return array(
- 'from' => 'Title of the page you want to move. Cannot be used together with fromid.',
- 'fromid' => 'Page ID of the page you want to move. Cannot be used together with from.',
- 'to' => 'Title you want to rename the page to.',
+ 'from' => "Title of the page you want to move. Cannot be used together with {$p}fromid",
+ 'fromid' => "Page ID of the page you want to move. Cannot be used together with {$p}from",
+ 'to' => 'Title you want to rename the page to',
'token' => 'A move token previously retrieved through prop=info',
- 'reason' => 'Reason for the move (optional).',
- 'movetalk' => 'Move the talk page, if it exists.',
+ 'reason' => 'Reason for the move (optional)',
+ 'movetalk' => 'Move the talk page, if it exists',
'movesubpages' => 'Move subpages, if applicable',
'noredirect' => 'Don\'t create a redirect',
'watch' => 'Add the page and the redirect to your watchlist',
}
public function getDescription() {
- return array(
- 'Move a page.'
- );
+ return 'Move a page';
}
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
- array( 'missingparam', 'to' ),
array( 'invalidtitle', 'from' ),
array( 'nosuchpageid', 'fromid' ),
array( 'notanarticle' ),