mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 00:00:49 +00:00
Make the API module handle missing pages and page creations
Change-Id: I91a43888435011b62e62cf4dde744b23a4ea65d6
This commit is contained in:
parent
675bd284c5
commit
563db3c4ad
|
@ -9,30 +9,36 @@ class ApiVisualEditor extends ApiBase {
|
|||
$params = $this->extractRequestParams();
|
||||
$page = Title::newFromText( $params['page'] );
|
||||
|
||||
if ($params['paction'] === 'parse') {
|
||||
$parsed = Http::get(
|
||||
$parsoid.$page
|
||||
);
|
||||
if ( $params['paction'] === 'parse' ) {
|
||||
if ( $page->exists() ) {
|
||||
$parsed = Http::get(
|
||||
$parsoid . $page->getPrefixedDBkey()
|
||||
);
|
||||
|
||||
if ( $parsed ) {
|
||||
$result = array(
|
||||
'result' => 'success',
|
||||
'parsed' => $parsed
|
||||
);
|
||||
if ( $parsed ) {
|
||||
$result = array(
|
||||
'result' => 'success',
|
||||
'parsed' => $parsed
|
||||
);
|
||||
} else {
|
||||
$result = array(
|
||||
'result' => 'error'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$result = array(
|
||||
'result' => 'error'
|
||||
);
|
||||
$result = array( 'result' => 'success', 'parsed' => '' );
|
||||
}
|
||||
} elseif ($params['paction'] === 'save') {
|
||||
} elseif ( $params['paction'] === 'save' ) {
|
||||
// API Posts HTML to Parsoid Service, receives Wikitext,
|
||||
// API Saves Wikitext to page.
|
||||
$wikitext = Http::post( $parsoid.$page, array( 'postData' => array( 'content' => $params['html'] ) ) );
|
||||
$wikitext = Http::post( $parsoid . $page->getPrefixedDBkey(),
|
||||
array( 'postData' => array( 'content' => $params['html'] ) )
|
||||
);
|
||||
|
||||
if ( $wikitext ) {
|
||||
|
||||
/* Save Page */
|
||||
$flags = $params['minor'] === 'true' ? EDIT_MINOR : EDIT_UPDATE;
|
||||
$flags = $params['minor'] === 'true' ? EDIT_MINOR : 0;
|
||||
|
||||
$wikiPage = WikiPage::factory( $page );
|
||||
$status = $wikiPage->doEdit(
|
||||
|
|
Loading…
Reference in a new issue