MediaWiki
master
|
00001 <?php 00028 class ApiParse extends ApiBase { 00029 00031 private $section = null; 00032 00034 private $content = null; 00035 00037 private $pstContent = null; 00038 00039 public function __construct( $main, $action ) { 00040 parent::__construct( $main, $action ); 00041 } 00042 00043 public function execute() { 00044 // The data is hot but user-dependent, like page views, so we set vary cookies 00045 $this->getMain()->setCacheMode( 'anon-public-user-private' ); 00046 00047 // Get parameters 00048 $params = $this->extractRequestParams(); 00049 $text = $params['text']; 00050 $title = $params['title']; 00051 $page = $params['page']; 00052 $pageid = $params['pageid']; 00053 $oldid = $params['oldid']; 00054 00055 $model = $params['contentmodel']; 00056 $format = $params['contentformat']; 00057 00058 if ( !is_null( $page ) && ( !is_null( $text ) || $title != 'API' ) ) { 00059 $this->dieUsage( 'The page parameter cannot be used together with the text and title parameters', 'params' ); 00060 } 00061 00062 $prop = array_flip( $params['prop'] ); 00063 00064 if ( isset( $params['section'] ) ) { 00065 $this->section = $params['section']; 00066 } else { 00067 $this->section = false; 00068 } 00069 00070 // The parser needs $wgTitle to be set, apparently the 00071 // $title parameter in Parser::parse isn't enough *sigh* 00072 // TODO: Does this still need $wgTitle? 00073 global $wgParser, $wgTitle; 00074 00075 // Currently unnecessary, code to act as a safeguard against any change in current behaviour of uselang breaks 00076 $oldLang = null; 00077 if ( isset( $params['uselang'] ) && $params['uselang'] != $this->getContext()->getLanguage()->getCode() ) { 00078 $oldLang = $this->getContext()->getLanguage(); // Backup language 00079 $this->getContext()->setLanguage( Language::factory( $params['uselang'] ) ); 00080 } 00081 00082 $redirValues = null; 00083 00084 // Return result 00085 $result = $this->getResult(); 00086 00087 if ( !is_null( $oldid ) || !is_null( $pageid ) || !is_null( $page ) ) { 00088 if ( !is_null( $oldid ) ) { 00089 // Don't use the parser cache 00090 $rev = Revision::newFromID( $oldid ); 00091 if ( !$rev ) { 00092 $this->dieUsage( "There is no revision ID $oldid", 'missingrev' ); 00093 } 00094 if ( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) { 00095 $this->dieUsage( "You don't have permission to view deleted revisions", 'permissiondenied' ); 00096 } 00097 00098 $titleObj = $rev->getTitle(); 00099 $wgTitle = $titleObj; 00100 $pageObj = WikiPage::factory( $titleObj ); 00101 $popts = $pageObj->makeParserOptions( $this->getContext() ); 00102 $popts->enableLimitReport( !$params['disablepp'] ); 00103 00104 // If for some reason the "oldid" is actually the current revision, it may be cached 00105 if ( $rev->isCurrent() ) { 00106 // May get from/save to parser cache 00107 $p_result = $this->getParsedContent( $pageObj, $popts, 00108 $pageid, isset( $prop['wikitext'] ) ) ; 00109 } else { // This is an old revision, so get the text differently 00110 $this->content = $rev->getContent( Revision::FOR_THIS_USER, $this->getUser() ); 00111 00112 if ( $this->section !== false ) { 00113 $this->content = $this->getSectionContent( $this->content, 'r' . $rev->getId() ); 00114 } 00115 00116 // Should we save old revision parses to the parser cache? 00117 $p_result = $this->content->getParserOutput( $titleObj, $rev->getId(), $popts ); 00118 } 00119 } else { // Not $oldid, but $pageid or $page 00120 if ( $params['redirects'] ) { 00121 $reqParams = array( 00122 'action' => 'query', 00123 'redirects' => '', 00124 ); 00125 if ( !is_null ( $pageid ) ) { 00126 $reqParams['pageids'] = $pageid; 00127 } else { // $page 00128 $reqParams['titles'] = $page; 00129 } 00130 $req = new FauxRequest( $reqParams ); 00131 $main = new ApiMain( $req ); 00132 $main->execute(); 00133 $data = $main->getResultData(); 00134 $redirValues = isset( $data['query']['redirects'] ) 00135 ? $data['query']['redirects'] 00136 : array(); 00137 $to = $page; 00138 foreach ( (array)$redirValues as $r ) { 00139 $to = $r['to']; 00140 } 00141 $pageParams = array( 'title' => $to ); 00142 } elseif ( !is_null( $pageid ) ) { 00143 $pageParams = array( 'pageid' => $pageid ); 00144 } else { // $page 00145 $pageParams = array( 'title' => $page ); 00146 } 00147 00148 $pageObj = $this->getTitleOrPageId( $pageParams, 'fromdb' ); 00149 $titleObj = $pageObj->getTitle(); 00150 if ( !$titleObj || !$titleObj->exists() ) { 00151 $this->dieUsage( "The page you specified doesn't exist", 'missingtitle' ); 00152 } 00153 $wgTitle = $titleObj; 00154 00155 if ( isset( $prop['revid'] ) ) { 00156 $oldid = $pageObj->getLatest(); 00157 } 00158 00159 $popts = $pageObj->makeParserOptions( $this->getContext() ); 00160 $popts->enableLimitReport( !$params['disablepp'] ); 00161 00162 // Potentially cached 00163 $p_result = $this->getParsedContent( $pageObj, $popts, $pageid, 00164 isset( $prop['wikitext'] ) ) ; 00165 } 00166 } else { // Not $oldid, $pageid, $page. Hence based on $text 00167 $titleObj = Title::newFromText( $title ); 00168 if ( !$titleObj ) { 00169 $this->dieUsageMsg( array( 'invalidtitle', $title ) ); 00170 } 00171 if ( !$titleObj->canExist() ) { 00172 $this->dieUsage( "Namespace doesn't allow actual pages", 'pagecannotexist' ); 00173 } 00174 $wgTitle = $titleObj; 00175 $pageObj = WikiPage::factory( $titleObj ); 00176 00177 $popts = $pageObj->makeParserOptions( $this->getContext() ); 00178 $popts->enableLimitReport( !$params['disablepp'] ); 00179 00180 if ( is_null( $text ) ) { 00181 $this->dieUsage( 'The text parameter should be passed with the title parameter. Should you be using the "page" parameter instead?', 'params' ); 00182 } 00183 00184 try { 00185 $this->content = ContentHandler::makeContent( $text, $titleObj, $model, $format ); 00186 } catch ( MWContentSerializationException $ex ) { 00187 $this->dieUsage( $ex->getMessage(), 'parseerror' ); 00188 } 00189 00190 if ( $this->section !== false ) { 00191 $this->content = $this->getSectionContent( $this->content, $titleObj->getText() ); 00192 } 00193 00194 if ( $params['pst'] || $params['onlypst'] ) { 00195 $this->pstContent = $this->content->preSaveTransform( $titleObj, $this->getUser(), $popts ); 00196 } 00197 if ( $params['onlypst'] ) { 00198 // Build a result and bail out 00199 $result_array = array(); 00200 $result_array['text'] = array(); 00201 $result->setContent( $result_array['text'], $this->pstContent->serialize( $format ) ); 00202 if ( isset( $prop['wikitext'] ) ) { 00203 $result_array['wikitext'] = array(); 00204 $result->setContent( $result_array['wikitext'], $this->content->serialize( $format ) ); 00205 } 00206 $result->addValue( null, $this->getModuleName(), $result_array ); 00207 return; 00208 } 00209 00210 // Not cached (save or load) 00211 if ( $params['pst'] ) { 00212 $p_result = $this->pstContent->getParserOutput( $titleObj, null, $popts ); 00213 } else { 00214 $p_result = $this->content->getParserOutput( $titleObj, null, $popts ); 00215 } 00216 } 00217 00218 $result_array = array(); 00219 00220 $result_array['title'] = $titleObj->getPrefixedText(); 00221 00222 if ( !is_null( $oldid ) ) { 00223 $result_array['revid'] = intval( $oldid ); 00224 } 00225 00226 if ( $params['redirects'] && !is_null( $redirValues ) ) { 00227 $result_array['redirects'] = $redirValues; 00228 } 00229 00230 if ( isset( $prop['text'] ) ) { 00231 $result_array['text'] = array(); 00232 $result->setContent( $result_array['text'], $p_result->getText() ); 00233 } 00234 00235 if ( !is_null( $params['summary'] ) ) { 00236 $result_array['parsedsummary'] = array(); 00237 $result->setContent( $result_array['parsedsummary'], Linker::formatComment( $params['summary'], $titleObj ) ); 00238 } 00239 00240 if ( isset( $prop['langlinks'] ) ) { 00241 $result_array['langlinks'] = $this->formatLangLinks( $p_result->getLanguageLinks() ); 00242 } 00243 if ( isset( $prop['languageshtml'] ) ) { 00244 $languagesHtml = $this->languagesHtml( $p_result->getLanguageLinks() ); 00245 $result_array['languageshtml'] = array(); 00246 $result->setContent( $result_array['languageshtml'], $languagesHtml ); 00247 } 00248 if ( isset( $prop['categories'] ) ) { 00249 $result_array['categories'] = $this->formatCategoryLinks( $p_result->getCategories() ); 00250 } 00251 if ( isset( $prop['categorieshtml'] ) ) { 00252 $categoriesHtml = $this->categoriesHtml( $p_result->getCategories() ); 00253 $result_array['categorieshtml'] = array(); 00254 $result->setContent( $result_array['categorieshtml'], $categoriesHtml ); 00255 } 00256 if ( isset( $prop['links'] ) ) { 00257 $result_array['links'] = $this->formatLinks( $p_result->getLinks() ); 00258 } 00259 if ( isset( $prop['templates'] ) ) { 00260 $result_array['templates'] = $this->formatLinks( $p_result->getTemplates() ); 00261 } 00262 if ( isset( $prop['images'] ) ) { 00263 $result_array['images'] = array_keys( $p_result->getImages() ); 00264 } 00265 if ( isset( $prop['externallinks'] ) ) { 00266 $result_array['externallinks'] = array_keys( $p_result->getExternalLinks() ); 00267 } 00268 if ( isset( $prop['sections'] ) ) { 00269 $result_array['sections'] = $p_result->getSections(); 00270 } 00271 00272 if ( isset( $prop['displaytitle'] ) ) { 00273 $result_array['displaytitle'] = $p_result->getDisplayTitle() ? 00274 $p_result->getDisplayTitle() : 00275 $titleObj->getPrefixedText(); 00276 } 00277 00278 if ( isset( $prop['headitems'] ) || isset( $prop['headhtml'] ) ) { 00279 $context = $this->getContext(); 00280 $context->setTitle( $titleObj ); 00281 $context->getOutput()->addParserOutputNoText( $p_result ); 00282 00283 if ( isset( $prop['headitems'] ) ) { 00284 $headItems = $this->formatHeadItems( $p_result->getHeadItems() ); 00285 00286 $css = $this->formatCss( $context->getOutput()->buildCssLinksArray() ); 00287 00288 $scripts = array( $context->getOutput()->getHeadScripts() ); 00289 00290 $result_array['headitems'] = array_merge( $headItems, $css, $scripts ); 00291 } 00292 00293 if ( isset( $prop['headhtml'] ) ) { 00294 $result_array['headhtml'] = array(); 00295 $result->setContent( $result_array['headhtml'], $context->getOutput()->headElement( $context->getSkin() ) ); 00296 } 00297 } 00298 00299 if ( isset( $prop['iwlinks'] ) ) { 00300 $result_array['iwlinks'] = $this->formatIWLinks( $p_result->getInterwikiLinks() ); 00301 } 00302 00303 if ( isset( $prop['wikitext'] ) ) { 00304 $result_array['wikitext'] = array(); 00305 $result->setContent( $result_array['wikitext'], $this->content->serialize( $format ) ); 00306 if ( !is_null( $this->pstContent ) ) { 00307 $result_array['psttext'] = array(); 00308 $result->setContent( $result_array['psttext'], $this->pstContent->serialize( $format ) ); 00309 } 00310 } 00311 if ( isset( $prop['properties'] ) ) { 00312 $result_array['properties'] = $this->formatProperties( $p_result->getProperties() ); 00313 } 00314 00315 if ( $params['generatexml'] ) { 00316 if ( $this->content->getModel() != CONTENT_MODEL_WIKITEXT ) { 00317 $this->dieUsage( "generatexml is only supported for wikitext content", "notwikitext" ); 00318 } 00319 00320 $wgParser->startExternalParse( $titleObj, $popts, OT_PREPROCESS ); 00321 $dom = $wgParser->preprocessToDom( $this->content->getNativeData() ); 00322 if ( is_callable( array( $dom, 'saveXML' ) ) ) { 00323 $xml = $dom->saveXML(); 00324 } else { 00325 $xml = $dom->__toString(); 00326 } 00327 $result_array['parsetree'] = array(); 00328 $result->setContent( $result_array['parsetree'], $xml ); 00329 } 00330 00331 $result_mapping = array( 00332 'redirects' => 'r', 00333 'langlinks' => 'll', 00334 'categories' => 'cl', 00335 'links' => 'pl', 00336 'templates' => 'tl', 00337 'images' => 'img', 00338 'externallinks' => 'el', 00339 'iwlinks' => 'iw', 00340 'sections' => 's', 00341 'headitems' => 'hi', 00342 'properties' => 'pp', 00343 ); 00344 $this->setIndexedTagNames( $result_array, $result_mapping ); 00345 $result->addValue( null, $this->getModuleName(), $result_array ); 00346 00347 if ( !is_null( $oldLang ) ) { 00348 $this->getContext()->setLanguage( $oldLang ); // Reset language to $oldLang 00349 } 00350 } 00351 00359 private function getParsedContent( WikiPage $page, $popts, $pageId = null, $getWikitext = false ) { 00360 $this->content = $page->getContent( Revision::RAW ); //XXX: really raw? 00361 00362 if ( $this->section !== false && $this->content !== null ) { 00363 $this->content = $this->getSectionContent( 00364 $this->content, 00365 !is_null( $pageId ) ? 'page id ' . $pageId : $page->getTitle()->getText() ); 00366 00367 // Not cached (save or load) 00368 return $this->content->getParserOutput( $page->getTitle(), null, $popts ); 00369 } else { 00370 // Try the parser cache first 00371 // getParserOutput will save to Parser cache if able 00372 $pout = $page->getParserOutput( $popts ); 00373 if ( !$pout ) { 00374 $this->dieUsage( "There is no revision ID {$page->getLatest()}", 'missingrev' ); 00375 } 00376 if ( $getWikitext ) { 00377 $this->content = $page->getContent( Revision::RAW ); 00378 } 00379 return $pout; 00380 } 00381 } 00382 00383 private function getSectionContent( Content $content, $what ) { 00384 // Not cached (save or load) 00385 $section = $content->getSection( $this->section ); 00386 if ( $section === false ) { 00387 $this->dieUsage( "There is no section {$this->section} in " . $what, 'nosuchsection' ); 00388 } 00389 if ( $section === null ) { 00390 $this->dieUsage( "Sections are not supported by " . $what, 'nosuchsection' ); 00391 $section = false; 00392 } 00393 return $section; 00394 } 00395 00396 private function formatLangLinks( $links ) { 00397 $result = array(); 00398 foreach ( $links as $link ) { 00399 $entry = array(); 00400 $bits = explode( ':', $link, 2 ); 00401 $title = Title::newFromText( $link ); 00402 00403 $entry['lang'] = $bits[0]; 00404 if ( $title ) { 00405 $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); 00406 } 00407 $this->getResult()->setContent( $entry, $bits[1] ); 00408 $result[] = $entry; 00409 } 00410 return $result; 00411 } 00412 00413 private function formatCategoryLinks( $links ) { 00414 $result = array(); 00415 foreach ( $links as $link => $sortkey ) { 00416 $entry = array(); 00417 $entry['sortkey'] = $sortkey; 00418 $this->getResult()->setContent( $entry, $link ); 00419 $result[] = $entry; 00420 } 00421 return $result; 00422 } 00423 00424 private function categoriesHtml( $categories ) { 00425 $context = $this->getContext(); 00426 $context->getOutput()->addCategoryLinks( $categories ); 00427 return $context->getSkin()->getCategories(); 00428 } 00429 00436 private function languagesHtml( $languages ) { 00437 wfDeprecated( __METHOD__, '1.18' ); 00438 00439 global $wgContLang, $wgHideInterlanguageLinks; 00440 00441 if ( $wgHideInterlanguageLinks || count( $languages ) == 0 ) { 00442 return ''; 00443 } 00444 00445 $s = htmlspecialchars( wfMessage( 'otherlanguages' )->text() . wfMessage( 'colon-separator' )->text() ); 00446 00447 $langs = array(); 00448 foreach ( $languages as $l ) { 00449 $nt = Title::newFromText( $l ); 00450 $text = Language::fetchLanguageName( $nt->getInterwiki() ); 00451 00452 $langs[] = Html::element( 'a', 00453 array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ), 00454 $text == '' ? $l : $text ); 00455 } 00456 00457 $s .= implode( wfMessage( 'pipe-separator' )->escaped(), $langs ); 00458 00459 if ( $wgContLang->isRTL() ) { 00460 $s = Html::rawElement( 'span', array( 'dir' => "LTR" ), $s ); 00461 } 00462 00463 return $s; 00464 } 00465 00466 private function formatLinks( $links ) { 00467 $result = array(); 00468 foreach ( $links as $ns => $nslinks ) { 00469 foreach ( $nslinks as $title => $id ) { 00470 $entry = array(); 00471 $entry['ns'] = $ns; 00472 $this->getResult()->setContent( $entry, Title::makeTitle( $ns, $title )->getFullText() ); 00473 if ( $id != 0 ) { 00474 $entry['exists'] = ''; 00475 } 00476 $result[] = $entry; 00477 } 00478 } 00479 return $result; 00480 } 00481 00482 private function formatIWLinks( $iw ) { 00483 $result = array(); 00484 foreach ( $iw as $prefix => $titles ) { 00485 foreach ( array_keys( $titles ) as $title ) { 00486 $entry = array(); 00487 $entry['prefix'] = $prefix; 00488 00489 $title = Title::newFromText( "{$prefix}:{$title}" ); 00490 if ( $title ) { 00491 $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ); 00492 } 00493 00494 $this->getResult()->setContent( $entry, $title->getFullText() ); 00495 $result[] = $entry; 00496 } 00497 } 00498 return $result; 00499 } 00500 00501 private function formatHeadItems( $headItems ) { 00502 $result = array(); 00503 foreach ( $headItems as $tag => $content ) { 00504 $entry = array(); 00505 $entry['tag'] = $tag; 00506 $this->getResult()->setContent( $entry, $content ); 00507 $result[] = $entry; 00508 } 00509 return $result; 00510 } 00511 00512 private function formatProperties( $properties ) { 00513 $result = array(); 00514 foreach ( $properties as $name => $value ) { 00515 $entry = array(); 00516 $entry['name'] = $name; 00517 $this->getResult()->setContent( $entry, $value ); 00518 $result[] = $entry; 00519 } 00520 return $result; 00521 } 00522 00523 private function formatCss( $css ) { 00524 $result = array(); 00525 foreach ( $css as $file => $link ) { 00526 $entry = array(); 00527 $entry['file'] = $file; 00528 $this->getResult()->setContent( $entry, $link ); 00529 $result[] = $entry; 00530 } 00531 return $result; 00532 } 00533 00534 private function setIndexedTagNames( &$array, $mapping ) { 00535 foreach ( $mapping as $key => $name ) { 00536 if ( isset( $array[$key] ) ) { 00537 $this->getResult()->setIndexedTagName( $array[$key], $name ); 00538 } 00539 } 00540 } 00541 00542 public function getAllowedParams() { 00543 return array( 00544 'title' => array( 00545 ApiBase::PARAM_DFLT => 'API', 00546 ), 00547 'text' => null, 00548 'summary' => null, 00549 'page' => null, 00550 'pageid' => array( 00551 ApiBase::PARAM_TYPE => 'integer', 00552 ), 00553 'redirects' => false, 00554 'oldid' => array( 00555 ApiBase::PARAM_TYPE => 'integer', 00556 ), 00557 'prop' => array( 00558 ApiBase::PARAM_DFLT => 'text|langlinks|categories|links|templates|images|externallinks|sections|revid|displaytitle|iwlinks|properties', 00559 ApiBase::PARAM_ISMULTI => true, 00560 ApiBase::PARAM_TYPE => array( 00561 'text', 00562 'langlinks', 00563 'languageshtml', 00564 'categories', 00565 'categorieshtml', 00566 'links', 00567 'templates', 00568 'images', 00569 'externallinks', 00570 'sections', 00571 'revid', 00572 'displaytitle', 00573 'headitems', 00574 'headhtml', 00575 'iwlinks', 00576 'wikitext', 00577 'properties', 00578 ) 00579 ), 00580 'pst' => false, 00581 'onlypst' => false, 00582 'uselang' => null, 00583 'section' => null, 00584 'disablepp' => false, 00585 'generatexml' => false, 00586 'contentformat' => array( 00587 ApiBase::PARAM_TYPE => ContentHandler::getAllContentFormats(), 00588 ), 00589 'contentmodel' => array( 00590 ApiBase::PARAM_TYPE => ContentHandler::getContentModels(), 00591 ) 00592 ); 00593 } 00594 00595 public function getParamDescription() { 00596 $p = $this->getModulePrefix(); 00597 return array( 00598 'text' => 'Wikitext to parse', 00599 'summary' => 'Summary to parse', 00600 'redirects' => "If the {$p}page or the {$p}pageid parameter is set to a redirect, resolve it", 00601 'title' => 'Title of page the text belongs to', 00602 'page' => "Parse the content of this page. Cannot be used together with {$p}text and {$p}title", 00603 'pageid' => "Parse the content of this page. Overrides {$p}page", 00604 'oldid' => "Parse the content of this revision. Overrides {$p}page and {$p}pageid", 00605 'prop' => array( 00606 'Which pieces of information to get', 00607 ' text - Gives the parsed text of the wikitext', 00608 ' langlinks - Gives the language links in the parsed wikitext', 00609 ' categories - Gives the categories in the parsed wikitext', 00610 ' categorieshtml - Gives the HTML version of the categories', 00611 ' languageshtml - Gives the HTML version of the language links', 00612 ' links - Gives the internal links in the parsed wikitext', 00613 ' templates - Gives the templates in the parsed wikitext', 00614 ' images - Gives the images in the parsed wikitext', 00615 ' externallinks - Gives the external links in the parsed wikitext', 00616 ' sections - Gives the sections in the parsed wikitext', 00617 ' revid - Adds the revision ID of the parsed page', 00618 ' displaytitle - Adds the title of the parsed wikitext', 00619 ' headitems - Gives items to put in the <head> of the page', 00620 ' headhtml - Gives parsed <head> of the page', 00621 ' iwlinks - Gives interwiki links in the parsed wikitext', 00622 ' wikitext - Gives the original wikitext that was parsed', 00623 ' properties - Gives various properties defined in the parsed wikitext', 00624 ), 00625 'pst' => array( 00626 'Do a pre-save transform on the input before parsing it', 00627 'Ignored if page, pageid or oldid is used' 00628 ), 00629 'onlypst' => array( 00630 'Do a pre-save transform (PST) on the input, but don\'t parse it', 00631 'Returns the same wikitext, after a PST has been applied. Ignored if page, pageid or oldid is used' 00632 ), 00633 'uselang' => 'Which language to parse the request in', 00634 'section' => 'Only retrieve the content of this section number', 00635 'disablepp' => 'Disable the PP Report from the parser output', 00636 'generatexml' => 'Generate XML parse tree (requires prop=wikitext)', 00637 'contentformat' => 'Content serialization format used for the input text', 00638 'contentmodel' => 'Content model of the new content', 00639 ); 00640 } 00641 00642 public function getDescription() { 00643 return array( 00644 'Parses wikitext and returns parser output', 00645 'See the various prop-Modules of action=query to get information from the current version of a page', 00646 ); 00647 } 00648 00649 public function getPossibleErrors() { 00650 return array_merge( parent::getPossibleErrors(), array( 00651 array( 'code' => 'params', 'info' => 'The page parameter cannot be used together with the text and title parameters' ), 00652 array( 'code' => 'params', 'info' => 'The text parameter should be passed with the title parameter. Should you be using the "page" parameter instead?' ), 00653 array( 'code' => 'missingrev', 'info' => 'There is no revision ID oldid' ), 00654 array( 'code' => 'permissiondenied', 'info' => 'You don\'t have permission to view deleted revisions' ), 00655 array( 'code' => 'missingtitle', 'info' => 'The page you specified doesn\'t exist' ), 00656 array( 'code' => 'nosuchsection', 'info' => 'There is no section sectionnumber in page' ), 00657 array( 'nosuchpageid' ), 00658 array( 'invalidtitle', 'title' ), 00659 array( 'code' => 'parseerror', 'info' => 'Failed to parse the given text.' ), 00660 array( 'code' => 'notwikitext', 'info' => 'The requested operation is only supported on wikitext content.' ), 00661 array( 'code' => 'pagecannotexist', 'info' => "Namespace doesn't allow actual pages" ), 00662 ) ); 00663 } 00664 00665 public function getExamples() { 00666 return array( 00667 'api.php?action=parse&text={{Project:Sandbox}}' 00668 ); 00669 } 00670 00671 public function getHelpUrls() { 00672 return 'https://www.mediawiki.org/wiki/API:Parsing_wikitext#parse'; 00673 } 00674 00675 public function getVersion() { 00676 return __CLASS__ . ': $Id$'; 00677 } 00678 }