Don't try and run a special page through action=parsex
[lhc/web/wiklou.git] / includes / api / ApiParse.php
1 <?php
2 /**
3 * Created on Dec 01, 2007
4 *
5 * Copyright © 2007 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
21 *
22 * @file
23 */
24
25 /**
26 * @ingroup API
27 */
28 class ApiParse extends ApiBase {
29
30 /** @var String $section */
31 private $section = null;
32
33 /** @var Content $content */
34 private $content = null;
35
36 /** @var Content $pstContent */
37 private $pstContent = null;
38
39 public function __construct( $main, $action ) {
40 parent::__construct( $main, $action );
41 }
42
43 public function execute() {
44 // The data is hot but user-dependent, like page views, so we set vary cookies
45 $this->getMain()->setCacheMode( 'anon-public-user-private' );
46
47 // Get parameters
48 $params = $this->extractRequestParams();
49 $text = $params['text'];
50 $title = $params['title'];
51 $page = $params['page'];
52 $pageid = $params['pageid'];
53 $oldid = $params['oldid'];
54
55 $model = $params['contentmodel'];
56 $format = $params['contentformat'];
57
58 if ( !is_null( $page ) && ( !is_null( $text ) || $title != 'API' ) ) {
59 $this->dieUsage( 'The page parameter cannot be used together with the text and title parameters', 'params' );
60 }
61
62 $prop = array_flip( $params['prop'] );
63
64 if ( isset( $params['section'] ) ) {
65 $this->section = $params['section'];
66 } else {
67 $this->section = false;
68 }
69
70 // The parser needs $wgTitle to be set, apparently the
71 // $title parameter in Parser::parse isn't enough *sigh*
72 // TODO: Does this still need $wgTitle?
73 global $wgParser, $wgTitle;
74
75 // Currently unnecessary, code to act as a safeguard against any change in current behaviour of uselang breaks
76 $oldLang = null;
77 if ( isset( $params['uselang'] ) && $params['uselang'] != $this->getContext()->getLanguage()->getCode() ) {
78 $oldLang = $this->getContext()->getLanguage(); // Backup language
79 $this->getContext()->setLanguage( Language::factory( $params['uselang'] ) );
80 }
81
82 $redirValues = null;
83
84 // Return result
85 $result = $this->getResult();
86
87 if ( !is_null( $oldid ) || !is_null( $pageid ) || !is_null( $page ) ) {
88 if ( !is_null( $oldid ) ) {
89 // Don't use the parser cache
90 $rev = Revision::newFromID( $oldid );
91 if ( !$rev ) {
92 $this->dieUsage( "There is no revision ID $oldid", 'missingrev' );
93 }
94 if ( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
95 $this->dieUsage( "You don't have permission to view deleted revisions", 'permissiondenied' );
96 }
97
98 $titleObj = $rev->getTitle();
99 $wgTitle = $titleObj;
100 $pageObj = WikiPage::factory( $titleObj );
101 $popts = $pageObj->makeParserOptions( $this->getContext() );
102 $popts->enableLimitReport( !$params['disablepp'] );
103
104 // If for some reason the "oldid" is actually the current revision, it may be cached
105 if ( $rev->isCurrent() ) {
106 // May get from/save to parser cache
107 $p_result = $this->getParsedContent( $pageObj, $popts,
108 $pageid, isset( $prop['wikitext'] ) ) ;
109 } else { // This is an old revision, so get the text differently
110 $this->content = $rev->getContent( Revision::FOR_THIS_USER, $this->getUser() );
111
112 if ( $this->section !== false ) {
113 $this->content = $this->getSectionContent( $this->content, 'r' . $rev->getId() );
114 }
115
116 // Should we save old revision parses to the parser cache?
117 $p_result = $this->content->getParserOutput( $titleObj, $rev->getId(), $popts );
118 }
119 } else { // Not $oldid, but $pageid or $page
120 if ( $params['redirects'] ) {
121 $reqParams = array(
122 'action' => 'query',
123 'redirects' => '',
124 );
125 if ( !is_null ( $pageid ) ) {
126 $reqParams['pageids'] = $pageid;
127 } else { // $page
128 $reqParams['titles'] = $page;
129 }
130 $req = new FauxRequest( $reqParams );
131 $main = new ApiMain( $req );
132 $main->execute();
133 $data = $main->getResultData();
134 $redirValues = isset( $data['query']['redirects'] )
135 ? $data['query']['redirects']
136 : array();
137 $to = $page;
138 foreach ( (array)$redirValues as $r ) {
139 $to = $r['to'];
140 }
141 $pageParams = array( 'title' => $to );
142 } elseif ( !is_null( $pageid ) ) {
143 $pageParams = array( 'pageid' => $pageid );
144 } else { // $page
145 $pageParams = array( 'title' => $page );
146 }
147
148 $pageObj = $this->getTitleOrPageId( $pageParams, 'fromdb' );
149 $titleObj = $pageObj->getTitle();
150 $wgTitle = $titleObj;
151
152 if ( isset( $prop['revid'] ) ) {
153 $oldid = $pageObj->getLatest();
154 }
155
156 $popts = $pageObj->makeParserOptions( $this->getContext() );
157 $popts->enableLimitReport( !$params['disablepp'] );
158
159 // Potentially cached
160 $p_result = $this->getParsedContent( $pageObj, $popts, $pageid,
161 isset( $prop['wikitext'] ) ) ;
162 }
163 } else { // Not $oldid, $pageid, $page. Hence based on $text
164 $titleObj = Title::newFromText( $title );
165 if ( !$titleObj ) {
166 $this->dieUsageMsg( array( 'invalidtitle', $title ) );
167 }
168 if ( $titleObj->isSpecialPage() ) {
169 $this->dieUsage( 'Special pages cannot be parsed through action=parse', 'targetisspecial' );
170 }
171 $wgTitle = $titleObj;
172 $pageObj = WikiPage::factory( $titleObj );
173
174 $popts = $pageObj->makeParserOptions( $this->getContext() );
175 $popts->enableLimitReport( !$params['disablepp'] );
176
177 if ( is_null( $text ) ) {
178 $this->dieUsage( 'The text parameter should be passed with the title parameter. Should you be using the "page" parameter instead?', 'params' );
179 }
180
181 try {
182 $this->content = ContentHandler::makeContent( $text, $titleObj, $model, $format );
183 } catch ( MWContentSerializationException $ex ) {
184 $this->dieUsage( $ex->getMessage(), 'parseerror' );
185 }
186
187 if ( $this->section !== false ) {
188 $this->content = $this->getSectionContent( $this->content, $titleObj->getText() );
189 }
190
191 if ( $params['pst'] || $params['onlypst'] ) {
192 $this->pstContent = $this->content->preSaveTransform( $titleObj, $this->getUser(), $popts );
193 }
194 if ( $params['onlypst'] ) {
195 // Build a result and bail out
196 $result_array = array();
197 $result_array['text'] = array();
198 $result->setContent( $result_array['text'], $this->pstContent->serialize( $format ) );
199 if ( isset( $prop['wikitext'] ) ) {
200 $result_array['wikitext'] = array();
201 $result->setContent( $result_array['wikitext'], $this->content->serialize( $format ) );
202 }
203 $result->addValue( null, $this->getModuleName(), $result_array );
204 return;
205 }
206
207 // Not cached (save or load)
208 if ( $params['pst'] ) {
209 $p_result = $this->pstContent->getParserOutput( $titleObj, null, $popts );
210 } else {
211 $p_result = $this->content->getParserOutput( $titleObj, null, $popts );
212 }
213 }
214
215 $result_array = array();
216
217 $result_array['title'] = $titleObj->getPrefixedText();
218
219 if ( !is_null( $oldid ) ) {
220 $result_array['revid'] = intval( $oldid );
221 }
222
223 if ( $params['redirects'] && !is_null( $redirValues ) ) {
224 $result_array['redirects'] = $redirValues;
225 }
226
227 if ( isset( $prop['text'] ) ) {
228 $result_array['text'] = array();
229 $result->setContent( $result_array['text'], $p_result->getText() );
230 }
231
232 if ( !is_null( $params['summary'] ) ) {
233 $result_array['parsedsummary'] = array();
234 $result->setContent( $result_array['parsedsummary'], Linker::formatComment( $params['summary'], $titleObj ) );
235 }
236
237 if ( isset( $prop['langlinks'] ) ) {
238 $result_array['langlinks'] = $this->formatLangLinks( $p_result->getLanguageLinks() );
239 }
240 if ( isset( $prop['languageshtml'] ) ) {
241 $languagesHtml = $this->languagesHtml( $p_result->getLanguageLinks() );
242 $result_array['languageshtml'] = array();
243 $result->setContent( $result_array['languageshtml'], $languagesHtml );
244 }
245 if ( isset( $prop['categories'] ) ) {
246 $result_array['categories'] = $this->formatCategoryLinks( $p_result->getCategories() );
247 }
248 if ( isset( $prop['categorieshtml'] ) ) {
249 $categoriesHtml = $this->categoriesHtml( $p_result->getCategories() );
250 $result_array['categorieshtml'] = array();
251 $result->setContent( $result_array['categorieshtml'], $categoriesHtml );
252 }
253 if ( isset( $prop['links'] ) ) {
254 $result_array['links'] = $this->formatLinks( $p_result->getLinks() );
255 }
256 if ( isset( $prop['templates'] ) ) {
257 $result_array['templates'] = $this->formatLinks( $p_result->getTemplates() );
258 }
259 if ( isset( $prop['images'] ) ) {
260 $result_array['images'] = array_keys( $p_result->getImages() );
261 }
262 if ( isset( $prop['externallinks'] ) ) {
263 $result_array['externallinks'] = array_keys( $p_result->getExternalLinks() );
264 }
265 if ( isset( $prop['sections'] ) ) {
266 $result_array['sections'] = $p_result->getSections();
267 }
268
269 if ( isset( $prop['displaytitle'] ) ) {
270 $result_array['displaytitle'] = $p_result->getDisplayTitle() ?
271 $p_result->getDisplayTitle() :
272 $titleObj->getPrefixedText();
273 }
274
275 if ( isset( $prop['headitems'] ) || isset( $prop['headhtml'] ) ) {
276 $context = $this->getContext();
277 $context->setTitle( $titleObj );
278 $context->getOutput()->addParserOutputNoText( $p_result );
279
280 if ( isset( $prop['headitems'] ) ) {
281 $headItems = $this->formatHeadItems( $p_result->getHeadItems() );
282
283 $css = $this->formatCss( $context->getOutput()->buildCssLinksArray() );
284
285 $scripts = array( $context->getOutput()->getHeadScripts() );
286
287 $result_array['headitems'] = array_merge( $headItems, $css, $scripts );
288 }
289
290 if ( isset( $prop['headhtml'] ) ) {
291 $result_array['headhtml'] = array();
292 $result->setContent( $result_array['headhtml'], $context->getOutput()->headElement( $context->getSkin() ) );
293 }
294 }
295
296 if ( isset( $prop['iwlinks'] ) ) {
297 $result_array['iwlinks'] = $this->formatIWLinks( $p_result->getInterwikiLinks() );
298 }
299
300 if ( isset( $prop['wikitext'] ) ) {
301 $result_array['wikitext'] = array();
302 $result->setContent( $result_array['wikitext'], $this->content->serialize( $format ) );
303 if ( !is_null( $this->pstContent ) ) {
304 $result_array['psttext'] = array();
305 $result->setContent( $result_array['psttext'], $this->pstContent->serialize( $format ) );
306 }
307 }
308 if ( isset( $prop['properties'] ) ) {
309 $result_array['properties'] = $this->formatProperties( $p_result->getProperties() );
310 }
311
312 if ( $params['generatexml'] ) {
313 if ( $this->content->getModel() != CONTENT_MODEL_WIKITEXT ) {
314 $this->dieUsage( "generatexml is only supported for wikitext content", "notwikitext" );
315 }
316
317 $wgParser->startExternalParse( $titleObj, $popts, OT_PREPROCESS );
318 $dom = $wgParser->preprocessToDom( $this->content->getNativeData() );
319 if ( is_callable( array( $dom, 'saveXML' ) ) ) {
320 $xml = $dom->saveXML();
321 } else {
322 $xml = $dom->__toString();
323 }
324 $result_array['parsetree'] = array();
325 $result->setContent( $result_array['parsetree'], $xml );
326 }
327
328 $result_mapping = array(
329 'redirects' => 'r',
330 'langlinks' => 'll',
331 'categories' => 'cl',
332 'links' => 'pl',
333 'templates' => 'tl',
334 'images' => 'img',
335 'externallinks' => 'el',
336 'iwlinks' => 'iw',
337 'sections' => 's',
338 'headitems' => 'hi',
339 'properties' => 'pp',
340 );
341 $this->setIndexedTagNames( $result_array, $result_mapping );
342 $result->addValue( null, $this->getModuleName(), $result_array );
343
344 if ( !is_null( $oldLang ) ) {
345 $this->getContext()->setLanguage( $oldLang ); // Reset language to $oldLang
346 }
347 }
348
349 /**
350 * @param $page WikiPage
351 * @param $popts ParserOptions
352 * @param $pageId Int
353 * @param $getWikitext Bool
354 * @return ParserOutput
355 */
356 private function getParsedContent( WikiPage $page, $popts, $pageId = null, $getWikitext = false ) {
357 $this->content = $page->getContent( Revision::RAW ); //XXX: really raw?
358
359 if ( $this->section !== false && $this->content !== null ) {
360 $this->content = $this->getSectionContent(
361 $this->content,
362 !is_null( $pageId ) ? 'page id ' . $pageId : $page->getTitle()->getText() );
363
364 // Not cached (save or load)
365 return $this->content->getParserOutput( $page->getTitle(), null, $popts );
366 } else {
367 // Try the parser cache first
368 // getParserOutput will save to Parser cache if able
369 $pout = $page->getParserOutput( $popts );
370 if ( !$pout ) {
371 $this->dieUsage( "There is no revision ID {$page->getLatest()}", 'missingrev' );
372 }
373 if ( $getWikitext ) {
374 $this->content = $page->getContent( Revision::RAW );
375 }
376 return $pout;
377 }
378 }
379
380 private function getSectionContent( Content $content, $what ) {
381 // Not cached (save or load)
382 $section = $content->getSection( $this->section );
383 if ( $section === false ) {
384 $this->dieUsage( "There is no section {$this->section} in " . $what, 'nosuchsection' );
385 }
386 if ( $section === null ) {
387 $this->dieUsage( "Sections are not supported by " . $what, 'nosuchsection' );
388 $section = false;
389 }
390 return $section;
391 }
392
393 private function formatLangLinks( $links ) {
394 $result = array();
395 foreach ( $links as $link ) {
396 $entry = array();
397 $bits = explode( ':', $link, 2 );
398 $title = Title::newFromText( $link );
399
400 $entry['lang'] = $bits[0];
401 if ( $title ) {
402 $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
403 }
404 $this->getResult()->setContent( $entry, $bits[1] );
405 $result[] = $entry;
406 }
407 return $result;
408 }
409
410 private function formatCategoryLinks( $links ) {
411 $result = array();
412 foreach ( $links as $link => $sortkey ) {
413 $entry = array();
414 $entry['sortkey'] = $sortkey;
415 $this->getResult()->setContent( $entry, $link );
416 $result[] = $entry;
417 }
418 return $result;
419 }
420
421 private function categoriesHtml( $categories ) {
422 $context = $this->getContext();
423 $context->getOutput()->addCategoryLinks( $categories );
424 return $context->getSkin()->getCategories();
425 }
426
427 /**
428 * @deprecated since 1.18 No modern skin generates language links this way, please use language links
429 * data to generate your own HTML.
430 * @param $languages array
431 * @return string
432 */
433 private function languagesHtml( $languages ) {
434 wfDeprecated( __METHOD__, '1.18' );
435
436 global $wgContLang, $wgHideInterlanguageLinks;
437
438 if ( $wgHideInterlanguageLinks || count( $languages ) == 0 ) {
439 return '';
440 }
441
442 $s = htmlspecialchars( wfMessage( 'otherlanguages' )->text() . wfMessage( 'colon-separator' )->text() );
443
444 $langs = array();
445 foreach ( $languages as $l ) {
446 $nt = Title::newFromText( $l );
447 $text = Language::fetchLanguageName( $nt->getInterwiki() );
448
449 $langs[] = Html::element( 'a',
450 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
451 $text == '' ? $l : $text );
452 }
453
454 $s .= implode( wfMessage( 'pipe-separator' )->escaped(), $langs );
455
456 if ( $wgContLang->isRTL() ) {
457 $s = Html::rawElement( 'span', array( 'dir' => "LTR" ), $s );
458 }
459
460 return $s;
461 }
462
463 private function formatLinks( $links ) {
464 $result = array();
465 foreach ( $links as $ns => $nslinks ) {
466 foreach ( $nslinks as $title => $id ) {
467 $entry = array();
468 $entry['ns'] = $ns;
469 $this->getResult()->setContent( $entry, Title::makeTitle( $ns, $title )->getFullText() );
470 if ( $id != 0 ) {
471 $entry['exists'] = '';
472 }
473 $result[] = $entry;
474 }
475 }
476 return $result;
477 }
478
479 private function formatIWLinks( $iw ) {
480 $result = array();
481 foreach ( $iw as $prefix => $titles ) {
482 foreach ( array_keys( $titles ) as $title ) {
483 $entry = array();
484 $entry['prefix'] = $prefix;
485
486 $title = Title::newFromText( "{$prefix}:{$title}" );
487 if ( $title ) {
488 $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
489 }
490
491 $this->getResult()->setContent( $entry, $title->getFullText() );
492 $result[] = $entry;
493 }
494 }
495 return $result;
496 }
497
498 private function formatHeadItems( $headItems ) {
499 $result = array();
500 foreach ( $headItems as $tag => $content ) {
501 $entry = array();
502 $entry['tag'] = $tag;
503 $this->getResult()->setContent( $entry, $content );
504 $result[] = $entry;
505 }
506 return $result;
507 }
508
509 private function formatProperties( $properties ) {
510 $result = array();
511 foreach ( $properties as $name => $value ) {
512 $entry = array();
513 $entry['name'] = $name;
514 $this->getResult()->setContent( $entry, $value );
515 $result[] = $entry;
516 }
517 return $result;
518 }
519
520 private function formatCss( $css ) {
521 $result = array();
522 foreach ( $css as $file => $link ) {
523 $entry = array();
524 $entry['file'] = $file;
525 $this->getResult()->setContent( $entry, $link );
526 $result[] = $entry;
527 }
528 return $result;
529 }
530
531 private function setIndexedTagNames( &$array, $mapping ) {
532 foreach ( $mapping as $key => $name ) {
533 if ( isset( $array[$key] ) ) {
534 $this->getResult()->setIndexedTagName( $array[$key], $name );
535 }
536 }
537 }
538
539 public function getAllowedParams() {
540 return array(
541 'title' => array(
542 ApiBase::PARAM_DFLT => 'API',
543 ),
544 'text' => null,
545 'summary' => null,
546 'page' => null,
547 'pageid' => array(
548 ApiBase::PARAM_TYPE => 'integer',
549 ),
550 'redirects' => false,
551 'oldid' => array(
552 ApiBase::PARAM_TYPE => 'integer',
553 ),
554 'prop' => array(
555 ApiBase::PARAM_DFLT => 'text|langlinks|categories|links|templates|images|externallinks|sections|revid|displaytitle|iwlinks|properties',
556 ApiBase::PARAM_ISMULTI => true,
557 ApiBase::PARAM_TYPE => array(
558 'text',
559 'langlinks',
560 'languageshtml',
561 'categories',
562 'categorieshtml',
563 'links',
564 'templates',
565 'images',
566 'externallinks',
567 'sections',
568 'revid',
569 'displaytitle',
570 'headitems',
571 'headhtml',
572 'iwlinks',
573 'wikitext',
574 'properties',
575 )
576 ),
577 'pst' => false,
578 'onlypst' => false,
579 'uselang' => null,
580 'section' => null,
581 'disablepp' => false,
582 'generatexml' => false,
583 'contentformat' => array(
584 ApiBase::PARAM_TYPE => ContentHandler::getAllContentFormats(),
585 ),
586 'contentmodel' => array(
587 ApiBase::PARAM_TYPE => ContentHandler::getContentModels(),
588 )
589 );
590 }
591
592 public function getParamDescription() {
593 $p = $this->getModulePrefix();
594 return array(
595 'text' => 'Wikitext to parse',
596 'summary' => 'Summary to parse',
597 'redirects' => "If the {$p}page or the {$p}pageid parameter is set to a redirect, resolve it",
598 'title' => 'Title of page the text belongs to',
599 'page' => "Parse the content of this page. Cannot be used together with {$p}text and {$p}title",
600 'pageid' => "Parse the content of this page. Overrides {$p}page",
601 'oldid' => "Parse the content of this revision. Overrides {$p}page and {$p}pageid",
602 'prop' => array(
603 'Which pieces of information to get',
604 ' text - Gives the parsed text of the wikitext',
605 ' langlinks - Gives the language links in the parsed wikitext',
606 ' categories - Gives the categories in the parsed wikitext',
607 ' categorieshtml - Gives the HTML version of the categories',
608 ' languageshtml - Gives the HTML version of the language links',
609 ' links - Gives the internal links in the parsed wikitext',
610 ' templates - Gives the templates in the parsed wikitext',
611 ' images - Gives the images in the parsed wikitext',
612 ' externallinks - Gives the external links in the parsed wikitext',
613 ' sections - Gives the sections in the parsed wikitext',
614 ' revid - Adds the revision ID of the parsed page',
615 ' displaytitle - Adds the title of the parsed wikitext',
616 ' headitems - Gives items to put in the <head> of the page',
617 ' headhtml - Gives parsed <head> of the page',
618 ' iwlinks - Gives interwiki links in the parsed wikitext',
619 ' wikitext - Gives the original wikitext that was parsed',
620 ' properties - Gives various properties defined in the parsed wikitext',
621 ),
622 'pst' => array(
623 'Do a pre-save transform on the input before parsing it',
624 'Ignored if page, pageid or oldid is used'
625 ),
626 'onlypst' => array(
627 'Do a pre-save transform (PST) on the input, but don\'t parse it',
628 'Returns the same wikitext, after a PST has been applied. Ignored if page, pageid or oldid is used'
629 ),
630 'uselang' => 'Which language to parse the request in',
631 'section' => 'Only retrieve the content of this section number',
632 'disablepp' => 'Disable the PP Report from the parser output',
633 'generatexml' => 'Generate XML parse tree',
634 'contentformat' => 'Content serialization format used for the input text',
635 'contentmodel' => 'Content model of the new content',
636 );
637 }
638
639 public function getDescription() {
640 return array(
641 'Parses wikitext and returns parser output',
642 'See the various prop-Modules of action=query to get information from the current version of a page',
643 );
644 }
645
646 public function getPossibleErrors() {
647 return array_merge( parent::getPossibleErrors(), array(
648 array( 'code' => 'params', 'info' => 'The page parameter cannot be used together with the text and title parameters' ),
649 array( 'code' => 'params', 'info' => 'The text parameter should be passed with the title parameter. Should you be using the "page" parameter instead?' ),
650 array( 'code' => 'missingrev', 'info' => 'There is no revision ID oldid' ),
651 array( 'code' => 'permissiondenied', 'info' => 'You don\'t have permission to view deleted revisions' ),
652 array( 'code' => 'missingtitle', 'info' => 'The page you specified doesn\'t exist' ),
653 array( 'code' => 'nosuchsection', 'info' => 'There is no section sectionnumber in page' ),
654 array( 'nosuchpageid' ),
655 array( 'invalidtitle', 'title' ),
656 array( 'code' => 'parseerror', 'info' => 'Failed to parse the given text.' ),
657 array( 'code' => 'notwikitext', 'info' => 'The requested operation is only supported on wikitext content.' ),
658 array( 'code' => 'targetisspecial', 'info' => 'Special pages cannot be parsed through action=parse' ),
659 ) );
660 }
661
662 public function getExamples() {
663 return array(
664 'api.php?action=parse&text={{Project:Sandbox}}'
665 );
666 }
667
668 public function getHelpUrls() {
669 return 'https://www.mediawiki.org/wiki/API:Parsing_wikitext#parse';
670 }
671
672 public function getVersion() {
673 return __CLASS__ . ': $Id$';
674 }
675 }