MediaWiki  master
ApiParse.php
Go to the documentation of this file.
1 <?php
25 
29 class ApiParse extends ApiBase {
30 
32  private $section = null;
33 
35  private $content = null;
36 
38  private $pstContent = null;
39 
41  private $contentIsDeleted = false, $contentIsSuppressed = false;
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 
50  // No easy way to say that text and title or revid are allowed together
51  // while the rest aren't, so just do it in three calls.
52  $this->requireMaxOneParameter( $params, 'page', 'pageid', 'oldid', 'text' );
53  $this->requireMaxOneParameter( $params, 'page', 'pageid', 'oldid', 'title' );
54  $this->requireMaxOneParameter( $params, 'page', 'pageid', 'oldid', 'revid' );
55 
56  $text = $params['text'];
57  $title = $params['title'];
58  if ( $title === null ) {
59  $titleProvided = false;
60  // A title is needed for parsing, so arbitrarily choose one
61  $title = 'API';
62  } else {
63  $titleProvided = true;
64  }
65 
66  $page = $params['page'];
67  $pageid = $params['pageid'];
68  $oldid = $params['oldid'];
69 
70  $model = $params['contentmodel'];
71  $format = $params['contentformat'];
72 
73  $prop = array_flip( $params['prop'] );
74 
75  if ( isset( $params['section'] ) ) {
76  $this->section = $params['section'];
77  if ( !preg_match( '/^((T-)?\d+|new)$/', $this->section ) ) {
78  $this->dieWithError( 'apierror-invalidsection' );
79  }
80  } else {
81  $this->section = false;
82  }
83 
84  // The parser needs $wgTitle to be set, apparently the
85  // $title parameter in Parser::parse isn't enough *sigh*
86  // TODO: Does this still need $wgTitle?
87  global $wgTitle;
88 
89  $redirValues = null;
90 
91  $needContent = isset( $prop['wikitext'] ) ||
92  isset( $prop['parsetree'] ) || $params['generatexml'];
93 
94  // Return result
95  $result = $this->getResult();
96 
97  if ( !is_null( $oldid ) || !is_null( $pageid ) || !is_null( $page ) ) {
98  if ( $this->section === 'new' ) {
99  $this->dieWithError( 'apierror-invalidparammix-parse-new-section', 'invalidparammix' );
100  }
101  if ( !is_null( $oldid ) ) {
102  // Don't use the parser cache
103  $rev = Revision::newFromId( $oldid );
104  if ( !$rev ) {
105  $this->dieWithError( [ 'apierror-nosuchrevid', $oldid ] );
106  }
107 
108  $this->checkTitleUserPermissions( $rev->getTitle(), 'read' );
109  if ( !$rev->userCan( RevisionRecord::DELETED_TEXT, $this->getUser() ) ) {
110  $this->dieWithError(
111  [ 'apierror-permissiondenied', $this->msg( 'action-deletedtext' ) ]
112  );
113  }
114 
115  $titleObj = $rev->getTitle();
116  $wgTitle = $titleObj;
117  $pageObj = WikiPage::factory( $titleObj );
118  list( $popts, $reset, $suppressCache ) = $this->makeParserOptions( $pageObj, $params );
119  $p_result = $this->getParsedContent(
120  $pageObj, $popts, $suppressCache, $pageid, $rev, $needContent
121  );
122  } else { // Not $oldid, but $pageid or $page
123  if ( $params['redirects'] ) {
124  $reqParams = [
125  'redirects' => '',
126  ];
127  if ( !is_null( $pageid ) ) {
128  $reqParams['pageids'] = $pageid;
129  } else { // $page
130  $reqParams['titles'] = $page;
131  }
132  $req = new FauxRequest( $reqParams );
133  $main = new ApiMain( $req );
134  $pageSet = new ApiPageSet( $main );
135  $pageSet->execute();
136  $redirValues = $pageSet->getRedirectTitlesAsResult( $this->getResult() );
137 
138  $to = $page;
139  foreach ( $pageSet->getRedirectTitles() as $title ) {
140  $to = $title->getFullText();
141  }
142  $pageParams = [ 'title' => $to ];
143  } elseif ( !is_null( $pageid ) ) {
144  $pageParams = [ 'pageid' => $pageid ];
145  } else { // $page
146  $pageParams = [ 'title' => $page ];
147  }
148 
149  $pageObj = $this->getTitleOrPageId( $pageParams, 'fromdb' );
150  $titleObj = $pageObj->getTitle();
151  if ( !$titleObj || !$titleObj->exists() ) {
152  $this->dieWithError( 'apierror-missingtitle' );
153  }
154 
155  $this->checkTitleUserPermissions( $titleObj, 'read' );
156  $wgTitle = $titleObj;
157 
158  if ( isset( $prop['revid'] ) ) {
159  $oldid = $pageObj->getLatest();
160  }
161 
162  list( $popts, $reset, $suppressCache ) = $this->makeParserOptions( $pageObj, $params );
163  $p_result = $this->getParsedContent(
164  $pageObj, $popts, $suppressCache, $pageid, null, $needContent
165  );
166  }
167  } else { // Not $oldid, $pageid, $page. Hence based on $text
168  $titleObj = Title::newFromText( $title );
169  if ( !$titleObj || $titleObj->isExternal() ) {
170  $this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $title ) ] );
171  }
172  $revid = $params['revid'];
173  if ( $revid !== null ) {
174  $rev = Revision::newFromId( $revid );
175  if ( !$rev ) {
176  $this->dieWithError( [ 'apierror-nosuchrevid', $revid ] );
177  }
178  $pTitleObj = $titleObj;
179  $titleObj = $rev->getTitle();
180  if ( $titleProvided ) {
181  if ( !$titleObj->equals( $pTitleObj ) ) {
182  $this->addWarning( [ 'apierror-revwrongpage', $rev->getId(),
183  wfEscapeWikiText( $pTitleObj->getPrefixedText() ) ] );
184  }
185  } else {
186  // Consider the title derived from the revid as having
187  // been provided.
188  $titleProvided = true;
189  }
190  }
191  $wgTitle = $titleObj;
192  if ( $titleObj->canExist() ) {
193  $pageObj = WikiPage::factory( $titleObj );
194  } else {
195  // Do like MediaWiki::initializeArticle()
196  $article = Article::newFromTitle( $titleObj, $this->getContext() );
197  $pageObj = $article->getPage();
198  }
199 
200  list( $popts, $reset ) = $this->makeParserOptions( $pageObj, $params );
201  $textProvided = !is_null( $text );
202 
203  if ( !$textProvided ) {
204  if ( $titleProvided && ( $prop || $params['generatexml'] ) ) {
205  if ( $revid !== null ) {
206  $this->addWarning( 'apiwarn-parse-revidwithouttext' );
207  } else {
208  $this->addWarning( 'apiwarn-parse-titlewithouttext' );
209  }
210  }
211  // Prevent warning from ContentHandler::makeContent()
212  $text = '';
213  }
214 
215  // If we are parsing text, do not use the content model of the default
216  // API title, but default to wikitext to keep BC.
217  if ( $textProvided && !$titleProvided && is_null( $model ) ) {
218  $model = CONTENT_MODEL_WIKITEXT;
219  $this->addWarning( [ 'apiwarn-parse-nocontentmodel', $model ] );
220  }
221 
222  try {
223  $this->content = ContentHandler::makeContent( $text, $titleObj, $model, $format );
224  } catch ( MWContentSerializationException $ex ) {
225  $this->dieWithException( $ex, [
226  'wrap' => ApiMessage::create( 'apierror-contentserializationexception', 'parseerror' )
227  ] );
228  }
229 
230  if ( $this->section !== false ) {
231  if ( $this->section === 'new' ) {
232  // Insert the section title above the content.
233  if ( !is_null( $params['sectiontitle'] ) && $params['sectiontitle'] !== '' ) {
234  $this->content = $this->content->addSectionHeader( $params['sectiontitle'] );
235  }
236  } else {
237  $this->content = $this->getSectionContent( $this->content, $titleObj->getPrefixedText() );
238  }
239  }
240 
241  if ( $params['pst'] || $params['onlypst'] ) {
242  $this->pstContent = $this->content->preSaveTransform( $titleObj, $this->getUser(), $popts );
243  }
244  if ( $params['onlypst'] ) {
245  // Build a result and bail out
246  $result_array = [];
247  $result_array['text'] = $this->pstContent->serialize( $format );
248  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'text';
249  if ( isset( $prop['wikitext'] ) ) {
250  $result_array['wikitext'] = $this->content->serialize( $format );
251  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'wikitext';
252  }
253  if ( !is_null( $params['summary'] ) ||
254  ( !is_null( $params['sectiontitle'] ) && $this->section === 'new' )
255  ) {
256  $result_array['parsedsummary'] = $this->formatSummary( $titleObj, $params );
257  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'parsedsummary';
258  }
259 
260  $result->addValue( null, $this->getModuleName(), $result_array );
261 
262  return;
263  }
264 
265  // Not cached (save or load)
266  if ( $params['pst'] ) {
267  $p_result = $this->pstContent->getParserOutput( $titleObj, $revid, $popts );
268  } else {
269  $p_result = $this->content->getParserOutput( $titleObj, $revid, $popts );
270  }
271  }
272 
273  $result_array = [];
274 
275  $result_array['title'] = $titleObj->getPrefixedText();
276  $result_array['pageid'] = $pageid ?: $pageObj->getId();
277  if ( $this->contentIsDeleted ) {
278  $result_array['textdeleted'] = true;
279  }
280  if ( $this->contentIsSuppressed ) {
281  $result_array['textsuppressed'] = true;
282  }
283 
284  if ( isset( $params['useskin'] ) ) {
285  $factory = MediaWikiServices::getInstance()->getSkinFactory();
286  $skin = $factory->makeSkin( Skin::normalizeKey( $params['useskin'] ) );
287  } else {
288  $skin = null;
289  }
290 
291  $outputPage = null;
292  if ( $skin || isset( $prop['headhtml'] ) || isset( $prop['categorieshtml'] ) ) {
293  // Enabling the skin via 'useskin', 'headhtml', or 'categorieshtml'
294  // gets OutputPage and Skin involved, which (among others) applies
295  // these hooks:
296  // - ParserOutputHooks
297  // - Hook: LanguageLinks
298  // - Hook: OutputPageParserOutput
299  // - Hook: OutputPageMakeCategoryLinks
300  $context = new DerivativeContext( $this->getContext() );
301  $context->setTitle( $titleObj );
302  $context->setWikiPage( $pageObj );
303 
304  if ( $skin ) {
305  // Use the skin specified by 'useskin'
306  $context->setSkin( $skin );
307  // Context clones the skin, refetch to stay in sync. (T166022)
308  $skin = $context->getSkin();
309  } else {
310  // Make sure the context's skin refers to the context. Without this,
311  // $outputPage->getSkin()->getOutput() !== $outputPage which
312  // confuses some of the output.
313  $context->setSkin( $context->getSkin() );
314  }
315 
316  $outputPage = new OutputPage( $context );
317  $outputPage->addParserOutputMetadata( $p_result );
318  if ( $this->content ) {
319  $outputPage->addContentOverride( $titleObj, $this->content );
320  }
321  $context->setOutput( $outputPage );
322 
323  if ( $skin ) {
324  // Based on OutputPage::headElement()
325  $skin->setupSkinUserCss( $outputPage );
326  // Based on OutputPage::output()
327  $outputPage->loadSkinModules( $skin );
328  }
329 
330  Hooks::run( 'ApiParseMakeOutputPage', [ $this, $outputPage ] );
331  }
332 
333  if ( !is_null( $oldid ) ) {
334  $result_array['revid'] = (int)$oldid;
335  }
336 
337  if ( $params['redirects'] && !is_null( $redirValues ) ) {
338  $result_array['redirects'] = $redirValues;
339  }
340 
341  if ( isset( $prop['text'] ) ) {
342  $result_array['text'] = $p_result->getText( [
343  'allowTOC' => !$params['disabletoc'],
344  'enableSectionEditLinks' => !$params['disableeditsection'],
345  'wrapperDivClass' => $params['wrapoutputclass'],
346  'deduplicateStyles' => !$params['disablestylededuplication'],
347  ] );
348  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'text';
349  }
350 
351  if ( !is_null( $params['summary'] ) ||
352  ( !is_null( $params['sectiontitle'] ) && $this->section === 'new' )
353  ) {
354  $result_array['parsedsummary'] = $this->formatSummary( $titleObj, $params );
355  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'parsedsummary';
356  }
357 
358  if ( isset( $prop['langlinks'] ) ) {
359  if ( $skin ) {
360  $langlinks = $outputPage->getLanguageLinks();
361  } else {
362  $langlinks = $p_result->getLanguageLinks();
363  // The deprecated 'effectivelanglinks' option depredates OutputPage
364  // support via 'useskin'. If not already applied, then run just this
365  // one hook of OutputPage::addParserOutputMetadata here.
366  if ( $params['effectivelanglinks'] ) {
367  $linkFlags = [];
368  Hooks::run( 'LanguageLinks', [ $titleObj, &$langlinks, &$linkFlags ] );
369  }
370  }
371 
372  $result_array['langlinks'] = $this->formatLangLinks( $langlinks );
373  }
374  if ( isset( $prop['categories'] ) ) {
375  $result_array['categories'] = $this->formatCategoryLinks( $p_result->getCategories() );
376  }
377  if ( isset( $prop['categorieshtml'] ) ) {
378  $result_array['categorieshtml'] = $outputPage->getSkin()->getCategories();
379  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'categorieshtml';
380  }
381  if ( isset( $prop['links'] ) ) {
382  $result_array['links'] = $this->formatLinks( $p_result->getLinks() );
383  }
384  if ( isset( $prop['templates'] ) ) {
385  $result_array['templates'] = $this->formatLinks( $p_result->getTemplates() );
386  }
387  if ( isset( $prop['images'] ) ) {
388  $result_array['images'] = array_keys( $p_result->getImages() );
389  }
390  if ( isset( $prop['externallinks'] ) ) {
391  $result_array['externallinks'] = array_keys( $p_result->getExternalLinks() );
392  }
393  if ( isset( $prop['sections'] ) ) {
394  $result_array['sections'] = $p_result->getSections();
395  }
396  if ( isset( $prop['parsewarnings'] ) ) {
397  $result_array['parsewarnings'] = $p_result->getWarnings();
398  }
399 
400  if ( isset( $prop['displaytitle'] ) ) {
401  $result_array['displaytitle'] = $p_result->getDisplayTitle() !== false
402  ? $p_result->getDisplayTitle() : $titleObj->getPrefixedText();
403  }
404 
405  if ( isset( $prop['headitems'] ) ) {
406  if ( $skin ) {
407  $result_array['headitems'] = $this->formatHeadItems( $outputPage->getHeadItemsArray() );
408  } else {
409  $result_array['headitems'] = $this->formatHeadItems( $p_result->getHeadItems() );
410  }
411  }
412 
413  if ( isset( $prop['headhtml'] ) ) {
414  $result_array['headhtml'] = $outputPage->headElement( $context->getSkin() );
415  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'headhtml';
416  }
417 
418  if ( isset( $prop['modules'] ) ) {
419  if ( $skin ) {
420  $result_array['modules'] = $outputPage->getModules();
421  // Deprecated since 1.32 (T188689)
422  $result_array['modulescripts'] = [];
423  $result_array['modulestyles'] = $outputPage->getModuleStyles();
424  } else {
425  $result_array['modules'] = array_values( array_unique( $p_result->getModules() ) );
426  // Deprecated since 1.32 (T188689)
427  $result_array['modulescripts'] = [];
428  $result_array['modulestyles'] = array_values( array_unique( $p_result->getModuleStyles() ) );
429  }
430  }
431 
432  if ( isset( $prop['jsconfigvars'] ) ) {
433  $jsconfigvars = $skin ? $outputPage->getJsConfigVars() : $p_result->getJsConfigVars();
434  $result_array['jsconfigvars'] = ApiResult::addMetadataToResultVars( $jsconfigvars );
435  }
436 
437  if ( isset( $prop['encodedjsconfigvars'] ) ) {
438  $jsconfigvars = $skin ? $outputPage->getJsConfigVars() : $p_result->getJsConfigVars();
439  $result_array['encodedjsconfigvars'] = FormatJson::encode(
440  $jsconfigvars,
441  false,
443  );
444  $result_array[ApiResult::META_SUBELEMENTS][] = 'encodedjsconfigvars';
445  }
446 
447  if ( isset( $prop['modules'] ) &&
448  !isset( $prop['jsconfigvars'] ) && !isset( $prop['encodedjsconfigvars'] ) ) {
449  $this->addWarning( 'apiwarn-moduleswithoutvars' );
450  }
451 
452  if ( isset( $prop['indicators'] ) ) {
453  if ( $skin ) {
454  $result_array['indicators'] = (array)$outputPage->getIndicators();
455  } else {
456  $result_array['indicators'] = (array)$p_result->getIndicators();
457  }
458  ApiResult::setArrayType( $result_array['indicators'], 'BCkvp', 'name' );
459  }
460 
461  if ( isset( $prop['iwlinks'] ) ) {
462  $result_array['iwlinks'] = $this->formatIWLinks( $p_result->getInterwikiLinks() );
463  }
464 
465  if ( isset( $prop['wikitext'] ) ) {
466  $result_array['wikitext'] = $this->content->serialize( $format );
467  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'wikitext';
468  if ( !is_null( $this->pstContent ) ) {
469  $result_array['psttext'] = $this->pstContent->serialize( $format );
470  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'psttext';
471  }
472  }
473  if ( isset( $prop['properties'] ) ) {
474  $result_array['properties'] = (array)$p_result->getProperties();
475  ApiResult::setArrayType( $result_array['properties'], 'BCkvp', 'name' );
476  }
477 
478  if ( isset( $prop['limitreportdata'] ) ) {
479  $result_array['limitreportdata'] =
480  $this->formatLimitReportData( $p_result->getLimitReportData() );
481  }
482  if ( isset( $prop['limitreporthtml'] ) ) {
483  $result_array['limitreporthtml'] = EditPage::getPreviewLimitReport( $p_result );
484  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'limitreporthtml';
485  }
486 
487  if ( isset( $prop['parsetree'] ) || $params['generatexml'] ) {
488  if ( $this->content->getModel() != CONTENT_MODEL_WIKITEXT ) {
489  $this->dieWithError( 'apierror-parsetree-notwikitext', 'notwikitext' );
490  }
491 
492  $parser = MediaWikiServices::getInstance()->getParser();
493  $parser->startExternalParse( $titleObj, $popts, Parser::OT_PREPROCESS );
494  $xml = $parser->preprocessToDom( $this->content->getText() )->__toString();
495  $result_array['parsetree'] = $xml;
496  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'parsetree';
497  }
498 
499  $result_mapping = [
500  'redirects' => 'r',
501  'langlinks' => 'll',
502  'categories' => 'cl',
503  'links' => 'pl',
504  'templates' => 'tl',
505  'images' => 'img',
506  'externallinks' => 'el',
507  'iwlinks' => 'iw',
508  'sections' => 's',
509  'headitems' => 'hi',
510  'modules' => 'm',
511  'indicators' => 'ind',
512  'modulescripts' => 'm',
513  'modulestyles' => 'm',
514  'properties' => 'pp',
515  'limitreportdata' => 'lr',
516  'parsewarnings' => 'pw'
517  ];
518  $this->setIndexedTagNames( $result_array, $result_mapping );
519  $result->addValue( null, $this->getModuleName(), $result_array );
520  }
521 
530  protected function makeParserOptions( WikiPage $pageObj, array $params ) {
531  $popts = $pageObj->makeParserOptions( $this->getContext() );
532  $popts->enableLimitReport( !$params['disablepp'] && !$params['disablelimitreport'] );
533  $popts->setIsPreview( $params['preview'] || $params['sectionpreview'] );
534  $popts->setIsSectionPreview( $params['sectionpreview'] );
535  if ( $params['disabletidy'] ) {
536  $popts->setTidy( false );
537  }
538  if ( $params['wrapoutputclass'] !== '' ) {
539  $popts->setWrapOutputClass( $params['wrapoutputclass'] );
540  }
541 
542  $reset = null;
543  $suppressCache = false;
544  Hooks::run( 'ApiMakeParserOptions',
545  [ $popts, $pageObj->getTitle(), $params, $this, &$reset, &$suppressCache ] );
546 
547  // Force cache suppression when $popts aren't cacheable.
548  $suppressCache = $suppressCache || !$popts->isSafeToCache();
549 
550  return [ $popts, $reset, $suppressCache ];
551  }
552 
562  private function getParsedContent(
563  WikiPage $page, $popts, $suppressCache, $pageId, $rev, $getContent
564  ) {
565  $revId = $rev ? $rev->getId() : null;
566  $isDeleted = $rev && $rev->isDeleted( RevisionRecord::DELETED_TEXT );
567 
568  if ( $getContent || $this->section !== false || $isDeleted ) {
569  if ( $rev ) {
570  $this->content = $rev->getContent( RevisionRecord::FOR_THIS_USER, $this->getUser() );
571  if ( !$this->content ) {
572  $this->dieWithError( [ 'apierror-missingcontent-revid', $revId ] );
573  }
574  } else {
575  $this->content = $page->getContent( RevisionRecord::FOR_THIS_USER, $this->getUser() );
576  if ( !$this->content ) {
577  $this->dieWithError( [ 'apierror-missingcontent-pageid', $page->getId() ] );
578  }
579  }
580  $this->contentIsDeleted = $isDeleted;
581  $this->contentIsSuppressed = $rev &&
582  $rev->isDeleted( RevisionRecord::DELETED_TEXT | RevisionRecord::DELETED_RESTRICTED );
583  }
584 
585  if ( $this->section !== false ) {
586  $this->content = $this->getSectionContent(
587  $this->content,
588  $pageId === null ? $page->getTitle()->getPrefixedText() : $this->msg( 'pageid', $pageId )
589  );
590  return $this->content->getParserOutput( $page->getTitle(), $revId, $popts );
591  }
592 
593  if ( $isDeleted ) {
594  // getParserOutput can't do revdeled revisions
595  $pout = $this->content->getParserOutput( $page->getTitle(), $revId, $popts );
596  } else {
597  // getParserOutput will save to Parser cache if able
598  $pout = $page->getParserOutput( $popts, $revId, $suppressCache );
599  }
600  if ( !$pout ) {
601  $this->dieWithError( [ 'apierror-nosuchrevid', $revId ?: $page->getLatest() ] ); // @codeCoverageIgnore
602  }
603 
604  return $pout;
605  }
606 
614  private function getSectionContent( Content $content, $what ) {
615  // Not cached (save or load)
616  $section = $content->getSection( $this->section );
617  if ( $section === false ) {
618  $this->dieWithError( [ 'apierror-nosuchsection-what', $this->section, $what ], 'nosuchsection' );
619  }
620  if ( $section === null ) {
621  $this->dieWithError( [ 'apierror-sectionsnotsupported-what', $what ], 'nosuchsection' );
622  $section = false;
623  }
624 
625  return $section;
626  }
627 
635  private function formatSummary( $title, $params ) {
636  $summary = $params['summary'] ?? '';
637  $sectionTitle = $params['sectiontitle'] ?? '';
638 
639  if ( $this->section === 'new' && ( $sectionTitle === '' || $summary === '' ) ) {
640  if ( $sectionTitle !== '' ) {
641  $summary = $params['sectiontitle'];
642  }
643  if ( $summary !== '' ) {
644  $summary = wfMessage( 'newsectionsummary' )
645  ->rawParams( MediaWikiServices::getInstance()->getParser()
646  ->stripSectionName( $summary ) )
647  ->inContentLanguage()->text();
648  }
649  }
650  return Linker::formatComment( $summary, $title, $this->section === 'new' );
651  }
652 
653  private function formatLangLinks( $links ) {
654  $result = [];
655  foreach ( $links as $link ) {
656  $entry = [];
657  $bits = explode( ':', $link, 2 );
658  $title = Title::newFromText( $link );
659 
660  $entry['lang'] = $bits[0];
661  if ( $title ) {
662  $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
663  // localised language name in 'uselang' language
664  $entry['langname'] = Language::fetchLanguageName(
665  $title->getInterwiki(),
666  $this->getLanguage()->getCode()
667  );
668 
669  // native language name
670  $entry['autonym'] = Language::fetchLanguageName( $title->getInterwiki() );
671  }
672  ApiResult::setContentValue( $entry, 'title', $bits[1] );
673  $result[] = $entry;
674  }
675 
676  return $result;
677  }
678 
679  private function formatCategoryLinks( $links ) {
680  $result = [];
681 
682  if ( !$links ) {
683  return $result;
684  }
685 
686  // Fetch hiddencat property
687  $lb = new LinkBatch;
688  $lb->setArray( [ NS_CATEGORY => $links ] );
689  $db = $this->getDB();
690  $res = $db->select( [ 'page', 'page_props' ],
691  [ 'page_title', 'pp_propname' ],
692  $lb->constructSet( 'page', $db ),
693  __METHOD__,
694  [],
695  [ 'page_props' => [
696  'LEFT JOIN', [ 'pp_propname' => 'hiddencat', 'pp_page = page_id' ]
697  ] ]
698  );
699  $hiddencats = [];
700  foreach ( $res as $row ) {
701  $hiddencats[$row->page_title] = isset( $row->pp_propname );
702  }
703 
704  $linkCache = MediaWikiServices::getInstance()->getLinkCache();
705 
706  foreach ( $links as $link => $sortkey ) {
707  $entry = [];
708  $entry['sortkey'] = $sortkey;
709  // array keys will cast numeric category names to ints, so cast back to string
710  ApiResult::setContentValue( $entry, 'category', (string)$link );
711  if ( !isset( $hiddencats[$link] ) ) {
712  $entry['missing'] = true;
713 
714  // We already know the link doesn't exist in the database, so
715  // tell LinkCache that before calling $title->isKnown().
716  $title = Title::makeTitle( NS_CATEGORY, $link );
717  $linkCache->addBadLinkObj( $title );
718  if ( $title->isKnown() ) {
719  $entry['known'] = true;
720  }
721  } elseif ( $hiddencats[$link] ) {
722  $entry['hidden'] = true;
723  }
724  $result[] = $entry;
725  }
726 
727  return $result;
728  }
729 
730  private function formatLinks( $links ) {
731  $result = [];
732  foreach ( $links as $ns => $nslinks ) {
733  foreach ( $nslinks as $title => $id ) {
734  $entry = [];
735  $entry['ns'] = $ns;
736  ApiResult::setContentValue( $entry, 'title', Title::makeTitle( $ns, $title )->getFullText() );
737  $entry['exists'] = $id != 0;
738  $result[] = $entry;
739  }
740  }
741 
742  return $result;
743  }
744 
745  private function formatIWLinks( $iw ) {
746  $result = [];
747  foreach ( $iw as $prefix => $titles ) {
748  foreach ( array_keys( $titles ) as $title ) {
749  $entry = [];
750  $entry['prefix'] = $prefix;
751 
752  $title = Title::newFromText( "{$prefix}:{$title}" );
753  if ( $title ) {
754  $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
755  }
756 
757  ApiResult::setContentValue( $entry, 'title', $title->getFullText() );
758  $result[] = $entry;
759  }
760  }
761 
762  return $result;
763  }
764 
765  private function formatHeadItems( $headItems ) {
766  $result = [];
767  foreach ( $headItems as $tag => $content ) {
768  $entry = [];
769  $entry['tag'] = $tag;
770  ApiResult::setContentValue( $entry, 'content', $content );
771  $result[] = $entry;
772  }
773 
774  return $result;
775  }
776 
777  private function formatLimitReportData( $limitReportData ) {
778  $result = [];
779 
780  foreach ( $limitReportData as $name => $value ) {
781  $entry = [];
782  $entry['name'] = $name;
783  if ( !is_array( $value ) ) {
784  $value = [ $value ];
785  }
787  $entry = array_merge( $entry, $value );
788  $result[] = $entry;
789  }
790 
791  return $result;
792  }
793 
794  private function setIndexedTagNames( &$array, $mapping ) {
795  foreach ( $mapping as $key => $name ) {
796  if ( isset( $array[$key] ) ) {
797  ApiResult::setIndexedTagName( $array[$key], $name );
798  }
799  }
800  }
801 
802  public function getAllowedParams() {
803  return [
804  'title' => null,
805  'text' => [
806  ApiBase::PARAM_TYPE => 'text',
807  ],
808  'revid' => [
809  ApiBase::PARAM_TYPE => 'integer',
810  ],
811  'summary' => null,
812  'page' => null,
813  'pageid' => [
814  ApiBase::PARAM_TYPE => 'integer',
815  ],
816  'redirects' => false,
817  'oldid' => [
818  ApiBase::PARAM_TYPE => 'integer',
819  ],
820  'prop' => [
821  ApiBase::PARAM_DFLT => 'text|langlinks|categories|links|templates|' .
822  'images|externallinks|sections|revid|displaytitle|iwlinks|' .
823  'properties|parsewarnings',
824  ApiBase::PARAM_ISMULTI => true,
826  'text',
827  'langlinks',
828  'categories',
829  'categorieshtml',
830  'links',
831  'templates',
832  'images',
833  'externallinks',
834  'sections',
835  'revid',
836  'displaytitle',
837  'headhtml',
838  'modules',
839  'jsconfigvars',
840  'encodedjsconfigvars',
841  'indicators',
842  'iwlinks',
843  'wikitext',
844  'properties',
845  'limitreportdata',
846  'limitreporthtml',
847  'parsetree',
848  'parsewarnings',
849  'headitems',
850  ],
852  'parsetree' => [ 'apihelp-parse-paramvalue-prop-parsetree', CONTENT_MODEL_WIKITEXT ],
853  ],
855  'headitems' => 'apiwarn-deprecation-parse-headitems',
856  ],
857  ],
858  'wrapoutputclass' => 'mw-parser-output',
859  'pst' => false,
860  'onlypst' => false,
861  'effectivelanglinks' => [
862  ApiBase::PARAM_DFLT => false,
864  ],
865  'section' => null,
866  'sectiontitle' => [
867  ApiBase::PARAM_TYPE => 'string',
868  ],
869  'disablepp' => [
870  ApiBase::PARAM_DFLT => false,
872  ],
873  'disablelimitreport' => false,
874  'disableeditsection' => false,
875  'disabletidy' => [
876  ApiBase::PARAM_DFLT => false,
877  ApiBase::PARAM_DEPRECATED => true, // Since 1.32
878  ],
879  'disablestylededuplication' => false,
880  'generatexml' => [
881  ApiBase::PARAM_DFLT => false,
883  'apihelp-parse-param-generatexml', CONTENT_MODEL_WIKITEXT
884  ],
886  ],
887  'preview' => false,
888  'sectionpreview' => false,
889  'disabletoc' => false,
890  'useskin' => [
891  ApiBase::PARAM_TYPE => array_keys( Skin::getAllowedSkins() ),
892  ],
893  'contentformat' => [
895  ],
896  'contentmodel' => [
898  ]
899  ];
900  }
901 
902  protected function getExamplesMessages() {
903  return [
904  'action=parse&page=Project:Sandbox'
905  => 'apihelp-parse-example-page',
906  'action=parse&text={{Project:Sandbox}}&contentmodel=wikitext'
907  => 'apihelp-parse-example-text',
908  'action=parse&text={{PAGENAME}}&title=Test'
909  => 'apihelp-parse-example-texttitle',
910  'action=parse&summary=Some+[[link]]&prop='
911  => 'apihelp-parse-example-summary',
912  ];
913  }
914 
915  public function getHelpUrls() {
916  return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Parsing_wikitext#parse';
917  }
918 }
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:138
getExamplesMessages()
Definition: ApiParse.php:902
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below...
Definition: ApiBase.php:94
setArray( $array)
Set the link list to a given 2-d array First key is the namespace, second is the DB key...
Definition: LinkBatch.php:100
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
formatCategoryLinks( $links)
Definition: ApiParse.php:679
getResult()
Get the result object.
Definition: ApiBase.php:640
static normalizeKey( $key)
Normalize a skin preference value to a form that can be loaded.
Definition: Skin.php:102
const CONTENT_MODEL_WIKITEXT
Definition: Defines.php:215
getLatest()
Get the page_latest field.
Definition: WikiPage.php:710
getParsedContent(WikiPage $page, $popts, $suppressCache, $pageId, $rev, $getContent)
Definition: ApiParse.php:562
This class contains a list of pages that the client has requested.
Definition: ApiPageSet.php:40
static getAllContentFormats()
per default it will return the text for text based content
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
Definition: ApiBase.php:55
getMain()
Get the main module.
Definition: ApiBase.php:536
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
static getContentModels()
getDB()
Gets a default replica DB connection object.
Definition: ApiBase.php:668
An IContextSource implementation which will inherit context from another source but allow individual ...
formatSummary( $title, $params)
This mimicks the behavior of EditPage in formatting a summary.
Definition: ApiParse.php:635
const ALL_OK
Skip escaping as many characters as reasonably possible.
Definition: FormatJson.php:55
$value
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
Definition: ApiBase.php:2009
formatHeadItems( $headItems)
Definition: ApiParse.php:765
const PROTO_CURRENT
Definition: Defines.php:202
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user...
Definition: ApiBase.php:761
dieWithException( $exception, array $options=[])
Abort execution with an error derived from an exception.
Definition: ApiBase.php:2021
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
static encode( $value, $pretty=false, $escaping=0)
Returns the JSON representation of a value.
Definition: FormatJson.php:115
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, this is an array mapping those values to $msg...
Definition: ApiBase.php:164
formatLimitReportData( $limitReportData)
Definition: ApiParse.php:777
setIndexedTagNames(&$array, $mapping)
Definition: ApiParse.php:794
static setContentValue(array &$arr, $name, $value, $flags=0)
Add an output value to the array by name and mark as META_CONTENT.
Definition: ApiResult.php:478
IContextSource $context
see documentation in includes Linker php for Linker::makeImageLink or false for current used if you return false $parser
Definition: hooks.txt:1781
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
Definition: ApiResult.php:616
const OT_PREPROCESS
Definition: Parser.php:116
getSection( $sectionId)
Returns the section with the given ID.
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImgAuthModifyHeaders':Executed just before a file is streamed to a user via img_auth.php, allowing headers to be modified beforehand. $title:LinkTarget object & $headers:HTTP headers(name=> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\*-\*)") will be honored when streaming the file. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED since 1.28! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1970
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:3039
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:34
formatIWLinks( $iw)
Definition: ApiParse.php:745
getSectionContent(Content $content, $what)
Extract the requested section from the given Content.
Definition: ApiParse.php:614
formatLinks( $links)
Definition: ApiParse.php:730
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
static formatComment( $comment, $title=null, $local=false, $wikiId=null)
This function is called by all recent changes variants, by the page history, and by the user contribu...
Definition: Linker.php:1160
formatLangLinks( $links)
Definition: ApiParse.php:653
static getPreviewLimitReport(ParserOutput $output=null)
Get the Limit report for page previews.
Definition: EditPage.php:3671
getHelpUrls()
Definition: ApiParse.php:915
$res
Definition: database.txt:21
static addMetadataToResultVars( $vars, $forceHash=true)
Add the correct metadata to an array of vars we want to export through the API.
Definition: ApiResult.php:1150
getContext()
Get the base IContextSource object.
$params
getTitle()
Get the title object of the article.
Definition: WikiPage.php:294
const NS_CATEGORY
Definition: Defines.php:74
This is the main API class, used for both external and internal processing.
Definition: ApiMain.php:41
bool $contentIsDeleted
Definition: ApiParse.php:41
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition: hooks.txt:767
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:912
getModuleName()
Get the name of the module being executed by this instance.
Definition: ApiBase.php:520
bool $contentIsSuppressed
Definition: ApiParse.php:41
execute()
Definition: ApiParse.php:43
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned $skin
Definition: hooks.txt:1972
checkTitleUserPermissions(LinkTarget $linkTarget, $actions, $options=[])
Helper function for permission-denied errors.
Definition: ApiBase.php:2148
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
Definition: hooks.txt:1748
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
requireMaxOneParameter( $params, $required)
Die if more than one of a certain set of parameters is set and not false.
Definition: ApiBase.php:931
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter...
Definition: ApiBase.php:131
static setIndexedTagNameRecursive(array &$arr, $tag)
Set indexed tag name on $arr and all subarrays.
Definition: ApiResult.php:641
makeParserOptions( $context)
Get parser options suitable for rendering the primary article wikitext.
Definition: WikiPage.php:1957
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:592
static fetchLanguageName( $code, $inLanguage=self::AS_AUTONYMS, $include=self::ALL)
Definition: Language.php:937
getTitleOrPageId( $params, $load=false)
Get a WikiPage object from a title or pageid param, if possible.
Definition: ApiBase.php:1034
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
this hook is for auditing only $req
Definition: hooks.txt:960
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles
Definition: linkcache.txt:17
getAllowedParams()
Definition: ApiParse.php:802
const META_SUBELEMENTS
Key for the &#39;subelements&#39; metadata item.
Definition: ApiResult.php:78
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
Definition: ApiBase.php:1928
const PARAM_DEPRECATED_VALUES
(array) When PARAM_TYPE is an array, this indicates which of the values are deprecated.
Definition: ApiBase.php:209
getContent( $audience=RevisionRecord::FOR_PUBLIC, User $user=null)
Get the content of the current revision.
Definition: WikiPage.php:816
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
Definition: ApiBase.php:58
This abstract class implements many basic API functions, and is the base of all API classes...
Definition: ApiBase.php:42
getParserOutput(ParserOptions $parserOptions, $oldid=null, $forceParse=false)
Get a ParserOutput for the given ParserOptions and revision ID.
Definition: WikiPage.php:1229
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
const PARAM_DEPRECATED
(boolean) Is the parameter deprecated (will show a warning)?
Definition: ApiBase.php:112
static newFromTitle( $title, IContextSource $context)
Create an Article object of the appropriate class for the given page.
Definition: Article.php:160
if(! $wgRequest->checkUrlExtension()) if(isset( $_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] !='') $wgTitle
Definition: api.php:57
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
Definition: ApiResult.php:728
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Definition: Revision.php:118
makeParserOptions(WikiPage $pageObj, array $params)
Constructs a ParserOptions object.
Definition: ApiParse.php:530
const META_BC_SUBELEMENTS
Key for the &#39;BC subelements&#39; metadata item.
Definition: ApiResult.php:143
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
static getAllowedSkins()
Fetch the list of user-selectable skins in regards to $wgSkipSkins.
Definition: Skin.php:81
Exception representing a failure to serialize or unserialize a content object.
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
Definition: ApiMessage.php:40
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:322