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