Merge "cleanup action=tokens"
[lhc/web/wiklou.git] / includes / api / ApiQuerySiteinfo.php
1 <?php
2 /**
3 *
4 *
5 * Created on Sep 25, 2006
6 *
7 * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
23 *
24 * @file
25 */
26
27 /**
28 * A query action to return meta information about the wiki site.
29 *
30 * @ingroup API
31 */
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 'languages':
82 $fit = $this->appendLanguages( $p );
83 break;
84 case 'skins':
85 $fit = $this->appendSkins( $p );
86 break;
87 case 'extensiontags':
88 $fit = $this->appendExtensionTags( $p );
89 break;
90 case 'functionhooks':
91 $fit = $this->appendFunctionHooks( $p );
92 break;
93 case 'showhooks':
94 $fit = $this->appendSubscribedHooks( $p );
95 break;
96 case 'variables':
97 $fit = $this->appendVariables( $p );
98 break;
99 case 'protocols':
100 $fit = $this->appendProtocols( $p );
101 break;
102 default:
103 ApiBase::dieDebug( __METHOD__, "Unknown prop=$p" );
104 }
105 if ( !$fit ) {
106 // Abuse siprop as a query-continue parameter
107 // and set it to all unprocessed props
108 $this->setContinueEnumParameter( 'prop', implode( '|',
109 array_diff( $params['prop'], $done ) ) );
110 break;
111 }
112 $done[] = $p;
113 }
114 }
115
116 protected function appendGeneralInfo( $property ) {
117 global $wgContLang,
118 $wgDisableLangConversion,
119 $wgDisableTitleConversion;
120
121 $data = array();
122 $mainPage = Title::newMainPage();
123 $data['mainpage'] = $mainPage->getPrefixedText();
124 $data['base'] = wfExpandUrl( $mainPage->getFullUrl(), PROTO_CURRENT );
125 $data['sitename'] = $GLOBALS['wgSitename'];
126 $data['generator'] = "MediaWiki {$GLOBALS['wgVersion']}";
127 $data['phpversion'] = phpversion();
128 $data['phpsapi'] = PHP_SAPI;
129 $data['dbtype'] = $GLOBALS['wgDBtype'];
130 $data['dbversion'] = $this->getDB()->getServerVersion();
131
132 if ( !$wgDisableLangConversion ) {
133 $data['langconversion'] = '';
134 }
135
136 if ( !$wgDisableTitleConversion ) {
137 $data['titleconversion'] = '';
138 }
139
140 if ( $wgContLang->linkPrefixExtension() ) {
141 $data['linkprefix'] = wfMessage( 'linkprefix' )->inContentLanguage()->text();
142 }
143
144 $linktrail = $wgContLang->linkTrail();
145 if ( $linktrail ) {
146 $data['linktrail'] = $linktrail;
147 }
148
149 $git = SpecialVersion::getGitHeadSha1( $GLOBALS['IP'] );
150 if ( $git ) {
151 $data['git-hash'] = $git;
152 } else {
153 $svn = SpecialVersion::getSvnRevision( $GLOBALS['IP'] );
154 if ( $svn ) {
155 $data['rev'] = $svn;
156 }
157 }
158
159 // 'case-insensitive' option is reserved for future
160 $data['case'] = $GLOBALS['wgCapitalLinks'] ? 'first-letter' : 'case-sensitive';
161
162 if ( isset( $GLOBALS['wgRightsCode'] ) ) {
163 $data['rightscode'] = $GLOBALS['wgRightsCode'];
164 }
165 $data['rights'] = $GLOBALS['wgRightsText'];
166 $data['lang'] = $GLOBALS['wgLanguageCode'];
167
168 $fallbacks = array();
169 foreach( $wgContLang->getFallbackLanguages() as $code ) {
170 $fallbacks[] = array( 'code' => $code );
171 }
172 $data['fallback'] = $fallbacks;
173 $this->getResult()->setIndexedTagName( $data['fallback'], 'lang' );
174
175 if( $wgContLang->hasVariants() ) {
176 $variants = array();
177 foreach( $wgContLang->getVariants() as $code ) {
178 $variants[] = array( 'code' => $code );
179 }
180 $data['variants'] = $variants;
181 $this->getResult()->setIndexedTagName( $data['variants'], 'lang' );
182 }
183
184 if ( $wgContLang->isRTL() ) {
185 $data['rtl'] = '';
186 }
187 $data['fallback8bitEncoding'] = $wgContLang->fallback8bitEncoding();
188
189 if ( wfReadOnly() ) {
190 $data['readonly'] = '';
191 $data['readonlyreason'] = wfReadOnlyReason();
192 }
193 if ( $GLOBALS['wgEnableWriteAPI'] ) {
194 $data['writeapi'] = '';
195 }
196
197 $tz = $GLOBALS['wgLocaltimezone'];
198 $offset = $GLOBALS['wgLocalTZoffset'];
199 if ( is_null( $tz ) ) {
200 $tz = 'UTC';
201 $offset = 0;
202 } elseif ( is_null( $offset ) ) {
203 $offset = 0;
204 }
205 $data['timezone'] = $tz;
206 $data['timeoffset'] = intval( $offset );
207 $data['articlepath'] = $GLOBALS['wgArticlePath'];
208 $data['scriptpath'] = $GLOBALS['wgScriptPath'];
209 $data['script'] = $GLOBALS['wgScript'];
210 $data['variantarticlepath'] = $GLOBALS['wgVariantArticlePath'];
211 $data['server'] = $GLOBALS['wgServer'];
212 $data['wikiid'] = wfWikiID();
213 $data['time'] = wfTimestamp( TS_ISO_8601, time() );
214
215 if ( $GLOBALS['wgMiserMode'] ) {
216 $data['misermode'] = '';
217 }
218
219 $data['maxuploadsize'] = UploadBase::getMaxUploadSize();
220
221 wfRunHooks( 'APIQuerySiteInfoGeneralInfo', array( $this, &$data ) );
222
223 return $this->getResult()->addValue( 'query', $property, $data );
224 }
225
226 protected function appendNamespaces( $property ) {
227 global $wgContLang;
228 $data = array();
229 foreach ( $wgContLang->getFormattedNamespaces() as $ns => $title ) {
230 $data[$ns] = array(
231 'id' => intval( $ns ),
232 'case' => MWNamespace::isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive',
233 );
234 ApiResult::setContent( $data[$ns], $title );
235 $canonical = MWNamespace::getCanonicalName( $ns );
236
237 if ( MWNamespace::hasSubpages( $ns ) ) {
238 $data[$ns]['subpages'] = '';
239 }
240
241 if ( $canonical ) {
242 $data[$ns]['canonical'] = strtr( $canonical, '_', ' ' );
243 }
244
245 if ( MWNamespace::isContent( $ns ) ) {
246 $data[$ns]['content'] = '';
247 }
248
249 if ( MWNamespace::isNonincludable( $ns ) ) {
250 $data[$ns]['nonincludable'] = '';
251 }
252
253 $contentmodel = MWNamespace::getNamespaceContentModel( $ns );
254 if ( $contentmodel ) {
255 $data[$ns]['defaultcontentmodel'] = $contentmodel;
256 }
257 }
258
259 $this->getResult()->setIndexedTagName( $data, 'ns' );
260 return $this->getResult()->addValue( 'query', $property, $data );
261 }
262
263 protected function appendNamespaceAliases( $property ) {
264 global $wgNamespaceAliases, $wgContLang;
265 $aliases = array_merge( $wgNamespaceAliases, $wgContLang->getNamespaceAliases() );
266 $namespaces = $wgContLang->getNamespaces();
267 $data = array();
268 foreach ( $aliases as $title => $ns ) {
269 if ( $namespaces[$ns] == $title ) {
270 // Don't list duplicates
271 continue;
272 }
273 $item = array(
274 'id' => intval( $ns )
275 );
276 ApiResult::setContent( $item, strtr( $title, '_', ' ' ) );
277 $data[] = $item;
278 }
279
280 $this->getResult()->setIndexedTagName( $data, 'ns' );
281 return $this->getResult()->addValue( 'query', $property, $data );
282 }
283
284 protected function appendSpecialPageAliases( $property ) {
285 global $wgContLang;
286 $data = array();
287 $aliases = $wgContLang->getSpecialPageAliases();
288 foreach ( SpecialPageFactory::getList() as $specialpage => $stuff ) {
289 if ( isset( $aliases[$specialpage] ) ) {
290 $arr = array( 'realname' => $specialpage, 'aliases' => $aliases[$specialpage] );
291 $this->getResult()->setIndexedTagName( $arr['aliases'], 'alias' );
292 $data[] = $arr;
293 }
294 }
295 $this->getResult()->setIndexedTagName( $data, 'specialpage' );
296 return $this->getResult()->addValue( 'query', $property, $data );
297 }
298
299 protected function appendMagicWords( $property ) {
300 global $wgContLang;
301 $data = array();
302 foreach ( $wgContLang->getMagicWords() as $magicword => $aliases ) {
303 $caseSensitive = array_shift( $aliases );
304 $arr = array( 'name' => $magicword, 'aliases' => $aliases );
305 if ( $caseSensitive ) {
306 $arr['case-sensitive'] = '';
307 }
308 $this->getResult()->setIndexedTagName( $arr['aliases'], 'alias' );
309 $data[] = $arr;
310 }
311 $this->getResult()->setIndexedTagName( $data, 'magicword' );
312 return $this->getResult()->addValue( 'query', $property, $data );
313 }
314
315 protected function appendInterwikiMap( $property, $filter ) {
316 $local = null;
317 if ( $filter === 'local' ) {
318 $local = 1;
319 } elseif ( $filter === '!local' ) {
320 $local = 0;
321 } elseif ( $filter ) {
322 ApiBase::dieDebug( __METHOD__, "Unknown filter=$filter" );
323 }
324
325 $params = $this->extractRequestParams();
326 $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : '';
327 $langNames = Language::fetchLanguageNames( $langCode );
328
329 $getPrefixes = Interwiki::getAllPrefixes( $local );
330 $data = array();
331
332 foreach ( $getPrefixes as $row ) {
333 $prefix = $row['iw_prefix'];
334 $val = array();
335 $val['prefix'] = $prefix;
336 if ( $row['iw_local'] == '1' ) {
337 $val['local'] = '';
338 }
339 // $val['trans'] = intval( $row['iw_trans'] ); // should this be exposed?
340 if ( isset( $langNames[$prefix] ) ) {
341 $val['language'] = $langNames[$prefix];
342 }
343 $val['url'] = wfExpandUrl( $row['iw_url'], PROTO_CURRENT );
344 if( isset( $row['iw_wikiid'] ) ) {
345 $val['wikiid'] = $row['iw_wikiid'];
346 }
347 if( isset( $row['iw_api'] ) ) {
348 $val['api'] = $row['iw_api'];
349 }
350
351 $data[] = $val;
352 }
353
354 $this->getResult()->setIndexedTagName( $data, 'iw' );
355 return $this->getResult()->addValue( 'query', $property, $data );
356 }
357
358 protected function appendDbReplLagInfo( $property, $includeAll ) {
359 global $wgShowHostnames;
360 $data = array();
361 $lb = wfGetLB();
362 if ( $includeAll ) {
363 if ( !$wgShowHostnames ) {
364 $this->dieUsage( 'Cannot view all servers info unless $wgShowHostnames is true', 'includeAllDenied' );
365 }
366
367 $lags = $lb->getLagTimes();
368 foreach ( $lags as $i => $lag ) {
369 $data[] = array(
370 'host' => $lb->getServerName( $i ),
371 'lag' => $lag
372 );
373 }
374 } else {
375 list( $host, $lag, $index ) = $lb->getMaxLag();
376 $data[] = array(
377 'host' => $wgShowHostnames
378 ? $lb->getServerName( $index )
379 : '',
380 'lag' => intval( $lag )
381 );
382 }
383
384 $result = $this->getResult();
385 $result->setIndexedTagName( $data, 'db' );
386 return $this->getResult()->addValue( 'query', $property, $data );
387 }
388
389 protected function appendStatistics( $property ) {
390 global $wgDisableCounters;
391 $data = array();
392 $data['pages'] = intval( SiteStats::pages() );
393 $data['articles'] = intval( SiteStats::articles() );
394 if ( !$wgDisableCounters ) {
395 $data['views'] = intval( SiteStats::views() );
396 }
397 $data['edits'] = intval( SiteStats::edits() );
398 $data['images'] = intval( SiteStats::images() );
399 $data['users'] = intval( SiteStats::users() );
400 $data['activeusers'] = intval( SiteStats::activeUsers() );
401 $data['admins'] = intval( SiteStats::numberingroup( 'sysop' ) );
402 $data['jobs'] = intval( SiteStats::jobs() );
403 return $this->getResult()->addValue( 'query', $property, $data );
404 }
405
406 protected function appendUserGroups( $property, $numberInGroup ) {
407 global $wgGroupPermissions, $wgAddGroups, $wgRemoveGroups, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
408
409 $data = array();
410 $result = $this->getResult();
411 foreach ( $wgGroupPermissions as $group => $permissions ) {
412 $arr = array(
413 'name' => $group,
414 'rights' => array_keys( $permissions, true ),
415 );
416
417 if ( $numberInGroup ) {
418 global $wgAutopromote;
419
420 if ( $group == 'user' ) {
421 $arr['number'] = SiteStats::users();
422
423 // '*' and autopromote groups have no size
424 } elseif ( $group !== '*' && !isset( $wgAutopromote[$group] ) ) {
425 $arr['number'] = SiteStats::numberInGroup( $group );
426 }
427 }
428
429 $groupArr = array(
430 'add' => $wgAddGroups,
431 'remove' => $wgRemoveGroups,
432 'add-self' => $wgGroupsAddToSelf,
433 'remove-self' => $wgGroupsRemoveFromSelf
434 );
435
436 foreach ( $groupArr as $type => $rights ) {
437 if ( isset( $rights[$group] ) ) {
438 $arr[$type] = $rights[$group];
439 $result->setIndexedTagName( $arr[$type], 'group' );
440 }
441 }
442
443 $result->setIndexedTagName( $arr['rights'], 'permission' );
444 $data[] = $arr;
445 }
446
447 $result->setIndexedTagName( $data, 'group' );
448 return $result->addValue( 'query', $property, $data );
449 }
450
451 protected function appendFileExtensions( $property ) {
452 global $wgFileExtensions;
453
454 $data = array();
455 foreach ( $wgFileExtensions as $ext ) {
456 $data[] = array( 'ext' => $ext );
457 }
458 $this->getResult()->setIndexedTagName( $data, 'fe' );
459 return $this->getResult()->addValue( 'query', $property, $data );
460 }
461
462 protected function appendExtensions( $property ) {
463 global $wgExtensionCredits;
464 $data = array();
465 foreach ( $wgExtensionCredits as $type => $extensions ) {
466 foreach ( $extensions as $ext ) {
467 $ret = array();
468 $ret['type'] = $type;
469 if ( isset( $ext['name'] ) ) {
470 $ret['name'] = $ext['name'];
471 }
472 if ( isset( $ext['description'] ) ) {
473 $ret['description'] = $ext['description'];
474 }
475 if ( isset( $ext['descriptionmsg'] ) ) {
476 // Can be a string or array( key, param1, param2, ... )
477 if ( is_array( $ext['descriptionmsg'] ) ) {
478 $ret['descriptionmsg'] = $ext['descriptionmsg'][0];
479 $ret['descriptionmsgparams'] = array_slice( $ext['descriptionmsg'], 1 );
480 $this->getResult()->setIndexedTagName( $ret['descriptionmsgparams'], 'param' );
481 } else {
482 $ret['descriptionmsg'] = $ext['descriptionmsg'];
483 }
484 }
485 if ( isset( $ext['author'] ) ) {
486 $ret['author'] = is_array( $ext['author'] ) ?
487 implode( ', ', $ext['author'] ) : $ext['author'];
488 }
489 if ( isset( $ext['url'] ) ) {
490 $ret['url'] = $ext['url'];
491 }
492 if ( isset( $ext['version'] ) ) {
493 $ret['version'] = $ext['version'];
494 } elseif ( isset( $ext['svn-revision'] ) &&
495 preg_match( '/\$(?:Rev|LastChangedRevision|Revision): *(\d+)/',
496 $ext['svn-revision'], $m ) )
497 {
498 $ret['version'] = 'r' . $m[1];
499 }
500 $data[] = $ret;
501 }
502 }
503
504 $this->getResult()->setIndexedTagName( $data, 'ext' );
505 return $this->getResult()->addValue( 'query', $property, $data );
506 }
507
508 protected function appendRightsInfo( $property ) {
509 global $wgRightsPage, $wgRightsUrl, $wgRightsText;
510 $title = Title::newFromText( $wgRightsPage );
511 $url = $title ? wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ) : $wgRightsUrl;
512 $text = $wgRightsText;
513 if ( !$text && $title ) {
514 $text = $title->getPrefixedText();
515 }
516
517 $data = array(
518 'url' => $url ? $url : '',
519 'text' => $text ? $text : ''
520 );
521
522 return $this->getResult()->addValue( 'query', $property, $data );
523 }
524
525 public function appendLanguages( $property ) {
526 $params = $this->extractRequestParams();
527 $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : '';
528 $langNames = Language::fetchLanguageNames( $langCode );
529
530 $data = array();
531
532 foreach ( $langNames as $code => $name ) {
533 $lang = array( 'code' => $code );
534 ApiResult::setContent( $lang, $name );
535 $data[] = $lang;
536 }
537 $this->getResult()->setIndexedTagName( $data, 'lang' );
538 return $this->getResult()->addValue( 'query', $property, $data );
539 }
540
541 public function appendSkins( $property ) {
542 $data = array();
543 foreach ( Skin::getSkinNames() as $name => $displayName ) {
544 $skin = array( 'code' => $name );
545 ApiResult::setContent( $skin, $displayName );
546 $data[] = $skin;
547 }
548 $this->getResult()->setIndexedTagName( $data, 'skin' );
549 return $this->getResult()->addValue( 'query', $property, $data );
550 }
551
552 public function appendExtensionTags( $property ) {
553 global $wgParser;
554 $wgParser->firstCallInit();
555 $tags = array_map( array( $this, 'formatParserTags' ), $wgParser->getTags() );
556 $this->getResult()->setIndexedTagName( $tags, 't' );
557 return $this->getResult()->addValue( 'query', $property, $tags );
558 }
559
560 public function appendFunctionHooks( $property ) {
561 global $wgParser;
562 $wgParser->firstCallInit();
563 $hooks = $wgParser->getFunctionHooks();
564 $this->getResult()->setIndexedTagName( $hooks, 'h' );
565 return $this->getResult()->addValue( 'query', $property, $hooks );
566 }
567
568 public function appendVariables( $property ) {
569 $variables = MagicWord::getVariableIDs();
570 $this->getResult()->setIndexedTagName( $variables, 'v' );
571 return $this->getResult()->addValue( 'query', $property, $variables );
572 }
573
574 public function appendProtocols( $property ) {
575 global $wgUrlProtocols;
576 // Make a copy of the global so we don't try to set the _element key of it - bug 45130
577 $protocols = array_values( $wgUrlProtocols );
578 $this->getResult()->setIndexedTagName( $protocols, 'p' );
579 return $this->getResult()->addValue( 'query', $property, $protocols );
580 }
581
582 private function formatParserTags( $item ) {
583 return "<{$item}>";
584 }
585
586 public function appendSubscribedHooks( $property ) {
587 global $wgHooks;
588 $myWgHooks = $wgHooks;
589 ksort( $myWgHooks );
590
591 $data = array();
592 foreach ( $myWgHooks as $hook => $hooks ) {
593 $arr = array(
594 'name' => $hook,
595 'subscribers' => array_map( array( 'SpecialVersion', 'arrayToString' ), $hooks ),
596 );
597
598 $this->getResult()->setIndexedTagName( $arr['subscribers'], 's' );
599 $data[] = $arr;
600 }
601
602 $this->getResult()->setIndexedTagName( $data, 'hook' );
603 return $this->getResult()->addValue( 'query', $property, $data );
604 }
605
606 public function getCacheMode( $params ) {
607 return 'public';
608 }
609
610 public function getAllowedParams() {
611 return array(
612 'prop' => array(
613 ApiBase::PARAM_DFLT => 'general',
614 ApiBase::PARAM_ISMULTI => true,
615 ApiBase::PARAM_TYPE => array(
616 'general',
617 'namespaces',
618 'namespacealiases',
619 'specialpagealiases',
620 'magicwords',
621 'interwikimap',
622 'dbrepllag',
623 'statistics',
624 'usergroups',
625 'extensions',
626 'fileextensions',
627 'rightsinfo',
628 'languages',
629 'skins',
630 'extensiontags',
631 'functionhooks',
632 'showhooks',
633 'variables',
634 'protocols',
635 )
636 ),
637 'filteriw' => array(
638 ApiBase::PARAM_TYPE => array(
639 'local',
640 '!local',
641 )
642 ),
643 'showalldb' => false,
644 'numberingroup' => false,
645 'inlanguagecode' => null,
646 );
647 }
648
649 public function getParamDescription() {
650 $p = $this->getModulePrefix();
651 return array(
652 'prop' => array(
653 'Which sysinfo properties to get:',
654 ' general - Overall system information',
655 ' namespaces - List of registered namespaces and their canonical names',
656 ' namespacealiases - List of registered namespace aliases',
657 ' specialpagealiases - List of special page aliases',
658 ' magicwords - List of magic words and their aliases',
659 ' statistics - Returns site statistics',
660 " interwikimap - Returns interwiki map (optionally filtered, (optionally localised by using {$p}inlanguagecode))",
661 ' dbrepllag - Returns database server with the highest replication lag',
662 ' usergroups - Returns user groups and the associated permissions',
663 ' extensions - Returns extensions installed on the wiki',
664 ' fileextensions - Returns list of file extensions allowed to be uploaded',
665 ' rightsinfo - Returns wiki rights (license) information if available',
666 " languages - Returns a list of languages MediaWiki supports (optionally localised by using {$p}inlanguagecode)",
667 ' skins - Returns a list of all enabled skins',
668 ' extensiontags - Returns a list of parser extension tags',
669 ' functionhooks - Returns a list of parser function hooks',
670 ' showhooks - Returns a list of all subscribed hooks (contents of $wgHooks)',
671 ' variables - Returns a list of variable IDs',
672 ' protocols - Returns a list of protocols that are allowed in external links.',
673 ),
674 'filteriw' => 'Return only local or only nonlocal entries of the interwiki map',
675 'showalldb' => 'List all database servers, not just the one lagging the most',
676 'numberingroup' => 'Lists the number of users in user groups',
677 'inlanguagecode' => 'Language code for localised language names (best effort, use CLDR extension)',
678 );
679 }
680
681 public function getDescription() {
682 return 'Return general information about the site';
683 }
684
685 public function getPossibleErrors() {
686 return array_merge( parent::getPossibleErrors(), array(
687 array( 'code' => 'includeAllDenied', 'info' => 'Cannot view all servers info unless $wgShowHostnames is true' ),
688 ) );
689 }
690
691 public function getExamples() {
692 return array(
693 'api.php?action=query&meta=siteinfo&siprop=general|namespaces|namespacealiases|statistics',
694 'api.php?action=query&meta=siteinfo&siprop=interwikimap&sifilteriw=local',
695 'api.php?action=query&meta=siteinfo&siprop=dbrepllag&sishowalldb=',
696 );
697 }
698
699 public function getHelpUrls() {
700 return 'https://www.mediawiki.org/wiki/API:Meta#siteinfo_.2F_si';
701 }
702 }