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