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