2008-03-03 18:19:52 +00:00
|
|
|
<?php
|
2010-02-22 12:18:42 +00:00
|
|
|
/**
|
2010-12-22 20:52:06 +00:00
|
|
|
*
|
2008-03-03 18:19:52 +00:00
|
|
|
*
|
2010-08-07 19:59:42 +00:00
|
|
|
* Created on August 16, 2007
|
|
|
|
|
*
|
2012-07-15 20:13:02 +00:00
|
|
|
* Copyright © 2007 Iker Labarga "<Firstname><Lastname>@gmail.com"
|
2008-03-03 18:19:52 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* 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.,
|
2010-06-21 13:13:32 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-03-03 18:19:52 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2010-08-07 19:59:42 +00:00
|
|
|
*
|
|
|
|
|
* @file
|
2008-03-03 18:19:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2008-09-04 13:40:33 +00:00
|
|
|
* A module that allows for editing and creating pages.
|
2008-03-03 18:19:52 +00:00
|
|
|
*
|
2008-09-04 13:40:33 +00:00
|
|
|
* Currently, this wraps around the EditPage class in an ugly way,
|
|
|
|
|
* EditPage.php should be rewritten to provide a cleaner interface
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup API
|
2008-03-03 18:19:52 +00:00
|
|
|
*/
|
|
|
|
|
class ApiEditPage extends ApiBase {
|
|
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
public function __construct( $query, $moduleName ) {
|
2010-02-22 12:18:42 +00:00
|
|
|
parent::__construct( $query, $moduleName );
|
2008-03-03 18:19:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function execute() {
|
2011-10-26 23:27:01 +00:00
|
|
|
$user = $this->getUser();
|
2008-03-03 18:19:52 +00:00
|
|
|
$params = $this->extractRequestParams();
|
2010-02-22 12:18:42 +00:00
|
|
|
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( is_null( $params['text'] ) && is_null( $params['appendtext'] ) &&
|
|
|
|
|
is_null( $params['prependtext'] ) &&
|
|
|
|
|
$params['undo'] == 0 )
|
2010-02-22 12:18:42 +00:00
|
|
|
{
|
2011-05-19 17:51:16 +00:00
|
|
|
$this->dieUsageMsg( 'missingtext' );
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2012-04-28 13:45:37 +00:00
|
|
|
$pageObj = $this->getTitleOrPageId( $params );
|
|
|
|
|
$titleObj = $pageObj->getTitle();
|
2012-04-07 21:47:06 +00:00
|
|
|
if ( $titleObj->isExternal() ) {
|
|
|
|
|
$this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2010-12-30 17:06:09 +00:00
|
|
|
|
2012-08-21 14:14:18 +00:00
|
|
|
if ( !isset( $params['contentmodel'] ) || $params['contentmodel'] == '' ) {
|
|
|
|
|
$contentHandler = $pageObj->getContentHandler();
|
|
|
|
|
} else {
|
|
|
|
|
$contentHandler = ContentHandler::getForModelID( $params['contentmodel'] );
|
|
|
|
|
}
|
2012-06-25 14:09:08 +00:00
|
|
|
|
|
|
|
|
// @todo ask handler whether direct editing is supported at all! make allowFlatEdit() method or some such
|
|
|
|
|
|
|
|
|
|
if ( !isset( $params['contentformat'] ) || $params['contentformat'] == '' ) {
|
2012-06-25 21:30:51 +00:00
|
|
|
$params['contentformat'] = $contentHandler->getDefaultFormat();
|
2012-06-25 14:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
2012-06-25 21:30:51 +00:00
|
|
|
$contentFormat = $params['contentformat'];
|
|
|
|
|
|
2012-06-25 14:09:08 +00:00
|
|
|
if ( !$contentHandler->isSupportedFormat( $contentFormat ) ) {
|
|
|
|
|
$name = $titleObj->getPrefixedDBkey();
|
|
|
|
|
$model = $contentHandler->getModelID();
|
|
|
|
|
|
2012-08-20 19:33:07 +00:00
|
|
|
$this->dieUsage( "The requested format $contentFormat is not supported for content model ".
|
|
|
|
|
" $model used by $name", 'badformat' );
|
2012-06-25 14:09:08 +00:00
|
|
|
}
|
|
|
|
|
|
2011-06-20 22:18:11 +00:00
|
|
|
$apiResult = $this->getResult();
|
2011-06-20 22:13:45 +00:00
|
|
|
|
2010-12-30 17:06:09 +00:00
|
|
|
if ( $params['redirect'] ) {
|
|
|
|
|
if ( $titleObj->isRedirect() ) {
|
2010-10-23 17:48:08 +00:00
|
|
|
$oldTitle = $titleObj;
|
2010-12-30 17:06:09 +00:00
|
|
|
|
2012-09-05 15:50:13 +00:00
|
|
|
$titles = Revision::newFromTitle( $oldTitle, false, Revision::READ_LATEST )
|
|
|
|
|
->getContent( Revision::FOR_THIS_USER )
|
|
|
|
|
->getRedirectChain();
|
2010-12-30 17:06:09 +00:00
|
|
|
// array_shift( $titles );
|
|
|
|
|
|
2010-10-23 17:48:08 +00:00
|
|
|
$redirValues = array();
|
|
|
|
|
foreach ( $titles as $id => $newTitle ) {
|
2010-12-30 17:06:09 +00:00
|
|
|
|
|
|
|
|
if ( !isset( $titles[ $id - 1 ] ) ) {
|
2010-10-23 17:48:08 +00:00
|
|
|
$titles[ $id - 1 ] = $oldTitle;
|
|
|
|
|
}
|
2010-12-30 17:06:09 +00:00
|
|
|
|
2010-10-23 17:48:08 +00:00
|
|
|
$redirValues[] = array(
|
|
|
|
|
'from' => $titles[ $id - 1 ]->getPrefixedText(),
|
|
|
|
|
'to' => $newTitle->getPrefixedText()
|
|
|
|
|
);
|
2010-12-30 17:06:09 +00:00
|
|
|
|
2010-10-23 17:48:08 +00:00
|
|
|
$titleObj = $newTitle;
|
|
|
|
|
}
|
2010-12-30 17:06:09 +00:00
|
|
|
|
2011-06-20 22:18:11 +00:00
|
|
|
$apiResult->setIndexedTagName( $redirValues, 'r' );
|
|
|
|
|
$apiResult->addValue( null, 'redirects', $redirValues );
|
2010-08-08 01:14:48 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-02-22 12:18:42 +00:00
|
|
|
|
|
|
|
|
if ( $params['createonly'] && $titleObj->exists() ) {
|
2011-05-19 17:51:16 +00:00
|
|
|
$this->dieUsageMsg( 'createonly-exists' );
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
|
|
|
|
if ( $params['nocreate'] && !$titleObj->exists() ) {
|
2011-05-19 17:51:16 +00:00
|
|
|
$this->dieUsageMsg( 'nocreate-missing' );
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2008-03-03 18:19:52 +00:00
|
|
|
// Now let's check whether we're even allowed to do this
|
2011-10-26 23:27:01 +00:00
|
|
|
$errors = $titleObj->getUserPermissionsErrors( 'edit', $user );
|
2010-02-22 12:18:42 +00:00
|
|
|
if ( !$titleObj->exists() ) {
|
2011-10-26 23:27:01 +00:00
|
|
|
$errors = array_merge( $errors, $titleObj->getUserPermissionsErrors( 'create', $user ) );
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
|
|
|
|
if ( count( $errors ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->dieUsageMsg( $errors[0] );
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2008-03-03 18:19:52 +00:00
|
|
|
|
2008-06-15 19:59:55 +00:00
|
|
|
$toMD5 = $params['text'];
|
2010-01-11 15:55:52 +00:00
|
|
|
if ( !is_null( $params['appendtext'] ) || !is_null( $params['prependtext'] ) )
|
2008-06-12 13:05:07 +00:00
|
|
|
{
|
2012-06-25 14:09:08 +00:00
|
|
|
$content = $pageObj->getContent();
|
|
|
|
|
|
|
|
|
|
if ( !( $content instanceof TextContent ) ) {
|
|
|
|
|
// @todo: ContentHandler should have an isFlat() method or some such
|
2012-08-20 19:33:07 +00:00
|
|
|
// @todo: XXX: or perhaps there should be Content::append(), Content::prepend()
|
|
|
|
|
// @todo: ...and Content::supportsConcatenation()
|
2012-06-25 21:30:51 +00:00
|
|
|
$mode = $contentHandler->getModelID();
|
2012-06-25 14:09:08 +00:00
|
|
|
$this->dieUsage( "Can't append to pages using content model $mode", 'appendnotsupported' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !$content ) {
|
|
|
|
|
# If this is a MediaWiki:x message, then load the messages
|
|
|
|
|
# and return the message value for x.
|
|
|
|
|
if ( $titleObj->getNamespace() == NS_MEDIAWIKI ) {
|
|
|
|
|
$text = $titleObj->getDefaultMessageText();
|
|
|
|
|
if ( $text === false ) {
|
|
|
|
|
$text = '';
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-21 14:14:18 +00:00
|
|
|
try {
|
|
|
|
|
$content = ContentHandler::makeContent( $text, $this->getTitle() );
|
|
|
|
|
} catch ( MWContentSerializationException $ex ) {
|
|
|
|
|
$this->dieUsage( $ex->getMessage(), 'parseerror' );
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-06-25 14:09:08 +00:00
|
|
|
}
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !is_null( $params['section'] ) ) {
|
2012-06-25 14:09:08 +00:00
|
|
|
if ( !$contentHandler->supportsSections() ) {
|
2012-06-25 21:30:51 +00:00
|
|
|
$modelName = $contentHandler->getModelID();
|
2012-06-25 14:09:08 +00:00
|
|
|
$this->dieUsage( "Sections are not supported for this content model: $modelName.", 'sectionsnotsupported' );
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-14 20:14:47 +00:00
|
|
|
// Process the content for section edits
|
2010-01-11 15:55:52 +00:00
|
|
|
$section = intval( $params['section'] );
|
2012-06-25 14:09:08 +00:00
|
|
|
$content = $content->getSection( $section );
|
|
|
|
|
|
|
|
|
|
if ( !$content ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->dieUsage( "There is no section {$section}.", 'nosuchsection' );
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2009-07-14 20:14:47 +00:00
|
|
|
}
|
2012-06-25 14:09:08 +00:00
|
|
|
|
|
|
|
|
if ( !$content ) {
|
|
|
|
|
$text = '';
|
|
|
|
|
} else {
|
|
|
|
|
$text = $content->serialize( $contentFormat );
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-05 17:09:41 +00:00
|
|
|
$params['text'] = $params['prependtext'] . $text . $params['appendtext'];
|
2008-06-15 19:59:55 +00:00
|
|
|
$toMD5 = $params['prependtext'] . $params['appendtext'];
|
2008-06-12 13:05:07 +00:00
|
|
|
}
|
2010-02-22 12:18:42 +00:00
|
|
|
|
|
|
|
|
if ( $params['undo'] > 0 ) {
|
|
|
|
|
if ( $params['undoafter'] > 0 ) {
|
|
|
|
|
if ( $params['undo'] < $params['undoafter'] ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
list( $params['undo'], $params['undoafter'] ) =
|
|
|
|
|
array( $params['undoafter'], $params['undo'] );
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2010-01-11 15:55:52 +00:00
|
|
|
$undoafterRev = Revision::newFromID( $params['undoafter'] );
|
2009-01-26 13:51:03 +00:00
|
|
|
}
|
2010-01-11 15:55:52 +00:00
|
|
|
$undoRev = Revision::newFromID( $params['undo'] );
|
2010-06-27 19:22:46 +00:00
|
|
|
if ( is_null( $undoRev ) || $undoRev->isDeleted( Revision::DELETED_TEXT ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->dieUsageMsg( array( 'nosuchrevid', $params['undo'] ) );
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2010-02-22 12:18:42 +00:00
|
|
|
if ( $params['undoafter'] == 0 ) {
|
2009-01-26 13:51:03 +00:00
|
|
|
$undoafterRev = $undoRev->getPrevious();
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2010-06-27 19:22:46 +00:00
|
|
|
if ( is_null( $undoafterRev ) || $undoafterRev->isDeleted( Revision::DELETED_TEXT ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->dieUsageMsg( array( 'nosuchrevid', $params['undoafter'] ) );
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2012-06-25 14:09:08 +00:00
|
|
|
if ( $undoRev->getPage() != $pageObj->getID() ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->dieUsageMsg( array( 'revwrongpage', $undoRev->getID(), $titleObj->getPrefixedText() ) );
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2012-06-25 14:09:08 +00:00
|
|
|
if ( $undoafterRev->getPage() != $pageObj->getID() ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->dieUsageMsg( array( 'revwrongpage', $undoafterRev->getID(), $titleObj->getPrefixedText() ) );
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
|
|
|
|
|
2012-08-21 14:14:18 +00:00
|
|
|
$newContent = $contentHandler->getUndoContent( $pageObj->getRevision(), $undoRev, $undoafterRev );
|
|
|
|
|
|
2012-06-25 14:09:08 +00:00
|
|
|
if ( !$newContent ) {
|
2011-05-19 17:51:16 +00:00
|
|
|
$this->dieUsageMsg( 'undo-failure' );
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2012-06-25 14:09:08 +00:00
|
|
|
|
|
|
|
|
$params['text'] = $newContent->serialize( $params['contentformat'] );
|
|
|
|
|
|
2009-01-26 13:51:03 +00:00
|
|
|
// If no summary was given and we only undid one rev,
|
|
|
|
|
// use an autosummary
|
2010-06-27 19:22:46 +00:00
|
|
|
if ( is_null( $params['summary'] ) && $titleObj->getNextRevisionID( $undoafterRev->getID() ) == $params['undo'] ) {
|
2012-08-20 14:55:28 +00:00
|
|
|
$params['summary'] = wfMessage( 'undo-summary', $params['undo'], $undoRev->getUserText() )->inContentLanguage()->text();
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2009-01-26 13:51:03 +00:00
|
|
|
}
|
2008-06-12 13:05:07 +00:00
|
|
|
|
2010-01-23 22:52:40 +00:00
|
|
|
// See if the MD5 hash checks out
|
2010-02-22 12:18:42 +00:00
|
|
|
if ( !is_null( $params['md5'] ) && md5( $toMD5 ) !== $params['md5'] ) {
|
2011-05-19 17:51:16 +00:00
|
|
|
$this->dieUsageMsg( 'hashcheckfailed' );
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
|
|
|
|
|
2008-03-03 18:19:52 +00:00
|
|
|
// EditPage wants to parse its stuff from a WebRequest
|
|
|
|
|
// That interface kind of sucks, but it's workable
|
2011-12-20 04:22:06 +00:00
|
|
|
$requestArray = array(
|
2010-02-22 12:18:42 +00:00
|
|
|
'wpTextbox1' => $params['text'],
|
2012-06-25 14:09:08 +00:00
|
|
|
'format' => $contentFormat,
|
|
|
|
|
'model' => $contentHandler->getModelID(),
|
2010-02-22 12:18:42 +00:00
|
|
|
'wpEditToken' => $params['token'],
|
|
|
|
|
'wpIgnoreBlankSummary' => ''
|
2008-03-03 18:19:52 +00:00
|
|
|
);
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2010-02-22 12:18:42 +00:00
|
|
|
if ( !is_null( $params['summary'] ) ) {
|
2011-12-20 04:22:06 +00:00
|
|
|
$requestArray['wpSummary'] = $params['summary'];
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2012-09-05 15:50:13 +00:00
|
|
|
|
2011-12-20 04:15:21 +00:00
|
|
|
if ( !is_null( $params['sectiontitle'] ) ) {
|
2011-12-20 04:22:06 +00:00
|
|
|
$requestArray['wpSectionTitle'] = $params['sectiontitle'];
|
2011-12-20 04:15:21 +00:00
|
|
|
}
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2010-01-23 22:52:40 +00:00
|
|
|
// Watch out for basetimestamp == ''
|
|
|
|
|
// wfTimestamp() treats it as NOW, almost certainly causing an edit conflict
|
2010-06-27 19:22:46 +00:00
|
|
|
if ( !is_null( $params['basetimestamp'] ) && $params['basetimestamp'] != '' ) {
|
2011-12-20 04:22:06 +00:00
|
|
|
$requestArray['wpEdittime'] = wfTimestamp( TS_MW, $params['basetimestamp'] );
|
2010-02-22 12:18:42 +00:00
|
|
|
} else {
|
2012-06-25 14:09:08 +00:00
|
|
|
$requestArray['wpEdittime'] = $pageObj->getTimestamp();
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2010-03-25 22:15:08 +00:00
|
|
|
if ( !is_null( $params['starttimestamp'] ) && $params['starttimestamp'] != '' ) {
|
2011-12-20 04:22:06 +00:00
|
|
|
$requestArray['wpStarttime'] = wfTimestamp( TS_MW, $params['starttimestamp'] );
|
2010-02-22 12:18:42 +00:00
|
|
|
} else {
|
2011-12-20 04:22:06 +00:00
|
|
|
$requestArray['wpStarttime'] = wfTimestampNow(); // Fake wpStartime
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2011-10-26 23:27:01 +00:00
|
|
|
if ( $params['minor'] || ( !$params['notminor'] && $user->getOption( 'minordefault' ) ) ) {
|
2011-12-20 04:22:06 +00:00
|
|
|
$requestArray['wpMinoredit'] = '';
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2010-02-22 12:18:42 +00:00
|
|
|
if ( $params['recreate'] ) {
|
2011-12-20 04:22:06 +00:00
|
|
|
$requestArray['wpRecreate'] = '';
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2010-02-22 12:18:42 +00:00
|
|
|
if ( !is_null( $params['section'] ) ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$section = intval( $params['section'] );
|
2010-06-27 19:22:46 +00:00
|
|
|
if ( $section == 0 && $params['section'] != '0' && $params['section'] != 'new' ) {
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->dieUsage( "The section parameter must be set to an integer or 'new'", "invalidsection" );
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2011-12-20 04:22:06 +00:00
|
|
|
$requestArray['wpSection'] = $params['section'];
|
2010-02-22 12:18:42 +00:00
|
|
|
} else {
|
2011-12-20 04:22:06 +00:00
|
|
|
$requestArray['wpSection'] = '';
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2010-04-12 10:44:45 +00:00
|
|
|
$watch = $this->getWatchlistValue( $params['watchlist'], $titleObj );
|
2010-03-25 22:15:08 +00:00
|
|
|
|
2009-07-14 20:48:00 +00:00
|
|
|
// Deprecated parameters
|
2010-02-22 12:18:42 +00:00
|
|
|
if ( $params['watch'] ) {
|
2008-03-03 18:19:52 +00:00
|
|
|
$watch = true;
|
2010-02-22 12:18:42 +00:00
|
|
|
} elseif ( $params['unwatch'] ) {
|
2008-03-03 18:19:52 +00:00
|
|
|
$watch = false;
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
|
|
|
|
|
2010-04-14 12:17:39 +00:00
|
|
|
if ( $watch ) {
|
2011-12-20 04:22:06 +00:00
|
|
|
$requestArray['wpWatchthis'] = '';
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2008-03-03 18:19:52 +00:00
|
|
|
|
2011-11-17 10:33:20 +00:00
|
|
|
global $wgTitle, $wgRequest;
|
|
|
|
|
|
2011-12-20 04:22:06 +00:00
|
|
|
$req = new DerivativeRequest( $this->getRequest(), $requestArray, true );
|
2011-11-17 10:33:20 +00:00
|
|
|
|
|
|
|
|
// Some functions depend on $wgTitle == $ep->mTitle
|
|
|
|
|
// TODO: Make them not or check if they still do
|
|
|
|
|
$wgTitle = $titleObj;
|
|
|
|
|
|
2012-06-25 14:09:08 +00:00
|
|
|
$articleObject = new Article( $titleObj );
|
|
|
|
|
$ep = new EditPage( $articleObject );
|
2012-03-09 17:23:05 +00:00
|
|
|
|
2011-11-17 10:33:20 +00:00
|
|
|
$ep->setContextTitle( $titleObj );
|
2010-01-11 15:55:52 +00:00
|
|
|
$ep->importFormData( $req );
|
2008-03-03 18:19:52 +00:00
|
|
|
|
2011-11-23 19:09:57 +00:00
|
|
|
// Run hooks
|
|
|
|
|
// Handle APIEditBeforeSave parameters
|
2008-03-03 18:19:52 +00:00
|
|
|
$r = array();
|
2010-06-27 19:22:46 +00:00
|
|
|
if ( !wfRunHooks( 'APIEditBeforeSave', array( $ep, $ep->textbox1, &$r ) ) ) {
|
2010-02-22 12:18:42 +00:00
|
|
|
if ( count( $r ) ) {
|
|
|
|
|
$r['result'] = 'Failure';
|
2011-06-20 22:18:11 +00:00
|
|
|
$apiResult->addValue( null, $this->getModuleName(), $r );
|
2008-04-14 07:45:50 +00:00
|
|
|
return;
|
2010-02-22 12:18:42 +00:00
|
|
|
} else {
|
2011-05-19 17:51:16 +00:00
|
|
|
$this->dieUsageMsg( 'hookaborted' );
|
2010-02-22 12:18:42 +00:00
|
|
|
}
|
2008-03-03 18:19:52 +00:00
|
|
|
}
|
2008-04-14 07:45:50 +00:00
|
|
|
|
2010-01-23 22:52:40 +00:00
|
|
|
// Do the actual save
|
2012-06-25 14:09:08 +00:00
|
|
|
$oldRevId = $articleObject->getRevIdFetched();
|
2011-06-20 22:18:11 +00:00
|
|
|
$result = null;
|
2010-01-23 22:52:40 +00:00
|
|
|
// Fake $wgRequest for some hooks inside EditPage
|
2011-05-17 22:03:20 +00:00
|
|
|
// @todo FIXME: This interface SUCKS
|
2008-05-28 09:14:35 +00:00
|
|
|
$oldRequest = $wgRequest;
|
|
|
|
|
$wgRequest = $req;
|
|
|
|
|
|
2011-10-26 23:27:01 +00:00
|
|
|
$status = $ep->internalAttemptSave( $result, $user->isAllowed( 'bot' ) && $params['bot'] );
|
2008-05-28 09:14:35 +00:00
|
|
|
$wgRequest = $oldRequest;
|
2010-08-12 14:25:07 +00:00
|
|
|
global $wgMaxArticleSize;
|
|
|
|
|
|
2011-08-26 16:26:17 +00:00
|
|
|
switch( $status->value ) {
|
2008-03-03 18:19:52 +00:00
|
|
|
case EditPage::AS_HOOK_ERROR:
|
|
|
|
|
case EditPage::AS_HOOK_ERROR_EXPECTED:
|
2011-05-19 17:51:16 +00:00
|
|
|
$this->dieUsageMsg( 'hookaborted' );
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2012-08-21 14:14:18 +00:00
|
|
|
case EditPage::AS_PARSE_ERROR:
|
|
|
|
|
$this->dieUsage( $status->getMessage(), 'parseerror' );
|
|
|
|
|
|
2008-03-03 18:19:52 +00:00
|
|
|
case EditPage::AS_IMAGE_REDIRECT_ANON:
|
2011-05-19 17:51:16 +00:00
|
|
|
$this->dieUsageMsg( 'noimageredirect-anon' );
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2008-03-03 18:19:52 +00:00
|
|
|
case EditPage::AS_IMAGE_REDIRECT_LOGGED:
|
2011-05-19 17:51:16 +00:00
|
|
|
$this->dieUsageMsg( 'noimageredirect-logged' );
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2008-03-03 18:19:52 +00:00
|
|
|
case EditPage::AS_SPAM_ERROR:
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->dieUsageMsg( array( 'spamdetected', $result['spam'] ) );
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2008-03-03 18:19:52 +00:00
|
|
|
case EditPage::AS_BLOCKED_PAGE_FOR_USER:
|
2011-05-19 17:51:16 +00:00
|
|
|
$this->dieUsageMsg( 'blockedtext' );
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2008-03-03 18:19:52 +00:00
|
|
|
case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED:
|
|
|
|
|
case EditPage::AS_CONTENT_TOO_BIG:
|
2010-01-11 15:55:52 +00:00
|
|
|
$this->dieUsageMsg( array( 'contenttoobig', $wgMaxArticleSize ) );
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2008-03-03 18:19:52 +00:00
|
|
|
case EditPage::AS_READ_ONLY_PAGE_ANON:
|
2011-05-19 17:51:16 +00:00
|
|
|
$this->dieUsageMsg( 'noedit-anon' );
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2008-03-03 18:19:52 +00:00
|
|
|
case EditPage::AS_READ_ONLY_PAGE_LOGGED:
|
2011-05-19 17:51:16 +00:00
|
|
|
$this->dieUsageMsg( 'noedit' );
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2008-03-03 18:19:52 +00:00
|
|
|
case EditPage::AS_READ_ONLY_PAGE:
|
2009-07-12 12:38:03 +00:00
|
|
|
$this->dieReadOnly();
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2008-03-03 18:19:52 +00:00
|
|
|
case EditPage::AS_RATE_LIMITED:
|
2011-05-19 17:51:16 +00:00
|
|
|
$this->dieUsageMsg( 'actionthrottledtext' );
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2008-03-03 18:19:52 +00:00
|
|
|
case EditPage::AS_ARTICLE_WAS_DELETED:
|
2011-05-19 17:51:16 +00:00
|
|
|
$this->dieUsageMsg( 'wasdeleted' );
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2008-03-03 18:19:52 +00:00
|
|
|
case EditPage::AS_NO_CREATE_PERMISSION:
|
2011-05-19 17:51:16 +00:00
|
|
|
$this->dieUsageMsg( 'nocreate-loggedin' );
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2008-03-03 18:19:52 +00:00
|
|
|
case EditPage::AS_BLANK_ARTICLE:
|
2011-05-19 17:51:16 +00:00
|
|
|
$this->dieUsageMsg( 'blankpage' );
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2008-03-03 18:19:52 +00:00
|
|
|
case EditPage::AS_CONFLICT_DETECTED:
|
2011-05-19 17:51:16 +00:00
|
|
|
$this->dieUsageMsg( 'editconflict' );
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2010-01-23 22:52:40 +00:00
|
|
|
// case EditPage::AS_SUMMARY_NEEDED: Can't happen since we set wpIgnoreBlankSummary
|
2008-08-26 20:40:44 +00:00
|
|
|
case EditPage::AS_TEXTBOX_EMPTY:
|
2011-05-19 17:51:16 +00:00
|
|
|
$this->dieUsageMsg( 'emptynewsection' );
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2008-03-03 18:19:52 +00:00
|
|
|
case EditPage::AS_SUCCESS_NEW_ARTICLE:
|
|
|
|
|
$r['new'] = '';
|
2010-07-06 13:15:59 +00:00
|
|
|
|
2008-03-03 18:19:52 +00:00
|
|
|
case EditPage::AS_SUCCESS_UPDATE:
|
2010-02-22 12:18:42 +00:00
|
|
|
$r['result'] = 'Success';
|
2010-01-11 15:55:52 +00:00
|
|
|
$r['pageid'] = intval( $titleObj->getArticleID() );
|
2008-03-03 18:19:52 +00:00
|
|
|
$r['title'] = $titleObj->getPrefixedText();
|
2012-06-25 14:09:08 +00:00
|
|
|
$r['contentmodel'] = $titleObj->getContentModel();
|
|
|
|
|
$newRevId = $articleObject->getLatest();
|
2010-02-22 12:18:42 +00:00
|
|
|
if ( $newRevId == $oldRevId ) {
|
2008-03-03 18:19:52 +00:00
|
|
|
$r['nochange'] = '';
|
2010-02-22 12:18:42 +00:00
|
|
|
} else {
|
2010-01-11 15:55:52 +00:00
|
|
|
$r['oldrevid'] = intval( $oldRevId );
|
|
|
|
|
$r['newrevid'] = intval( $newRevId );
|
|
|
|
|
$r['newtimestamp'] = wfTimestamp( TS_ISO_8601,
|
2012-06-25 14:09:08 +00:00
|
|
|
$pageObj->getTimestamp() );
|
2008-03-03 18:19:52 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2010-07-23 07:33:40 +00:00
|
|
|
|
2010-06-27 19:22:46 +00:00
|
|
|
case EditPage::AS_SUMMARY_NEEDED:
|
2011-05-19 17:51:16 +00:00
|
|
|
$this->dieUsageMsg( 'summaryrequired' );
|
2010-01-23 22:26:40 +00:00
|
|
|
|
2009-10-28 13:35:39 +00:00
|
|
|
case EditPage::AS_END:
|
2012-05-10 04:48:16 +00:00
|
|
|
default:
|
2011-08-26 16:26:17 +00:00
|
|
|
// $status came from WikiPage::doEdit()
|
|
|
|
|
$errors = $status->getErrorsArray();
|
|
|
|
|
$this->dieUsageMsg( $errors[0] ); // TODO: Add new errors to message map
|
|
|
|
|
break;
|
2008-03-03 18:19:52 +00:00
|
|
|
}
|
2011-06-20 22:18:11 +00:00
|
|
|
$apiResult->addValue( null, $this->getModuleName(), $r );
|
2008-03-03 18:19:52 +00:00
|
|
|
}
|
|
|
|
|
|
2008-05-23 22:02:23 +00:00
|
|
|
public function mustBePosted() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-06 13:49:44 +00:00
|
|
|
public function isWriteMode() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-26 22:56:31 +00:00
|
|
|
public function getDescription() {
|
2008-03-03 18:19:52 +00:00
|
|
|
return 'Create and edit pages.';
|
|
|
|
|
}
|
2010-02-22 12:18:42 +00:00
|
|
|
|
2010-02-14 14:29:24 +00:00
|
|
|
public function getPossibleErrors() {
|
2010-02-16 22:01:38 +00:00
|
|
|
global $wgMaxArticleSize;
|
2010-02-22 12:18:42 +00:00
|
|
|
|
2012-04-05 20:54:18 +00:00
|
|
|
return array_merge( parent::getPossibleErrors(),
|
2012-04-07 21:47:06 +00:00
|
|
|
$this->getTitleOrPageIdErrorMessage(),
|
2012-04-05 20:54:18 +00:00
|
|
|
array(
|
|
|
|
|
array( 'missingtext' ),
|
|
|
|
|
array( 'createonly-exists' ),
|
|
|
|
|
array( 'nocreate-missing' ),
|
|
|
|
|
array( 'nosuchrevid', 'undo' ),
|
|
|
|
|
array( 'nosuchrevid', 'undoafter' ),
|
|
|
|
|
array( 'revwrongpage', 'id', 'text' ),
|
|
|
|
|
array( 'undo-failure' ),
|
|
|
|
|
array( 'hashcheckfailed' ),
|
|
|
|
|
array( 'hookaborted' ),
|
2012-08-21 14:14:18 +00:00
|
|
|
array( 'code' => 'parseerror', 'info' => 'Failed to parse the given text.' ),
|
2012-04-05 20:54:18 +00:00
|
|
|
array( 'noimageredirect-anon' ),
|
|
|
|
|
array( 'noimageredirect-logged' ),
|
|
|
|
|
array( 'spamdetected', 'spam' ),
|
|
|
|
|
array( 'summaryrequired' ),
|
|
|
|
|
array( 'blockedtext' ),
|
|
|
|
|
array( 'contenttoobig', $wgMaxArticleSize ),
|
|
|
|
|
array( 'noedit-anon' ),
|
|
|
|
|
array( 'noedit' ),
|
|
|
|
|
array( 'actionthrottledtext' ),
|
|
|
|
|
array( 'wasdeleted' ),
|
|
|
|
|
array( 'nocreate-loggedin' ),
|
|
|
|
|
array( 'blankpage' ),
|
|
|
|
|
array( 'editconflict' ),
|
|
|
|
|
array( 'emptynewsection' ),
|
|
|
|
|
array( 'unknownerror', 'retval' ),
|
|
|
|
|
array( 'code' => 'nosuchsection', 'info' => 'There is no section section.' ),
|
|
|
|
|
array( 'code' => 'invalidsection', 'info' => 'The section parameter must be set to an integer or \'new\'' ),
|
2012-06-25 14:09:08 +00:00
|
|
|
array( 'code' => 'sectionsnotsupported', 'info' => 'Sections are not supported for this type of page.' ),
|
2012-08-20 19:33:07 +00:00
|
|
|
array( 'code' => 'editnotsupported', 'info' => 'Editing of this type of page is not supported using '
|
|
|
|
|
. 'the text based edit API.' ),
|
|
|
|
|
array( 'code' => 'appendnotsupported', 'info' => 'This type of page can not be edited by appending '
|
|
|
|
|
. 'or prepending text.' ),
|
|
|
|
|
array( 'code' => 'badformat', 'info' => 'The requested serialization format can not be applied to '
|
|
|
|
|
. 'the page\'s content model' ),
|
2012-04-05 20:54:18 +00:00
|
|
|
array( 'customcssprotected' ),
|
|
|
|
|
array( 'customjsprotected' ),
|
|
|
|
|
)
|
|
|
|
|
);
|
2010-02-13 00:28:27 +00:00
|
|
|
}
|
|
|
|
|
|
2011-08-17 22:24:21 +00:00
|
|
|
public function getAllowedParams() {
|
2010-02-22 12:18:42 +00:00
|
|
|
return array(
|
2010-08-04 14:15:33 +00:00
|
|
|
'title' => array(
|
|
|
|
|
ApiBase::PARAM_TYPE => 'string',
|
2012-04-05 20:54:18 +00:00
|
|
|
),
|
|
|
|
|
'pageid' => array(
|
|
|
|
|
ApiBase::PARAM_TYPE => 'integer',
|
2010-08-04 14:15:33 +00:00
|
|
|
),
|
2008-03-12 13:25:12 +00:00
|
|
|
'section' => null,
|
2011-12-20 04:15:21 +00:00
|
|
|
'sectiontitle' => array(
|
|
|
|
|
ApiBase::PARAM_TYPE => 'string',
|
|
|
|
|
ApiBase::PARAM_REQUIRED => false,
|
|
|
|
|
),
|
2008-03-03 18:19:52 +00:00
|
|
|
'text' => null,
|
2012-07-18 17:24:38 +00:00
|
|
|
'token' => array(
|
|
|
|
|
ApiBase::PARAM_TYPE => 'string',
|
|
|
|
|
ApiBase::PARAM_REQUIRED => true
|
|
|
|
|
),
|
2008-03-03 18:19:52 +00:00
|
|
|
'summary' => null,
|
|
|
|
|
'minor' => false,
|
|
|
|
|
'notminor' => false,
|
|
|
|
|
'bot' => false,
|
|
|
|
|
'basetimestamp' => null,
|
2008-10-04 13:43:17 +00:00
|
|
|
'starttimestamp' => null,
|
2008-03-03 18:19:52 +00:00
|
|
|
'recreate' => false,
|
2008-03-25 21:12:01 +00:00
|
|
|
'createonly' => false,
|
2008-06-15 20:37:28 +00:00
|
|
|
'nocreate' => false,
|
2009-10-28 00:56:07 +00:00
|
|
|
'watch' => array(
|
2010-02-22 12:18:42 +00:00
|
|
|
ApiBase::PARAM_DFLT => false,
|
|
|
|
|
ApiBase::PARAM_DEPRECATED => true,
|
2009-10-28 00:56:07 +00:00
|
|
|
),
|
|
|
|
|
'unwatch' => array(
|
2010-02-22 12:18:42 +00:00
|
|
|
ApiBase::PARAM_DFLT => false,
|
|
|
|
|
ApiBase::PARAM_DEPRECATED => true,
|
2009-10-28 00:56:07 +00:00
|
|
|
),
|
2009-07-14 20:48:00 +00:00
|
|
|
'watchlist' => array(
|
2010-02-22 12:18:42 +00:00
|
|
|
ApiBase::PARAM_DFLT => 'preferences',
|
|
|
|
|
ApiBase::PARAM_TYPE => array(
|
2010-01-11 15:55:52 +00:00
|
|
|
'watch',
|
|
|
|
|
'unwatch',
|
|
|
|
|
'preferences',
|
2009-07-14 20:48:00 +00:00
|
|
|
'nochange'
|
|
|
|
|
),
|
|
|
|
|
),
|
2008-05-28 09:22:40 +00:00
|
|
|
'md5' => null,
|
2008-06-12 13:05:07 +00:00
|
|
|
'prependtext' => null,
|
|
|
|
|
'appendtext' => null,
|
2009-01-26 13:51:03 +00:00
|
|
|
'undo' => array(
|
2010-02-22 12:18:42 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'integer'
|
2009-01-26 13:51:03 +00:00
|
|
|
),
|
|
|
|
|
'undoafter' => array(
|
2010-02-22 12:18:42 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'integer'
|
2009-01-26 13:51:03 +00:00
|
|
|
),
|
2010-08-08 01:14:48 +00:00
|
|
|
'redirect' => array(
|
|
|
|
|
ApiBase::PARAM_TYPE => 'boolean',
|
|
|
|
|
ApiBase::PARAM_DFLT => false,
|
|
|
|
|
),
|
2012-08-21 14:14:18 +00:00
|
|
|
'contentformat' => array(
|
|
|
|
|
ApiBase::PARAM_TYPE => ContentHandler::getAllContentFormats(),
|
|
|
|
|
),
|
|
|
|
|
'contentmodel' => array(
|
|
|
|
|
ApiBase::PARAM_TYPE => ContentHandler::getContentModels(),
|
|
|
|
|
)
|
2008-03-03 18:19:52 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-17 22:24:21 +00:00
|
|
|
public function getParamDescription() {
|
2010-05-11 22:30:18 +00:00
|
|
|
$p = $this->getModulePrefix();
|
2010-02-22 12:18:42 +00:00
|
|
|
return array(
|
2012-04-05 20:54:18 +00:00
|
|
|
'title' => "Title of the page you want to edit. Cannot be used together with {$p}pageid",
|
2012-04-07 17:55:49 +00:00
|
|
|
'pageid' => "Page ID of the page you want to edit. Cannot be used together with {$p}title",
|
2008-03-12 13:25:12 +00:00
|
|
|
'section' => 'Section number. 0 for the top section, \'new\' for a new section',
|
2011-12-20 04:15:21 +00:00
|
|
|
'sectiontitle' => 'The title for a new section',
|
2008-03-03 18:19:52 +00:00
|
|
|
'text' => 'Page content',
|
2011-06-17 14:55:03 +00:00
|
|
|
'token' => array( 'Edit token. You can get one of these through prop=info.',
|
2012-04-28 18:59:01 +00:00
|
|
|
"The token should always be sent as the last parameter, or at least, after the {$p}text parameter"
|
2011-06-17 14:55:03 +00:00
|
|
|
),
|
2012-04-28 18:59:01 +00:00
|
|
|
'summary' => "Edit summary. Also section title when {$p}section=new and {$p}sectiontitle is not set",
|
2008-03-03 18:19:52 +00:00
|
|
|
'minor' => 'Minor edit',
|
|
|
|
|
'notminor' => 'Non-minor edit',
|
|
|
|
|
'bot' => 'Mark this edit as bot',
|
2011-06-17 16:03:52 +00:00
|
|
|
'basetimestamp' => array( 'Timestamp of the base revision (obtained through prop=revisions&rvprop=timestamp).',
|
2012-04-28 18:59:01 +00:00
|
|
|
'Used to detect edit conflicts; leave unset to ignore conflicts'
|
2008-03-03 18:19:52 +00:00
|
|
|
),
|
2010-01-11 15:55:52 +00:00
|
|
|
'starttimestamp' => array( 'Timestamp when you obtained the edit token.',
|
2010-05-11 22:30:18 +00:00
|
|
|
'Used to detect edit conflicts; leave unset to ignore conflicts'
|
2008-10-04 13:43:17 +00:00
|
|
|
),
|
2008-03-03 18:19:52 +00:00
|
|
|
'recreate' => 'Override any errors about the article having been deleted in the meantime',
|
2008-06-15 20:37:28 +00:00
|
|
|
'createonly' => 'Don\'t edit the page if it exists already',
|
|
|
|
|
'nocreate' => 'Throw an error if the page doesn\'t exist',
|
2009-10-28 00:56:07 +00:00
|
|
|
'watch' => 'Add the page to your watchlist',
|
|
|
|
|
'unwatch' => 'Remove the page from your watchlist',
|
2009-07-14 20:48:00 +00:00
|
|
|
'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch',
|
2010-05-11 22:30:18 +00:00
|
|
|
'md5' => array( "The MD5 hash of the {$p}text parameter, or the {$p}prependtext and {$p}appendtext parameters concatenated.",
|
2011-07-28 19:13:58 +00:00
|
|
|
'If set, the edit won\'t be done unless the hash is correct' ),
|
2010-05-11 22:30:18 +00:00
|
|
|
'prependtext' => "Add this text to the beginning of the page. Overrides {$p}text",
|
2012-04-28 18:59:01 +00:00
|
|
|
'appendtext' => array( "Add this text to the end of the page. Overrides {$p}text.",
|
|
|
|
|
"Use {$p}section=new to append a new section" ),
|
2010-05-11 22:30:18 +00:00
|
|
|
'undo' => "Undo this revision. Overrides {$p}text, {$p}prependtext and {$p}appendtext",
|
2009-01-26 13:51:03 +00:00
|
|
|
'undoafter' => 'Undo all revisions from undo to this one. If not set, just undo one revision',
|
2010-08-08 01:14:48 +00:00
|
|
|
'redirect' => 'Automatically resolve redirects',
|
2012-08-21 14:14:18 +00:00
|
|
|
'contentformat' => 'Content serialization format used for the input text',
|
|
|
|
|
'contentmodel' => 'Content model of the new content',
|
2008-03-03 18:19:52 +00:00
|
|
|
);
|
|
|
|
|
}
|
2010-02-22 12:18:42 +00:00
|
|
|
|
Added result properties to action=paraminfo
Added information about the properties of the results of API calls
to action=paraminfo, including information about "property groups":
what should the prop parameter be set to to get that property.
Uses the same format for types as parameters already do.
The output format of some modules doesn't fit this, so the result
properties for them weren't added, or only partially.
Partially implemented modules:
* expandtemplates:
parsetree is in its own tag
* protect, allusers, backlinks, deletedrevs, info, imageinfo,
logevents, querypage, recentchanges, revisions, searchinfo,
usercontribs, userinfo, users, watchlist, upload:
response with partially complex structure
Not implemented modules:
* feedcontributions, feedwatchlist, opensearch, rds:
non-standard reponse
* help:
error is normal response; not very useful for automated tools anyway
* paraminfo, parse, pageprops, siteinfo, userrights:
response with complex structure
Change-Id: Iff2a9bef79f994e73eef3062b4dd5461bff968ab
2012-05-02 15:00:30 +00:00
|
|
|
public function getResultProperties() {
|
|
|
|
|
return array(
|
|
|
|
|
'' => array(
|
|
|
|
|
'new' => 'boolean',
|
|
|
|
|
'result' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => array(
|
|
|
|
|
'Success',
|
|
|
|
|
'Failure'
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
'pageid' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'integer',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
),
|
|
|
|
|
'title' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'string',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
),
|
|
|
|
|
'nochange' => 'boolean',
|
|
|
|
|
'oldrevid' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'integer',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
),
|
|
|
|
|
'newrevid' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'integer',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
),
|
|
|
|
|
'newtimestamp' => array(
|
|
|
|
|
ApiBase::PROP_TYPE => 'string',
|
|
|
|
|
ApiBase::PROP_NULLABLE => true
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-01 20:12:50 +00:00
|
|
|
public function needsToken() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-15 23:53:43 +00:00
|
|
|
public function getTokenSalt() {
|
2010-02-16 21:59:16 +00:00
|
|
|
return '';
|
2010-02-14 22:20:27 +00:00
|
|
|
}
|
2008-03-03 18:19:52 +00:00
|
|
|
|
2011-08-17 22:24:21 +00:00
|
|
|
public function getExamples() {
|
2010-02-22 12:18:42 +00:00
|
|
|
return array(
|
2011-12-27 16:22:35 +00:00
|
|
|
|
|
|
|
|
'api.php?action=edit&title=Test&summary=test%20summary&text=article%20content&basetimestamp=20070824123454&token=%2B\\'
|
|
|
|
|
=> 'Edit a page (anonymous user)',
|
|
|
|
|
|
|
|
|
|
'api.php?action=edit&title=Test&summary=NOTOC&minor=&prependtext=__NOTOC__%0A&basetimestamp=20070824123454&token=%2B\\'
|
|
|
|
|
=> 'Prepend __NOTOC__ to a page (anonymous user)',
|
|
|
|
|
'api.php?action=edit&title=Test&undo=13585&undoafter=13579&basetimestamp=20070824123454&token=%2B\\'
|
|
|
|
|
=> 'Undo r13579 through r13585 with autosummary (anonymous user)',
|
2008-03-03 18:19:52 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-17 16:38:24 +00:00
|
|
|
public function getHelpUrls() {
|
2011-11-28 15:43:11 +00:00
|
|
|
return 'https://www.mediawiki.org/wiki/API:Edit';
|
2011-07-17 16:38:24 +00:00
|
|
|
}
|
|
|
|
|
|
2008-03-03 18:19:52 +00:00
|
|
|
public function getVersion() {
|
2008-03-03 19:34:11 +00:00
|
|
|
return __CLASS__ . ': $Id$';
|
2008-03-03 18:19:52 +00:00
|
|
|
}
|
2008-03-12 13:25:12 +00:00
|
|
|
}
|