MediaWiki  1.29.1
ApiParse.php
Go to the documentation of this file.
1 <?php
28 class ApiParse extends ApiBase {
29 
31  private $section = null;
32 
34  private $content = null;
35 
37  private $pstContent = null;
38 
39  public function execute() {
40  // The data is hot but user-dependent, like page views, so we set vary cookies
41  $this->getMain()->setCacheMode( 'anon-public-user-private' );
42 
43  // Get parameters
44  $params = $this->extractRequestParams();
45 
46  // No easy way to say that text & title are allowed together while the
47  // rest aren't, so just do it in two calls.
48  $this->requireMaxOneParameter( $params, 'page', 'pageid', 'oldid', 'text' );
49  $this->requireMaxOneParameter( $params, 'page', 'pageid', 'oldid', 'title' );
50 
51  $text = $params['text'];
52  $title = $params['title'];
53  if ( $title === null ) {
54  $titleProvided = false;
55  // A title is needed for parsing, so arbitrarily choose one
56  $title = 'API';
57  } else {
58  $titleProvided = true;
59  }
60 
61  $page = $params['page'];
62  $pageid = $params['pageid'];
63  $oldid = $params['oldid'];
64 
65  $model = $params['contentmodel'];
66  $format = $params['contentformat'];
67 
68  $prop = array_flip( $params['prop'] );
69 
70  if ( isset( $params['section'] ) ) {
71  $this->section = $params['section'];
72  if ( !preg_match( '/^((T-)?\d+|new)$/', $this->section ) ) {
73  $this->dieWithError( 'apierror-invalidsection' );
74  }
75  } else {
76  $this->section = false;
77  }
78 
79  // The parser needs $wgTitle to be set, apparently the
80  // $title parameter in Parser::parse isn't enough *sigh*
81  // TODO: Does this still need $wgTitle?
83 
84  $redirValues = null;
85 
86  // Return result
87  $result = $this->getResult();
88 
89  if ( !is_null( $oldid ) || !is_null( $pageid ) || !is_null( $page ) ) {
90  if ( $this->section === 'new' ) {
91  $this->dieWithError( 'apierror-invalidparammix-parse-new-section', 'invalidparammix' );
92  }
93  if ( !is_null( $oldid ) ) {
94  // Don't use the parser cache
95  $rev = Revision::newFromId( $oldid );
96  if ( !$rev ) {
97  $this->dieWithError( [ 'apierror-nosuchrevid', $oldid ] );
98  }
99 
100  $this->checkTitleUserPermissions( $rev->getTitle(), 'read' );
101  if ( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
102  $this->dieWithError(
103  [ 'apierror-permissiondenied', $this->msg( 'action-deletedtext' ) ]
104  );
105  }
106 
107  $titleObj = $rev->getTitle();
108  $wgTitle = $titleObj;
109  $pageObj = WikiPage::factory( $titleObj );
110  list( $popts, $reset, $suppressCache ) = $this->makeParserOptions( $pageObj, $params );
111 
112  // If for some reason the "oldid" is actually the current revision, it may be cached
113  // Deliberately comparing $pageObj->getLatest() with $rev->getId(), rather than
114  // checking $rev->isCurrent(), because $pageObj is what actually ends up being used,
115  // and if its ->getLatest() is outdated, $rev->isCurrent() won't tell us that.
116  if ( !$suppressCache && $rev->getId() == $pageObj->getLatest() ) {
117  // May get from/save to parser cache
118  $p_result = $this->getParsedContent( $pageObj, $popts,
119  $pageid, isset( $prop['wikitext'] ) );
120  } else { // This is an old revision, so get the text differently
121  $this->content = $rev->getContent( Revision::FOR_THIS_USER, $this->getUser() );
122 
123  if ( $this->section !== false ) {
124  $this->content = $this->getSectionContent(
125  $this->content, $this->msg( 'revid', $rev->getId() )
126  );
127  }
128 
129  // Should we save old revision parses to the parser cache?
130  $p_result = $this->content->getParserOutput( $titleObj, $rev->getId(), $popts );
131  }
132  } else { // Not $oldid, but $pageid or $page
133  if ( $params['redirects'] ) {
134  $reqParams = [
135  'redirects' => '',
136  ];
137  if ( !is_null( $pageid ) ) {
138  $reqParams['pageids'] = $pageid;
139  } else { // $page
140  $reqParams['titles'] = $page;
141  }
142  $req = new FauxRequest( $reqParams );
143  $main = new ApiMain( $req );
144  $pageSet = new ApiPageSet( $main );
145  $pageSet->execute();
146  $redirValues = $pageSet->getRedirectTitlesAsResult( $this->getResult() );
147 
148  $to = $page;
149  foreach ( $pageSet->getRedirectTitles() as $title ) {
150  $to = $title->getFullText();
151  }
152  $pageParams = [ 'title' => $to ];
153  } elseif ( !is_null( $pageid ) ) {
154  $pageParams = [ 'pageid' => $pageid ];
155  } else { // $page
156  $pageParams = [ 'title' => $page ];
157  }
158 
159  $pageObj = $this->getTitleOrPageId( $pageParams, 'fromdb' );
160  $titleObj = $pageObj->getTitle();
161  if ( !$titleObj || !$titleObj->exists() ) {
162  $this->dieWithError( 'apierror-missingtitle' );
163  }
164 
165  $this->checkTitleUserPermissions( $titleObj, 'read' );
166  $wgTitle = $titleObj;
167 
168  if ( isset( $prop['revid'] ) ) {
169  $oldid = $pageObj->getLatest();
170  }
171 
172  list( $popts, $reset, $suppressCache ) = $this->makeParserOptions( $pageObj, $params );
173 
174  // Don't pollute the parser cache when setting options that aren't
175  // in ParserOptions::optionsHash()
177  $suppressCache = $suppressCache ||
178  $params['disablepp'] ||
179  $params['disablelimitreport'] ||
180  $params['preview'] ||
181  $params['sectionpreview'] ||
182  $params['disabletidy'];
183 
184  if ( $suppressCache ) {
185  $this->content = $this->getContent( $pageObj, $pageid );
186  $p_result = $this->content->getParserOutput( $titleObj, null, $popts );
187  } else {
188  // Potentially cached
189  $p_result = $this->getParsedContent( $pageObj, $popts, $pageid,
190  isset( $prop['wikitext'] ) );
191  }
192  }
193  } else { // Not $oldid, $pageid, $page. Hence based on $text
194  $titleObj = Title::newFromText( $title );
195  if ( !$titleObj || $titleObj->isExternal() ) {
196  $this->dieWithError( [ 'apierror-invalidtitle', wfEscapeWikiText( $title ) ] );
197  }
198  $wgTitle = $titleObj;
199  if ( $titleObj->canExist() ) {
200  $pageObj = WikiPage::factory( $titleObj );
201  } else {
202  // Do like MediaWiki::initializeArticle()
203  $article = Article::newFromTitle( $titleObj, $this->getContext() );
204  $pageObj = $article->getPage();
205  }
206 
207  list( $popts, $reset ) = $this->makeParserOptions( $pageObj, $params );
208  $textProvided = !is_null( $text );
209 
210  if ( !$textProvided ) {
211  if ( $titleProvided && ( $prop || $params['generatexml'] ) ) {
212  $this->addWarning( 'apiwarn-parse-titlewithouttext' );
213  }
214  // Prevent warning from ContentHandler::makeContent()
215  $text = '';
216  }
217 
218  // If we are parsing text, do not use the content model of the default
219  // API title, but default to wikitext to keep BC.
220  if ( $textProvided && !$titleProvided && is_null( $model ) ) {
221  $model = CONTENT_MODEL_WIKITEXT;
222  $this->addWarning( [ 'apiwarn-parse-nocontentmodel', $model ] );
223  }
224 
225  try {
226  $this->content = ContentHandler::makeContent( $text, $titleObj, $model, $format );
227  } catch ( MWContentSerializationException $ex ) {
228  $this->dieWithException( $ex, [
229  'wrap' => ApiMessage::create( 'apierror-contentserializationexception', 'parseerror' )
230  ] );
231  }
232 
233  if ( $this->section !== false ) {
234  if ( $this->section === 'new' ) {
235  // Insert the section title above the content.
236  if ( !is_null( $params['sectiontitle'] ) && $params['sectiontitle'] !== '' ) {
237  $this->content = $this->content->addSectionHeader( $params['sectiontitle'] );
238  }
239  } else {
240  $this->content = $this->getSectionContent( $this->content, $titleObj->getPrefixedText() );
241  }
242  }
243 
244  if ( $params['pst'] || $params['onlypst'] ) {
245  $this->pstContent = $this->content->preSaveTransform( $titleObj, $this->getUser(), $popts );
246  }
247  if ( $params['onlypst'] ) {
248  // Build a result and bail out
249  $result_array = [];
250  $result_array['text'] = $this->pstContent->serialize( $format );
251  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'text';
252  if ( isset( $prop['wikitext'] ) ) {
253  $result_array['wikitext'] = $this->content->serialize( $format );
254  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'wikitext';
255  }
256  if ( !is_null( $params['summary'] ) ||
257  ( !is_null( $params['sectiontitle'] ) && $this->section === 'new' )
258  ) {
259  $result_array['parsedsummary'] = $this->formatSummary( $titleObj, $params );
260  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'parsedsummary';
261  }
262 
263  $result->addValue( null, $this->getModuleName(), $result_array );
264 
265  return;
266  }
267 
268  // Not cached (save or load)
269  if ( $params['pst'] ) {
270  $p_result = $this->pstContent->getParserOutput( $titleObj, null, $popts );
271  } else {
272  $p_result = $this->content->getParserOutput( $titleObj, null, $popts );
273  }
274  }
275 
276  $result_array = [];
277 
278  $result_array['title'] = $titleObj->getPrefixedText();
279  $result_array['pageid'] = $pageid ?: $pageObj->getId();
280 
281  if ( !is_null( $oldid ) ) {
282  $result_array['revid'] = intval( $oldid );
283  }
284 
285  if ( $params['redirects'] && !is_null( $redirValues ) ) {
286  $result_array['redirects'] = $redirValues;
287  }
288 
289  if ( $params['disabletoc'] ) {
290  $p_result->setTOCEnabled( false );
291  }
292 
293  if ( isset( $prop['text'] ) ) {
294  $result_array['text'] = $p_result->getText();
295  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'text';
296  }
297 
298  if ( !is_null( $params['summary'] ) ||
299  ( !is_null( $params['sectiontitle'] ) && $this->section === 'new' )
300  ) {
301  $result_array['parsedsummary'] = $this->formatSummary( $titleObj, $params );
302  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'parsedsummary';
303  }
304 
305  if ( isset( $prop['langlinks'] ) ) {
306  $langlinks = $p_result->getLanguageLinks();
307 
308  if ( $params['effectivelanglinks'] ) {
309  // Link flags are ignored for now, but may in the future be
310  // included in the result.
311  $linkFlags = [];
312  Hooks::run( 'LanguageLinks', [ $titleObj, &$langlinks, &$linkFlags ] );
313  }
314  } else {
315  $langlinks = false;
316  }
317 
318  if ( isset( $prop['langlinks'] ) ) {
319  $result_array['langlinks'] = $this->formatLangLinks( $langlinks );
320  }
321  if ( isset( $prop['categories'] ) ) {
322  $result_array['categories'] = $this->formatCategoryLinks( $p_result->getCategories() );
323  }
324  if ( isset( $prop['categorieshtml'] ) ) {
325  $result_array['categorieshtml'] = $this->categoriesHtml( $p_result->getCategories() );
326  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'categorieshtml';
327  }
328  if ( isset( $prop['links'] ) ) {
329  $result_array['links'] = $this->formatLinks( $p_result->getLinks() );
330  }
331  if ( isset( $prop['templates'] ) ) {
332  $result_array['templates'] = $this->formatLinks( $p_result->getTemplates() );
333  }
334  if ( isset( $prop['images'] ) ) {
335  $result_array['images'] = array_keys( $p_result->getImages() );
336  }
337  if ( isset( $prop['externallinks'] ) ) {
338  $result_array['externallinks'] = array_keys( $p_result->getExternalLinks() );
339  }
340  if ( isset( $prop['sections'] ) ) {
341  $result_array['sections'] = $p_result->getSections();
342  }
343  if ( isset( $prop['parsewarnings'] ) ) {
344  $result_array['parsewarnings'] = $p_result->getWarnings();
345  }
346 
347  if ( isset( $prop['displaytitle'] ) ) {
348  $result_array['displaytitle'] = $p_result->getDisplayTitle() ?:
349  $titleObj->getPrefixedText();
350  }
351 
352  if ( isset( $prop['headitems'] ) ) {
353  $result_array['headitems'] = $this->formatHeadItems( $p_result->getHeadItems() );
354  $this->addDeprecation( 'apiwarn-deprecation-parse-headitems', 'action=parse&prop=headitems' );
355  }
356 
357  if ( isset( $prop['headhtml'] ) ) {
358  $context = new DerivativeContext( $this->getContext() );
359  $context->setTitle( $titleObj );
360  $context->setWikiPage( $pageObj );
361 
362  // We need an OutputPage tied to $context, not to the
363  // RequestContext at the root of the stack.
364  $output = new OutputPage( $context );
365  $output->addParserOutputMetadata( $p_result );
366 
367  $result_array['headhtml'] = $output->headElement( $context->getSkin() );
368  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'headhtml';
369  }
370 
371  if ( isset( $prop['modules'] ) ) {
372  $result_array['modules'] = array_values( array_unique( $p_result->getModules() ) );
373  $result_array['modulescripts'] = array_values( array_unique( $p_result->getModuleScripts() ) );
374  $result_array['modulestyles'] = array_values( array_unique( $p_result->getModuleStyles() ) );
375  }
376 
377  if ( isset( $prop['jsconfigvars'] ) ) {
378  $result_array['jsconfigvars'] =
379  ApiResult::addMetadataToResultVars( $p_result->getJsConfigVars() );
380  }
381 
382  if ( isset( $prop['encodedjsconfigvars'] ) ) {
383  $result_array['encodedjsconfigvars'] = FormatJson::encode(
384  $p_result->getJsConfigVars(), false, FormatJson::ALL_OK
385  );
386  $result_array[ApiResult::META_SUBELEMENTS][] = 'encodedjsconfigvars';
387  }
388 
389  if ( isset( $prop['modules'] ) &&
390  !isset( $prop['jsconfigvars'] ) && !isset( $prop['encodedjsconfigvars'] ) ) {
391  $this->addWarning( 'apiwarn-moduleswithoutvars' );
392  }
393 
394  if ( isset( $prop['indicators'] ) ) {
395  $result_array['indicators'] = (array)$p_result->getIndicators();
396  ApiResult::setArrayType( $result_array['indicators'], 'BCkvp', 'name' );
397  }
398 
399  if ( isset( $prop['iwlinks'] ) ) {
400  $result_array['iwlinks'] = $this->formatIWLinks( $p_result->getInterwikiLinks() );
401  }
402 
403  if ( isset( $prop['wikitext'] ) ) {
404  $result_array['wikitext'] = $this->content->serialize( $format );
405  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'wikitext';
406  if ( !is_null( $this->pstContent ) ) {
407  $result_array['psttext'] = $this->pstContent->serialize( $format );
408  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'psttext';
409  }
410  }
411  if ( isset( $prop['properties'] ) ) {
412  $result_array['properties'] = (array)$p_result->getProperties();
413  ApiResult::setArrayType( $result_array['properties'], 'BCkvp', 'name' );
414  }
415 
416  if ( isset( $prop['limitreportdata'] ) ) {
417  $result_array['limitreportdata'] =
418  $this->formatLimitReportData( $p_result->getLimitReportData() );
419  }
420  if ( isset( $prop['limitreporthtml'] ) ) {
421  $result_array['limitreporthtml'] = EditPage::getPreviewLimitReport( $p_result );
422  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'limitreporthtml';
423  }
424 
425  if ( isset( $prop['parsetree'] ) || $params['generatexml'] ) {
426  if ( $this->content->getModel() != CONTENT_MODEL_WIKITEXT ) {
427  $this->dieWithError( 'apierror-parsetree-notwikitext', 'notwikitext' );
428  }
429 
430  $wgParser->startExternalParse( $titleObj, $popts, Parser::OT_PREPROCESS );
431  $dom = $wgParser->preprocessToDom( $this->content->getNativeData() );
432  if ( is_callable( [ $dom, 'saveXML' ] ) ) {
433  $xml = $dom->saveXML();
434  } else {
435  $xml = $dom->__toString();
436  }
437  $result_array['parsetree'] = $xml;
438  $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'parsetree';
439  }
440 
441  $result_mapping = [
442  'redirects' => 'r',
443  'langlinks' => 'll',
444  'categories' => 'cl',
445  'links' => 'pl',
446  'templates' => 'tl',
447  'images' => 'img',
448  'externallinks' => 'el',
449  'iwlinks' => 'iw',
450  'sections' => 's',
451  'headitems' => 'hi',
452  'modules' => 'm',
453  'indicators' => 'ind',
454  'modulescripts' => 'm',
455  'modulestyles' => 'm',
456  'properties' => 'pp',
457  'limitreportdata' => 'lr',
458  'parsewarnings' => 'pw'
459  ];
460  $this->setIndexedTagNames( $result_array, $result_mapping );
461  $result->addValue( null, $this->getModuleName(), $result_array );
462  }
463 
472  protected function makeParserOptions( WikiPage $pageObj, array $params ) {
473  $popts = $pageObj->makeParserOptions( $this->getContext() );
474  $popts->enableLimitReport( !$params['disablepp'] && !$params['disablelimitreport'] );
475  $popts->setIsPreview( $params['preview'] || $params['sectionpreview'] );
476  $popts->setIsSectionPreview( $params['sectionpreview'] );
477  $popts->setEditSection( !$params['disableeditsection'] );
478  if ( $params['disabletidy'] ) {
479  $popts->setTidy( false );
480  }
481 
482  $reset = null;
483  $suppressCache = false;
484  Hooks::run( 'ApiMakeParserOptions',
485  [ $popts, $pageObj->getTitle(), $params, $this, &$reset, &$suppressCache ] );
486 
487  return [ $popts, $reset, $suppressCache ];
488  }
489 
497  private function getParsedContent( WikiPage $page, $popts, $pageId = null, $getWikitext = false ) {
498  $this->content = $this->getContent( $page, $pageId );
499 
500  if ( $this->section !== false && $this->content !== null ) {
501  // Not cached (save or load)
502  return $this->content->getParserOutput( $page->getTitle(), null, $popts );
503  }
504 
505  // Try the parser cache first
506  // getParserOutput will save to Parser cache if able
507  $pout = $page->getParserOutput( $popts );
508  if ( !$pout ) {
509  $this->dieWithError( [ 'apierror-nosuchrevid', $page->getLatest() ] );
510  }
511  if ( $getWikitext ) {
512  $this->content = $page->getContent( Revision::RAW );
513  }
514 
515  return $pout;
516  }
517 
525  private function getContent( WikiPage $page, $pageId = null ) {
526  $content = $page->getContent( Revision::RAW ); // XXX: really raw?
527 
528  if ( $this->section !== false && $content !== null ) {
529  $content = $this->getSectionContent(
530  $content,
531  !is_null( $pageId )
532  ? $this->msg( 'pageid', $pageId )
533  : $page->getTitle()->getPrefixedText()
534  );
535  }
536  return $content;
537  }
538 
546  private function getSectionContent( Content $content, $what ) {
547  // Not cached (save or load)
548  $section = $content->getSection( $this->section );
549  if ( $section === false ) {
550  $this->dieWithError( [ 'apierror-nosuchsection-what', $this->section, $what ], 'nosuchsection' );
551  }
552  if ( $section === null ) {
553  $this->dieWithError( [ 'apierror-sectionsnotsupported-what', $what ], 'nosuchsection' );
554  $section = false;
555  }
556 
557  return $section;
558  }
559 
567  private function formatSummary( $title, $params ) {
569  $summary = !is_null( $params['summary'] ) ? $params['summary'] : '';
570  $sectionTitle = !is_null( $params['sectiontitle'] ) ? $params['sectiontitle'] : '';
571 
572  if ( $this->section === 'new' && ( $sectionTitle === '' || $summary === '' ) ) {
573  if ( $sectionTitle !== '' ) {
574  $summary = $params['sectiontitle'];
575  }
576  if ( $summary !== '' ) {
577  $summary = wfMessage( 'newsectionsummary' )
578  ->rawParams( $wgParser->stripSectionName( $summary ) )
579  ->inContentLanguage()->text();
580  }
581  }
582  return Linker::formatComment( $summary, $title, $this->section === 'new' );
583  }
584 
585  private function formatLangLinks( $links ) {
586  $result = [];
587  foreach ( $links as $link ) {
588  $entry = [];
589  $bits = explode( ':', $link, 2 );
591 
592  $entry['lang'] = $bits[0];
593  if ( $title ) {
594  $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
595  // localised language name in 'uselang' language
596  $entry['langname'] = Language::fetchLanguageName(
597  $title->getInterwiki(),
598  $this->getLanguage()->getCode()
599  );
600 
601  // native language name
602  $entry['autonym'] = Language::fetchLanguageName( $title->getInterwiki() );
603  }
604  ApiResult::setContentValue( $entry, 'title', $bits[1] );
605  $result[] = $entry;
606  }
607 
608  return $result;
609  }
610 
611  private function formatCategoryLinks( $links ) {
612  $result = [];
613 
614  if ( !$links ) {
615  return $result;
616  }
617 
618  // Fetch hiddencat property
619  $lb = new LinkBatch;
620  $lb->setArray( [ NS_CATEGORY => $links ] );
621  $db = $this->getDB();
622  $res = $db->select( [ 'page', 'page_props' ],
623  [ 'page_title', 'pp_propname' ],
624  $lb->constructSet( 'page', $db ),
625  __METHOD__,
626  [],
627  [ 'page_props' => [
628  'LEFT JOIN', [ 'pp_propname' => 'hiddencat', 'pp_page = page_id' ]
629  ] ]
630  );
631  $hiddencats = [];
632  foreach ( $res as $row ) {
633  $hiddencats[$row->page_title] = isset( $row->pp_propname );
634  }
635 
636  $linkCache = LinkCache::singleton();
637 
638  foreach ( $links as $link => $sortkey ) {
639  $entry = [];
640  $entry['sortkey'] = $sortkey;
641  // array keys will cast numeric category names to ints, so cast back to string
642  ApiResult::setContentValue( $entry, 'category', (string)$link );
643  if ( !isset( $hiddencats[$link] ) ) {
644  $entry['missing'] = true;
645 
646  // We already know the link doesn't exist in the database, so
647  // tell LinkCache that before calling $title->isKnown().
649  $linkCache->addBadLinkObj( $title );
650  if ( $title->isKnown() ) {
651  $entry['known'] = true;
652  }
653  } elseif ( $hiddencats[$link] ) {
654  $entry['hidden'] = true;
655  }
656  $result[] = $entry;
657  }
658 
659  return $result;
660  }
661 
662  private function categoriesHtml( $categories ) {
663  $context = $this->getContext();
664  $context->getOutput()->addCategoryLinks( $categories );
665 
666  return $context->getSkin()->getCategories();
667  }
668 
669  private function formatLinks( $links ) {
670  $result = [];
671  foreach ( $links as $ns => $nslinks ) {
672  foreach ( $nslinks as $title => $id ) {
673  $entry = [];
674  $entry['ns'] = $ns;
675  ApiResult::setContentValue( $entry, 'title', Title::makeTitle( $ns, $title )->getFullText() );
676  $entry['exists'] = $id != 0;
677  $result[] = $entry;
678  }
679  }
680 
681  return $result;
682  }
683 
684  private function formatIWLinks( $iw ) {
685  $result = [];
686  foreach ( $iw as $prefix => $titles ) {
687  foreach ( array_keys( $titles ) as $title ) {
688  $entry = [];
689  $entry['prefix'] = $prefix;
690 
691  $title = Title::newFromText( "{$prefix}:{$title}" );
692  if ( $title ) {
693  $entry['url'] = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
694  }
695 
696  ApiResult::setContentValue( $entry, 'title', $title->getFullText() );
697  $result[] = $entry;
698  }
699  }
700 
701  return $result;
702  }
703 
704  private function formatHeadItems( $headItems ) {
705  $result = [];
706  foreach ( $headItems as $tag => $content ) {
707  $entry = [];
708  $entry['tag'] = $tag;
709  ApiResult::setContentValue( $entry, 'content', $content );
710  $result[] = $entry;
711  }
712 
713  return $result;
714  }
715 
716  private function formatLimitReportData( $limitReportData ) {
717  $result = [];
718 
719  foreach ( $limitReportData as $name => $value ) {
720  $entry = [];
721  $entry['name'] = $name;
722  if ( !is_array( $value ) ) {
723  $value = [ $value ];
724  }
726  $entry = array_merge( $entry, $value );
727  $result[] = $entry;
728  }
729 
730  return $result;
731  }
732 
733  private function setIndexedTagNames( &$array, $mapping ) {
734  foreach ( $mapping as $key => $name ) {
735  if ( isset( $array[$key] ) ) {
736  ApiResult::setIndexedTagName( $array[$key], $name );
737  }
738  }
739  }
740 
741  public function getAllowedParams() {
742  return [
743  'title' => null,
744  'text' => [
745  ApiBase::PARAM_TYPE => 'text',
746  ],
747  'summary' => null,
748  'page' => null,
749  'pageid' => [
750  ApiBase::PARAM_TYPE => 'integer',
751  ],
752  'redirects' => false,
753  'oldid' => [
754  ApiBase::PARAM_TYPE => 'integer',
755  ],
756  'prop' => [
757  ApiBase::PARAM_DFLT => 'text|langlinks|categories|links|templates|' .
758  'images|externallinks|sections|revid|displaytitle|iwlinks|' .
759  'properties|parsewarnings',
760  ApiBase::PARAM_ISMULTI => true,
762  'text',
763  'langlinks',
764  'categories',
765  'categorieshtml',
766  'links',
767  'templates',
768  'images',
769  'externallinks',
770  'sections',
771  'revid',
772  'displaytitle',
773  'headitems',
774  'headhtml',
775  'modules',
776  'jsconfigvars',
777  'encodedjsconfigvars',
778  'indicators',
779  'iwlinks',
780  'wikitext',
781  'properties',
782  'limitreportdata',
783  'limitreporthtml',
784  'parsetree',
785  'parsewarnings'
786  ],
788  'parsetree' => [ 'apihelp-parse-paramvalue-prop-parsetree', CONTENT_MODEL_WIKITEXT ],
789  ],
790  ],
791  'pst' => false,
792  'onlypst' => false,
793  'effectivelanglinks' => false,
794  'section' => null,
795  'sectiontitle' => [
796  ApiBase::PARAM_TYPE => 'string',
797  ],
798  'disablepp' => [
799  ApiBase::PARAM_DFLT => false,
801  ],
802  'disablelimitreport' => false,
803  'disableeditsection' => false,
804  'disabletidy' => false,
805  'generatexml' => [
806  ApiBase::PARAM_DFLT => false,
808  'apihelp-parse-param-generatexml', CONTENT_MODEL_WIKITEXT
809  ],
811  ],
812  'preview' => false,
813  'sectionpreview' => false,
814  'disabletoc' => false,
815  'contentformat' => [
817  ],
818  'contentmodel' => [
820  ]
821  ];
822  }
823 
824  protected function getExamplesMessages() {
825  return [
826  'action=parse&page=Project:Sandbox'
827  => 'apihelp-parse-example-page',
828  'action=parse&text={{Project:Sandbox}}&contentmodel=wikitext'
829  => 'apihelp-parse-example-text',
830  'action=parse&text={{PAGENAME}}&title=Test'
831  => 'apihelp-parse-example-texttitle',
832  'action=parse&summary=Some+[[link]]&prop='
833  => 'apihelp-parse-example-summary',
834  ];
835  }
836 
837  public function getHelpUrls() {
838  return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Parsing_wikitext#parse';
839  }
840 }
ApiMain
This is the main API class, used for both external and internal processing.
Definition: ApiMain.php:45
ContextSource\$context
IContextSource $context
Definition: ContextSource.php:34
ApiParse\formatIWLinks
formatIWLinks( $iw)
Definition: ApiParse.php:684
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:265
ContextSource\getContext
getContext()
Get the base IContextSource object.
Definition: ContextSource.php:41
ContentHandler\getAllContentFormats
static getAllContentFormats()
Definition: ContentHandler.php:369
ApiBase\addWarning
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
Definition: ApiBase.php:1720
Revision\newFromId
static newFromId( $id, $flags=0)
Load a page revision from a given revision ID number.
Definition: Revision.php:116
content
per default it will return the text for text based content
Definition: contenthandler.txt:104
$wgParser
$wgParser
Definition: Setup.php:796
ContextSource\msg
msg()
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:187
IContextSource\getSkin
getSkin()
Get the Skin object.
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:585
ApiBase\dieWithError
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
Definition: ApiBase.php:1796
ApiBase\PARAM_HELP_MSG
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition: ApiBase.php:128
$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. '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 '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! 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! 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:1954
ApiResult\META_BC_SUBELEMENTS
const META_BC_SUBELEMENTS
Key for the 'BC subelements' metadata item.
Definition: ApiResult.php:141
ApiBase\getTitleOrPageId
getTitleOrPageId( $params, $load=false)
Get a WikiPage object from a title or pageid param, if possible.
Definition: ApiBase.php:895
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:91
ApiParse\formatLinks
formatLinks( $links)
Definition: ApiParse.php:669
ApiBase\getResult
getResult()
Get the result object.
Definition: ApiBase.php:610
ApiParse\getContent
getContent(WikiPage $page, $pageId=null)
Get the content for the given page and the requested section.
Definition: ApiParse.php:525
$req
this hook is for auditing only $req
Definition: hooks.txt:990
WikiPage
Class representing a MediaWiki article and history.
Definition: WikiPage.php:36
OT_PREPROCESS
const OT_PREPROCESS
Definition: Defines.php:184
$params
$params
Definition: styleTest.css.php:40
WikiPage\makeParserOptions
makeParserOptions( $context)
Get parser options suitable for rendering the primary article wikitext.
Definition: WikiPage.php:1945
ApiBase\getDB
getDB()
Gets a default replica DB connection object.
Definition: ApiBase.php:638
$res
$res
Definition: database.txt:21
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:304
$wgTitle
if(! $wgRequest->checkUrlExtension()) if(! $wgEnableAPI) $wgTitle
Definition: api.php:57
CONTENT_MODEL_WIKITEXT
const CONTENT_MODEL_WIKITEXT
Definition: Defines.php:233
ApiParse\$section
$section
Definition: ApiParse.php:31
ContextSource\getUser
getUser()
Get the User object.
Definition: ContextSource.php:133
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:98
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:44
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:41
ContextSource\getLanguage
getLanguage()
Get the Language object.
Definition: ContextSource.php:143
Revision\FOR_THIS_USER
const FOR_THIS_USER
Definition: Revision.php:99
EditPage\getPreviewLimitReport
static getPreviewLimitReport( $output)
Get the Limit report for page previews.
Definition: EditPage.php:3518
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:109
ApiParse\getParsedContent
getParsedContent(WikiPage $page, $popts, $pageId=null, $getWikitext=false)
Definition: ApiParse.php:497
DerivativeContext
An IContextSource implementation which will inherit context from another source but allow individual ...
Definition: DerivativeContext.php:31
ApiParse
Definition: ApiParse.php:28
FormatJson\encode
static encode( $value, $pretty=false, $escaping=0)
Returns the JSON representation of a value.
Definition: FormatJson.php:127
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:837
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:934
WikiPage\factory
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:120
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:1152
$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
ContentHandler\getContentModels
static getContentModels()
Definition: ContentHandler.php:361
ApiParse\getAllowedParams
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
Definition: ApiParse.php:741
$page
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition: hooks.txt:2536
$tag
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books $tag
Definition: hooks.txt:1028
ApiResult\META_SUBELEMENTS
const META_SUBELEMENTS
Key for the 'subelements' metadata item.
Definition: ApiResult.php:76
ApiParse\formatLimitReportData
formatLimitReportData( $limitReportData)
Definition: ApiParse.php:716
WikiPage\getTitle
getTitle()
Get the title object of the article.
Definition: WikiPage.php:237
MWContentSerializationException
Exception representing a failure to serialize or unserialize a content object.
Definition: MWContentSerializationException.php:7
PROTO_CURRENT
const PROTO_CURRENT
Definition: Defines.php:220
WikiPage\getContent
getContent( $audience=Revision::FOR_PUBLIC, User $user=null)
Get the content of the current revision.
Definition: WikiPage.php:663
ApiBase\dieWithException
dieWithException( $exception, array $options=[])
Abort execution with an error derived from an exception.
Definition: ApiBase.php:1808
$output
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object & $output
Definition: hooks.txt:1049
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:514
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
NS_CATEGORY
const NS_CATEGORY
Definition: Defines.php:76
WikiPage\getLatest
getLatest()
Get the page_latest field.
Definition: WikiPage.php:569
ApiMessage\create
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
Definition: ApiMessage.php:212
ApiParse\formatSummary
formatSummary( $title, $params)
This mimicks the behavior of EditPage in formatting a summary.
Definition: ApiParse.php:567
OutputPage
This class should be covered by a general architecture document which does not exist as of January 20...
Definition: OutputPage.php:44
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:129
ApiParse\formatCategoryLinks
formatCategoryLinks( $links)
Definition: ApiParse.php:611
ApiBase\extractRequestParams
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition: ApiBase.php:718
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:45
ApiBase\addDeprecation
addDeprecation( $msg, $feature, $data=[])
Add a deprecation warning for this module.
Definition: ApiBase.php:1734
ApiParse\setIndexedTagNames
setIndexedTagNames(&$array, $mapping)
Definition: ApiParse.php:733
ApiBase\checkTitleUserPermissions
checkTitleUserPermissions(Title $title, $actions, $user=null)
Helper function for permission-denied errors.
Definition: ApiBase.php:1908
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1657
Revision\RAW
const RAW
Definition: Revision.php:100
ApiBase\requireMaxOneParameter
requireMaxOneParameter( $params, $required)
Die if more than one of a certain set of parameters is set and not false.
Definition: ApiBase.php:792
Language\fetchLanguageName
static fetchLanguageName( $code, $inLanguage=null, $include='all')
Definition: Language.php:891
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:1094
Content
Base interface for content objects.
Definition: Content.php:34
ApiParse\categoriesHtml
categoriesHtml( $categories)
Definition: ApiParse.php:662
LinkCache\singleton
static singleton()
Get an instance of this class.
Definition: LinkCache.php:67
ApiBase\PARAM_DFLT
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
Definition: ApiBase.php:52
$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:1741
ApiParse\getExamplesMessages
getExamplesMessages()
Returns usage examples for this module.
Definition: ApiParse.php:824
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:490
ApiBase\PARAM_ISMULTI
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
Definition: ApiBase.php:55
$article
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
Definition: hooks.txt:78
ApiParse\getSectionContent
getSectionContent(Content $content, $what)
Extract the requested section from the given Content.
Definition: ApiParse.php:546
$link
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:2929
ApiBase\getMain
getMain()
Get the main module.
Definition: ApiBase.php:506
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 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
ApiParse\formatHeadItems
formatHeadItems( $headItems)
Definition: ApiParse.php:704
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:160
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
ApiParse\makeParserOptions
makeParserOptions(WikiPage $pageObj, array $params)
Constructs a ParserOptions object.
Definition: ApiParse.php:472
IContextSource\getOutput
getOutput()
Get the OutputPage object.
ApiParse\$content
$content
Definition: ApiParse.php:34
Revision\DELETED_TEXT
const DELETED_TEXT
Definition: Revision.php:90
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:552
array
the array() calling protocol came about after MediaWiki 1.4rc1.
ApiParse\execute
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
Definition: ApiParse.php:39
Article\newFromTitle
static newFromTitle( $title, IContextSource $context)
Create an Article object of the appropriate class for the given page.
Definition: Article.php:113