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