2022-09-04 09:00:14 +00:00
|
|
|
<?php
|
|
|
|
namespace MediaWiki\Extension\VisualEditor;
|
|
|
|
|
|
|
|
use MediaWiki\Page\PageIdentity;
|
|
|
|
use MediaWiki\Revision\RevisionRecord;
|
2023-07-07 08:11:15 +00:00
|
|
|
use Wikimedia\Bcp47Code\Bcp47Code;
|
2022-09-04 09:00:14 +00:00
|
|
|
|
|
|
|
interface ParsoidClient {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request page HTML
|
|
|
|
*
|
|
|
|
* @param RevisionRecord $revision Page revision
|
2023-07-07 08:11:15 +00:00
|
|
|
* @param Bcp47Code|null $targetLanguage Desired output language
|
2022-09-04 09:00:14 +00:00
|
|
|
*
|
2023-08-14 15:14:12 +00:00
|
|
|
* @return array An array mimicking a RESTbase server's response, with keys: 'headers' and 'body'
|
|
|
|
* @phan-return array{body:string,headers:array<string,string>}
|
2022-09-04 09:00:14 +00:00
|
|
|
*/
|
2023-07-07 08:11:15 +00:00
|
|
|
public function getPageHtml( RevisionRecord $revision, ?Bcp47Code $targetLanguage ): array;
|
2022-09-04 09:00:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Transform HTML to wikitext via Parsoid
|
|
|
|
*
|
|
|
|
* @param PageIdentity $page The page the content belongs to
|
2023-07-07 08:11:15 +00:00
|
|
|
* @param Bcp47Code $targetLanguage The desired output language
|
2022-09-04 09:00:14 +00:00
|
|
|
* @param string $html The HTML of the page to be transformed
|
|
|
|
* @param ?int $oldid What oldid revision, if any, to base the request from (default: `null`)
|
|
|
|
* @param ?string $etag The ETag to set in the HTTP request header
|
|
|
|
*
|
2023-08-14 15:14:12 +00:00
|
|
|
* @return array An array mimicking a RESTbase server's response, with keys: 'headers' and 'body'
|
|
|
|
* @phan-return array{body:string,headers:array<string,string>}
|
2022-09-04 09:00:14 +00:00
|
|
|
*/
|
|
|
|
public function transformHTML(
|
|
|
|
PageIdentity $page,
|
2023-07-07 08:11:15 +00:00
|
|
|
Bcp47Code $targetLanguage,
|
2022-09-04 09:00:14 +00:00
|
|
|
string $html,
|
|
|
|
?int $oldid,
|
|
|
|
?string $etag
|
|
|
|
): array;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Transform wikitext to HTML via Parsoid.
|
|
|
|
*
|
|
|
|
* @param PageIdentity $page The page the content belongs to
|
2023-07-07 08:11:15 +00:00
|
|
|
* @param Bcp47Code $targetLanguage The desired output language
|
2022-09-04 09:00:14 +00:00
|
|
|
* @param string $wikitext The wikitext fragment to parse
|
|
|
|
* @param bool $bodyOnly Whether to provide only the contents of the `<body>` tag
|
|
|
|
* @param ?int $oldid What oldid revision, if any, to base the request from (default: `null`)
|
|
|
|
* @param bool $stash Whether to stash the result in the server-side cache (default: `false`)
|
|
|
|
*
|
2023-08-14 15:14:12 +00:00
|
|
|
* @return array An array mimicking a RESTbase server's response, with keys: 'headers' and 'body'
|
|
|
|
* @phan-return array{body:string,headers:array<string,string>}
|
2022-09-04 09:00:14 +00:00
|
|
|
*/
|
|
|
|
public function transformWikitext(
|
|
|
|
PageIdentity $page,
|
2023-07-07 08:11:15 +00:00
|
|
|
Bcp47Code $targetLanguage,
|
2022-09-04 09:00:14 +00:00
|
|
|
string $wikitext,
|
|
|
|
bool $bodyOnly,
|
|
|
|
?int $oldid,
|
|
|
|
bool $stash
|
|
|
|
): array;
|
|
|
|
}
|