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