MediaWiki  1.23.12
ApiQuerySiteinfo.php
Go to the documentation of this file.
1 <?php
32 class ApiQuerySiteinfo extends ApiQueryBase {
33 
34  public function __construct( $query, $moduleName ) {
35  parent::__construct( $query, $moduleName, 'si' );
36  }
37 
38  public function execute() {
39  $params = $this->extractRequestParams();
40  $done = array();
41  $fit = false;
42  foreach ( $params['prop'] as $p ) {
43  switch ( $p ) {
44  case 'general':
45  $fit = $this->appendGeneralInfo( $p );
46  break;
47  case 'namespaces':
48  $fit = $this->appendNamespaces( $p );
49  break;
50  case 'namespacealiases':
51  $fit = $this->appendNamespaceAliases( $p );
52  break;
53  case 'specialpagealiases':
54  $fit = $this->appendSpecialPageAliases( $p );
55  break;
56  case 'magicwords':
57  $fit = $this->appendMagicWords( $p );
58  break;
59  case 'interwikimap':
60  $filteriw = isset( $params['filteriw'] ) ? $params['filteriw'] : false;
61  $fit = $this->appendInterwikiMap( $p, $filteriw );
62  break;
63  case 'dbrepllag':
64  $fit = $this->appendDbReplLagInfo( $p, $params['showalldb'] );
65  break;
66  case 'statistics':
67  $fit = $this->appendStatistics( $p );
68  break;
69  case 'usergroups':
70  $fit = $this->appendUserGroups( $p, $params['numberingroup'] );
71  break;
72  case 'extensions':
73  $fit = $this->appendExtensions( $p );
74  break;
75  case 'fileextensions':
76  $fit = $this->appendFileExtensions( $p );
77  break;
78  case 'rightsinfo':
79  $fit = $this->appendRightsInfo( $p );
80  break;
81  case 'restrictions':
82  $fit = $this->appendRestrictions( $p );
83  break;
84  case 'languages':
85  $fit = $this->appendLanguages( $p );
86  break;
87  case 'skins':
88  $fit = $this->appendSkins( $p );
89  break;
90  case 'extensiontags':
91  $fit = $this->appendExtensionTags( $p );
92  break;
93  case 'functionhooks':
94  $fit = $this->appendFunctionHooks( $p );
95  break;
96  case 'showhooks':
97  $fit = $this->appendSubscribedHooks( $p );
98  break;
99  case 'variables':
100  $fit = $this->appendVariables( $p );
101  break;
102  case 'protocols':
103  $fit = $this->appendProtocols( $p );
104  break;
105  case 'defaultoptions':
106  $fit = $this->appendDefaultOptions( $p );
107  break;
108  default:
109  ApiBase::dieDebug( __METHOD__, "Unknown prop=$p" );
110  }
111  if ( !$fit ) {
112  // Abuse siprop as a query-continue parameter
113  // and set it to all unprocessed props
114  $this->setContinueEnumParameter( 'prop', implode( '|',
115  array_diff( $params['prop'], $done ) ) );
116  break;
117  }
118  $done[] = $p;
119  }
120  }
121 
122  protected function appendGeneralInfo( $property ) {
123  global $wgContLang, $wgDisableLangConversion, $wgDisableTitleConversion;
124 
125  $data = array();
126  $mainPage = Title::newMainPage();
127  $data['mainpage'] = $mainPage->getPrefixedText();
128  $data['base'] = wfExpandUrl( $mainPage->getFullURL(), PROTO_CURRENT );
129  $data['sitename'] = $GLOBALS['wgSitename'];
130 
131  // wgLogo can either be a relative or an absolute path
132  // make sure we always return an absolute path
133  $data['logo'] = wfExpandUrl( $GLOBALS['wgLogo'], PROTO_RELATIVE );
134 
135  $data['generator'] = "MediaWiki {$GLOBALS['wgVersion']}";
136  $data['phpversion'] = phpversion();
137  $data['phpsapi'] = PHP_SAPI;
138  $data['dbtype'] = $GLOBALS['wgDBtype'];
139  $data['dbversion'] = $this->getDB()->getServerVersion();
140 
141  $allowFrom = array( '' );
142  $allowException = true;
143  if ( !$GLOBALS['wgAllowExternalImages'] ) {
144  if ( $GLOBALS['wgEnableImageWhitelist'] ) {
145  $data['imagewhitelistenabled'] = '';
146  }
147  $allowFrom = $GLOBALS['wgAllowExternalImagesFrom'];
148  $allowException = !empty( $allowFrom );
149  }
150  if ( $allowException ) {
151  $data['externalimages'] = (array)$allowFrom;
152  $this->getResult()->setIndexedTagName( $data['externalimages'], 'prefix' );
153  }
154 
155  if ( !$wgDisableLangConversion ) {
156  $data['langconversion'] = '';
157  }
158 
159  if ( !$wgDisableTitleConversion ) {
160  $data['titleconversion'] = '';
161  }
162 
163  if ( $wgContLang->linkPrefixExtension() ) {
164  $linkPrefixCharset = $wgContLang->linkPrefixCharset();
165  $data['linkprefixcharset'] = $linkPrefixCharset;
166  // For backwards compatability
167  $data['linkprefix'] = "/^((?>.*[^$linkPrefixCharset]|))(.+)$/sDu";
168  } else {
169  $data['linkprefixcharset'] = '';
170  $data['linkprefix'] = '';
171  }
172 
173  $linktrail = $wgContLang->linkTrail();
174  if ( $linktrail ) {
175  $data['linktrail'] = $linktrail;
176  } else {
177  $data['linktrail'] = '';
178  }
179 
181  if ( $git ) {
182  $data['git-hash'] = $git;
183  } else {
185  if ( $svn ) {
186  $data['rev'] = $svn;
187  }
188  }
189 
190  // 'case-insensitive' option is reserved for future
191  $data['case'] = $GLOBALS['wgCapitalLinks'] ? 'first-letter' : 'case-sensitive';
192 
193  $data['lang'] = $GLOBALS['wgLanguageCode'];
194 
195  $fallbacks = array();
196  foreach ( $wgContLang->getFallbackLanguages() as $code ) {
197  $fallbacks[] = array( 'code' => $code );
198  }
199  $data['fallback'] = $fallbacks;
200  $this->getResult()->setIndexedTagName( $data['fallback'], 'lang' );
201 
202  if ( $wgContLang->hasVariants() ) {
203  $variants = array();
204  foreach ( $wgContLang->getVariants() as $code ) {
205  $variants[] = array(
206  'code' => $code,
207  'name' => $wgContLang->getVariantname( $code ),
208  );
209  }
210  $data['variants'] = $variants;
211  $this->getResult()->setIndexedTagName( $data['variants'], 'lang' );
212  }
213 
214  if ( $wgContLang->isRTL() ) {
215  $data['rtl'] = '';
216  }
217  $data['fallback8bitEncoding'] = $wgContLang->fallback8bitEncoding();
218 
219  if ( wfReadOnly() ) {
220  $data['readonly'] = '';
221  $data['readonlyreason'] = wfReadOnlyReason();
222  }
223  if ( $GLOBALS['wgEnableWriteAPI'] ) {
224  $data['writeapi'] = '';
225  }
226 
227  $tz = $GLOBALS['wgLocaltimezone'];
228  $offset = $GLOBALS['wgLocalTZoffset'];
229  if ( is_null( $tz ) ) {
230  $tz = 'UTC';
231  $offset = 0;
232  } elseif ( is_null( $offset ) ) {
233  $offset = 0;
234  }
235  $data['timezone'] = $tz;
236  $data['timeoffset'] = intval( $offset );
237  $data['articlepath'] = $GLOBALS['wgArticlePath'];
238  $data['scriptpath'] = $GLOBALS['wgScriptPath'];
239  $data['script'] = $GLOBALS['wgScript'];
240  $data['variantarticlepath'] = $GLOBALS['wgVariantArticlePath'];
241  $data['server'] = $GLOBALS['wgServer'];
242  $data['wikiid'] = wfWikiID();
243  $data['time'] = wfTimestamp( TS_ISO_8601, time() );
244 
245  if ( $GLOBALS['wgMiserMode'] ) {
246  $data['misermode'] = '';
247  }
248 
249  $data['maxuploadsize'] = UploadBase::getMaxUploadSize();
250  $data['minuploadchunksize'] = (int)$this->getConfig()->get( 'MinUploadChunkSize' );
251 
252  $data['thumblimits'] = $GLOBALS['wgThumbLimits'];
253  $this->getResult()->setIndexedTagName( $data['thumblimits'], 'limit' );
254  $data['imagelimits'] = array();
255  $this->getResult()->setIndexedTagName( $data['imagelimits'], 'limit' );
256  foreach ( $GLOBALS['wgImageLimits'] as $k => $limit ) {
257  $data['imagelimits'][$k] = array( 'width' => $limit[0], 'height' => $limit[1] );
258  }
259 
260  if ( !empty( $GLOBALS['wgFavicon'] ) ) {
261  // wgFavicon can either be a relative or an absolute path
262  // make sure we always return an absolute path
263  $data['favicon'] = wfExpandUrl( $GLOBALS['wgFavicon'], PROTO_RELATIVE );
264  }
265 
266  wfRunHooks( 'APIQuerySiteInfoGeneralInfo', array( $this, &$data ) );
267 
268  return $this->getResult()->addValue( 'query', $property, $data );
269  }
270 
271  protected function appendNamespaces( $property ) {
273  $data = array();
274  foreach ( $wgContLang->getFormattedNamespaces() as $ns => $title ) {
275  $data[$ns] = array(
276  'id' => intval( $ns ),
277  'case' => MWNamespace::isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive',
278  );
279  ApiResult::setContent( $data[$ns], $title );
280  $canonical = MWNamespace::getCanonicalName( $ns );
281 
282  if ( MWNamespace::hasSubpages( $ns ) ) {
283  $data[$ns]['subpages'] = '';
284  }
285 
286  if ( $canonical ) {
287  $data[$ns]['canonical'] = strtr( $canonical, '_', ' ' );
288  }
289 
290  if ( MWNamespace::isContent( $ns ) ) {
291  $data[$ns]['content'] = '';
292  }
293 
294  if ( MWNamespace::isNonincludable( $ns ) ) {
295  $data[$ns]['nonincludable'] = '';
296  }
297 
298  $contentmodel = MWNamespace::getNamespaceContentModel( $ns );
299  if ( $contentmodel ) {
300  $data[$ns]['defaultcontentmodel'] = $contentmodel;
301  }
302  }
303 
304  $this->getResult()->setIndexedTagName( $data, 'ns' );
305 
306  return $this->getResult()->addValue( 'query', $property, $data );
307  }
308 
309  protected function appendNamespaceAliases( $property ) {
311  $aliases = array_merge( $wgNamespaceAliases, $wgContLang->getNamespaceAliases() );
312  $namespaces = $wgContLang->getNamespaces();
313  $data = array();
314  foreach ( $aliases as $title => $ns ) {
315  if ( $namespaces[$ns] == $title ) {
316  // Don't list duplicates
317  continue;
318  }
319  $item = array(
320  'id' => intval( $ns )
321  );
322  ApiResult::setContent( $item, strtr( $title, '_', ' ' ) );
323  $data[] = $item;
324  }
325 
326  sort( $data );
327 
328  $this->getResult()->setIndexedTagName( $data, 'ns' );
329 
330  return $this->getResult()->addValue( 'query', $property, $data );
331  }
332 
333  protected function appendSpecialPageAliases( $property ) {
335  $data = array();
336  $aliases = $wgContLang->getSpecialPageAliases();
337  foreach ( SpecialPageFactory::getList() as $specialpage => $stuff ) {
338  if ( isset( $aliases[$specialpage] ) ) {
339  $arr = array( 'realname' => $specialpage, 'aliases' => $aliases[$specialpage] );
340  $this->getResult()->setIndexedTagName( $arr['aliases'], 'alias' );
341  $data[] = $arr;
342  }
343  }
344  $this->getResult()->setIndexedTagName( $data, 'specialpage' );
345 
346  return $this->getResult()->addValue( 'query', $property, $data );
347  }
348 
349  protected function appendMagicWords( $property ) {
351  $data = array();
352  foreach ( $wgContLang->getMagicWords() as $magicword => $aliases ) {
353  $caseSensitive = array_shift( $aliases );
354  $arr = array( 'name' => $magicword, 'aliases' => $aliases );
355  if ( $caseSensitive ) {
356  $arr['case-sensitive'] = '';
357  }
358  $this->getResult()->setIndexedTagName( $arr['aliases'], 'alias' );
359  $data[] = $arr;
360  }
361  $this->getResult()->setIndexedTagName( $data, 'magicword' );
362 
363  return $this->getResult()->addValue( 'query', $property, $data );
364  }
365 
366  protected function appendInterwikiMap( $property, $filter ) {
367  $local = null;
368  if ( $filter === 'local' ) {
369  $local = 1;
370  } elseif ( $filter === '!local' ) {
371  $local = 0;
372  } elseif ( $filter ) {
373  ApiBase::dieDebug( __METHOD__, "Unknown filter=$filter" );
374  }
375 
376  $params = $this->extractRequestParams();
377  $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : '';
378  $langNames = Language::fetchLanguageNames( $langCode );
379 
380  $getPrefixes = Interwiki::getAllPrefixes( $local );
381  $data = array();
382 
383  foreach ( $getPrefixes as $row ) {
384  $prefix = $row['iw_prefix'];
385  $val = array();
386  $val['prefix'] = $prefix;
387  if ( $row['iw_local'] == '1' ) {
388  $val['local'] = '';
389  }
390  if ( $row['iw_trans'] == '1' ) {
391  $val['trans'] = '';
392  }
393  if ( isset( $langNames[$prefix] ) ) {
394  $val['language'] = $langNames[$prefix];
395  }
396  $val['url'] = wfExpandUrl( $row['iw_url'], PROTO_CURRENT );
397  if ( isset( $row['iw_wikiid'] ) ) {
398  $val['wikiid'] = $row['iw_wikiid'];
399  }
400  if ( isset( $row['iw_api'] ) ) {
401  $val['api'] = $row['iw_api'];
402  }
403 
404  $data[] = $val;
405  }
406 
407  $this->getResult()->setIndexedTagName( $data, 'iw' );
408 
409  return $this->getResult()->addValue( 'query', $property, $data );
410  }
411 
412  protected function appendDbReplLagInfo( $property, $includeAll ) {
413  global $wgShowHostnames;
414  $data = array();
415  $lb = wfGetLB();
416  if ( $includeAll ) {
417  if ( !$wgShowHostnames ) {
418  $this->dieUsage(
419  'Cannot view all servers info unless $wgShowHostnames is true',
420  'includeAllDenied'
421  );
422  }
423 
424  $lags = $lb->getLagTimes();
425  foreach ( $lags as $i => $lag ) {
426  $data[] = array(
427  'host' => $lb->getServerName( $i ),
428  'lag' => $lag
429  );
430  }
431  } else {
432  list( , $lag, $index ) = $lb->getMaxLag();
433  $data[] = array(
434  'host' => $wgShowHostnames
435  ? $lb->getServerName( $index )
436  : '',
437  'lag' => intval( $lag )
438  );
439  }
440 
441  $result = $this->getResult();
442  $result->setIndexedTagName( $data, 'db' );
443 
444  return $this->getResult()->addValue( 'query', $property, $data );
445  }
446 
447  protected function appendStatistics( $property ) {
448  global $wgDisableCounters;
449  $data = array();
450  $data['pages'] = intval( SiteStats::pages() );
451  $data['articles'] = intval( SiteStats::articles() );
452  if ( !$wgDisableCounters ) {
453  $data['views'] = intval( SiteStats::views() );
454  }
455  $data['edits'] = intval( SiteStats::edits() );
456  $data['images'] = intval( SiteStats::images() );
457  $data['users'] = intval( SiteStats::users() );
458  $data['activeusers'] = intval( SiteStats::activeUsers() );
459  $data['admins'] = intval( SiteStats::numberingroup( 'sysop' ) );
460  $data['jobs'] = intval( SiteStats::jobs() );
461 
462  wfRunHooks( 'APIQuerySiteInfoStatisticsInfo', array( &$data ) );
463 
464  return $this->getResult()->addValue( 'query', $property, $data );
465  }
466 
467  protected function appendUserGroups( $property, $numberInGroup ) {
468  global $wgGroupPermissions, $wgAddGroups, $wgRemoveGroups;
469  global $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
470 
471  $data = array();
472  $result = $this->getResult();
473  foreach ( $wgGroupPermissions as $group => $permissions ) {
474  $arr = array(
475  'name' => $group,
476  'rights' => array_keys( $permissions, true ),
477  );
478 
479  if ( $numberInGroup ) {
480  global $wgAutopromote;
481 
482  if ( $group == 'user' ) {
483  $arr['number'] = SiteStats::users();
484  // '*' and autopromote groups have no size
485  } elseif ( $group !== '*' && !isset( $wgAutopromote[$group] ) ) {
486  $arr['number'] = SiteStats::numberInGroup( $group );
487  }
488  }
489 
490  $groupArr = array(
491  'add' => $wgAddGroups,
492  'remove' => $wgRemoveGroups,
493  'add-self' => $wgGroupsAddToSelf,
494  'remove-self' => $wgGroupsRemoveFromSelf
495  );
496 
497  foreach ( $groupArr as $type => $rights ) {
498  if ( isset( $rights[$group] ) ) {
499  $arr[$type] = $rights[$group];
500  $result->setIndexedTagName( $arr[$type], 'group' );
501  }
502  }
503 
504  $result->setIndexedTagName( $arr['rights'], 'permission' );
505  $data[] = $arr;
506  }
507 
508  $result->setIndexedTagName( $data, 'group' );
509 
510  return $result->addValue( 'query', $property, $data );
511  }
512 
513  protected function appendFileExtensions( $property ) {
515 
516  $data = array();
517  foreach ( array_unique( $wgFileExtensions ) as $ext ) {
518  $data[] = array( 'ext' => $ext );
519  }
520  $this->getResult()->setIndexedTagName( $data, 'fe' );
521 
522  return $this->getResult()->addValue( 'query', $property, $data );
523  }
524 
525  protected function appendExtensions( $property ) {
526  global $wgExtensionCredits;
527  $data = array();
528  foreach ( $wgExtensionCredits as $type => $extensions ) {
529  foreach ( $extensions as $ext ) {
530  $ret = array();
531  $ret['type'] = $type;
532  if ( isset( $ext['name'] ) ) {
533  $ret['name'] = $ext['name'];
534  }
535  if ( isset( $ext['description'] ) ) {
536  $ret['description'] = $ext['description'];
537  }
538  if ( isset( $ext['descriptionmsg'] ) ) {
539  // Can be a string or array( key, param1, param2, ... )
540  if ( is_array( $ext['descriptionmsg'] ) ) {
541  $ret['descriptionmsg'] = $ext['descriptionmsg'][0];
542  $ret['descriptionmsgparams'] = array_slice( $ext['descriptionmsg'], 1 );
543  $this->getResult()->setIndexedTagName( $ret['descriptionmsgparams'], 'param' );
544  } else {
545  $ret['descriptionmsg'] = $ext['descriptionmsg'];
546  }
547  }
548  if ( isset( $ext['author'] ) ) {
549  $ret['author'] = is_array( $ext['author'] ) ?
550  implode( ', ', $ext['author'] ) : $ext['author'];
551  }
552  if ( isset( $ext['url'] ) ) {
553  $ret['url'] = $ext['url'];
554  }
555  if ( isset( $ext['version'] ) ) {
556  $ret['version'] = $ext['version'];
557  } elseif ( isset( $ext['svn-revision'] ) &&
558  preg_match( '/\$(?:Rev|LastChangedRevision|Revision): *(\d+)/',
559  $ext['svn-revision'], $m )
560  ) {
561  $ret['version'] = 'r' . $m[1];
562  }
563  if ( isset( $ext['path'] ) ) {
564  $extensionPath = dirname( $ext['path'] );
565  $gitInfo = new GitInfo( $extensionPath );
566  $vcsVersion = $gitInfo->getHeadSHA1();
567  if ( $vcsVersion !== false ) {
568  $ret['vcs-system'] = 'git';
569  $ret['vcs-version'] = $vcsVersion;
570  $ret['vcs-url'] = $gitInfo->getHeadViewUrl();
571  $vcsDate = $gitInfo->getHeadCommitDate();
572  if ( $vcsDate !== false ) {
573  $ret['vcs-date'] = wfTimestamp( TS_ISO_8601, $vcsDate );
574  }
575  } else {
576  $svnInfo = SpecialVersion::getSvnInfo( $extensionPath );
577  if ( $svnInfo !== false ) {
578  $ret['vcs-system'] = 'svn';
579  $ret['vcs-version'] = $svnInfo['checkout-rev'];
580  $ret['vcs-url'] = isset( $svnInfo['viewvc-url'] ) ? $svnInfo['viewvc-url'] : '';
581  }
582  }
583 
584  if ( SpecialVersion::getExtLicenseFileName( $extensionPath ) ) {
585  $ret['license-name'] = isset( $ext['license-name'] ) ? $ext['license-name'] : '';
586  $ret['license'] = SpecialPage::getTitleFor(
587  'Version',
588  "License/{$ext['name']}"
589  )->getLinkURL();
590  }
591 
592  if ( SpecialVersion::getExtAuthorsFileName( $extensionPath ) ) {
593  $ret['credits'] = SpecialPage::getTitleFor(
594  'Version',
595  "Credits/{$ext['name']}"
596  )->getLinkURL();
597  }
598  }
599  $data[] = $ret;
600  }
601  }
602 
603  $this->getResult()->setIndexedTagName( $data, 'ext' );
604 
605  return $this->getResult()->addValue( 'query', $property, $data );
606  }
607 
608  protected function appendRightsInfo( $property ) {
609  global $wgRightsPage, $wgRightsUrl, $wgRightsText;
610  $title = Title::newFromText( $wgRightsPage );
611  $url = $title ? wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ) : $wgRightsUrl;
612  $text = $wgRightsText;
613  if ( !$text && $title ) {
614  $text = $title->getPrefixedText();
615  }
616 
617  $data = array(
618  'url' => $url ? $url : '',
619  'text' => $text ? $text : ''
620  );
621 
622  return $this->getResult()->addValue( 'query', $property, $data );
623  }
624 
625  protected function appendRestrictions( $property ) {
626  global $wgRestrictionTypes, $wgRestrictionLevels,
627  $wgCascadingRestrictionLevels, $wgSemiprotectedRestrictionLevels;
628 
629  $data = array(
630  'types' => $wgRestrictionTypes,
631  'levels' => $wgRestrictionLevels,
632  'cascadinglevels' => $wgCascadingRestrictionLevels,
633  'semiprotectedlevels' => $wgSemiprotectedRestrictionLevels,
634  );
635 
636  $this->getResult()->setIndexedTagName( $data['types'], 'type' );
637  $this->getResult()->setIndexedTagName( $data['levels'], 'level' );
638  $this->getResult()->setIndexedTagName( $data['cascadinglevels'], 'level' );
639  $this->getResult()->setIndexedTagName( $data['semiprotectedlevels'], 'level' );
640 
641  return $this->getResult()->addValue( 'query', $property, $data );
642  }
643 
644  public function appendLanguages( $property ) {
645  $params = $this->extractRequestParams();
646  $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : '';
647  $langNames = Language::fetchLanguageNames( $langCode );
648 
649  $data = array();
650 
651  foreach ( $langNames as $code => $name ) {
652  $lang = array( 'code' => $code );
653  ApiResult::setContent( $lang, $name );
654  $data[] = $lang;
655  }
656  $this->getResult()->setIndexedTagName( $data, 'lang' );
657 
658  return $this->getResult()->addValue( 'query', $property, $data );
659  }
660 
661  public function appendSkins( $property ) {
662  $data = array();
663  $allowed = Skin::getAllowedSkins();
664  $default = Skin::normalizeKey( 'default' );
665  foreach ( Skin::getSkinNames() as $name => $displayName ) {
666  $skin = array( 'code' => $name );
667  ApiResult::setContent( $skin, $displayName );
668  if ( !isset( $allowed[$name] ) ) {
669  $skin['unusable'] = '';
670  }
671  if ( $name === $default ) {
672  $skin['default'] = '';
673  }
674  $data[] = $skin;
675  }
676  $this->getResult()->setIndexedTagName( $data, 'skin' );
677 
678  return $this->getResult()->addValue( 'query', $property, $data );
679  }
680 
681  public function appendExtensionTags( $property ) {
683  $wgParser->firstCallInit();
684  $tags = array_map( array( $this, 'formatParserTags' ), $wgParser->getTags() );
685  $this->getResult()->setIndexedTagName( $tags, 't' );
686 
687  return $this->getResult()->addValue( 'query', $property, $tags );
688  }
689 
690  public function appendFunctionHooks( $property ) {
692  $wgParser->firstCallInit();
693  $hooks = $wgParser->getFunctionHooks();
694  $this->getResult()->setIndexedTagName( $hooks, 'h' );
695 
696  return $this->getResult()->addValue( 'query', $property, $hooks );
697  }
698 
699  public function appendVariables( $property ) {
700  $variables = MagicWord::getVariableIDs();
701  $this->getResult()->setIndexedTagName( $variables, 'v' );
702 
703  return $this->getResult()->addValue( 'query', $property, $variables );
704  }
705 
706  public function appendProtocols( $property ) {
707  global $wgUrlProtocols;
708  // Make a copy of the global so we don't try to set the _element key of it - bug 45130
709  $protocols = array_values( $wgUrlProtocols );
710  $this->getResult()->setIndexedTagName( $protocols, 'p' );
711 
712  return $this->getResult()->addValue( 'query', $property, $protocols );
713  }
714 
715  public function appendDefaultOptions( $property ) {
716  return $this->getResult()->addValue( 'query', $property, User::getDefaultOptions() );
717  }
718 
719  private function formatParserTags( $item ) {
720  return "<{$item}>";
721  }
722 
723  public function appendSubscribedHooks( $property ) {
725  $myWgHooks = $wgHooks;
726  ksort( $myWgHooks );
727 
728  $data = array();
729  foreach ( $myWgHooks as $hook => $hooks ) {
730  $arr = array(
731  'name' => $hook,
732  'subscribers' => array_map( array( 'SpecialVersion', 'arrayToString' ), $hooks ),
733  );
734 
735  $this->getResult()->setIndexedTagName( $arr['subscribers'], 's' );
736  $data[] = $arr;
737  }
738 
739  $this->getResult()->setIndexedTagName( $data, 'hook' );
740 
741  return $this->getResult()->addValue( 'query', $property, $data );
742  }
743 
744  public function getCacheMode( $params ) {
745  return 'public';
746  }
747 
748  public function getAllowedParams() {
749  return array(
750  'prop' => array(
751  ApiBase::PARAM_DFLT => 'general',
752  ApiBase::PARAM_ISMULTI => true,
754  'general',
755  'namespaces',
756  'namespacealiases',
757  'specialpagealiases',
758  'magicwords',
759  'interwikimap',
760  'dbrepllag',
761  'statistics',
762  'usergroups',
763  'extensions',
764  'fileextensions',
765  'rightsinfo',
766  'restrictions',
767  'languages',
768  'skins',
769  'extensiontags',
770  'functionhooks',
771  'showhooks',
772  'variables',
773  'protocols',
774  'defaultoptions',
775  )
776  ),
777  'filteriw' => array(
779  'local',
780  '!local',
781  )
782  ),
783  'showalldb' => false,
784  'numberingroup' => false,
785  'inlanguagecode' => null,
786  );
787  }
788 
789  public function getParamDescription() {
790  $p = $this->getModulePrefix();
791 
792  return array(
793  'prop' => array(
794  'Which sysinfo properties to get:',
795  ' general - Overall system information',
796  ' namespaces - List of registered namespaces and their canonical names',
797  ' namespacealiases - List of registered namespace aliases',
798  ' specialpagealiases - List of special page aliases',
799  ' magicwords - List of magic words and their aliases',
800  ' statistics - Returns site statistics',
801  ' interwikimap - Returns interwiki map ' .
802  "(optionally filtered, (optionally localised by using {$p}inlanguagecode))",
803  ' dbrepllag - Returns database server with the highest replication lag',
804  ' usergroups - Returns user groups and the associated permissions',
805  ' extensions - Returns extensions installed on the wiki',
806  ' fileextensions - Returns list of file extensions allowed to be uploaded',
807  ' rightsinfo - Returns wiki rights (license) information if available',
808  ' restrictions - Returns information on available restriction (protection) types',
809  ' languages - Returns a list of languages MediaWiki supports' .
810  "(optionally localised by using {$p}inlanguagecode)",
811  ' skins - Returns a list of all enabled skins',
812  ' extensiontags - Returns a list of parser extension tags',
813  ' functionhooks - Returns a list of parser function hooks',
814  ' showhooks - Returns a list of all subscribed hooks (contents of $wgHooks)',
815  ' variables - Returns a list of variable IDs',
816  ' protocols - Returns a list of protocols that are allowed in external links.',
817  ' defaultoptions - Returns the default values for user preferences.',
818  ),
819  'filteriw' => 'Return only local or only nonlocal entries of the interwiki map',
820  'showalldb' => 'List all database servers, not just the one lagging the most',
821  'numberingroup' => 'Lists the number of users in user groups',
822  'inlanguagecode' => 'Language code for localised language names ' .
823  '(best effort, use CLDR extension)',
824  );
825  }
826 
827  public function getDescription() {
828  return 'Return general information about the site.';
829  }
830 
831  public function getPossibleErrors() {
832  return array_merge( parent::getPossibleErrors(), array( array(
833  'code' => 'includeAllDenied',
834  'info' => 'Cannot view all servers info unless $wgShowHostnames is true'
835  ), ) );
836  }
837 
838  public function getExamples() {
839  return array(
840  'api.php?action=query&meta=siteinfo&siprop=general|namespaces|namespacealiases|statistics',
841  'api.php?action=query&meta=siteinfo&siprop=interwikimap&sifilteriw=local',
842  'api.php?action=query&meta=siteinfo&siprop=dbrepllag&sishowalldb=',
843  );
844  }
845 
846  public function getHelpUrls() {
847  return 'https://www.mediawiki.org/wiki/API:Meta#siteinfo_.2F_si';
848  }
849 }
SiteStats\articles
static articles()
Definition: SiteStats.php:124
ContextSource\getConfig
getConfig()
Get the Config object.
Definition: ContextSource.php:67
SpecialPageFactory\getList
static getList()
Get the special page list.
Definition: SpecialPageFactory.php:182
$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. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag '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 '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. '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 '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 '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 wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() '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 User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers '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) '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:Associative array mapping language codes to prefixed links of the form "language:title". & $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. 'LinkBegin':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:1528
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:189
MWNamespace\isNonincludable
static isNonincludable( $index)
It is not possible to use pages from this namespace as template?
Definition: Namespace.php:417
SpecialVersion\getExtAuthorsFileName
static getExtAuthorsFileName( $extDir)
Obtains the full path of an extensions authors or credits file if one exists.
Definition: SpecialVersion.php:911
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
SiteStats\users
static users()
Definition: SiteStats.php:140
SiteStats\activeUsers
static activeUsers()
Definition: SiteStats.php:148
ApiResult\setContent
static setContent(&$arr, $value, $subElemName=null)
Adds a content element to an array.
Definition: ApiResult.php:201
$extensions
$extensions
Definition: importImages.php:62
wfGetLB
wfGetLB( $wiki=false)
Get a load balancer object.
Definition: GlobalFunctions.php:3716
Title\newMainPage
static newMainPage()
Create a new Title for the Main Page.
Definition: Title.php:441
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:2530
ApiBase\PARAM_TYPE
const PARAM_TYPE
Definition: ApiBase.php:50
MWNamespace\getNamespaceContentModel
static getNamespaceContentModel( $index)
Get the default content model for a namespace This does not mean that all pages in that namespace hav...
Definition: Namespace.php:430
SiteStats\pages
static pages()
Definition: SiteStats.php:132
ApiBase\getResult
getResult()
Get the result object.
Definition: ApiBase.php:205
$ret
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 & $ret
Definition: hooks.txt:1530
SiteStats\numberingroup
static numberingroup( $group)
Find the number of users in a given user group.
Definition: SiteStats.php:166
Interwiki\getAllPrefixes
static getAllPrefixes( $local=null)
Returns all interwiki prefixes.
Definition: Interwiki.php:367
$params
$params
Definition: styleTest.css.php:40
$limit
if( $sleep) $limit
Definition: importImages.php:99
wfReadOnly
wfReadOnly()
Check whether the wiki is in read-only mode.
Definition: GlobalFunctions.php:1360
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name.
Definition: SpecialPage.php:74
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:56
$wgHooks
$wgHooks['ArticleShow'][]
Definition: hooks.txt:110
SpecialVersion\getSvnRevision
static getSvnRevision( $dir)
Retrieve the revision number of a Subversion working directory.
Definition: SpecialVersion.php:1103
Skin\getSkinNames
static getSkinNames()
Fetch the set of available skins.
Definition: Skin.php:44
User\getDefaultOptions
static getDefaultOptions()
Combine the language default options with any site-specific options and add the default language vari...
Definition: User.php:1350
SiteStats\images
static images()
Definition: SiteStats.php:156
ApiBase\getParamDescription
getParamDescription()
Returns an array of parameter descriptions.
Definition: ApiBase.php:577
ApiQueryBase\__construct
__construct(ApiBase $query, $moduleName, $paramPrefix='')
Definition: ApiQueryBase.php:43
$lb
if( $wgAPIRequestLog) $lb
Definition: api.php:126
MagicWord\getVariableIDs
static getVariableIDs()
Get an array of parser variable IDs.
Definition: MagicWord.php:252
$property
$property
Definition: styleTest.css.php:44
Skin\normalizeKey
static normalizeKey( $key)
Normalize a skin preference value to a form that can be loaded.
Definition: Skin.php:136
Language\fetchLanguageNames
static fetchLanguageNames( $inLanguage=null, $include='mw')
Get an array of language names, indexed by code.
Definition: Language.php:875
ApiQueryBase
This is a base class for all Query modules.
Definition: ApiQueryBase.php:34
ApiBase\getDescription
getDescription()
Returns the description string for this module.
Definition: ApiBase.php:541
TS_ISO_8601
const TS_ISO_8601
ISO 8601 format with no timezone: 1986-02-09T20:00:00Z.
Definition: GlobalFunctions.php:2495
ApiQueryBase\getDB
getDB()
Get the Query database connection (read-only)
Definition: ApiQueryBase.php:417
MWNamespace\isContent
static isContent( $index)
Does this namespace contain content, for the purposes of calculating statistics, etc?
Definition: Namespace.php:304
PROTO_CURRENT
const PROTO_CURRENT
Definition: Defines.php:270
wfRunHooks
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
Definition: GlobalFunctions.php:4058
MWNamespace\hasSubpages
static hasSubpages( $index)
Does the namespace allow subpages?
Definition: Namespace.php:325
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
$wgFileExtensions
if(! $wgHtml5Version && $wgAllowRdfaAttributes) $wgFileExtensions
Definition: Setup.php:369
ApiBase\getHelpUrls
getHelpUrls()
Definition: ApiBase.php:2104
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
SpecialVersion\getExtLicenseFileName
static getExtLicenseFileName( $extDir)
Obtains the full path of an extensions copying or license file if one exists.
Definition: SpecialVersion.php:940
ApiBase\getModulePrefix
getModulePrefix()
Get parameter prefix (usually two letters or an empty string).
Definition: ApiBase.php:165
wfWikiID
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Definition: GlobalFunctions.php:3660
ApiBase\extractRequestParams
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition: ApiBase.php:687
GitInfo
Definition: GitInfo.php:26
$title
presenting them properly to the user as errors is done by the caller $title
Definition: hooks.txt:1324
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
$wgNamespaceAliases
$wgNamespaceAliases['Image']
The canonical names of namespaces 6 and 7 are, as of v1.14, "File" and "File_talk".
Definition: Setup.php:142
ApiBase\dieUsage
dieUsage( $description, $errorCode, $httpRespCode=0, $extradata=null)
Throw a UsageException, which will (if uncaught) call the main module's error handler and die with an...
Definition: ApiBase.php:1363
SpecialVersion\getSvnInfo
static getSvnInfo( $dir)
Get an associative array of information about a given path, from its .svn subdirectory.
Definition: SpecialVersion.php:1029
SiteStats\jobs
static jobs()
Definition: SiteStats.php:189
PROTO_RELATIVE
const PROTO_RELATIVE
Definition: Defines.php:269
SpecialVersion\getGitHeadSha1
static getGitHeadSha1( $dir)
Definition: SpecialVersion.php:1119
ApiQueryBase\getCacheMode
getCacheMode( $params)
Get the cache mode for the data generated by this module.
Definition: ApiQueryBase.php:61
$linkPrefixCharset
$linkPrefixCharset
Definition: MessagesCrh_cyrl.php:102
$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:1530
$namespaces
namespace and then decline to actually register it & $namespaces
Definition: hooks.txt:815
wfReadOnlyReason
wfReadOnlyReason()
Get the value of $wgReadOnly or the contents of $wgReadOnlyFile.
Definition: GlobalFunctions.php:1369
$wgParser
$wgParser
Definition: Setup.php:587
$ext
$ext
Definition: NoLocalSettings.php:34
ApiBase\PARAM_DFLT
const PARAM_DFLT
Definition: ApiBase.php:46
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
MWNamespace\isCapitalized
static isCapitalized( $index)
Is the namespace first-letter capitalized?
Definition: Namespace.php:378
ApiBase\PARAM_ISMULTI
const PARAM_ISMULTI
Definition: ApiBase.php:48
ApiBase\getAllowedParams
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
Definition: ApiBase.php:565
SiteStats\views
static views()
Definition: SiteStats.php:108
ApiQueryBase\setContinueEnumParameter
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
Definition: ApiQueryBase.php:404
ApiBase\getExamples
getExamples()
Returns usage examples for this module.
Definition: ApiBase.php:549
Skin\getAllowedSkins
static getAllowedSkins()
Fetch the list of user-selectable skins in regards to $wgSkipSkins.
Definition: Skin.php:108
$query
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1105
ApiBase\dieDebug
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
Definition: ApiBase.php:2010
ApiBase\execute
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
MWNamespace\getCanonicalName
static getCanonicalName( $index)
Returns the canonical (English) name for a given index.
Definition: Namespace.php:237
SiteStats\edits
static edits()
Definition: SiteStats.php:116
ApiQueryBase\getPossibleErrors
getPossibleErrors()
Definition: ApiQueryBase.php:603
$GLOBALS
$GLOBALS['IP']
Definition: ComposerHookHandler.php:6
wfExpandUrl
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
Definition: GlobalFunctions.php:544
$type
$type
Definition: testCompression.php:46