MediaWiki  1.32.5
ApiParse.php
Go to the documentation of this file.
1 <?php
24 
28 class ApiParse extends ApiBase {
29 
31  private $section = null;
32 
34  private $content = null;
35 
37  private $pstContent = null;
38 
40  private $contentIsDeleted = false, $contentIsSuppressed = false;
41 
42  public function execute() {
43  // The data is hot but user-dependent, like page views, so we set vary cookies
44  $this->getMain()->setCacheMode( 'anon-public-user-private' );
45 
46  // Get parameters
47  $params = $this->extractRequestParams();
48 
49  // No easy way to say that text and title or revid are allowed together
50  // while the rest aren't, so just do it in three calls.
51  $this->requireMaxOneParameter( $params, 'page', 'pageid', 'oldid', 'text' );
52  $this->requireMaxOneParameter( $params, 'page', 'pageid', 'oldid', 'title' );
53  $this->requireMaxOneParameter( $params, 'page', 'pageid', 'oldid', 'revid' );
54 
55  $text = $params['text'];
56  $title = $params['title'];
57  if ( $title === null ) {
58  $titleProvided = false;
59  // A title is needed for parsing, so arbitrarily choose one
60  $title = 'API';
61  } else {
62  $titleProvided = true;
63  }
64 
65  $page = $params['page'];
66  $pageid = $params['pageid'];
67  $oldid = $params['oldid'];
68 
69  $model = $params['contentmodel'];
70  $format = $params['contentformat'];
71 
72  $prop = array_flip( $params['prop'] );
73 
74  if ( isset( $params['section'] ) ) {
75  $this->section = $params['section'];
76  if ( !preg_match( '/^((T-)?\d+|new)$/', $this->section ) ) {
77  $this->dieWithError( 'apierror-invalidsection' );
78  }
79  } else {
80  $this->section = false;
81  }
82 
83  // The parser needs $wgTitle to be set, apparently the
84  // $title parameter in Parser::parse isn't enough *sigh*
85  // TODO: Does this still need $wgTitle?
86  global $wgParser, $wgTitle;
87 
88  $redirValues = null;
89 
90  $needContent = isset( $prop['wikitext'] ) ||
91  isset( $prop['parsetree'] ) || $params['generatexml'];
92 
93  // Return result
94  $result = $this->getResult();
95 
96  if ( !is_null( $oldid ) || !is_null( $pageid ) || !is_null( $page ) ) {
97  if ( $this->section === 'new' ) {
98  $this->dieWithError( 'apierror-invalidparammix-parse-new-section', 'invalidparammix' );
99  }
100  if ( !is_null( $oldid ) ) {
101  // Don't use the parser cache
102  $rev = Revision::newFromId( $oldid );
103  if ( !$rev ) {
104  $this->dieWithError( [ 'apierror-nosuchrevid', $oldid ] );
105  }
106 
107  $this->checkTitleUserPermissions( $rev->getTitle(), 'read' );
108  if ( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
109  $this->dieWithError(
110  [ 'apierror-permissiondenied', $this->msg( 'action-deletedtext' ) ]
111  );
112  }
113 
114  $titleObj = $rev->getTitle();
115  $wgTitle = $titleObj;
116  $pageObj = WikiPage::factory( $titleObj );
117  list( $popts, $reset, $suppressCache ) = $this->makeParserOptions( $pageObj, $params );
118  $p_result = $this->getParsedContent(
119  $pageObj, $popts, $suppressCache, $pageid, $rev, $needContent
120  );
121  } else { // Not $oldid, but $pageid or $page
122  if ( $params['redirects'] ) {
123  $reqParams = [
124  'redirects' => '',
125  ];
126  if ( !is_null( $pageid ) ) {
127  $reqParams['pageids'] = $pageid;
128  } else { // $page
129  $reqParams['titles'] = $page;
130  }
131  $req = new FauxRequest( $reqParams );
132  $main = new ApiMain( $req );
133  $pageSet = new ApiPageSet( $main );
134  $pageSet->execute();
135  $redirValues = $pageSet->getRedirectTitlesAsResult( $this->getResult() );
136 
137  $to = $page;
138  foreach ( $pageSet->getRedirectTitles() as $title ) {
139  $to = $title->getFullText();
140  }
141  $pageParams = [ 'title' => $to ];
142  } elseif ( !is_null( $pageid ) ) {
143  $pageParams = [ 'pageid' => $pageid ];
144  } else { // $page
145  $pageParams = [ 'title' => $page ];
146  }
147 
148  $pageObj = $this->getTitleOrPageId( $pageParams, 'fromdb' );
149  $titleObj = $pageObj->getTitle();
150  if ( !$titleObj || !$titleObj->exists() ) {
151  $this->dieWithError( 'apierror-missingtitle' );
152  }
153 
154  $this->checkTitleUserPermissions( $titleObj, 'read' );
155  $wgTitle = $titleObj;
156 
157  if ( isset( $prop['revid'] ) ) {
158  $oldid = $pageObj->getLatest();
159  }
160 
161  list( $popts, $reset, $suppressCache ) = $this->makeParserOptions( $pageObj, $params );
162  $p_result = $this->getParsedContent(
163  $pageObj, $popts, $suppressCache, $pageid, null, $needContent
164  );
165  }
166  } else { // Not $oldid, $pageid, $page. Hence based on $text
167  $titleObj = Title::newFromText( $title );
168  if ( !$titleObj || $titleObj->isExternal() ) {
169  $this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $title ) ] );
170  }
171  $revid = $params['revid'];
172  if ( $revid !== null ) {
173  $rev = Revision::newFromId( $revid );
174  if ( !$rev ) {
175  $this->dieWithError( [ 'apierror-nosuchrevid', $revid ] );
176  }
177  $pTitleObj = $titleObj;
178  $titleObj = $rev->getTitle();
179  if ( $titleProvided ) {
180  if ( !$titleObj->equals( $pTitleObj ) ) {
181  $this->addWarning( [ 'apierror-revwrongpage', $rev->getId(),
182  wfEscapeWikiText( $pTitleObj->getPrefixedText() ) ] );
183  }
184  } else {
185  // Consider the title derived from the revid as having
186  // been provided.
187  $titleProvided = true;
188  }
189  }
190  $wgTitle = $titleObj;
191  if ( $titleObj->canExist() ) {
192  $pageObj = WikiPage::factory( $titleObj );
193  } else {
194  // Do like MediaWiki::initializeArticle()
195  $article = Article::newFromTitle( $titleObj, $this->getContext() );
196  $pageObj = $article->getPage();
197  }
198 
199  list( $popts, $reset ) = $this->makeParserOptions( $pageObj, $params );
200  $textProvided = !is_null( $text );
201 
202  if ( !$textProvided ) {
203  if ( $titleProvided && ( $prop || $params['generatexml'] ) ) {
204  if ( $revid !== null ) {
205  $this->addWarning( 'apiwarn-parse-revidwithouttext' );
206  } else {
207  $this->addWarning( 'apiwarn-parse-titlewithouttext' );
208  }
209  }
210  // Prevent warning from ContentHandler::makeContent()
211  $text = '';
212  }
213 
214  // If we are parsing text, do not use the content model of the default
215  // API title, but default to wikitext to keep BC.
216  if ( $textProvided && !$titleProvided && is_null( $model ) ) {
217  $model = CONTENT_MODEL_WIKITEXT;
218  $this->addWarning( [ 'apiwarn-parse-nocontentmodel', $model ] );
219  }
220 
221  try {
222  $this->content = ContentHandler::makeContent( $text, $titleObj, $model, $format );
223  } catch ( MWContentSerializationException $ex ) {
224  $this->dieWithException( $ex, [
225  'wrap' => ApiMessage::create( 'apierror-contentserializationexception', 'parseerror' )
226  ] );
227  }
228 
229  if ( $this->section !== false ) {
230  if ( $this->section === 'new' ) {
231  // Insert the section title above the content.
232  if ( !is_null( $params['sectiontitle'] ) && $params['sectiontitle'] !== '' ) {
233  $this->content = $this->content->addSectionHeader( $params['sectiontitle'] );
234  }
235  } else {
236  $this->content = $this->getSectionContent( $this->content, $titleObj->getPrefixedText() );
237  }
238  }
239 
240  if ( $params['pst'] || $params['onlypst'] ) {
241  $this->pstContent = $this->content->preSaveTransform( $titleObj, $this->getUser(), $popts );
242  }
243  if ( $params['onlypst'] ) {
244  // Build a result and bail out
245  $result_array = [];
246  $result_array['text'] = $this->pstContent->serialize( $format );
247  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'text';
248  if ( isset( $prop['wikitext'] ) ) {
249  $result_array['wikitext'] = $this->content->serialize( $format );
250  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'wikitext';
251  }
252  if ( !is_null( $params['summary'] ) ||
253  ( !is_null( $params['sectiontitle'] ) && $this->section === 'new' )
254  ) {
255  $result_array['parsedsummary'] = $this->formatSummary( $titleObj, $params );
256  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'parsedsummary';
257  }
258 
259  $result->addValue( null, $this->getModuleName(), $result_array );
260 
261  return;
262  }
263 
264  // Not cached (save or load)
265  if ( $params['pst'] ) {
266  $p_result = $this->pstContent->getParserOutput( $titleObj, $revid, $popts );
267  } else {
268  $p_result = $this->content->getParserOutput( $titleObj, $revid, $popts );
269  }
270  }
271 
272  $result_array = [];
273 
274  $result_array['title'] = $titleObj->getPrefixedText();
275  $result_array['pageid'] = $pageid ?: $pageObj->getId();
276  if ( $this->contentIsDeleted ) {
277  $result_array['textdeleted'] = true;
278  }
279  if ( $this->contentIsSuppressed ) {
280  $result_array['textsuppressed'] = true;
281  }
282 
283  if ( isset( $params['useskin'] ) ) {
284  $factory = MediaWikiServices::getInstance()->getSkinFactory();
285  $skin = $factory->makeSkin( Skin::normalizeKey( $params['useskin'] ) );
286  } else {
287  $skin = null;
288  }
289 
290  $outputPage = null;
291  if ( $skin || isset( $prop['headhtml'] ) || isset( $prop['categorieshtml'] ) ) {
292  // Enabling the skin via 'useskin', 'headhtml', or 'categorieshtml'
293  // gets OutputPage and Skin involved, which (among others) applies
294  // these hooks:
295  // - ParserOutputHooks
296  // - Hook: LanguageLinks
297  // - Hook: OutputPageParserOutput
298  // - Hook: OutputPageMakeCategoryLinks
299  $context = new DerivativeContext( $this->getContext() );
300  $context->setTitle( $titleObj );
301  $context->setWikiPage( $pageObj );
302 
303  if ( $skin ) {
304  // Use the skin specified by 'useskin'
305  $context->setSkin( $skin );
306  // Context clones the skin, refetch to stay in sync. (T166022)
307  $skin = $context->getSkin();
308  } else {
309  // Make sure the context's skin refers to the context. Without this,
310  // $outputPage->getSkin()->getOutput() !== $outputPage which
311  // confuses some of the output.
312  $context->setSkin( $context->getSkin() );
313  }
314 
315  $outputPage = new OutputPage( $context );
316  $outputPage->addParserOutputMetadata( $p_result );
317  if ( $this->content ) {
318  $outputPage->addContentOverride( $titleObj, $this->content );
319  }
320  $context->setOutput( $outputPage );
321 
322  if ( $skin ) {
323  // Based on OutputPage::headElement()
324  $skin->setupSkinUserCss( $outputPage );
325  // Based on OutputPage::output()
326  $outputPage->loadSkinModules( $skin );
327  }
328 
329  Hooks::run( 'ApiParseMakeOutputPage', [ $this, $outputPage ] );
330  }
331 
332  if ( !is_null( $oldid ) ) {
333  $result_array['revid'] = intval( $oldid );
334  }
335 
336  if ( $params['redirects'] && !is_null( $redirValues ) ) {
337  $result_array['redirects'] = $redirValues;
338  }
339 
340  if ( isset( $prop['text'] ) ) {
341  $result_array['text'] = $p_result->getText( [
342  'allowTOC' => !$params['disabletoc'],
343  'enableSectionEditLinks' => !$params['disableeditsection'],
344  'wrapperDivClass' => $params['wrapoutputclass'],
345  'deduplicateStyles' => !$params['disablestylededuplication'],
346  ] );
347  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'text';
348  }
349 
350  if ( !is_null( $params['summary'] ) ||
351  ( !is_null( $params['sectiontitle'] ) && $this->section === 'new' )
352  ) {
353  $result_array['parsedsummary'] = $this->formatSummary( $titleObj, $params );
354  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'parsedsummary';
355  }
356 
357  if ( isset( $prop['langlinks'] ) ) {
358  if ( $skin ) {
359  $langlinks = $outputPage->getLanguageLinks();
360  } else {
361  $langlinks = $p_result->getLanguageLinks();
362  // The deprecated 'effectivelanglinks' option depredates OutputPage
363  // support via 'useskin'. If not already applied, then run just this
364  // one hook of OutputPage::addParserOutputMetadata here.
365  if ( $params['effectivelanglinks'] ) {
366  $linkFlags = [];
367  Hooks::run( 'LanguageLinks', [ $titleObj, &$langlinks, &$linkFlags ] );
368  }
369  }
370 
371  $result_array['langlinks'] = $this->formatLangLinks( $langlinks );
372  }
373  if ( isset( $prop['categories'] ) ) {
374  $result_array['categories'] = $this->formatCategoryLinks( $p_result->getCategories() );
375  }
376  if ( isset( $prop['categorieshtml'] ) ) {
377  $result_array['categorieshtml'] = $outputPage->getSkin()->getCategories();
378  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'categorieshtml';
379  }
380  if ( isset( $prop['links'] ) ) {
381  $result_array['links'] = $this->formatLinks( $p_result->getLinks() );
382  }
383  if ( isset( $prop['templates'] ) ) {
384  $result_array['templates'] = $this->formatLinks( $p_result->getTemplates() );
385  }
386  if ( isset( $prop['images'] ) ) {
387  $result_array['images'] = array_keys( $p_result->getImages() );
388  }
389  if ( isset( $prop['externallinks'] ) ) {
390  $result_array['externallinks'] = array_keys( $p_result->getExternalLinks() );
391  }
392  if ( isset( $prop['sections'] ) ) {
393  $result_array['sections'] = $p_result->getSections();
394  }
395  if ( isset( $prop['parsewarnings'] ) ) {
396  $result_array['parsewarnings'] = $p_result->getWarnings();
397  }
398 
399  if ( isset( $prop['displaytitle'] ) ) {
400  $result_array['displaytitle'] = $p_result->getDisplayTitle() !== false
401  ? $p_result->getDisplayTitle() : $titleObj->getPrefixedText();
402  }
403 
404  if ( isset( $prop['headitems'] ) ) {
405  if ( $skin ) {
406  $result_array['headitems'] = $this->formatHeadItems( $outputPage->getHeadItemsArray() );
407  } else {
408  $result_array['headitems'] = $this->formatHeadItems( $p_result->getHeadItems() );
409  }
410  }
411 
412  if ( isset( $prop['headhtml'] ) ) {
413  $result_array['headhtml'] = $outputPage->headElement( $context->getSkin() );
414  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'headhtml';
415  }
416 
417  if ( isset( $prop['modules'] ) ) {
418  if ( $skin ) {
419  $result_array['modules'] = $outputPage->getModules();
420  $result_array['modulescripts'] = $outputPage->getModuleScripts();
421  $result_array['modulestyles'] = $outputPage->getModuleStyles();
422  } else {
423  $result_array['modules'] = array_values( array_unique( $p_result->getModules() ) );
424  $result_array['modulescripts'] = array_values( array_unique( $p_result->getModuleScripts() ) );
425  $result_array['modulestyles'] = array_values( array_unique( $p_result->getModuleStyles() ) );
426  }
427  }
428 
429  if ( isset( $prop['jsconfigvars'] ) ) {
430  $jsconfigvars = $skin ? $outputPage->getJsConfigVars() : $p_result->getJsConfigVars();
431  $result_array['jsconfigvars'] = ApiResult::addMetadataToResultVars( $jsconfigvars );
432  }
433 
434  if ( isset( $prop['encodedjsconfigvars'] ) ) {
435  $jsconfigvars = $skin ? $outputPage->getJsConfigVars() : $p_result->getJsConfigVars();
436  $result_array['encodedjsconfigvars'] = FormatJson::encode(
437  $jsconfigvars,
438  false,
440  );
441  $result_array[ApiResult::META_SUBELEMENTS][] = 'encodedjsconfigvars';
442  }
443 
444  if ( isset( $prop['modules'] ) &&
445  !isset( $prop['jsconfigvars'] ) && !isset( $prop['encodedjsconfigvars'] ) ) {
446  $this->addWarning( 'apiwarn-moduleswithoutvars' );
447  }
448 
449  if ( isset( $prop['indicators'] ) ) {
450  if ( $skin ) {
451  $result_array['indicators'] = (array)$outputPage->getIndicators();
452  } else {
453  $result_array['indicators'] = (array)$p_result->getIndicators();
454  }
455  ApiResult::setArrayType( $result_array['indicators'], 'BCkvp', 'name' );
456  }
457 
458  if ( isset( $prop['iwlinks'] ) ) {
459  $result_array['iwlinks'] = $this->formatIWLinks( $p_result->getInterwikiLinks() );
460  }
461 
462  if ( isset( $prop['wikitext'] ) ) {
463  $result_array['wikitext'] = $this->content->serialize( $format );
464  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'wikitext';
465  if ( !is_null( $this->pstContent ) ) {
466  $result_array['psttext'] = $this->pstContent->serialize( $format );
467  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'psttext';
468  }
469  }
470  if ( isset( $prop['properties'] ) ) {
471  $result_array['properties'] = (array)$p_result->getProperties();
472  ApiResult::setArrayType( $result_array['properties'], 'BCkvp', 'name' );
473  }
474 
475  if ( isset( $prop['limitreportdata'] ) ) {
476  $result_array['limitreportdata'] =
477  $this->formatLimitReportData( $p_result->getLimitReportData() );
478  }
479  if ( isset( $prop['limitreporthtml'] ) ) {
480  $result_array['limitreporthtml'] = EditPage::getPreviewLimitReport( $p_result );
481  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'limitreporthtml';
482  }
483 
484  if ( isset( $prop['parsetree'] ) || $params['generatexml'] ) {
485  if ( $this->content->getModel() != CONTENT_MODEL_WIKITEXT ) {
486  $this->dieWithError( 'apierror-parsetree-notwikitext', 'notwikitext' );
487  }
488 
489  $wgParser->startExternalParse( $titleObj, $popts, Parser::OT_PREPROCESS );
490  $xml = $wgParser->preprocessToDom( $this->content->getNativeData() )->__toString();
491  $result_array['parsetree'] = $xml;
492  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'parsetree';
493  }
494 
495  $result_mapping = [
496  'redirects' => 'r',
497  'langlinks' => 'll',
498  'categories' => 'cl',
499  'links' => 'pl',
500  'templates' => 'tl',
501  'images' => 'img',
502  'externallinks' => 'el',
503  'iwlinks' => 'iw',
504  'sections' => 's',
505  'headitems' => 'hi',
506  'modules' => 'm',
507  'indicators' => 'ind',
508  'modulescripts' => 'm',
509  'modulestyles' => 'm',
510  'properties' => 'pp',
511  'limitreportdata' => 'lr',
512  'parsewarnings' => 'pw'
513  ];
514  $this->setIndexedTagNames( $result_array, $result_mapping );
515  $result->addValue( null, $this->getModuleName(), $result_array );
516  }
517 
526  protected function makeParserOptions( WikiPage $pageObj, array $params ) {
527  $popts = $pageObj->makeParserOptions( $this->getContext() );
528  $popts->enableLimitReport( !$params['disablepp'] && !$params['disablelimitreport'] );
529  $popts->setIsPreview( $params['preview'] || $params['sectionpreview'] );
530  $popts->setIsSectionPreview( $params['sectionpreview'] );
531  if ( $params['disabletidy'] ) {
532  $popts->setTidy( false );
533  }
534  if ( $params['wrapoutputclass'] !== '' ) {
535  $popts->setWrapOutputClass( $params['wrapoutputclass'] );
536  }
537 
538  $reset = null;
539  $suppressCache = false;
540  Hooks::run( 'ApiMakeParserOptions',
541  [ $popts, $pageObj->getTitle(), $params, $this, &$reset, &$suppressCache ] );
542 
543  // Force cache suppression when $popts aren't cacheable.
544  $suppressCache = $suppressCache || !$popts->isSafeToCache();
545 
546  return [ $popts, $reset, $suppressCache ];
547  }
548 
558  private function getParsedContent(
559  WikiPage $page, $popts, $suppressCache, $pageId, $rev, $getContent
560  ) {
561  $revId = $rev ? $rev->getId() : null;
562  $isDeleted = $rev && $rev->isDeleted( Revision::DELETED_TEXT );
563 
564  if ( $getContent || $this->section !== false || $isDeleted ) {
565  if ( $rev ) {
566  $this->content = $rev->getContent( Revision::FOR_THIS_USER, $this->getUser() );
567  if ( !$this->content ) {
568  $this->dieWithError( [ 'apierror-missingcontent-revid', $revId ] );
569  }
570  } else {
571  $this->content = $page->getContent( Revision::FOR_THIS_USER, $this->getUser() );
572  if ( !$this->content ) {
573  $this->dieWithError( [ 'apierror-missingcontent-pageid', $page->getId() ] );
574  }
575  }
576  $this->contentIsDeleted = $isDeleted;
577  $this->contentIsSuppressed = $rev &&
579  }
580 
581  if ( $this->section !== false ) {
582  $this->content = $this->getSectionContent(
583  $this->content,
584  $pageId === null ? $page->getTitle()->getPrefixedText() : $this->msg( 'pageid', $pageId )
585  );
586  return $this->content->getParserOutput( $page->getTitle(), $revId, $popts );
587  }
588 
589  if ( $isDeleted ) {
590  // getParserOutput can't do revdeled revisions
591  $pout = $this->content->getParserOutput( $page->getTitle(), $revId, $popts );
592  } else {
593  // getParserOutput will save to Parser cache if able
594  $pout = $page->getParserOutput( $popts, $revId, $suppressCache );
595  }
596  if ( !$pout ) {
597  $this->dieWithError( [ 'apierror-nosuchrevid', $revId ?: $page->getLatest() ] ); // @codeCoverageIgnore
598  }
599 
600  return $pout;
601  }
602 
610  private function getSectionContent( Content $content, $what ) {
611  // Not cached (save or load)
612  $section = $content->getSection( $this->section );
613  if ( $section === false ) {
614  $this->dieWithError( [ 'apierror-nosuchsection-what', $this->section, $what ], 'nosuchsection' );
615  }
616  if ( $section === null ) {
617  $this->dieWithError( [ 'apierror-sectionsnotsupported-what', $what ], 'nosuchsection' );
618  $section = false;
619  }
620 
621  return $section;
622  }
623 
631  private function formatSummary( $title, $params ) {
632  global $wgParser;
633  $summary = !is_null( $params['summary'] ) ? $params['summary'] : '';
634  $sectionTitle = !is_null( $params['sectiontitle'] ) ? $params['sectiontitle'] : '';
635 
636  if ( $this->section === 'new' && ( $sectionTitle === '' || $summary === '' ) ) {
637  if ( $sectionTitle !== '' ) {
638  $summary = $params['sectiontitle'];
639  }
640  if ( $summary !== '' ) {
641  $summary = wfMessage( 'newsectionsummary' )
642  ->rawParams( $wgParser->stripSectionName( $summary ) )
643  ->inContentLanguage()->text();
644  }
645  }
646  return Linker::formatComment( $summary, $title, $this->section === 'new' );
647  }
648 
649  private function formatLangLinks( $links ) {
650  $result = [];
651  foreach ( $links as $link ) {
652  $entry = [];
653  $bits = explode( ':', $link, 2 );
655 
656  $entry['lang'] = $bits[0];
657  if ( $title ) {
658  $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
659  // localised language name in 'uselang' language
660  $entry['langname'] = Language::fetchLanguageName(
661  $title->getInterwiki(),
662  $this->getLanguage()->getCode()
663  );
664 
665  // native language name
666  $entry['autonym'] = Language::fetchLanguageName( $title->getInterwiki() );
667  }
668  ApiResult::setContentValue( $entry, 'title', $bits[1] );
669  $result[] = $entry;
670  }
671 
672  return $result;
673  }
674 
675  private function formatCategoryLinks( $links ) {
676  $result = [];
677 
678  if ( !$links ) {
679  return $result;
680  }
681 
682  // Fetch hiddencat property
683  $lb = new LinkBatch;
684  $lb->setArray( [ NS_CATEGORY => $links ] );
685  $db = $this->getDB();
686  $res = $db->select( [ 'page', 'page_props' ],
687  [ 'page_title', 'pp_propname' ],
688  $lb->constructSet( 'page', $db ),
689  __METHOD__,
690  [],
691  [ 'page_props' => [
692  'LEFT JOIN', [ 'pp_propname' => 'hiddencat', 'pp_page = page_id' ]
693  ] ]
694  );
695  $hiddencats = [];
696  foreach ( $res as $row ) {
697  $hiddencats[$row->page_title] = isset( $row->pp_propname );
698  }
699 
700  $linkCache = MediaWikiServices::getInstance()->getLinkCache();
701 
702  foreach ( $links as $link => $sortkey ) {
703  $entry = [];
704  $entry['sortkey'] = $sortkey;
705  // array keys will cast numeric category names to ints, so cast back to string
706  ApiResult::setContentValue( $entry, 'category', (string)$link );
707  if ( !isset( $hiddencats[$link] ) ) {
708  $entry['missing'] = true;
709 
710  // We already know the link doesn't exist in the database, so
711  // tell LinkCache that before calling $title->isKnown().
713  $linkCache->addBadLinkObj( $title );
714  if ( $title->isKnown() ) {
715  $entry['known'] = true;
716  }
717  } elseif ( $hiddencats[$link] ) {
718  $entry['hidden'] = true;
719  }
720  $result[] = $entry;
721  }
722 
723  return $result;
724  }
725 
726  private function formatLinks( $links ) {
727  $result = [];
728  foreach ( $links as $ns => $nslinks ) {
729  foreach ( $nslinks as $title => $id ) {
730  $entry = [];
731  $entry['ns'] = $ns;
732  ApiResult::setContentValue( $entry, 'title', Title::makeTitle( $ns, $title )->getFullText() );
733  $entry['exists'] = $id != 0;
734  $result[] = $entry;
735  }
736  }
737 
738  return $result;
739  }
740 
741  private function formatIWLinks( $iw ) {
742  $result = [];
743  foreach ( $iw as $prefix => $titles ) {
744  foreach ( array_keys( $titles ) as $title ) {
745  $entry = [];
746  $entry['prefix'] = $prefix;
747 
748  $title = Title::newFromText( "{$prefix}:{$title}" );
749  if ( $title ) {
750  $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
751  }
752 
753  ApiResult::setContentValue( $entry, 'title', $title->getFullText() );
754  $result[] = $entry;
755  }
756  }
757 
758  return $result;
759  }
760 
761  private function formatHeadItems( $headItems ) {
762  $result = [];
763  foreach ( $headItems as $tag => $content ) {
764  $entry = [];
765  $entry['tag'] = $tag;
766  ApiResult::setContentValue( $entry, 'content', $content );
767  $result[] = $entry;
768  }
769 
770  return $result;
771  }
772 
773  private function formatLimitReportData( $limitReportData ) {
774  $result = [];
775 
776  foreach ( $limitReportData as $name => $value ) {
777  $entry = [];
778  $entry['name'] = $name;
779  if ( !is_array( $value ) ) {
780  $value = [ $value ];
781  }
783  $entry = array_merge( $entry, $value );
784  $result[] = $entry;
785  }
786 
787  return $result;
788  }
789 
790  private function setIndexedTagNames( &$array, $mapping ) {
791  foreach ( $mapping as $key => $name ) {
792  if ( isset( $array[$key] ) ) {
793  ApiResult::setIndexedTagName( $array[$key], $name );
794  }
795  }
796  }
797 
798  public function getAllowedParams() {
799  return [
800  'title' => null,
801  'text' => [
802  ApiBase::PARAM_TYPE => 'text',
803  ],
804  'revid' => [
805  ApiBase::PARAM_TYPE => 'integer',
806  ],
807  'summary' => null,
808  'page' => null,
809  'pageid' => [
810  ApiBase::PARAM_TYPE => 'integer',
811  ],
812  'redirects' => false,
813  'oldid' => [
814  ApiBase::PARAM_TYPE => 'integer',
815  ],
816  'prop' => [
817  ApiBase::PARAM_DFLT => 'text|langlinks|categories|links|templates|' .
818  'images|externallinks|sections|revid|displaytitle|iwlinks|' .
819  'properties|parsewarnings',
820  ApiBase::PARAM_ISMULTI => true,
822  'text',
823  'langlinks',
824  'categories',
825  'categorieshtml',
826  'links',
827  'templates',
828  'images',
829  'externallinks',
830  'sections',
831  'revid',
832  'displaytitle',
833  'headhtml',
834  'modules',
835  'jsconfigvars',
836  'encodedjsconfigvars',
837  'indicators',
838  'iwlinks',
839  'wikitext',
840  'properties',
841  'limitreportdata',
842  'limitreporthtml',
843  'parsetree',
844  'parsewarnings',
845  'headitems',
846  ],
848  'parsetree' => [ 'apihelp-parse-paramvalue-prop-parsetree', CONTENT_MODEL_WIKITEXT ],
849  ],
851  'headitems' => 'apiwarn-deprecation-parse-headitems',
852  ],
853  ],
854  'wrapoutputclass' => 'mw-parser-output',
855  'pst' => false,
856  'onlypst' => false,
857  'effectivelanglinks' => [
858  ApiBase::PARAM_DFLT => false,
860  ],
861  'section' => null,
862  'sectiontitle' => [
863  ApiBase::PARAM_TYPE => 'string',
864  ],
865  'disablepp' => [
866  ApiBase::PARAM_DFLT => false,
868  ],
869  'disablelimitreport' => false,
870  'disableeditsection' => false,
871  'disabletidy' => [
872  ApiBase::PARAM_DFLT => false,
873  ApiBase::PARAM_DEPRECATED => true, // Since 1.32
874  ],
875  'disablestylededuplication' => false,
876  'generatexml' => [
877  ApiBase::PARAM_DFLT => false,
879  'apihelp-parse-param-generatexml', CONTENT_MODEL_WIKITEXT
880  ],
882  ],
883  'preview' => false,
884  'sectionpreview' => false,
885  'disabletoc' => false,
886  'useskin' => [
887  ApiBase::PARAM_TYPE => array_keys( Skin::getAllowedSkins() ),
888  ],
889  'contentformat' => [
891  ],
892  'contentmodel' => [
894  ]
895  ];
896  }
897 
898  protected function getExamplesMessages() {
899  return [
900  'action=parse&page=Project:Sandbox'
901  => 'apihelp-parse-example-page',
902  'action=parse&text={{Project:Sandbox}}&contentmodel=wikitext'
903  => 'apihelp-parse-example-text',
904  'action=parse&text={{PAGENAME}}&title=Test'
905  => 'apihelp-parse-example-texttitle',
906  'action=parse&summary=Some+[[link]]&prop='
907  => 'apihelp-parse-example-summary',
908  ];
909  }
910 
911  public function getHelpUrls() {
912  return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Parsing_wikitext#parse';
913  }
914 }
Language\fetchLanguageName
static fetchLanguageName( $code, $inLanguage=self::AS_AUTONYMS, $include=self::ALL)
Definition: Language.php:940
ApiMain
This is the main API class, used for both external and internal processing.
Definition: ApiMain.php:41
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:33
ApiParse\formatIWLinks
formatIWLinks( $iw)
Definition: ApiParse.php:741
Revision\DELETED_RESTRICTED
const DELETED_RESTRICTED
Definition: Revision.php:50
$article
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers change it to an object instance and return false override the list derivative used the name of the old file & $article
Definition: hooks.txt:1515
FauxRequest
WebRequest clone which takes values from a provided array.
Definition: FauxRequest.php:33
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:280
ContextSource\getContext
getContext()
Get the base IContextSource object.
Definition: ContextSource.php:40
ApiParse\getParsedContent
getParsedContent(WikiPage $page, $popts, $suppressCache, $pageId, $rev, $getContent)
Definition: ApiParse.php:558
ContentHandler\getAllContentFormats
static getAllContentFormats()
Definition: ContentHandler.php:380
ApiBase\addWarning
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
Definition: ApiBase.php:1906
Revision\newFromId
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Definition: Revision.php:114
content
per default it will return the text for text based content
Definition: contenthandler.txt:104
$wgParser
$wgParser
Definition: Setup.php:921
IContextSource\getSkin
getSkin()
LinkBatch
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:34
ApiParse\formatLangLinks
formatLangLinks( $links)
Definition: ApiParse.php:649
ApiBase\dieWithError
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
Definition: ApiBase.php:1987
ApiBase\PARAM_HELP_MSG
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition: ApiBase.php:124
ContextSource\msg
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:168
$result
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=(\d*-\d*)") 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. 'LanguageGetMagic':DEPRECATED since 1.16! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) '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 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) '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:2042
ApiResult\META_BC_SUBELEMENTS
const META_BC_SUBELEMENTS
Key for the 'BC subelements' metadata item.
Definition: ApiResult.php:143
ApiBase\getTitleOrPageId
getTitleOrPageId( $params, $load=false)
Get a WikiPage object from a title or pageid param, if possible.
Definition: ApiBase.php:1042
ApiBase\PARAM_TYPE
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
Definition: ApiBase.php:87
ApiParse\formatLinks
formatLinks( $links)
Definition: ApiParse.php:726
ApiBase\getResult
getResult()
Get the result object.
Definition: ApiBase.php:659
$req
this hook is for auditing only $req
Definition: hooks.txt:1018
WikiPage
Class representing a MediaWiki article and history.
Definition: WikiPage.php:44
OT_PREPROCESS
const OT_PREPROCESS
Definition: Defines.php:186
$params
$params
Definition: styleTest.css.php:44
WikiPage\makeParserOptions
makeParserOptions( $context)
Get parser options suitable for rendering the primary article wikitext.
Definition: WikiPage.php:1917
ApiBase\getDB
getDB()
Gets a default replica DB connection object.
Definition: ApiBase.php:687
$res
$res
Definition: database.txt:21
$wgTitle
if(! $wgRequest->checkUrlExtension()) if(isset( $_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] !='') $wgTitle
Definition: api.php:57
CONTENT_MODEL_WIKITEXT
const CONTENT_MODEL_WIKITEXT
Definition: Defines.php:235
ApiParse\$contentIsDeleted
bool $contentIsDeleted
Definition: ApiParse.php:40
ApiParse\$section
$section
Definition: ApiParse.php:31
ContextSource\getUser
getUser()
Definition: ContextSource.php:120
ApiBase\PARAM_DEPRECATED_VALUES
const PARAM_DEPRECATED_VALUES
(array) When PARAM_TYPE is an array, this indicates which of the values are deprecated.
Definition: ApiBase.php:202
LinkBatch\setArray
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
FormatJson\ALL_OK
const ALL_OK
Skip escaping as many characters as reasonably possible.
Definition: FormatJson.php:55
ApiPageSet
This class contains a list of pages that the client has requested.
Definition: ApiPageSet.php:40
php
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
ApiBase
This abstract class implements many basic API functions, and is the base of all API classes.
Definition: ApiBase.php:37
ContextSource\getLanguage
getLanguage()
Definition: ContextSource.php:128
Revision\FOR_THIS_USER
const FOR_THIS_USER
Definition: Revision.php:56
ApiResult\setContentValue
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
ApiBase\PARAM_DEPRECATED
const PARAM_DEPRECATED
(boolean) Is the parameter deprecated (will show a warning)?
Definition: ApiBase.php:105
DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition: DerivativeContext.php:30
ApiParse
Definition: ApiParse.php:28
FormatJson\encode
static encode( $value, $pretty=false, $escaping=0)
Returns the JSON representation of a value.
Definition: FormatJson.php:115
ApiParse\$pstContent
$pstContent
Definition: ApiParse.php:37
ApiResult\setArrayType
static setArrayType(array &$arr, $type, $kvpKeyName=null)
Set the array data type.
Definition: ApiResult.php:728
ApiParse\getHelpUrls
getHelpUrls()
Return links to more detailed help pages about the module.
Definition: ApiParse.php:911
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:964
WikiPage\factory
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:127
ApiResult\addMetadataToResultVars
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
$titles
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
Skin\normalizeKey
static normalizeKey( $key)
Normalize a skin preference value to a form that can be loaded.
Definition: Skin.php:101
ContentHandler\getContentModels
static getContentModels()
Definition: ContentHandler.php:372
ApiParse\getAllowedParams
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
Definition: ApiParse.php:798
WikiPage\getParserOutput
getParserOutput(ParserOptions $parserOptions, $oldid=null, $forceParse=false)
Get a ParserOutput for the given ParserOptions and revision ID.
Definition: WikiPage.php:1197
ApiResult\META_SUBELEMENTS
const META_SUBELEMENTS
Key for the 'subelements' metadata item.
Definition: ApiResult.php:78
WikiPage\getId
getId()
Definition: WikiPage.php:578
ApiParse\formatLimitReportData
formatLimitReportData( $limitReportData)
Definition: ApiParse.php:773
EditPage\getPreviewLimitReport
static getPreviewLimitReport(ParserOutput $output=null)
Get the Limit report for page previews.
Definition: EditPage.php:3634
WikiPage\getTitle
getTitle()
Get the title object of the article.
Definition: WikiPage.php:276
MWContentSerializationException
Exception representing a failure to serialize or unserialize a content object.
Definition: MWContentSerializationException.php:7
PROTO_CURRENT
const PROTO_CURRENT
Definition: Defines.php:222
WikiPage\getContent
getContent( $audience=Revision::FOR_PUBLIC, User $user=null)
Get the content of the current revision.
Definition: WikiPage.php:798
ApiBase\dieWithException
dieWithException( $exception, array $options=[])
Abort execution with an error derived from an exception.
Definition: ApiBase.php:1999
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
ApiBase\extractRequestParams
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition: ApiBase.php:770
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:545
NS_CATEGORY
const NS_CATEGORY
Definition: Defines.php:78
WikiPage\getLatest
getLatest()
Get the page_latest field.
Definition: WikiPage.php:692
ApiMessage\create
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
Definition: ApiMessage.php:40
array
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
ApiParse\formatSummary
formatSummary( $title, $params)
This mimicks the behavior of EditPage in formatting a summary.
Definition: ApiParse.php:631
list
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
ContentHandler\makeContent
static makeContent( $text, Title $title=null, $modelId=null, $format=null)
Convenience function for creating a Content object from a given textual representation.
Definition: ContentHandler.php:133
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
ApiParse\formatCategoryLinks
formatCategoryLinks( $links)
Definition: ApiParse.php:675
ApiResult\setIndexedTagName
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
Definition: ApiResult.php:616
$value
$value
Definition: styleTest.css.php:49
ApiParse\setIndexedTagNames
setIndexedTagNames(&$array, $mapping)
Definition: ApiParse.php:790
ApiBase\checkTitleUserPermissions
checkTitleUserPermissions(Title $title, $actions, $user=null)
Helper function for permission-denied errors.
Definition: ApiBase.php:2113
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1617
ApiBase\requireMaxOneParameter
requireMaxOneParameter( $params, $required)
Die if more than one of a certain set of parameters is set and not false.
Definition: ApiBase.php:939
Linker\formatComment
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:1088
Content
Base interface for content objects.
Definition: Content.php:34
ApiBase\PARAM_DFLT
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
Definition: ApiBase.php:48
$rev
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:1808
ApiParse\getExamplesMessages
getExamplesMessages()
Returns usage examples for this module.
Definition: ApiParse.php:898
as
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
ApiBase\getModuleName
getModuleName()
Get the name of the module being executed by this instance.
Definition: ApiBase.php:539
ApiBase\PARAM_ISMULTI
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
Definition: ApiBase.php:51
$skin
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:2044
ApiParse\getSectionContent
getSectionContent(Content $content, $what)
Extract the requested section from the given Content.
Definition: ApiParse.php:610
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:3098
ApiBase\getMain
getMain()
Get the main module.
Definition: ApiBase.php:555
MediaWikiServices
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
Skin\getAllowedSkins
static getAllowedSkins()
Fetch the list of user-selectable skins in regards to $wgSkipSkins.
Definition: Skin.php:80
ApiParse\formatHeadItems
formatHeadItems( $headItems)
Definition: ApiParse.php:761
wfMessage
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
ApiResult\setIndexedTagNameRecursive
static setIndexedTagNameRecursive(array &$arr, $tag)
Set indexed tag name on $arr and all subarrays.
Definition: ApiResult.php:641
ApiBase\PARAM_HELP_MSG_PER_VALUE
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:157
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
ApiParse\makeParserOptions
makeParserOptions(WikiPage $pageObj, array $params)
Constructs a ParserOptions object.
Definition: ApiParse.php:526
ApiParse\$content
$content
Definition: ApiParse.php:34
Revision\DELETED_TEXT
const DELETED_TEXT
Definition: Revision.php:47
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:512
ApiParse\$contentIsSuppressed
bool $contentIsSuppressed
Definition: ApiParse.php:40
ApiParse\execute
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
Definition: ApiParse.php:42
Article\newFromTitle
static newFromTitle( $title, IContextSource $context)
Create an Article object of the appropriate class for the given page.
Definition: Article.php:160