2012-05-25 19:50:48 +00:00
|
|
|
<?php
|
2012-07-19 00:11:26 +00:00
|
|
|
/**
|
|
|
|
* Parsoid API wrapper.
|
2012-07-19 21:25:16 +00:00
|
|
|
*
|
2012-07-19 00:11:26 +00:00
|
|
|
* @file
|
|
|
|
* @ingroup Extensions
|
2015-01-08 23:54:03 +00:00
|
|
|
* @copyright 2011-2015 VisualEditor Team and others; see AUTHORS.txt
|
2012-07-19 00:11:26 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2012-05-25 19:50:48 +00:00
|
|
|
class ApiVisualEditor extends ApiBase {
|
2013-07-05 07:56:28 +00:00
|
|
|
|
2014-08-13 08:15:42 +00:00
|
|
|
/**
|
|
|
|
* @var Config
|
|
|
|
*/
|
|
|
|
protected $veConfig;
|
|
|
|
|
2014-12-18 00:49:55 +00:00
|
|
|
/**
|
|
|
|
* @var VirtualRESTServiceClient
|
|
|
|
*/
|
|
|
|
protected $serviceClient;
|
|
|
|
|
2014-08-13 08:15:42 +00:00
|
|
|
public function __construct( ApiMain $main, $name, Config $config ) {
|
|
|
|
parent::__construct( $main, $name );
|
|
|
|
$this->veConfig = $config;
|
2014-12-18 00:49:55 +00:00
|
|
|
$this->serviceClient = new VirtualRESTServiceClient( new MultiHttpClient( array() ) );
|
2015-03-04 14:52:07 +00:00
|
|
|
$this->serviceClient->mount( '/parsoid/', $this->getVRSObject() );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates the virtual REST service object to be used in VE's API calls. The
|
|
|
|
* method determines whether to instantiate a ParsoidVirtualRESTService or a
|
|
|
|
* RestbaseVirtualRESTService object based on configuration directives: if
|
|
|
|
* $wgVirtualRestConfig['modules']['restbase'] is defined, RESTBase is chosen,
|
|
|
|
* otherwise Parsoid is used (either by using the MW Core config, or the
|
|
|
|
* VE-local one).
|
|
|
|
*
|
|
|
|
* @return VirtualRESTService the VirtualRESTService object to use
|
|
|
|
*/
|
|
|
|
private function getVRSObject() {
|
|
|
|
// the params array to create the service object with
|
|
|
|
$params = array();
|
|
|
|
// the VRS class to use, defaults to Parsoid
|
|
|
|
$class = 'ParsoidVirtualRESTService';
|
|
|
|
$config = $this->veConfig;
|
|
|
|
// the global virtual rest service config object, if any
|
|
|
|
$vrs = $this->getConfig()->get( 'VirtualRestConfig' );
|
|
|
|
if ( isset( $vrs['modules'] ) && isset( $vrs['modules']['restbase'] ) ) {
|
|
|
|
// if restbase is available, use it
|
|
|
|
$params = $vrs['modules']['restbase'];
|
|
|
|
$class = 'RestbaseVirtualRESTService';
|
|
|
|
// remove once VE generates restbase paths
|
|
|
|
$params['parsoidCompat'] = true;
|
|
|
|
} elseif ( isset( $vrs['modules'] ) && isset( $vrs['modules']['parsoid'] ) ) {
|
|
|
|
// there's a global parsoid config, use it next
|
|
|
|
$params = $vrs['modules']['parsoid'];
|
|
|
|
} else {
|
|
|
|
// no global modules defined, fall back to old defaults
|
|
|
|
$params = array(
|
|
|
|
'URL' => $config->get( 'VisualEditorParsoidURL' ),
|
|
|
|
'prefix' => $config->get( 'VisualEditorParsoidPrefix' ),
|
|
|
|
'timeout' => $config->get( 'VisualEditorParsoidTimeout' ),
|
|
|
|
'HTTPProxy' => $config->get( 'VisualEditorParsoidHTTPProxy' ),
|
|
|
|
'forwardCookies' => $config->get( 'VisualEditorParsoidForwardCookies' )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
// merge the global and service-specific params
|
|
|
|
if ( isset( $vrs['global'] ) ) {
|
|
|
|
$params = array_merge( $vrs['global'], $params );
|
|
|
|
}
|
|
|
|
// set up cookie forwarding
|
|
|
|
if ( $params['forwardCookies'] && !User::isEveryoneAllowed( 'read' ) ) {
|
|
|
|
$params['forwardCookies'] = RequestContext::getMain()->getRequest()->getHeader( 'Cookie' );
|
|
|
|
} else {
|
|
|
|
$params['forwardCookies'] = false;
|
|
|
|
}
|
|
|
|
// create the VRS object and return it
|
|
|
|
return new $class( $params );
|
2014-02-07 16:10:59 +00:00
|
|
|
}
|
|
|
|
|
2015-01-07 21:56:19 +00:00
|
|
|
private function requestParsoid( $method, $path, $params ) {
|
2014-12-18 00:49:55 +00:00
|
|
|
$request = array(
|
|
|
|
'method' => $method,
|
2015-01-07 21:56:19 +00:00
|
|
|
'url' => '/parsoid/local/v1/' . $path
|
2014-04-18 20:17:02 +00:00
|
|
|
);
|
2014-12-18 00:49:55 +00:00
|
|
|
if ( $method === 'GET' ) {
|
|
|
|
$request['query'] = $params;
|
2014-04-18 20:17:02 +00:00
|
|
|
} else {
|
2014-12-18 00:49:55 +00:00
|
|
|
$request['body'] = $params;
|
2014-04-18 20:17:02 +00:00
|
|
|
}
|
2014-12-18 00:49:55 +00:00
|
|
|
$response = $this->serviceClient->run( $request );
|
|
|
|
if ( $response['code'] === 200 && $response['error'] === "" ) {
|
2014-04-18 20:17:02 +00:00
|
|
|
// Pass thru performance data from Parsoid to the client, unless the response was
|
|
|
|
// served directly from Varnish, in which case discard the value of the XPP header
|
|
|
|
// and use it to declare the cache hit instead.
|
2015-02-16 01:13:54 +00:00
|
|
|
$headers = $response['headers'];
|
2015-03-13 00:52:52 +00:00
|
|
|
$xpp = null;
|
2015-02-16 01:13:54 +00:00
|
|
|
if ( isset( $headers['x-cache'] ) && strpos( $headers['x-cache'], 'hit' ) !== false ) {
|
2014-04-18 20:17:02 +00:00
|
|
|
$xpp = 'cached-response=true';
|
2015-03-13 00:52:52 +00:00
|
|
|
} elseif ( isset( $headers['x-parsoid-performance'] ) ) {
|
2015-02-16 01:13:54 +00:00
|
|
|
$xpp = $headers['x-parsoid-performance'];
|
2014-04-18 20:17:02 +00:00
|
|
|
}
|
|
|
|
if ( $xpp !== null ) {
|
|
|
|
$resp = $this->getRequest()->response();
|
|
|
|
$resp->header( 'X-Parsoid-Performance: ' . $xpp );
|
|
|
|
}
|
2014-12-18 00:49:55 +00:00
|
|
|
} elseif ( $response['error'] !== '' ) {
|
|
|
|
$this->dieUsage( 'parsoidserver-http-error: ' . $response['error'], $response['error'] );
|
|
|
|
} else { // error null, code not 200
|
|
|
|
$this->dieUsage( 'parsoidserver-http: HTTP ' . $response['code'], $response['code'] );
|
2014-04-18 20:17:02 +00:00
|
|
|
}
|
2014-12-18 00:49:55 +00:00
|
|
|
return $response['body'];
|
2014-04-18 20:17:02 +00:00
|
|
|
}
|
|
|
|
|
2013-11-01 21:30:22 +00:00
|
|
|
protected function storeInSerializationCache( $title, $oldid, $html ) {
|
2014-08-13 08:15:42 +00:00
|
|
|
global $wgMemc;
|
2013-11-01 21:30:22 +00:00
|
|
|
$content = $this->postHTML( $title, $html, array( 'oldid' => $oldid ) );
|
|
|
|
if ( $content === false ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$hash = md5( $content );
|
|
|
|
$key = wfMemcKey( 'visualeditor', 'serialization', $hash );
|
2014-08-13 08:15:42 +00:00
|
|
|
$wgMemc->set( $key, $content, $this->veConfig->get( 'VisualEditorSerializationCacheTimeout' ) );
|
2013-11-01 21:30:22 +00:00
|
|
|
return $hash;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function trySerializationCache( $hash ) {
|
|
|
|
global $wgMemc;
|
|
|
|
$key = wfMemcKey( 'visualeditor', 'serialization', $hash );
|
|
|
|
return $wgMemc->get( $key );
|
|
|
|
}
|
|
|
|
|
2013-04-15 23:22:51 +00:00
|
|
|
protected function postHTML( $title, $html, $parserParams ) {
|
|
|
|
if ( $parserParams['oldid'] === 0 ) {
|
|
|
|
$parserParams['oldid'] = '';
|
|
|
|
}
|
2015-01-07 21:56:19 +00:00
|
|
|
return $this->requestParsoid(
|
|
|
|
'POST',
|
|
|
|
'transform/html/to/wikitext/' . urlencode( $title->getPrefixedDBkey() ),
|
2014-04-18 20:17:02 +00:00
|
|
|
array(
|
2014-12-18 00:49:55 +00:00
|
|
|
'html' => $html,
|
2014-04-18 20:17:02 +00:00
|
|
|
'oldid' => $parserParams['oldid'],
|
2012-11-15 01:16:13 +00:00
|
|
|
)
|
2012-11-14 18:33:57 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-10-22 22:47:21 +00:00
|
|
|
protected function pstWikitext( $title, $wikitext ) {
|
2015-03-17 20:43:03 +00:00
|
|
|
return ContentHandler::makeContent( $wikitext, $title, CONTENT_MODEL_WIKITEXT )
|
2014-10-22 22:47:21 +00:00
|
|
|
->preSaveTransform(
|
|
|
|
$title,
|
|
|
|
$this->getUser(),
|
|
|
|
WikiPage::factory( $title )->makeParserOptions( $this->getContext() )
|
|
|
|
)
|
|
|
|
->serialize( 'text/x-wiki' );
|
|
|
|
}
|
|
|
|
|
2014-04-18 20:19:54 +00:00
|
|
|
protected function parseWikitextFragment( $title, $wikitext ) {
|
2015-01-07 21:56:19 +00:00
|
|
|
return $this->requestParsoid(
|
|
|
|
'POST',
|
|
|
|
'transform/wikitext/to/html/' . urlencode( $title->getPrefixedDBkey() ),
|
2014-04-18 20:19:54 +00:00
|
|
|
array(
|
2014-12-18 00:49:55 +00:00
|
|
|
'wikitext' => $wikitext,
|
2014-04-18 20:19:54 +00:00
|
|
|
'body' => 1,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-11-14 18:33:57 +00:00
|
|
|
protected function diffWikitext( $title, $wikitext ) {
|
|
|
|
$apiParams = array(
|
|
|
|
'action' => 'query',
|
|
|
|
'prop' => 'revisions',
|
|
|
|
'titles' => $title->getPrefixedDBkey(),
|
2014-10-22 22:47:21 +00:00
|
|
|
'rvdifftotext' => $this->pstWikitext( $title, $wikitext )
|
2012-11-14 18:33:57 +00:00
|
|
|
);
|
|
|
|
$api = new ApiMain(
|
|
|
|
new DerivativeRequest(
|
|
|
|
$this->getRequest(),
|
|
|
|
$apiParams,
|
|
|
|
false // was posted?
|
|
|
|
),
|
|
|
|
false // enable write?
|
|
|
|
);
|
|
|
|
$api->execute();
|
2014-12-30 22:20:55 +00:00
|
|
|
if ( defined( 'ApiResult::META_CONTENT' ) ) {
|
|
|
|
$result = $api->getResult()->getResultData();
|
|
|
|
// Transform content nodes to '*'
|
|
|
|
$result = ApiResult::transformForBC( $result );
|
|
|
|
} else {
|
|
|
|
$result = $api->getResultData();
|
|
|
|
}
|
2012-12-07 16:23:23 +00:00
|
|
|
if ( !isset( $result['query']['pages'][$title->getArticleID()]['revisions'][0]['diff']['*'] ) ) {
|
2013-05-14 17:40:00 +00:00
|
|
|
return array( 'result' => 'fail' );
|
2012-12-07 16:23:23 +00:00
|
|
|
}
|
|
|
|
$diffRows = $result['query']['pages'][$title->getArticleID()]['revisions'][0]['diff']['*'];
|
|
|
|
|
2013-05-10 22:32:23 +00:00
|
|
|
if ( $diffRows !== '' ) {
|
|
|
|
$context = new DerivativeContext( $this->getContext() );
|
|
|
|
$context->setTitle( $title );
|
|
|
|
$engine = new DifferenceEngine( $context );
|
2013-05-14 17:40:00 +00:00
|
|
|
return array(
|
|
|
|
'result' => 'success',
|
|
|
|
'diff' => $engine->addHeader(
|
|
|
|
$diffRows,
|
2014-12-17 23:41:15 +00:00
|
|
|
$context->msg( 'currentrev' )->parse(),
|
|
|
|
$context->msg( 'yourtext' )->parse()
|
2013-05-14 17:40:00 +00:00
|
|
|
)
|
2013-05-10 22:32:23 +00:00
|
|
|
);
|
|
|
|
} else {
|
2013-05-14 17:40:00 +00:00
|
|
|
return array( 'result' => 'nochanges' );
|
2013-05-10 22:32:23 +00:00
|
|
|
}
|
2012-11-14 18:33:57 +00:00
|
|
|
}
|
2012-05-25 22:23:40 +00:00
|
|
|
|
2013-12-04 15:30:21 +00:00
|
|
|
protected function getLangLinks( $title ) {
|
|
|
|
$apiParams = array(
|
|
|
|
'action' => 'query',
|
|
|
|
'prop' => 'langlinks',
|
|
|
|
'lllimit' => 500,
|
|
|
|
'titles' => $title->getPrefixedDBkey(),
|
|
|
|
'indexpageids' => 1,
|
|
|
|
);
|
|
|
|
$api = new ApiMain(
|
|
|
|
new DerivativeRequest(
|
|
|
|
$this->getRequest(),
|
|
|
|
$apiParams,
|
|
|
|
false // was posted?
|
|
|
|
),
|
|
|
|
true // enable write?
|
|
|
|
);
|
|
|
|
|
|
|
|
$api->execute();
|
2014-12-30 22:20:55 +00:00
|
|
|
if ( defined( 'ApiResult::META_CONTENT' ) ) {
|
|
|
|
$result = $api->getResult()->getResultData();
|
|
|
|
// Remove any metadata keys from the langlinks array
|
|
|
|
$result = ApiResult::removeMetadata( $result );
|
|
|
|
} else {
|
|
|
|
$result = $api->getResultData();
|
|
|
|
}
|
2013-12-04 15:30:21 +00:00
|
|
|
if ( !isset( $result['query']['pages'][$title->getArticleID()]['langlinks'] ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$langlinks = $result['query']['pages'][$title->getArticleID()]['langlinks'];
|
|
|
|
$langnames = Language::fetchLanguageNames();
|
|
|
|
foreach ( $langlinks as $i => $lang ) {
|
|
|
|
$langlinks[$i]['langname'] = $langnames[$langlinks[$i]['lang']];
|
|
|
|
}
|
|
|
|
return $langlinks;
|
|
|
|
}
|
|
|
|
|
2012-05-25 19:50:48 +00:00
|
|
|
public function execute() {
|
2012-07-21 17:37:20 +00:00
|
|
|
$user = $this->getUser();
|
2012-05-25 19:50:48 +00:00
|
|
|
$params = $this->extractRequestParams();
|
2014-03-21 00:44:30 +00:00
|
|
|
|
2015-03-26 19:32:01 +00:00
|
|
|
$title = Title::newFromText( $params['page'] );
|
|
|
|
if ( !$title ) {
|
2012-11-14 18:33:57 +00:00
|
|
|
$this->dieUsageMsg( 'invalidtitle', $params['page'] );
|
|
|
|
}
|
2015-03-26 19:32:01 +00:00
|
|
|
if ( !in_array( $title->getNamespace(), $this->veConfig->get( 'VisualEditorNamespaces' ) ) ) {
|
2012-11-14 18:33:57 +00:00
|
|
|
$this->dieUsage( "VisualEditor is not enabled in namespace " .
|
2015-03-26 19:32:01 +00:00
|
|
|
$title->getNamespace(), 'novenamespace' );
|
2012-11-14 18:33:57 +00:00
|
|
|
}
|
2012-05-25 19:50:48 +00:00
|
|
|
|
2013-05-15 23:51:11 +00:00
|
|
|
$parserParams = array();
|
|
|
|
if ( isset( $params['oldid'] ) ) {
|
|
|
|
$parserParams['oldid'] = $params['oldid'];
|
|
|
|
}
|
2012-08-23 19:01:07 +00:00
|
|
|
|
2014-06-23 17:55:59 +00:00
|
|
|
$html = $params['html'];
|
|
|
|
if ( substr( $html, 0, 11 ) === 'rawdeflate,' ) {
|
|
|
|
$html = gzinflate( base64_decode( substr( $html, 11 ) ) );
|
|
|
|
}
|
|
|
|
|
2015-03-26 19:32:01 +00:00
|
|
|
wfDebugLog( 'visualeditor', "called on '$title' with paction: '{$params['paction']}'" );
|
2013-05-15 21:17:06 +00:00
|
|
|
switch ( $params['paction'] ) {
|
|
|
|
case 'parse':
|
2015-03-13 22:15:17 +00:00
|
|
|
case 'metadata':
|
2013-05-15 21:17:06 +00:00
|
|
|
// Dirty hack to provide the correct context for edit notices
|
|
|
|
global $wgTitle; // FIXME NOOOOOOOOES
|
2015-03-26 19:32:01 +00:00
|
|
|
$wgTitle = $title;
|
|
|
|
RequestContext::getMain()->setTitle( $title );
|
2015-03-13 22:15:17 +00:00
|
|
|
|
|
|
|
// Get information about current revision
|
|
|
|
if ( $title->exists() ) {
|
|
|
|
$latestRevision = Revision::newFromTitle( $title );
|
|
|
|
if ( $latestRevision === null ) {
|
|
|
|
$this->dieUsage( 'Could not find latest revision for title', 'latestnotfound' );
|
|
|
|
}
|
|
|
|
$revision = null;
|
|
|
|
if ( !isset( $parserParams['oldid'] ) || $parserParams['oldid'] === 0 ) {
|
|
|
|
$parserParams['oldid'] = $latestRevision->getId();
|
|
|
|
$revision = $latestRevision;
|
|
|
|
} else {
|
|
|
|
$revision = Revision::newFromId( $parserParams['oldid'] );
|
|
|
|
if ( $revision === null ) {
|
|
|
|
$this->dieUsage( 'Could not find revision ID ' . $parserParams['oldid'], 'oldidnotfound' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$restoring = $revision && !$revision->isCurrent();
|
|
|
|
$baseTimestamp = $latestRevision->getTimestamp();
|
|
|
|
$oldid = intval( $parserParams['oldid'] );
|
|
|
|
|
|
|
|
// If requested, request HTML from Parsoid
|
|
|
|
if ( $params['paction'] === 'parse' ) {
|
|
|
|
$content = $this->requestParsoid(
|
|
|
|
'GET',
|
|
|
|
'page/' . urlencode( $title->getPrefixedDBkey() ) . '/html',
|
|
|
|
$parserParams
|
|
|
|
);
|
|
|
|
if ( $content === false ) {
|
|
|
|
$this->dieUsage( 'Error contacting the Parsoid server', 'parsoidserver' );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$content = '';
|
|
|
|
$baseTimestamp = wfTimestampNow();
|
|
|
|
$oldid = 0;
|
|
|
|
$restoring = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get edit notices
|
2015-03-26 19:32:01 +00:00
|
|
|
$notices = $title->getEditNotices();
|
2015-03-13 22:15:17 +00:00
|
|
|
|
|
|
|
// Anonymous user notice
|
2013-05-15 21:17:06 +00:00
|
|
|
if ( $user->isAnon() ) {
|
2014-09-02 18:56:55 +00:00
|
|
|
$notices[] = $this->msg(
|
|
|
|
'anoneditwarning',
|
|
|
|
// Log-in link
|
|
|
|
'{{fullurl:Special:UserLogin|returnto={{FULLPAGENAMEE}}}}',
|
|
|
|
// Sign-up link
|
|
|
|
'{{fullurl:Special:UserLogin/signup|returnto={{FULLPAGENAMEE}}}}'
|
|
|
|
)->parseAsBlock();
|
2012-12-11 03:40:09 +00:00
|
|
|
}
|
2015-03-13 22:15:17 +00:00
|
|
|
|
|
|
|
// Old revision notice
|
|
|
|
if ( $restoring ) {
|
2014-03-26 22:20:08 +00:00
|
|
|
$notices[] = $this->msg( 'editingold' )->parseAsBlock();
|
2014-03-26 21:33:19 +00:00
|
|
|
}
|
|
|
|
|
2015-03-13 22:15:17 +00:00
|
|
|
// New page notices
|
2015-03-26 19:32:01 +00:00
|
|
|
if ( !$title->exists() ) {
|
2014-03-26 21:33:19 +00:00
|
|
|
$notices[] = $this->msg(
|
|
|
|
$user->isLoggedIn() ? 'newarticletext' : 'newarticletextanon',
|
|
|
|
Skin::makeInternalOrExternalUrl(
|
|
|
|
$this->msg( 'helppage' )->inContentLanguage()->text()
|
|
|
|
)
|
|
|
|
)->parseAsBlock();
|
2013-07-24 09:43:21 +00:00
|
|
|
// Page protected from creation
|
2015-03-26 19:32:01 +00:00
|
|
|
if ( $title->getRestrictions( 'create' ) ) {
|
2014-03-26 21:33:19 +00:00
|
|
|
$notices[] = $this->msg( 'titleprotectedwarning' )->parseAsBlock();
|
2013-05-15 21:17:06 +00:00
|
|
|
}
|
|
|
|
}
|
2014-03-26 21:33:19 +00:00
|
|
|
|
2014-04-30 19:28:29 +00:00
|
|
|
// Look at protection status to set up notices + surface class(es)
|
|
|
|
$protectedClasses = array();
|
2015-03-26 19:32:01 +00:00
|
|
|
if ( MWNamespace::getRestrictionLevels( $title->getNamespace() ) !== array( '' ) ) {
|
2014-04-16 23:16:06 +00:00
|
|
|
// Page protected from editing
|
2015-03-26 19:32:01 +00:00
|
|
|
if ( $title->isProtected( 'edit' ) ) {
|
2014-04-16 23:16:06 +00:00
|
|
|
# Is the title semi-protected?
|
2015-03-26 19:32:01 +00:00
|
|
|
if ( $title->isSemiProtected() ) {
|
2014-04-30 19:28:29 +00:00
|
|
|
$protectedClasses[] = 'mw-textarea-sprotected';
|
|
|
|
|
2014-04-16 23:16:06 +00:00
|
|
|
$noticeMsg = 'semiprotectedpagewarning';
|
|
|
|
} else {
|
2014-04-30 19:28:29 +00:00
|
|
|
$protectedClasses[] = 'mw-textarea-protected';
|
|
|
|
|
2014-04-16 23:16:06 +00:00
|
|
|
# Then it must be protected based on static groups (regular)
|
|
|
|
$noticeMsg = 'protectedpagewarning';
|
|
|
|
}
|
|
|
|
$notices[] = $this->msg( $noticeMsg )->parseAsBlock() .
|
2015-03-26 19:32:01 +00:00
|
|
|
$this->getLastLogEntry( $title, 'protect' );
|
2014-03-17 22:11:01 +00:00
|
|
|
}
|
|
|
|
|
2014-04-16 23:16:06 +00:00
|
|
|
// Deal with cascading edit protection
|
2015-03-26 19:32:01 +00:00
|
|
|
list( $sources, $restrictions ) = $title->getCascadeProtectionSources();
|
2014-04-16 23:16:06 +00:00
|
|
|
if ( isset( $restrictions['edit'] ) ) {
|
2014-04-30 19:28:29 +00:00
|
|
|
$protectedClasses[] = ' mw-textarea-cprotected';
|
|
|
|
|
2014-04-16 23:16:06 +00:00
|
|
|
$notice = $this->msg( 'cascadeprotectedwarning' )->parseAsBlock() . '<ul>';
|
|
|
|
// Unfortunately there's no nice way to get only the pages which cause
|
|
|
|
// editing to be restricted
|
|
|
|
foreach ( $sources as $source ) {
|
|
|
|
$notice .= "<li>" . Linker::link( $source ) . "</li>";
|
|
|
|
}
|
|
|
|
$notice .= '</ul>';
|
|
|
|
$notices[] = $notice;
|
|
|
|
}
|
2014-03-26 20:39:45 +00:00
|
|
|
}
|
|
|
|
|
2015-03-13 22:15:17 +00:00
|
|
|
// Permission notice
|
2015-03-26 19:32:01 +00:00
|
|
|
if ( !$title->userCan( 'create' ) && !$title->exists() ) {
|
2014-07-05 19:09:23 +00:00
|
|
|
$notices[] = $this->msg(
|
|
|
|
'permissionserrorstext-withaction', 1, $this->msg( 'action-createpage' )
|
|
|
|
) . "<br>" . $this->msg( 'nocreatetext' )->parse();
|
|
|
|
}
|
|
|
|
|
2014-03-26 20:39:45 +00:00
|
|
|
// Show notice when editing user / user talk page of a user that doesn't exist
|
|
|
|
// or who is blocked
|
|
|
|
// HACK of course this code is partly duplicated from EditPage.php :(
|
2015-03-26 19:32:01 +00:00
|
|
|
if ( $title->getNamespace() == NS_USER || $title->getNamespace() == NS_USER_TALK ) {
|
|
|
|
$parts = explode( '/', $title->getText(), 2 );
|
2014-03-26 20:39:45 +00:00
|
|
|
$targetUsername = $parts[0];
|
|
|
|
$targetUser = User::newFromName( $targetUsername, false /* allow IP users*/ );
|
|
|
|
|
|
|
|
if (
|
|
|
|
!( $targetUser && $targetUser->isLoggedIn() ) &&
|
|
|
|
!User::isIP( $targetUsername )
|
|
|
|
) { // User does not exist
|
|
|
|
$notices[] = "<div class=\"mw-userpage-userdoesnotexist error\">\n" .
|
|
|
|
$this->msg( 'userpage-userdoesnotexist', wfEscapeWikiText( $targetUsername ) ) .
|
|
|
|
"\n</div>";
|
|
|
|
} elseif ( $targetUser->isBlocked() ) { // Show log extract if the user is currently blocked
|
|
|
|
$notices[] = $this->msg(
|
|
|
|
'blocked-notice-logextract',
|
|
|
|
$targetUser->getName() // Support GENDER in notice
|
|
|
|
)->parseAsBlock() . $this->getLastLogEntry( $targetUser->getUserPage(), 'block' );
|
|
|
|
}
|
2014-03-17 22:11:01 +00:00
|
|
|
}
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
|
2015-03-13 22:15:17 +00:00
|
|
|
// Blocked user notice
|
2015-03-26 19:32:01 +00:00
|
|
|
if ( $user->isBlockedFrom( $title ) && $user->getBlock()->prevents( 'edit' ) !== false ) {
|
2014-03-17 21:22:41 +00:00
|
|
|
$notices[] = call_user_func_array(
|
|
|
|
array( $this, 'msg' ),
|
|
|
|
$user->getBlock()->getPermissionsError( $this->getContext() )
|
|
|
|
)->parseAsBlock();
|
|
|
|
}
|
|
|
|
|
2015-03-13 22:15:17 +00:00
|
|
|
// Blocked user notice for global blocks
|
2014-04-22 00:22:48 +00:00
|
|
|
if ( class_exists( 'GlobalBlocking' ) ) {
|
|
|
|
$error = GlobalBlocking::getUserBlockErrors(
|
|
|
|
$user,
|
|
|
|
$this->getRequest()->getIP()
|
|
|
|
);
|
|
|
|
if ( count( $error ) ) {
|
|
|
|
$notices[] = call_user_func_array(
|
|
|
|
array( $this, 'msg' ),
|
|
|
|
$error
|
|
|
|
)->parseAsBlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
// HACK: Build a fake EditPage so we can get checkboxes from it
|
2015-03-26 19:32:01 +00:00
|
|
|
$article = new Article( $title ); // Deliberately omitting ,0 so oldid comes from request
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
$ep = new EditPage( $article );
|
2013-08-02 18:37:30 +00:00
|
|
|
$req = $this->getRequest();
|
2014-01-09 21:16:55 +00:00
|
|
|
$req->setVal( 'format', 'text/x-wiki' );
|
2013-08-02 18:37:30 +00:00
|
|
|
$ep->importFormData( $req ); // By reference for some reason (bug 52466)
|
Render check boxes from EditPage
EditPage has a lovely getCheckboxes() function which includes the
minor and watch checkboxes as rendered by MW core, as well as any
checkboxes extensions like FlaggedRevs might have added. Output
these in the API, render them, and send their values back.
ApiVisualEditor.php:
* Build a fake EditPage, get its checkboxes, and return them
ApiVisualEditorEdit.php:
* Pass through posted request data to ApiEdit, which passes it
through to EditPage thanks to Idab5b524b0e3 in core
ve.init.mw.ViewPageTarget.js:
* Remove minor and watch checkboxes from the save dialog template
and replace them with a generic checkbox container
* Have getSaveOptions() pull the state of all checkboxes in
** Special-case minor and watch, and pass the rest straight through
** Move normalization from true/false to presence/absence here, from
ve.init.mw.Target.prototype.save(), because here we know which ones
are checkboxes and we don't know that in save() without
special-casing
* Remove getSaveDialogHtml(), we don't need to hide checkboxes based on
rights anymore because in that case the API just won't send them to us.
** Moved logic for checking the watch checkbox down to where the same
logic for the minor checkbox already is
* Unwrap getSaveDialogHtml() in setupSaveDialog()
* Access minor and watch by their new IDs throughout
ve.init.mw.Target.js:
* Get and store checkboxes from the API
* Pass all keys straight through to the API
Bug: 49699
Change-Id: I09d02a42b05146bc9b7080ab38338ae869bf15e3
2013-07-24 06:39:03 +00:00
|
|
|
$tabindex = 0;
|
|
|
|
$states = array( 'minor' => false, 'watch' => false );
|
|
|
|
$checkboxes = $ep->getCheckboxes( $tabindex, $states );
|
|
|
|
|
2014-03-11 00:46:26 +00:00
|
|
|
// HACK: Find out which red links are on the page
|
|
|
|
// We do the lookup for the current version. This might not be entirely complete
|
|
|
|
// if we're loading an oldid, but it'll probably be close enough, and LinkCache
|
|
|
|
// will automatically request any additional data it needs.
|
|
|
|
$links = array();
|
2015-03-26 19:32:01 +00:00
|
|
|
$wikipage = WikiPage::factory( $title );
|
2014-03-11 00:46:26 +00:00
|
|
|
$popts = $wikipage->makeParserOptions( 'canonical' );
|
|
|
|
$cached = ParserCache::singleton()->get( $article, $popts, true );
|
2015-02-03 04:30:00 +00:00
|
|
|
$links = array(
|
|
|
|
// Array of linked pages that are missing
|
|
|
|
'missing' => array(),
|
|
|
|
// For current revisions: true (treat all non-missing pages as existing)
|
|
|
|
// For old revisions: array of linked pages that exist
|
2015-03-13 22:15:17 +00:00
|
|
|
'extant' => $restoring || !$cached ? array() : true,
|
2015-02-03 04:30:00 +00:00
|
|
|
);
|
2014-03-11 00:46:26 +00:00
|
|
|
if ( $cached ) {
|
|
|
|
foreach ( $cached->getLinks() as $ns => $dbks ) {
|
|
|
|
foreach ( $dbks as $dbk => $id ) {
|
2015-02-03 04:30:00 +00:00
|
|
|
$pft = Title::makeTitle( $ns, $dbk )->getPrefixedText();
|
|
|
|
if ( $id == 0 ) {
|
|
|
|
$links['missing'][] = $pft;
|
2015-03-13 22:15:17 +00:00
|
|
|
} elseif ( $restoring ) {
|
2015-02-03 04:30:00 +00:00
|
|
|
$links['extant'][] = $pft;
|
|
|
|
}
|
2014-03-11 00:46:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-02-03 04:30:00 +00:00
|
|
|
// Add information about current page
|
2015-03-26 19:32:01 +00:00
|
|
|
if ( !$title->exists() ) {
|
|
|
|
$links['missing'][] = $title->getPrefixedText();
|
2015-03-13 22:15:17 +00:00
|
|
|
} elseif ( $restoring ) {
|
2015-03-26 19:32:01 +00:00
|
|
|
$links['extant'][] = $title->getPrefixedText();
|
2015-02-03 04:30:00 +00:00
|
|
|
}
|
2014-12-17 01:07:57 +00:00
|
|
|
|
2014-03-11 00:46:26 +00:00
|
|
|
// On parser cache miss, just don't bother populating red link data
|
|
|
|
|
2015-03-13 22:15:17 +00:00
|
|
|
$result = array(
|
|
|
|
'result' => 'success',
|
|
|
|
'notices' => $notices,
|
|
|
|
'checkboxes' => $checkboxes,
|
|
|
|
'links' => $links,
|
|
|
|
'protectedClasses' => implode( ' ', $protectedClasses ),
|
|
|
|
'watched' => $user->isWatched( $title ),
|
|
|
|
'basetimestamp' => $baseTimestamp,
|
|
|
|
'starttimestamp' => wfTimestampNow(),
|
|
|
|
'oldid' => $oldid,
|
|
|
|
|
|
|
|
);
|
|
|
|
if ( $params['paction'] === 'parse' ) {
|
|
|
|
$result['content'] = $content;
|
2013-05-15 21:17:06 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-12-04 15:30:21 +00:00
|
|
|
|
2013-05-15 23:51:11 +00:00
|
|
|
case 'parsefragment':
|
2014-10-22 22:47:21 +00:00
|
|
|
$wikitext = $params['wikitext'];
|
|
|
|
if ( $params['pst'] ) {
|
2015-03-26 19:32:01 +00:00
|
|
|
$wikitext = $this->pstWikitext( $title, $wikitext );
|
2014-10-22 22:47:21 +00:00
|
|
|
}
|
2015-03-26 19:32:01 +00:00
|
|
|
$content = $this->parseWikitextFragment( $title, $wikitext );
|
2013-05-15 23:51:11 +00:00
|
|
|
if ( $content === false ) {
|
2014-04-18 20:19:54 +00:00
|
|
|
$this->dieUsage( 'Error contacting the Parsoid server', 'parsoidserver' );
|
2013-05-15 23:51:11 +00:00
|
|
|
} else {
|
|
|
|
$result = array(
|
|
|
|
'result' => 'success',
|
|
|
|
'content' => $content
|
|
|
|
);
|
|
|
|
}
|
|
|
|
break;
|
2013-12-04 15:30:21 +00:00
|
|
|
|
2013-05-15 21:17:06 +00:00
|
|
|
case 'serialize':
|
2013-11-01 21:30:22 +00:00
|
|
|
if ( $params['cachekey'] !== null ) {
|
|
|
|
$content = $this->trySerializationCache( $params['cachekey'] );
|
|
|
|
if ( !is_string( $content ) ) {
|
|
|
|
$this->dieUsage( 'No cached serialization found with that key', 'badcachekey' );
|
|
|
|
}
|
2012-06-01 23:26:03 +00:00
|
|
|
} else {
|
2013-11-01 21:30:22 +00:00
|
|
|
if ( $params['html'] === null ) {
|
|
|
|
$this->dieUsageMsg( 'missingparam', 'html' );
|
|
|
|
}
|
2015-03-26 19:32:01 +00:00
|
|
|
$content = $this->postHTML( $title, $html, $parserParams );
|
2013-11-01 21:30:22 +00:00
|
|
|
if ( $content === false ) {
|
|
|
|
$this->dieUsage( 'Error contacting the Parsoid server', 'parsoidserver' );
|
|
|
|
}
|
2013-05-15 21:17:06 +00:00
|
|
|
}
|
2013-11-01 21:30:22 +00:00
|
|
|
$result = array( 'result' => 'success', 'content' => $content );
|
2013-05-15 21:17:06 +00:00
|
|
|
break;
|
2013-12-04 15:30:21 +00:00
|
|
|
|
2013-06-28 22:46:15 +00:00
|
|
|
case 'diff':
|
2013-11-01 21:30:22 +00:00
|
|
|
if ( $params['cachekey'] !== null ) {
|
|
|
|
$wikitext = $this->trySerializationCache( $params['cachekey'] );
|
|
|
|
if ( !is_string( $wikitext ) ) {
|
|
|
|
$this->dieUsage( 'No cached serialization found with that key', 'badcachekey' );
|
|
|
|
}
|
|
|
|
} else {
|
2015-03-26 19:32:01 +00:00
|
|
|
$wikitext = $this->postHTML( $title, $html, $parserParams );
|
2013-11-01 21:30:22 +00:00
|
|
|
if ( $wikitext === false ) {
|
|
|
|
$this->dieUsage( 'Error contacting the Parsoid server', 'parsoidserver' );
|
|
|
|
}
|
2013-06-28 22:46:15 +00:00
|
|
|
}
|
|
|
|
|
2015-03-26 19:32:01 +00:00
|
|
|
$diff = $this->diffWikitext( $title, $wikitext );
|
2013-06-28 22:46:15 +00:00
|
|
|
if ( $diff['result'] === 'fail' ) {
|
|
|
|
$this->dieUsage( 'Diff failed', 'difffailed' );
|
|
|
|
}
|
|
|
|
$result = $diff;
|
|
|
|
|
2013-11-01 21:30:22 +00:00
|
|
|
break;
|
2013-12-04 15:30:21 +00:00
|
|
|
|
2013-11-01 21:30:22 +00:00
|
|
|
case 'serializeforcache':
|
2015-03-26 19:32:01 +00:00
|
|
|
$key = $this->storeInSerializationCache( $title, $parserParams['oldid'], $html );
|
2013-11-01 21:30:22 +00:00
|
|
|
$result = array( 'result' => 'success', 'cachekey' => $key );
|
2013-05-15 21:17:06 +00:00
|
|
|
break;
|
2013-12-04 15:30:21 +00:00
|
|
|
|
|
|
|
case 'getlanglinks':
|
2015-03-26 19:32:01 +00:00
|
|
|
$langlinks = $this->getLangLinks( $title );
|
2013-12-04 15:30:21 +00:00
|
|
|
if ( $langlinks === false ) {
|
|
|
|
$this->dieUsage( 'Error querying MediaWiki API', 'parsoidserver' );
|
|
|
|
} else {
|
|
|
|
$result = array( 'result' => 'success', 'langlinks' => $langlinks );
|
|
|
|
}
|
|
|
|
break;
|
2012-05-25 19:50:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->getResult()->addValue( null, $this->getModuleName(), $result );
|
|
|
|
}
|
|
|
|
|
2014-03-26 20:39:45 +00:00
|
|
|
/**
|
|
|
|
* Gets the relevant HTML for the latest log entry on a given title, including a full log link.
|
|
|
|
*
|
|
|
|
* @param $title Title
|
|
|
|
* @param $types array|string
|
2014-08-17 19:43:56 +00:00
|
|
|
* @return string
|
2014-03-26 20:39:45 +00:00
|
|
|
*/
|
|
|
|
private function getLastLogEntry( $title, $types = '' ) {
|
|
|
|
$lp = new LogPager(
|
|
|
|
new LogEventsList( $this->getContext() ),
|
|
|
|
$types,
|
|
|
|
'',
|
|
|
|
$title->getPrefixedDbKey()
|
|
|
|
);
|
|
|
|
$lp->mLimit = 1;
|
|
|
|
|
|
|
|
return $lp->getBody() . Linker::link(
|
|
|
|
SpecialPage::getTitleFor( 'Log' ),
|
|
|
|
$this->msg( 'log-fulllog' )->escaped(),
|
|
|
|
array(),
|
|
|
|
array(
|
|
|
|
'page' => $title->getPrefixedDBkey(),
|
|
|
|
'type' => is_string( $types ) ? $types : null
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-05-25 19:50:48 +00:00
|
|
|
public function getAllowedParams() {
|
|
|
|
return array(
|
|
|
|
'page' => array(
|
|
|
|
ApiBase::PARAM_REQUIRED => true,
|
|
|
|
),
|
2014-03-21 00:44:30 +00:00
|
|
|
'format' => array(
|
2015-02-03 18:24:51 +00:00
|
|
|
ApiBase::PARAM_DFLT => 'jsonfm',
|
2014-03-21 00:44:30 +00:00
|
|
|
ApiBase::PARAM_TYPE => array( 'json', 'jsonfm' ),
|
|
|
|
),
|
2012-05-25 19:50:48 +00:00
|
|
|
'paction' => array(
|
|
|
|
ApiBase::PARAM_REQUIRED => true,
|
2013-11-01 21:30:22 +00:00
|
|
|
ApiBase::PARAM_TYPE => array(
|
2014-03-21 00:44:30 +00:00
|
|
|
'parse',
|
2015-03-13 22:15:17 +00:00
|
|
|
'metadata',
|
2014-03-21 00:44:30 +00:00
|
|
|
'parsefragment',
|
|
|
|
'serialize',
|
|
|
|
'serializeforcache',
|
|
|
|
'diff',
|
|
|
|
'getlanglinks',
|
2013-11-01 21:30:22 +00:00
|
|
|
),
|
2012-05-25 22:23:40 +00:00
|
|
|
),
|
2013-05-15 23:51:11 +00:00
|
|
|
'wikitext' => null,
|
|
|
|
'oldid' => null,
|
2012-11-28 23:57:00 +00:00
|
|
|
'html' => null,
|
2013-11-01 21:30:22 +00:00
|
|
|
'cachekey' => null,
|
2014-10-22 22:47:21 +00:00
|
|
|
'pst' => false,
|
2012-05-25 19:50:48 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function needsToken() {
|
2013-07-11 17:09:28 +00:00
|
|
|
return false;
|
2012-11-14 18:33:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function mustBePosted() {
|
2013-12-04 15:30:21 +00:00
|
|
|
return false;
|
2012-11-14 18:33:57 +00:00
|
|
|
}
|
|
|
|
|
2014-10-14 00:20:50 +00:00
|
|
|
public function isInternal() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-11-14 18:33:57 +00:00
|
|
|
public function isWriteMode() {
|
|
|
|
return true;
|
2012-05-25 19:50:48 +00:00
|
|
|
}
|
|
|
|
|
2014-10-29 20:02:11 +00:00
|
|
|
/**
|
|
|
|
* @deprecated since MediaWiki core 1.25
|
|
|
|
*/
|
2012-05-25 19:50:48 +00:00
|
|
|
public function getParamDescription() {
|
|
|
|
return array(
|
2012-05-31 00:09:06 +00:00
|
|
|
'page' => 'The page to perform actions on.',
|
2012-11-14 18:33:57 +00:00
|
|
|
'paction' => 'Action to perform',
|
2013-07-11 17:09:28 +00:00
|
|
|
'oldid' => 'The revision number to use (defaults to latest version).',
|
2014-10-22 22:47:21 +00:00
|
|
|
'html' => 'HTML to send to Parsoid to convert to wikitext',
|
|
|
|
'wikitext' => 'Wikitext to send to Parsoid to convert to HTML (paction=parsefragment)',
|
|
|
|
'pst' => 'Pre-save transform wikitext before sending it to Parsoid (paction=parsefragment)',
|
2013-11-01 21:30:22 +00:00
|
|
|
'cachekey' => 'For serialize or diff, use the result of a previous serializeforcache'
|
|
|
|
. ' request with this key. Overrides html.',
|
2012-05-25 19:50:48 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-10-29 20:02:11 +00:00
|
|
|
/**
|
|
|
|
* @deprecated since MediaWiki core 1.25
|
|
|
|
*/
|
2012-05-25 19:50:48 +00:00
|
|
|
public function getDescription() {
|
|
|
|
return 'Returns HTML5 for a page from the parsoid service.';
|
|
|
|
}
|
|
|
|
}
|