Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
DataAccess | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPageInfo | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getFileInfo | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
doPst | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
parseWikitext | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
preprocessWikitext | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
fetchTemplateSource | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
fetchTemplateData | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
logLinterData | n/a |
0 / 0 |
n/a |
0 / 0 |
0 |
1 | <?php |
2 | declare( strict_types = 1 ); |
3 | |
4 | namespace Wikimedia\Parsoid\Config; |
5 | |
6 | use Wikimedia\Parsoid\Core\ContentMetadataCollector; |
7 | use Wikimedia\Parsoid\Core\LinkTarget; |
8 | |
9 | /** |
10 | * MediaWiki data access abstract class for Parsoid |
11 | */ |
12 | abstract class DataAccess { |
13 | /** |
14 | * Base constructor. |
15 | * |
16 | * This constructor is public because it is used to create mock objects |
17 | * in our test suite. |
18 | */ |
19 | public function __construct() { |
20 | } |
21 | |
22 | /** |
23 | * Return target data for formatting links. |
24 | * |
25 | * Replaces Batcher.getPageProps() |
26 | * |
27 | * @param PageConfig|LinkTarget $pageConfigOrTitle |
28 | * Either a PageConfig or else just the context title from the PageConfig |
29 | * (as a LinkTarget) |
30 | * @param string[] $titles |
31 | * @return array<string,array> [ string Title => array ], where the array contains |
32 | * - pageId: (int|null) Page ID |
33 | * - revId: (int|null) Current revision of the page |
34 | * - missing: (bool) Whether the page is missing |
35 | * - known: (bool) Whether the special page is known |
36 | * - redirect: (bool) Whether the page is a redirect |
37 | * - linkclasses: (string[]) Extensible "link color" information; see |
38 | * ApiQueryInfo::getLinkClasses() in MediaWiki core |
39 | */ |
40 | abstract public function getPageInfo( $pageConfigOrTitle, array $titles ): array; |
41 | |
42 | /** |
43 | * Return information about files (images) |
44 | * |
45 | * This replaces ImageInfoRequest and Batcher.imageinfo() |
46 | * |
47 | * @param PageConfig $pageConfig |
48 | * @param array $files [ [string Name, array Dims] ]. The array may contain |
49 | * - width: (int) Requested thumbnail width |
50 | * - height: (int) Requested thumbnail height |
51 | * - page: (int) Requested thumbnail page number |
52 | * - seek: (int) Requested thumbnail time offset |
53 | * @return array [ array|null ], where the array contains |
54 | * - width: (int|false) File width, false if unknown |
55 | * - height: (int|false) File height, false if unknown |
56 | * - size: (int|false) File size in bytes, false if unknown |
57 | * - mediatype: (string) File media type |
58 | * - mime: (string) File MIME type |
59 | * - url: (string) File URL |
60 | * - mustRender: (bool) False if the file can be directly rendered by browsers |
61 | * - badFile: (bool) Whether the file is on the "bad image list" |
62 | * - duration: (float, optional) Duration of the media in seconds |
63 | * - thumberror: (string, optional) Error text if thumbnailing failed. Ugh. |
64 | * - responsiveUrls: (string[], optional) Map of display densities to URLs. |
65 | * - thumbdata: (mixed, optional) MediaWiki File->getAPIData() |
66 | * - thumburl: (string, optional) Thumbnail URL |
67 | * - thumbwidth: (int, optional) Thumbnail width |
68 | * - thumbheight: (int, optional) Thumbnail height |
69 | * - timestamp: (string, optional) Timestamp |
70 | * - sha1: (string, optional) SHA-1 |
71 | */ |
72 | abstract public function getFileInfo( PageConfig $pageConfig, array $files ): array; |
73 | |
74 | /** |
75 | * Perform a pre-save transform on wikitext |
76 | * |
77 | * This replaces PHPParseRequest with onlypst = true |
78 | * |
79 | * @todo Parsoid should be able to do this itself. |
80 | * @param PageConfig $pageConfig |
81 | * @param string $wikitext |
82 | * @return string Processed wikitext |
83 | */ |
84 | abstract public function doPst( PageConfig $pageConfig, string $wikitext ): string; |
85 | |
86 | /** |
87 | * Perform a parse on wikitext |
88 | * |
89 | * This replaces PHPParseRequest with onlypst = false, and Batcher.parse() |
90 | * |
91 | * @todo Parsoid should be able to do this itself. |
92 | * @param PageConfig $pageConfig |
93 | * @param ContentMetadataCollector $metadata Will collect metadata about |
94 | * the parsed content. |
95 | * @param string $wikitext |
96 | * @return string Output HTML |
97 | */ |
98 | abstract public function parseWikitext( |
99 | PageConfig $pageConfig, |
100 | ContentMetadataCollector $metadata, |
101 | string $wikitext |
102 | ): string; |
103 | |
104 | /** |
105 | * Preprocess wikitext |
106 | * |
107 | * This replaces PreprocessorRequest and Batcher.preprocess() |
108 | * |
109 | * @todo Parsoid should be able to do this itself. |
110 | * @param PageConfig $pageConfig |
111 | * @param ContentMetadataCollector $metadata Will collect metadata about |
112 | * the preprocessed content. |
113 | * @param string $wikitext |
114 | * @return string Expanded wikitext |
115 | */ |
116 | abstract public function preprocessWikitext( |
117 | PageConfig $pageConfig, |
118 | ContentMetadataCollector $metadata, |
119 | string $wikitext |
120 | ): string; |
121 | |
122 | /** |
123 | * Fetch latest revision of article/template content for transclusion. |
124 | * |
125 | * Technically, the ParserOptions might select a different |
126 | * revision other than the latest via |
127 | * ParserOptions::getTemplateCallback() (used for FlaggedRevisions, |
128 | * etc), but the point is that template lookups are by title, not |
129 | * revision id. |
130 | * |
131 | * This replaces TemplateRequest |
132 | * |
133 | * @todo TemplateRequest also returns a bunch of other data, but seems to never use it except for |
134 | * TemplateRequest.setPageSrcInfo() which is replaced by PageConfig. |
135 | * @param PageConfig $pageConfig |
136 | * @param LinkTarget $title Title of the page to fetch |
137 | * @return PageContent|null |
138 | */ |
139 | abstract public function fetchTemplateSource( |
140 | PageConfig $pageConfig, LinkTarget $title |
141 | ): ?PageContent; |
142 | |
143 | /** |
144 | * Fetch templatedata for a title |
145 | * |
146 | * This replaces TemplateDataRequest |
147 | * |
148 | * @param PageConfig $pageConfig |
149 | * @param LinkTarget $title |
150 | * @return array|null |
151 | */ |
152 | abstract public function fetchTemplateData( PageConfig $pageConfig, LinkTarget $title ): ?array; |
153 | |
154 | /** |
155 | * Log linter data. |
156 | * |
157 | * @param PageConfig $pageConfig |
158 | * @param array $lints |
159 | */ |
160 | abstract public function logLinterData( PageConfig $pageConfig, array $lints ): void; |
161 | } |