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