Merge "Put the check for empty comment outside of the section anchor section of EditP...
[lhc/web/wiklou.git] / includes / api / ApiEditPage.php
1 <?php
2 /**
3 *
4 *
5 * Created on August 16, 2007
6 *
7 * Copyright © 2007 Iker Labarga "<Firstname><Lastname>@gmail.com"
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
23 *
24 * @file
25 */
26
27 /**
28 * A module that allows for editing and creating pages.
29 *
30 * Currently, this wraps around the EditPage class in an ugly way,
31 * EditPage.php should be rewritten to provide a cleaner interface
32 * @ingroup API
33 */
34 class ApiEditPage extends ApiBase {
35
36 public function execute() {
37 $user = $this->getUser();
38 $params = $this->extractRequestParams();
39
40 if ( is_null( $params['text'] ) && is_null( $params['appendtext'] ) &&
41 is_null( $params['prependtext'] ) &&
42 $params['undo'] == 0 )
43 {
44 $this->dieUsageMsg( 'missingtext' );
45 }
46
47 $pageObj = $this->getTitleOrPageId( $params );
48 $titleObj = $pageObj->getTitle();
49 if ( $titleObj->isExternal() ) {
50 $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
51 }
52
53 $apiResult = $this->getResult();
54
55 if ( $params['redirect'] ) {
56 if ( $titleObj->isRedirect() ) {
57 $oldTitle = $titleObj;
58
59 $titles = Revision::newFromTitle( $oldTitle, false, Revision::READ_LATEST )
60 ->getContent( Revision::FOR_THIS_USER, $user )
61 ->getRedirectChain();
62 // array_shift( $titles );
63
64 $redirValues = array();
65 foreach ( $titles as $id => $newTitle ) {
66
67 if ( !isset( $titles[$id - 1] ) ) {
68 $titles[$id - 1] = $oldTitle;
69 }
70
71 $redirValues[] = array(
72 'from' => $titles[$id - 1]->getPrefixedText(),
73 'to' => $newTitle->getPrefixedText()
74 );
75
76 $titleObj = $newTitle;
77 }
78
79 $apiResult->setIndexedTagName( $redirValues, 'r' );
80 $apiResult->addValue( null, 'redirects', $redirValues );
81
82 // Since the page changed, update $pageObj
83 $pageObj = WikiPage::factory( $titleObj );
84 }
85 }
86
87 if ( !isset( $params['contentmodel'] ) || $params['contentmodel'] == '' ) {
88 $contentHandler = $pageObj->getContentHandler();
89 } else {
90 $contentHandler = ContentHandler::getForModelID( $params['contentmodel'] );
91 }
92
93 // @todo ask handler whether direct editing is supported at all! make allowFlatEdit() method or some such
94
95 if ( !isset( $params['contentformat'] ) || $params['contentformat'] == '' ) {
96 $params['contentformat'] = $contentHandler->getDefaultFormat();
97 }
98
99 $contentFormat = $params['contentformat'];
100
101 if ( !$contentHandler->isSupportedFormat( $contentFormat ) ) {
102 $name = $titleObj->getPrefixedDBkey();
103 $model = $contentHandler->getModelID();
104
105 $this->dieUsage( "The requested format $contentFormat is not supported for content model ".
106 " $model used by $name", 'badformat' );
107 }
108
109 if ( $params['createonly'] && $titleObj->exists() ) {
110 $this->dieUsageMsg( 'createonly-exists' );
111 }
112 if ( $params['nocreate'] && !$titleObj->exists() ) {
113 $this->dieUsageMsg( 'nocreate-missing' );
114 }
115
116 // Now let's check whether we're even allowed to do this
117 $errors = $titleObj->getUserPermissionsErrors( 'edit', $user );
118 if ( !$titleObj->exists() ) {
119 $errors = array_merge( $errors, $titleObj->getUserPermissionsErrors( 'create', $user ) );
120 }
121 if ( count( $errors ) ) {
122 $this->dieUsageMsg( $errors[0] );
123 }
124
125 $toMD5 = $params['text'];
126 if ( !is_null( $params['appendtext'] ) || !is_null( $params['prependtext'] ) )
127 {
128 $content = $pageObj->getContent();
129
130 if ( !$content ) {
131 if ( $titleObj->getNamespace() == NS_MEDIAWIKI ) {
132 # If this is a MediaWiki:x message, then load the messages
133 # and return the message value for x.
134 $text = $titleObj->getDefaultMessageText();
135 if ( $text === false ) {
136 $text = '';
137 }
138
139 try {
140 $content = ContentHandler::makeContent( $text, $this->getTitle() );
141 } catch ( MWContentSerializationException $ex ) {
142 $this->dieUsage( $ex->getMessage(), 'parseerror' );
143 return;
144 }
145 } else {
146 # Otherwise, make a new empty content.
147 $content = $contentHandler->makeEmptyContent();
148 }
149 }
150
151 // @todo: Add support for appending/prepending to the Content interface
152
153 if ( !( $content instanceof TextContent ) ) {
154 $mode = $contentHandler->getModelID();
155 $this->dieUsage( "Can't append to pages using content model $mode", 'appendnotsupported' );
156 }
157
158 if ( !is_null( $params['section'] ) ) {
159 if ( !$contentHandler->supportsSections() ) {
160 $modelName = $contentHandler->getModelID();
161 $this->dieUsage( "Sections are not supported for this content model: $modelName.", 'sectionsnotsupported' );
162 }
163
164 // Process the content for section edits
165 $section = intval( $params['section'] );
166 $content = $content->getSection( $section );
167
168 if ( !$content ) {
169 $this->dieUsage( "There is no section {$section}.", 'nosuchsection' );
170 }
171 }
172
173 if ( !$content ) {
174 $text = '';
175 } else {
176 $text = $content->serialize( $contentFormat );
177 }
178
179 $params['text'] = $params['prependtext'] . $text . $params['appendtext'];
180 $toMD5 = $params['prependtext'] . $params['appendtext'];
181 }
182
183 if ( $params['undo'] > 0 ) {
184 if ( $params['undoafter'] > 0 ) {
185 if ( $params['undo'] < $params['undoafter'] ) {
186 list( $params['undo'], $params['undoafter'] ) =
187 array( $params['undoafter'], $params['undo'] );
188 }
189 $undoafterRev = Revision::newFromID( $params['undoafter'] );
190 }
191 $undoRev = Revision::newFromID( $params['undo'] );
192 if ( is_null( $undoRev ) || $undoRev->isDeleted( Revision::DELETED_TEXT ) ) {
193 $this->dieUsageMsg( array( 'nosuchrevid', $params['undo'] ) );
194 }
195
196 if ( $params['undoafter'] == 0 ) {
197 $undoafterRev = $undoRev->getPrevious();
198 }
199 if ( is_null( $undoafterRev ) || $undoafterRev->isDeleted( Revision::DELETED_TEXT ) ) {
200 $this->dieUsageMsg( array( 'nosuchrevid', $params['undoafter'] ) );
201 }
202
203 if ( $undoRev->getPage() != $pageObj->getID() ) {
204 $this->dieUsageMsg( array( 'revwrongpage', $undoRev->getID(), $titleObj->getPrefixedText() ) );
205 }
206 if ( $undoafterRev->getPage() != $pageObj->getID() ) {
207 $this->dieUsageMsg( array( 'revwrongpage', $undoafterRev->getID(), $titleObj->getPrefixedText() ) );
208 }
209
210 $newContent = $contentHandler->getUndoContent( $pageObj->getRevision(), $undoRev, $undoafterRev );
211
212 if ( !$newContent ) {
213 $this->dieUsageMsg( 'undo-failure' );
214 }
215
216 $params['text'] = $newContent->serialize( $params['contentformat'] );
217
218 // If no summary was given and we only undid one rev,
219 // use an autosummary
220 if ( is_null( $params['summary'] ) && $titleObj->getNextRevisionID( $undoafterRev->getID() ) == $params['undo'] ) {
221 $params['summary'] = wfMessage( 'undo-summary', $params['undo'], $undoRev->getUserText() )->inContentLanguage()->text();
222 }
223 }
224
225 // See if the MD5 hash checks out
226 if ( !is_null( $params['md5'] ) && md5( $toMD5 ) !== $params['md5'] ) {
227 $this->dieUsageMsg( 'hashcheckfailed' );
228 }
229
230 // EditPage wants to parse its stuff from a WebRequest
231 // That interface kind of sucks, but it's workable
232 $requestArray = array(
233 'wpTextbox1' => $params['text'],
234 'format' => $contentFormat,
235 'model' => $contentHandler->getModelID(),
236 'wpEditToken' => $params['token'],
237 'wpIgnoreBlankSummary' => ''
238 );
239
240 if ( !is_null( $params['summary'] ) ) {
241 $requestArray['wpSummary'] = $params['summary'];
242 }
243
244 if ( !is_null( $params['sectiontitle'] ) ) {
245 $requestArray['wpSectionTitle'] = $params['sectiontitle'];
246 }
247
248 // TODO: Pass along information from 'undoafter' as well
249 if ( $params['undo'] > 0 ) {
250 $requestArray['wpUndidRevision'] = $params['undo'];
251 }
252
253 // Watch out for basetimestamp == ''
254 // wfTimestamp() treats it as NOW, almost certainly causing an edit conflict
255 if ( !is_null( $params['basetimestamp'] ) && $params['basetimestamp'] != '' ) {
256 $requestArray['wpEdittime'] = wfTimestamp( TS_MW, $params['basetimestamp'] );
257 } else {
258 $requestArray['wpEdittime'] = $pageObj->getTimestamp();
259 }
260
261 if ( !is_null( $params['starttimestamp'] ) && $params['starttimestamp'] != '' ) {
262 $requestArray['wpStarttime'] = wfTimestamp( TS_MW, $params['starttimestamp'] );
263 } else {
264 $requestArray['wpStarttime'] = wfTimestampNow(); // Fake wpStartime
265 }
266
267 if ( $params['minor'] || ( !$params['notminor'] && $user->getOption( 'minordefault' ) ) ) {
268 $requestArray['wpMinoredit'] = '';
269 }
270
271 if ( $params['recreate'] ) {
272 $requestArray['wpRecreate'] = '';
273 }
274
275 if ( !is_null( $params['section'] ) ) {
276 $section = intval( $params['section'] );
277 if ( $section == 0 && $params['section'] != '0' && $params['section'] != 'new' ) {
278 $this->dieUsage( "The section parameter must be set to an integer or 'new'", "invalidsection" );
279 }
280 $requestArray['wpSection'] = $params['section'];
281 } else {
282 $requestArray['wpSection'] = '';
283 }
284
285 $watch = $this->getWatchlistValue( $params['watchlist'], $titleObj );
286
287 // Deprecated parameters
288 if ( $params['watch'] ) {
289 $watch = true;
290 } elseif ( $params['unwatch'] ) {
291 $watch = false;
292 }
293
294 if ( $watch ) {
295 $requestArray['wpWatchthis'] = '';
296 }
297
298 global $wgTitle, $wgRequest;
299
300 $req = new DerivativeRequest( $this->getRequest(), $requestArray, true );
301
302 // Some functions depend on $wgTitle == $ep->mTitle
303 // TODO: Make them not or check if they still do
304 $wgTitle = $titleObj;
305
306 $articleContext = new RequestContext;
307 $articleContext->setRequest( $req );
308 $articleContext->setWikiPage( $pageObj );
309 $articleContext->setUser( $this->getUser() );
310
311 $articleObject = Article::newFromWikiPage( $pageObj, $articleContext );
312
313 $ep = new EditPage( $articleObject );
314
315 // allow editing of non-textual content.
316 $ep->allowNonTextContent = true;
317
318 $ep->setContextTitle( $titleObj );
319 $ep->importFormData( $req );
320
321 // Run hooks
322 // Handle APIEditBeforeSave parameters
323 $r = array();
324 if ( !wfRunHooks( 'APIEditBeforeSave', array( $ep, $ep->textbox1, &$r ) ) ) {
325 if ( count( $r ) ) {
326 $r['result'] = 'Failure';
327 $apiResult->addValue( null, $this->getModuleName(), $r );
328 return;
329 } else {
330 $this->dieUsageMsg( 'hookaborted' );
331 }
332 }
333
334 // Do the actual save
335 $oldRevId = $articleObject->getRevIdFetched();
336 $result = null;
337 // Fake $wgRequest for some hooks inside EditPage
338 // @todo FIXME: This interface SUCKS
339 $oldRequest = $wgRequest;
340 $wgRequest = $req;
341
342 $status = $ep->internalAttemptSave( $result, $user->isAllowed( 'bot' ) && $params['bot'] );
343 $wgRequest = $oldRequest;
344 global $wgMaxArticleSize;
345
346 switch( $status->value ) {
347 case EditPage::AS_HOOK_ERROR:
348 case EditPage::AS_HOOK_ERROR_EXPECTED:
349 $this->dieUsageMsg( 'hookaborted' );
350
351 case EditPage::AS_PARSE_ERROR:
352 $this->dieUsage( $status->getMessage(), 'parseerror' );
353
354 case EditPage::AS_IMAGE_REDIRECT_ANON:
355 $this->dieUsageMsg( 'noimageredirect-anon' );
356
357 case EditPage::AS_IMAGE_REDIRECT_LOGGED:
358 $this->dieUsageMsg( 'noimageredirect-logged' );
359
360 case EditPage::AS_SPAM_ERROR:
361 $this->dieUsageMsg( array( 'spamdetected', $result['spam'] ) );
362
363 case EditPage::AS_BLOCKED_PAGE_FOR_USER:
364 $this->dieUsageMsg( 'blockedtext' );
365
366 case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED:
367 case EditPage::AS_CONTENT_TOO_BIG:
368 $this->dieUsageMsg( array( 'contenttoobig', $wgMaxArticleSize ) );
369
370 case EditPage::AS_READ_ONLY_PAGE_ANON:
371 $this->dieUsageMsg( 'noedit-anon' );
372
373 case EditPage::AS_READ_ONLY_PAGE_LOGGED:
374 $this->dieUsageMsg( 'noedit' );
375
376 case EditPage::AS_READ_ONLY_PAGE:
377 $this->dieReadOnly();
378
379 case EditPage::AS_RATE_LIMITED:
380 $this->dieUsageMsg( 'actionthrottledtext' );
381
382 case EditPage::AS_ARTICLE_WAS_DELETED:
383 $this->dieUsageMsg( 'wasdeleted' );
384
385 case EditPage::AS_NO_CREATE_PERMISSION:
386 $this->dieUsageMsg( 'nocreate-loggedin' );
387
388 case EditPage::AS_BLANK_ARTICLE:
389 $this->dieUsageMsg( 'blankpage' );
390
391 case EditPage::AS_CONFLICT_DETECTED:
392 $this->dieUsageMsg( 'editconflict' );
393
394 // case EditPage::AS_SUMMARY_NEEDED: Can't happen since we set wpIgnoreBlankSummary
395 case EditPage::AS_TEXTBOX_EMPTY:
396 $this->dieUsageMsg( 'emptynewsection' );
397
398 case EditPage::AS_SUCCESS_NEW_ARTICLE:
399 $r['new'] = '';
400
401 case EditPage::AS_SUCCESS_UPDATE:
402 $r['result'] = 'Success';
403 $r['pageid'] = intval( $titleObj->getArticleID() );
404 $r['title'] = $titleObj->getPrefixedText();
405 $r['contentmodel'] = $titleObj->getContentModel();
406 $newRevId = $articleObject->getLatest();
407 if ( $newRevId == $oldRevId ) {
408 $r['nochange'] = '';
409 } else {
410 $r['oldrevid'] = intval( $oldRevId );
411 $r['newrevid'] = intval( $newRevId );
412 $r['newtimestamp'] = wfTimestamp( TS_ISO_8601,
413 $pageObj->getTimestamp() );
414 }
415 break;
416
417 case EditPage::AS_SUMMARY_NEEDED:
418 $this->dieUsageMsg( 'summaryrequired' );
419
420 case EditPage::AS_END:
421 default:
422 // $status came from WikiPage::doEdit()
423 $errors = $status->getErrorsArray();
424 $this->dieUsageMsg( $errors[0] ); // TODO: Add new errors to message map
425 break;
426 }
427 $apiResult->addValue( null, $this->getModuleName(), $r );
428 }
429
430 public function mustBePosted() {
431 return true;
432 }
433
434 public function isWriteMode() {
435 return true;
436 }
437
438 public function getDescription() {
439 return 'Create and edit pages.';
440 }
441
442 public function getPossibleErrors() {
443 global $wgMaxArticleSize;
444
445 return array_merge( parent::getPossibleErrors(),
446 $this->getTitleOrPageIdErrorMessage(),
447 array(
448 array( 'missingtext' ),
449 array( 'createonly-exists' ),
450 array( 'nocreate-missing' ),
451 array( 'nosuchrevid', 'undo' ),
452 array( 'nosuchrevid', 'undoafter' ),
453 array( 'revwrongpage', 'id', 'text' ),
454 array( 'undo-failure' ),
455 array( 'hashcheckfailed' ),
456 array( 'hookaborted' ),
457 array( 'code' => 'parseerror', 'info' => 'Failed to parse the given text.' ),
458 array( 'noimageredirect-anon' ),
459 array( 'noimageredirect-logged' ),
460 array( 'spamdetected', 'spam' ),
461 array( 'summaryrequired' ),
462 array( 'blockedtext' ),
463 array( 'contenttoobig', $wgMaxArticleSize ),
464 array( 'noedit-anon' ),
465 array( 'noedit' ),
466 array( 'actionthrottledtext' ),
467 array( 'wasdeleted' ),
468 array( 'nocreate-loggedin' ),
469 array( 'blankpage' ),
470 array( 'editconflict' ),
471 array( 'emptynewsection' ),
472 array( 'unknownerror', 'retval' ),
473 array( 'code' => 'nosuchsection', 'info' => 'There is no section section.' ),
474 array( 'code' => 'invalidsection', 'info' => 'The section parameter must be set to an integer or \'new\'' ),
475 array( 'code' => 'sectionsnotsupported', 'info' => 'Sections are not supported for this type of page.' ),
476 array( 'code' => 'editnotsupported', 'info' => 'Editing of this type of page is not supported using '
477 . 'the text based edit API.' ),
478 array( 'code' => 'appendnotsupported', 'info' => 'This type of page can not be edited by appending '
479 . 'or prepending text.' ),
480 array( 'code' => 'badformat', 'info' => 'The requested serialization format can not be applied to '
481 . 'the page\'s content model' ),
482 array( 'customcssprotected' ),
483 array( 'customjsprotected' ),
484 )
485 );
486 }
487
488 public function getAllowedParams() {
489 return array(
490 'title' => array(
491 ApiBase::PARAM_TYPE => 'string',
492 ),
493 'pageid' => array(
494 ApiBase::PARAM_TYPE => 'integer',
495 ),
496 'section' => null,
497 'sectiontitle' => array(
498 ApiBase::PARAM_TYPE => 'string',
499 ApiBase::PARAM_REQUIRED => false,
500 ),
501 'text' => null,
502 'token' => array(
503 ApiBase::PARAM_TYPE => 'string',
504 ApiBase::PARAM_REQUIRED => true
505 ),
506 'summary' => null,
507 'minor' => false,
508 'notminor' => false,
509 'bot' => false,
510 'basetimestamp' => null,
511 'starttimestamp' => null,
512 'recreate' => false,
513 'createonly' => false,
514 'nocreate' => false,
515 'watch' => array(
516 ApiBase::PARAM_DFLT => false,
517 ApiBase::PARAM_DEPRECATED => true,
518 ),
519 'unwatch' => array(
520 ApiBase::PARAM_DFLT => false,
521 ApiBase::PARAM_DEPRECATED => true,
522 ),
523 'watchlist' => array(
524 ApiBase::PARAM_DFLT => 'preferences',
525 ApiBase::PARAM_TYPE => array(
526 'watch',
527 'unwatch',
528 'preferences',
529 'nochange'
530 ),
531 ),
532 'md5' => null,
533 'prependtext' => null,
534 'appendtext' => null,
535 'undo' => array(
536 ApiBase::PARAM_TYPE => 'integer'
537 ),
538 'undoafter' => array(
539 ApiBase::PARAM_TYPE => 'integer'
540 ),
541 'redirect' => array(
542 ApiBase::PARAM_TYPE => 'boolean',
543 ApiBase::PARAM_DFLT => false,
544 ),
545 'contentformat' => array(
546 ApiBase::PARAM_TYPE => ContentHandler::getAllContentFormats(),
547 ),
548 'contentmodel' => array(
549 ApiBase::PARAM_TYPE => ContentHandler::getContentModels(),
550 )
551 );
552 }
553
554 public function getParamDescription() {
555 $p = $this->getModulePrefix();
556 return array(
557 'title' => "Title of the page you want to edit. Cannot be used together with {$p}pageid",
558 'pageid' => "Page ID of the page you want to edit. Cannot be used together with {$p}title",
559 'section' => 'Section number. 0 for the top section, \'new\' for a new section',
560 'sectiontitle' => 'The title for a new section',
561 'text' => 'Page content',
562 'token' => array( 'Edit token. You can get one of these through prop=info.',
563 "The token should always be sent as the last parameter, or at least, after the {$p}text parameter"
564 ),
565 'summary' => "Edit summary. Also section title when {$p}section=new and {$p}sectiontitle is not set",
566 'minor' => 'Minor edit',
567 'notminor' => 'Non-minor edit',
568 'bot' => 'Mark this edit as bot',
569 'basetimestamp' => array( 'Timestamp of the base revision (obtained through prop=revisions&rvprop=timestamp).',
570 'Used to detect edit conflicts; leave unset to ignore conflicts'
571 ),
572 'starttimestamp' => array( 'Timestamp when you obtained the edit token.',
573 'Used to detect edit conflicts; leave unset to ignore conflicts'
574 ),
575 'recreate' => 'Override any errors about the article having been deleted in the meantime',
576 'createonly' => 'Don\'t edit the page if it exists already',
577 'nocreate' => 'Throw an error if the page doesn\'t exist',
578 'watch' => 'Add the page to your watchlist',
579 'unwatch' => 'Remove the page from your watchlist',
580 'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch',
581 'md5' => array( "The MD5 hash of the {$p}text parameter, or the {$p}prependtext and {$p}appendtext parameters concatenated.",
582 'If set, the edit won\'t be done unless the hash is correct' ),
583 'prependtext' => "Add this text to the beginning of the page. Overrides {$p}text",
584 'appendtext' => array( "Add this text to the end of the page. Overrides {$p}text.",
585 "Use {$p}section=new to append a new section" ),
586 'undo' => "Undo this revision. Overrides {$p}text, {$p}prependtext and {$p}appendtext",
587 'undoafter' => 'Undo all revisions from undo to this one. If not set, just undo one revision',
588 'redirect' => 'Automatically resolve redirects',
589 'contentformat' => 'Content serialization format used for the input text',
590 'contentmodel' => 'Content model of the new content',
591 );
592 }
593
594 public function getResultProperties() {
595 return array(
596 '' => array(
597 'new' => 'boolean',
598 'result' => array(
599 ApiBase::PROP_TYPE => array(
600 'Success',
601 'Failure'
602 ),
603 ),
604 'pageid' => array(
605 ApiBase::PROP_TYPE => 'integer',
606 ApiBase::PROP_NULLABLE => true
607 ),
608 'title' => array(
609 ApiBase::PROP_TYPE => 'string',
610 ApiBase::PROP_NULLABLE => true
611 ),
612 'nochange' => 'boolean',
613 'oldrevid' => array(
614 ApiBase::PROP_TYPE => 'integer',
615 ApiBase::PROP_NULLABLE => true
616 ),
617 'newrevid' => array(
618 ApiBase::PROP_TYPE => 'integer',
619 ApiBase::PROP_NULLABLE => true
620 ),
621 'newtimestamp' => array(
622 ApiBase::PROP_TYPE => 'string',
623 ApiBase::PROP_NULLABLE => true
624 )
625 )
626 );
627 }
628
629 public function needsToken() {
630 return true;
631 }
632
633 public function getTokenSalt() {
634 return '';
635 }
636
637 public function getExamples() {
638 return array(
639
640 'api.php?action=edit&title=Test&summary=test%20summary&text=article%20content&basetimestamp=20070824123454&token=%2B\\'
641 => 'Edit a page (anonymous user)',
642
643 'api.php?action=edit&title=Test&summary=NOTOC&minor=&prependtext=__NOTOC__%0A&basetimestamp=20070824123454&token=%2B\\'
644 => 'Prepend __NOTOC__ to a page (anonymous user)',
645 'api.php?action=edit&title=Test&undo=13585&undoafter=13579&basetimestamp=20070824123454&token=%2B\\'
646 => 'Undo r13579 through r13585 with autosummary (anonymous user)',
647 );
648 }
649
650 public function getHelpUrls() {
651 return 'https://www.mediawiki.org/wiki/API:Edit';
652 }
653 }