1a55d5a16b629dd7be89fa97b5f09fd6609adb17
[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 $wgTitle = $titleObj;
169 $pageObj = WikiPage::factory( $titleObj );
170
171 $popts = $pageObj->makeParserOptions( $this->getContext() );
172 $popts->enableLimitReport( !$params['disablepp'] );
173
174 if ( is_null( $text ) ) {
175 $this->dieUsage( 'The text parameter should be passed with the title parameter. Should you be using the "page" parameter instead?', 'params' );
176 }
177
178 try {
179 $this->content = ContentHandler::makeContent( $text, $titleObj, $model, $format );
180 } catch ( MWContentSerializationException $ex ) {
181 $this->dieUsage( $ex->getMessage(), 'parseerror' );
182 }
183
184 if ( $this->section !== false ) {
185 $this->content = $this->getSectionContent( $this->content, $titleObj->getText() );
186 }
187
188 if ( $params['pst'] || $params['onlypst'] ) {
189 $this->pstContent = $this->content->preSaveTransform( $titleObj, $this->getUser(), $popts );
190 }
191 if ( $params['onlypst'] ) {
192 // Build a result and bail out
193 $result_array = array();
194 $result_array['text'] = array();
195 $result->setContent( $result_array['text'], $this->pstContent->serialize( $format ) );
196 if ( isset( $prop['wikitext'] ) ) {
197 $result_array['wikitext'] = array();
198 $result->setContent( $result_array['wikitext'], $this->content->serialize( $format ) );
199 }
200 $result->addValue( null, $this->getModuleName(), $result_array );
201 return;
202 }
203
204 // Not cached (save or load)
205 if ( $params['pst'] ) {
206 $p_result = $this->pstContent->getParserOutput( $titleObj, null, $popts );
207 } else {
208 $p_result = $this->content->getParserOutput( $titleObj, null, $popts );
209 }
210 }
211
212 $result_array = array();
213
214 $result_array['title'] = $titleObj->getPrefixedText();
215
216 if ( !is_null( $oldid ) ) {
217 $result_array['revid'] = intval( $oldid );
218 }
219
220 if ( $params['redirects'] && !is_null( $redirValues ) ) {
221 $result_array['redirects'] = $redirValues;
222 }
223
224 if ( isset( $prop['text'] ) ) {
225 $result_array['text'] = array();
226 $result->setContent( $result_array['text'], $p_result->getText() );
227 }
228
229 if ( !is_null( $params['summary'] ) ) {
230 $result_array['parsedsummary'] = array();
231 $result->setContent( $result_array['parsedsummary'], Linker::formatComment( $params['summary'], $titleObj ) );
232 }
233
234 if ( isset( $prop['langlinks'] ) ) {
235 $result_array['langlinks'] = $this->formatLangLinks( $p_result->getLanguageLinks() );
236 }
237 if ( isset( $prop['languageshtml'] ) ) {
238 $languagesHtml = $this->languagesHtml( $p_result->getLanguageLinks() );
239 $result_array['languageshtml'] = array();
240 $result->setContent( $result_array['languageshtml'], $languagesHtml );
241 }
242 if ( isset( $prop['categories'] ) ) {
243 $result_array['categories'] = $this->formatCategoryLinks( $p_result->getCategories() );
244 }
245 if ( isset( $prop['categorieshtml'] ) ) {
246 $categoriesHtml = $this->categoriesHtml( $p_result->getCategories() );
247 $result_array['categorieshtml'] = array();
248 $result->setContent( $result_array['categorieshtml'], $categoriesHtml );
249 }
250 if ( isset( $prop['links'] ) ) {
251 $result_array['links'] = $this->formatLinks( $p_result->getLinks() );
252 }
253 if ( isset( $prop['templates'] ) ) {
254 $result_array['templates'] = $this->formatLinks( $p_result->getTemplates() );
255 }
256 if ( isset( $prop['images'] ) ) {
257 $result_array['images'] = array_keys( $p_result->getImages() );
258 }
259 if ( isset( $prop['externallinks'] ) ) {
260 $result_array['externallinks'] = array_keys( $p_result->getExternalLinks() );
261 }
262 if ( isset( $prop['sections'] ) ) {
263 $result_array['sections'] = $p_result->getSections();
264 }
265
266 if ( isset( $prop['displaytitle'] ) ) {
267 $result_array['displaytitle'] = $p_result->getDisplayTitle() ?
268 $p_result->getDisplayTitle() :
269 $titleObj->getPrefixedText();
270 }
271
272 if ( isset( $prop['headitems'] ) || isset( $prop['headhtml'] ) ) {
273 $context = $this->getContext();
274 $context->setTitle( $titleObj );
275 $context->getOutput()->addParserOutputNoText( $p_result );
276
277 if ( isset( $prop['headitems'] ) ) {
278 $headItems = $this->formatHeadItems( $p_result->getHeadItems() );
279
280 $css = $this->formatCss( $context->getOutput()->buildCssLinksArray() );
281
282 $scripts = array( $context->getOutput()->getHeadScripts() );
283
284 $result_array['headitems'] = array_merge( $headItems, $css, $scripts );
285 }
286
287 if ( isset( $prop['headhtml'] ) ) {
288 $result_array['headhtml'] = array();
289 $result->setContent( $result_array['headhtml'], $context->getOutput()->headElement( $context->getSkin() ) );
290 }
291 }
292
293 if ( isset( $prop['iwlinks'] ) ) {
294 $result_array['iwlinks'] = $this->formatIWLinks( $p_result->getInterwikiLinks() );
295 }
296
297 if ( isset( $prop['wikitext'] ) ) {
298 $result_array['wikitext'] = array();
299 $result->setContent( $result_array['wikitext'], $this->content->serialize( $format ) );
300 if ( !is_null( $this->pstContent ) ) {
301 $result_array['psttext'] = array();
302 $result->setContent( $result_array['psttext'], $this->pstContent->serialize( $format ) );
303 }
304 }
305 if ( isset( $prop['properties'] ) ) {
306 $result_array['properties'] = $this->formatProperties( $p_result->getProperties() );
307 }
308
309 if ( $params['generatexml'] ) {
310 if ( $this->content->getModel() != CONTENT_MODEL_WIKITEXT ) {
311 $this->dieUsage( "generatexml is only supported for wikitext content", "notwikitext" );
312 }
313
314 $wgParser->startExternalParse( $titleObj, $popts, OT_PREPROCESS );
315 $dom = $wgParser->preprocessToDom( $this->content->getNativeData() );
316 if ( is_callable( array( $dom, 'saveXML' ) ) ) {
317 $xml = $dom->saveXML();
318 } else {
319 $xml = $dom->__toString();
320 }
321 $result_array['parsetree'] = array();
322 $result->setContent( $result_array['parsetree'], $xml );
323 }
324
325 $result_mapping = array(
326 'redirects' => 'r',
327 'langlinks' => 'll',
328 'categories' => 'cl',
329 'links' => 'pl',
330 'templates' => 'tl',
331 'images' => 'img',
332 'externallinks' => 'el',
333 'iwlinks' => 'iw',
334 'sections' => 's',
335 'headitems' => 'hi',
336 'properties' => 'pp',
337 );
338 $this->setIndexedTagNames( $result_array, $result_mapping );
339 $result->addValue( null, $this->getModuleName(), $result_array );
340
341 if ( !is_null( $oldLang ) ) {
342 $this->getContext()->setLanguage( $oldLang ); // Reset language to $oldLang
343 }
344 }
345
346 /**
347 * @param $page WikiPage
348 * @param $popts ParserOptions
349 * @param $pageId Int
350 * @param $getWikitext Bool
351 * @return ParserOutput
352 */
353 private function getParsedContent( WikiPage $page, $popts, $pageId = null, $getWikitext = false ) {
354 $this->content = $page->getContent( Revision::RAW ); //XXX: really raw?
355
356 if ( $this->section !== false ) {
357 $this->content = $this->getSectionContent(
358 $this->content,
359 !is_null( $pageId ) ? 'page id ' . $pageId : $page->getTitle()->getText() );
360
361 // Not cached (save or load)
362 return $this->content->getParserOutput( $page->getTitle(), null, $popts );
363 } else {
364 // Try the parser cache first
365 // getParserOutput will save to Parser cache if able
366 $pout = $page->getParserOutput( $popts );
367 if ( !$pout ) {
368 $this->dieUsage( "There is no revision ID {$page->getLatest()}", 'missingrev' );
369 }
370 if ( $getWikitext ) {
371 $this->content = $page->getContent( Revision::RAW );
372 }
373 return $pout;
374 }
375 }
376
377 private function getSectionContent( Content $content, $what ) {
378 // Not cached (save or load)
379 $section = $content->getSection( $this->section );
380 if ( $section === false ) {
381 $this->dieUsage( "There is no section {$this->section} in " . $what, 'nosuchsection' );
382 }
383 if ( $section === null ) {
384 $this->dieUsage( "Sections are not supported by " . $what, 'nosuchsection' );
385 $section = false;
386 }
387 return $section;
388 }
389
390 private function formatLangLinks( $links ) {
391 $result = array();
392 foreach ( $links as $link ) {
393 $entry = array();
394 $bits = explode( ':', $link, 2 );
395 $title = Title::newFromText( $link );
396
397 $entry['lang'] = $bits[0];
398 if ( $title ) {
399 $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
400 }
401 $this->getResult()->setContent( $entry, $bits[1] );
402 $result[] = $entry;
403 }
404 return $result;
405 }
406
407 private function formatCategoryLinks( $links ) {
408 $result = array();
409 foreach ( $links as $link => $sortkey ) {
410 $entry = array();
411 $entry['sortkey'] = $sortkey;
412 $this->getResult()->setContent( $entry, $link );
413 $result[] = $entry;
414 }
415 return $result;
416 }
417
418 private function categoriesHtml( $categories ) {
419 $context = $this->getContext();
420 $context->getOutput()->addCategoryLinks( $categories );
421 return $context->getSkin()->getCategories();
422 }
423
424 /**
425 * @deprecated since 1.18 No modern skin generates language links this way, please use language links
426 * data to generate your own HTML.
427 * @param $languages array
428 * @return string
429 */
430 private function languagesHtml( $languages ) {
431 wfDeprecated( __METHOD__, '1.18' );
432
433 global $wgContLang, $wgHideInterlanguageLinks;
434
435 if ( $wgHideInterlanguageLinks || count( $languages ) == 0 ) {
436 return '';
437 }
438
439 $s = htmlspecialchars( wfMessage( 'otherlanguages' )->text() . wfMessage( 'colon-separator' )->text() );
440
441 $langs = array();
442 foreach ( $languages as $l ) {
443 $nt = Title::newFromText( $l );
444 $text = Language::fetchLanguageName( $nt->getInterwiki() );
445
446 $langs[] = Html::element( 'a',
447 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
448 $text == '' ? $l : $text );
449 }
450
451 $s .= implode( wfMessage( 'pipe-separator' )->escaped(), $langs );
452
453 if ( $wgContLang->isRTL() ) {
454 $s = Html::rawElement( 'span', array( 'dir' => "LTR" ), $s );
455 }
456
457 return $s;
458 }
459
460 private function formatLinks( $links ) {
461 $result = array();
462 foreach ( $links as $ns => $nslinks ) {
463 foreach ( $nslinks as $title => $id ) {
464 $entry = array();
465 $entry['ns'] = $ns;
466 $this->getResult()->setContent( $entry, Title::makeTitle( $ns, $title )->getFullText() );
467 if ( $id != 0 ) {
468 $entry['exists'] = '';
469 }
470 $result[] = $entry;
471 }
472 }
473 return $result;
474 }
475
476 private function formatIWLinks( $iw ) {
477 $result = array();
478 foreach ( $iw as $prefix => $titles ) {
479 foreach ( array_keys( $titles ) as $title ) {
480 $entry = array();
481 $entry['prefix'] = $prefix;
482
483 $title = Title::newFromText( "{$prefix}:{$title}" );
484 if ( $title ) {
485 $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
486 }
487
488 $this->getResult()->setContent( $entry, $title->getFullText() );
489 $result[] = $entry;
490 }
491 }
492 return $result;
493 }
494
495 private function formatHeadItems( $headItems ) {
496 $result = array();
497 foreach ( $headItems as $tag => $content ) {
498 $entry = array();
499 $entry['tag'] = $tag;
500 $this->getResult()->setContent( $entry, $content );
501 $result[] = $entry;
502 }
503 return $result;
504 }
505
506 private function formatProperties( $properties ) {
507 $result = array();
508 foreach ( $properties as $name => $value ) {
509 $entry = array();
510 $entry['name'] = $name;
511 $this->getResult()->setContent( $entry, $value );
512 $result[] = $entry;
513 }
514 return $result;
515 }
516
517 private function formatCss( $css ) {
518 $result = array();
519 foreach ( $css as $file => $link ) {
520 $entry = array();
521 $entry['file'] = $file;
522 $this->getResult()->setContent( $entry, $link );
523 $result[] = $entry;
524 }
525 return $result;
526 }
527
528 private function setIndexedTagNames( &$array, $mapping ) {
529 foreach ( $mapping as $key => $name ) {
530 if ( isset( $array[$key] ) ) {
531 $this->getResult()->setIndexedTagName( $array[$key], $name );
532 }
533 }
534 }
535
536 public function getAllowedParams() {
537 return array(
538 'title' => array(
539 ApiBase::PARAM_DFLT => 'API',
540 ),
541 'text' => null,
542 'summary' => null,
543 'page' => null,
544 'pageid' => array(
545 ApiBase::PARAM_TYPE => 'integer',
546 ),
547 'redirects' => false,
548 'oldid' => array(
549 ApiBase::PARAM_TYPE => 'integer',
550 ),
551 'prop' => array(
552 ApiBase::PARAM_DFLT => 'text|langlinks|categories|links|templates|images|externallinks|sections|revid|displaytitle|iwlinks|properties',
553 ApiBase::PARAM_ISMULTI => true,
554 ApiBase::PARAM_TYPE => array(
555 'text',
556 'langlinks',
557 'languageshtml',
558 'categories',
559 'categorieshtml',
560 'links',
561 'templates',
562 'images',
563 'externallinks',
564 'sections',
565 'revid',
566 'displaytitle',
567 'headitems',
568 'headhtml',
569 'iwlinks',
570 'wikitext',
571 'properties',
572 )
573 ),
574 'pst' => false,
575 'onlypst' => false,
576 'uselang' => null,
577 'section' => null,
578 'disablepp' => false,
579 'generatexml' => false,
580 'contentformat' => array(
581 ApiBase::PARAM_TYPE => ContentHandler::getAllContentFormats(),
582 ),
583 'contentmodel' => array(
584 ApiBase::PARAM_TYPE => ContentHandler::getContentModels(),
585 )
586 );
587 }
588
589 public function getParamDescription() {
590 $p = $this->getModulePrefix();
591 return array(
592 'text' => 'Wikitext to parse',
593 'summary' => 'Summary to parse',
594 'redirects' => "If the {$p}page or the {$p}pageid parameter is set to a redirect, resolve it",
595 'title' => 'Title of page the text belongs to',
596 'page' => "Parse the content of this page. Cannot be used together with {$p}text and {$p}title",
597 'pageid' => "Parse the content of this page. Overrides {$p}page",
598 'oldid' => "Parse the content of this revision. Overrides {$p}page and {$p}pageid",
599 'prop' => array(
600 'Which pieces of information to get',
601 ' text - Gives the parsed text of the wikitext',
602 ' langlinks - Gives the language links in the parsed wikitext',
603 ' categories - Gives the categories in the parsed wikitext',
604 ' categorieshtml - Gives the HTML version of the categories',
605 ' languageshtml - Gives the HTML version of the language links',
606 ' links - Gives the internal links in the parsed wikitext',
607 ' templates - Gives the templates in the parsed wikitext',
608 ' images - Gives the images in the parsed wikitext',
609 ' externallinks - Gives the external links in the parsed wikitext',
610 ' sections - Gives the sections in the parsed wikitext',
611 ' revid - Adds the revision ID of the parsed page',
612 ' displaytitle - Adds the title of the parsed wikitext',
613 ' headitems - Gives items to put in the <head> of the page',
614 ' headhtml - Gives parsed <head> of the page',
615 ' iwlinks - Gives interwiki links in the parsed wikitext',
616 ' wikitext - Gives the original wikitext that was parsed',
617 ' properties - Gives various properties defined in the parsed wikitext',
618 ),
619 'pst' => array(
620 'Do a pre-save transform on the input before parsing it',
621 'Ignored if page, pageid or oldid is used'
622 ),
623 'onlypst' => array(
624 'Do a pre-save transform (PST) on the input, but don\'t parse it',
625 'Returns the same wikitext, after a PST has been applied. Ignored if page, pageid or oldid is used'
626 ),
627 'uselang' => 'Which language to parse the request in',
628 'section' => 'Only retrieve the content of this section number',
629 'disablepp' => 'Disable the PP Report from the parser output',
630 'generatexml' => 'Generate XML parse tree',
631 'contentformat' => 'Content serialization format used for the input text',
632 'contentmodel' => 'Content model of the new content',
633 );
634 }
635
636 public function getDescription() {
637 return array(
638 'Parses wikitext and returns parser output',
639 'See the various prop-Modules of action=query to get information from the current version of a page',
640 );
641 }
642
643 public function getPossibleErrors() {
644 return array_merge( parent::getPossibleErrors(), array(
645 array( 'code' => 'params', 'info' => 'The page parameter cannot be used together with the text and title parameters' ),
646 array( 'code' => 'params', 'info' => 'The text parameter should be passed with the title parameter. Should you be using the "page" parameter instead?' ),
647 array( 'code' => 'missingrev', 'info' => 'There is no revision ID oldid' ),
648 array( 'code' => 'permissiondenied', 'info' => 'You don\'t have permission to view deleted revisions' ),
649 array( 'code' => 'missingtitle', 'info' => 'The page you specified doesn\'t exist' ),
650 array( 'code' => 'nosuchsection', 'info' => 'There is no section sectionnumber in page' ),
651 array( 'nosuchpageid' ),
652 array( 'invalidtitle', 'title' ),
653 array( 'code' => 'parseerror', 'info' => 'Failed to parse the given text.' ),
654 array( 'code' => 'notwikitext', 'info' => 'The requested operation is only supported on wikitext content.' ),
655 ) );
656 }
657
658 public function getExamples() {
659 return array(
660 'api.php?action=parse&text={{Project:Sandbox}}'
661 );
662 }
663
664 public function getHelpUrls() {
665 return 'https://www.mediawiki.org/wiki/API:Parsing_wikitext#parse';
666 }
667
668 public function getVersion() {
669 return __CLASS__ . ': $Id$';
670 }
671 }