Add APIQuerySiteInfoStatisticsInfo hook
[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 // $val['trans'] = intval( $row['iw_trans'] ); // should this be exposed?
361 if ( isset( $langNames[$prefix] ) ) {
362 $val['language'] = $langNames[$prefix];
363 }
364 $val['url'] = wfExpandUrl( $row['iw_url'], PROTO_CURRENT );
365 if ( isset( $row['iw_wikiid'] ) ) {
366 $val['wikiid'] = $row['iw_wikiid'];
367 }
368 if ( isset( $row['iw_api'] ) ) {
369 $val['api'] = $row['iw_api'];
370 }
371
372 $data[] = $val;
373 }
374
375 $this->getResult()->setIndexedTagName( $data, 'iw' );
376 return $this->getResult()->addValue( 'query', $property, $data );
377 }
378
379 protected function appendDbReplLagInfo( $property, $includeAll ) {
380 global $wgShowHostnames;
381 $data = array();
382 $lb = wfGetLB();
383 if ( $includeAll ) {
384 if ( !$wgShowHostnames ) {
385 $this->dieUsage( 'Cannot view all servers info unless $wgShowHostnames is true', 'includeAllDenied' );
386 }
387
388 $lags = $lb->getLagTimes();
389 foreach ( $lags as $i => $lag ) {
390 $data[] = array(
391 'host' => $lb->getServerName( $i ),
392 'lag' => $lag
393 );
394 }
395 } else {
396 list( , $lag, $index ) = $lb->getMaxLag();
397 $data[] = array(
398 'host' => $wgShowHostnames
399 ? $lb->getServerName( $index )
400 : '',
401 'lag' => intval( $lag )
402 );
403 }
404
405 $result = $this->getResult();
406 $result->setIndexedTagName( $data, 'db' );
407 return $this->getResult()->addValue( 'query', $property, $data );
408 }
409
410 protected function appendStatistics( $property ) {
411 global $wgDisableCounters;
412 $data = array();
413 $data['pages'] = intval( SiteStats::pages() );
414 $data['articles'] = intval( SiteStats::articles() );
415 if ( !$wgDisableCounters ) {
416 $data['views'] = intval( SiteStats::views() );
417 }
418 $data['edits'] = intval( SiteStats::edits() );
419 $data['images'] = intval( SiteStats::images() );
420 $data['users'] = intval( SiteStats::users() );
421 $data['activeusers'] = intval( SiteStats::activeUsers() );
422 $data['admins'] = intval( SiteStats::numberingroup( 'sysop' ) );
423 $data['jobs'] = intval( SiteStats::jobs() );
424
425 wfRunHooks( 'APIQuerySiteInfoStatisticsInfo', array( &$data ) );
426
427 return $this->getResult()->addValue( 'query', $property, $data );
428 }
429
430 protected function appendUserGroups( $property, $numberInGroup ) {
431 global $wgGroupPermissions, $wgAddGroups, $wgRemoveGroups;
432 global $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
433
434 $data = array();
435 $result = $this->getResult();
436 foreach ( $wgGroupPermissions as $group => $permissions ) {
437 $arr = array(
438 'name' => $group,
439 'rights' => array_keys( $permissions, true ),
440 );
441
442 if ( $numberInGroup ) {
443 global $wgAutopromote;
444
445 if ( $group == 'user' ) {
446 $arr['number'] = SiteStats::users();
447
448 // '*' and autopromote groups have no size
449 } elseif ( $group !== '*' && !isset( $wgAutopromote[$group] ) ) {
450 $arr['number'] = SiteStats::numberInGroup( $group );
451 }
452 }
453
454 $groupArr = array(
455 'add' => $wgAddGroups,
456 'remove' => $wgRemoveGroups,
457 'add-self' => $wgGroupsAddToSelf,
458 'remove-self' => $wgGroupsRemoveFromSelf
459 );
460
461 foreach ( $groupArr as $type => $rights ) {
462 if ( isset( $rights[$group] ) ) {
463 $arr[$type] = $rights[$group];
464 $result->setIndexedTagName( $arr[$type], 'group' );
465 }
466 }
467
468 $result->setIndexedTagName( $arr['rights'], 'permission' );
469 $data[] = $arr;
470 }
471
472 $result->setIndexedTagName( $data, 'group' );
473 return $result->addValue( 'query', $property, $data );
474 }
475
476 protected function appendFileExtensions( $property ) {
477 global $wgFileExtensions;
478
479 $data = array();
480 foreach ( array_unique( $wgFileExtensions ) as $ext ) {
481 $data[] = array( 'ext' => $ext );
482 }
483 $this->getResult()->setIndexedTagName( $data, 'fe' );
484 return $this->getResult()->addValue( 'query', $property, $data );
485 }
486
487 protected function appendExtensions( $property ) {
488 global $wgExtensionCredits;
489 $data = array();
490 foreach ( $wgExtensionCredits as $type => $extensions ) {
491 foreach ( $extensions as $ext ) {
492 $ret = array();
493 $ret['type'] = $type;
494 if ( isset( $ext['name'] ) ) {
495 $ret['name'] = $ext['name'];
496 }
497 if ( isset( $ext['description'] ) ) {
498 $ret['description'] = $ext['description'];
499 }
500 if ( isset( $ext['descriptionmsg'] ) ) {
501 // Can be a string or array( key, param1, param2, ... )
502 if ( is_array( $ext['descriptionmsg'] ) ) {
503 $ret['descriptionmsg'] = $ext['descriptionmsg'][0];
504 $ret['descriptionmsgparams'] = array_slice( $ext['descriptionmsg'], 1 );
505 $this->getResult()->setIndexedTagName( $ret['descriptionmsgparams'], 'param' );
506 } else {
507 $ret['descriptionmsg'] = $ext['descriptionmsg'];
508 }
509 }
510 if ( isset( $ext['author'] ) ) {
511 $ret['author'] = is_array( $ext['author'] ) ?
512 implode( ', ', $ext['author'] ) : $ext['author'];
513 }
514 if ( isset( $ext['url'] ) ) {
515 $ret['url'] = $ext['url'];
516 }
517 if ( isset( $ext['version'] ) ) {
518 $ret['version'] = $ext['version'];
519 } elseif ( isset( $ext['svn-revision'] ) &&
520 preg_match( '/\$(?:Rev|LastChangedRevision|Revision): *(\d+)/',
521 $ext['svn-revision'], $m ) )
522 {
523 $ret['version'] = 'r' . $m[1];
524 }
525 $data[] = $ret;
526 }
527 }
528
529 $this->getResult()->setIndexedTagName( $data, 'ext' );
530 return $this->getResult()->addValue( 'query', $property, $data );
531 }
532
533 protected function appendRightsInfo( $property ) {
534 global $wgRightsPage, $wgRightsUrl, $wgRightsText;
535 $title = Title::newFromText( $wgRightsPage );
536 $url = $title ? wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ) : $wgRightsUrl;
537 $text = $wgRightsText;
538 if ( !$text && $title ) {
539 $text = $title->getPrefixedText();
540 }
541
542 $data = array(
543 'url' => $url ? $url : '',
544 'text' => $text ? $text : ''
545 );
546
547 return $this->getResult()->addValue( 'query', $property, $data );
548 }
549
550 public function appendLanguages( $property ) {
551 $params = $this->extractRequestParams();
552 $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : '';
553 $langNames = Language::fetchLanguageNames( $langCode );
554
555 $data = array();
556
557 foreach ( $langNames as $code => $name ) {
558 $lang = array( 'code' => $code );
559 ApiResult::setContent( $lang, $name );
560 $data[] = $lang;
561 }
562 $this->getResult()->setIndexedTagName( $data, 'lang' );
563 return $this->getResult()->addValue( 'query', $property, $data );
564 }
565
566 public function appendSkins( $property ) {
567 $data = array();
568 $usable = Skin::getUsableSkins();
569 $default = Skin::normalizeKey( 'default' );
570 foreach ( Skin::getSkinNames() as $name => $displayName ) {
571 $skin = array( 'code' => $name );
572 ApiResult::setContent( $skin, $displayName );
573 if ( !isset( $usable[$name] ) ) {
574 $skin['unusable'] = '';
575 }
576 if ( $name === $default ) {
577 $skin['default'] = '';
578 }
579 $data[] = $skin;
580 }
581 $this->getResult()->setIndexedTagName( $data, 'skin' );
582 return $this->getResult()->addValue( 'query', $property, $data );
583 }
584
585 public function appendExtensionTags( $property ) {
586 global $wgParser;
587 $wgParser->firstCallInit();
588 $tags = array_map( array( $this, 'formatParserTags' ), $wgParser->getTags() );
589 $this->getResult()->setIndexedTagName( $tags, 't' );
590 return $this->getResult()->addValue( 'query', $property, $tags );
591 }
592
593 public function appendFunctionHooks( $property ) {
594 global $wgParser;
595 $wgParser->firstCallInit();
596 $hooks = $wgParser->getFunctionHooks();
597 $this->getResult()->setIndexedTagName( $hooks, 'h' );
598 return $this->getResult()->addValue( 'query', $property, $hooks );
599 }
600
601 public function appendVariables( $property ) {
602 $variables = MagicWord::getVariableIDs();
603 $this->getResult()->setIndexedTagName( $variables, 'v' );
604 return $this->getResult()->addValue( 'query', $property, $variables );
605 }
606
607 public function appendProtocols( $property ) {
608 global $wgUrlProtocols;
609 // Make a copy of the global so we don't try to set the _element key of it - bug 45130
610 $protocols = array_values( $wgUrlProtocols );
611 $this->getResult()->setIndexedTagName( $protocols, 'p' );
612 return $this->getResult()->addValue( 'query', $property, $protocols );
613 }
614
615 private function formatParserTags( $item ) {
616 return "<{$item}>";
617 }
618
619 public function appendSubscribedHooks( $property ) {
620 global $wgHooks;
621 $myWgHooks = $wgHooks;
622 ksort( $myWgHooks );
623
624 $data = array();
625 foreach ( $myWgHooks as $hook => $hooks ) {
626 $arr = array(
627 'name' => $hook,
628 'subscribers' => array_map( array( 'SpecialVersion', 'arrayToString' ), $hooks ),
629 );
630
631 $this->getResult()->setIndexedTagName( $arr['subscribers'], 's' );
632 $data[] = $arr;
633 }
634
635 $this->getResult()->setIndexedTagName( $data, 'hook' );
636 return $this->getResult()->addValue( 'query', $property, $data );
637 }
638
639 public function getCacheMode( $params ) {
640 return 'public';
641 }
642
643 public function getAllowedParams() {
644 return array(
645 'prop' => array(
646 ApiBase::PARAM_DFLT => 'general',
647 ApiBase::PARAM_ISMULTI => true,
648 ApiBase::PARAM_TYPE => array(
649 'general',
650 'namespaces',
651 'namespacealiases',
652 'specialpagealiases',
653 'magicwords',
654 'interwikimap',
655 'dbrepllag',
656 'statistics',
657 'usergroups',
658 'extensions',
659 'fileextensions',
660 'rightsinfo',
661 'languages',
662 'skins',
663 'extensiontags',
664 'functionhooks',
665 'showhooks',
666 'variables',
667 'protocols',
668 )
669 ),
670 'filteriw' => array(
671 ApiBase::PARAM_TYPE => array(
672 'local',
673 '!local',
674 )
675 ),
676 'showalldb' => false,
677 'numberingroup' => false,
678 'inlanguagecode' => null,
679 );
680 }
681
682 public function getParamDescription() {
683 $p = $this->getModulePrefix();
684 return array(
685 'prop' => array(
686 'Which sysinfo properties to get:',
687 ' general - Overall system information',
688 ' namespaces - List of registered namespaces and their canonical names',
689 ' namespacealiases - List of registered namespace aliases',
690 ' specialpagealiases - List of special page aliases',
691 ' magicwords - List of magic words and their aliases',
692 ' statistics - Returns site statistics',
693 " interwikimap - Returns interwiki map " .
694 "(optionally filtered, (optionally localised by using {$p}inlanguagecode))",
695 ' dbrepllag - Returns database server with the highest replication lag',
696 ' usergroups - Returns user groups and the associated permissions',
697 ' extensions - Returns extensions installed on the wiki',
698 ' fileextensions - Returns list of file extensions allowed to be uploaded',
699 ' rightsinfo - Returns wiki rights (license) information if available',
700 " languages - Returns a list of languages MediaWiki supports" .
701 "(optionally localised by using {$p}inlanguagecode)",
702 ' skins - Returns a list of all enabled skins',
703 ' extensiontags - Returns a list of parser extension tags',
704 ' functionhooks - Returns a list of parser function hooks',
705 ' showhooks - Returns a list of all subscribed hooks (contents of $wgHooks)',
706 ' variables - Returns a list of variable IDs',
707 ' protocols - Returns a list of protocols that are allowed in external links.',
708 ),
709 'filteriw' => 'Return only local or only nonlocal entries of the interwiki map',
710 'showalldb' => 'List all database servers, not just the one lagging the most',
711 'numberingroup' => 'Lists the number of users in user groups',
712 'inlanguagecode' => 'Language code for localised language names (best effort, use CLDR extension)',
713 );
714 }
715
716 public function getDescription() {
717 return 'Return general information about the site';
718 }
719
720 public function getPossibleErrors() {
721 return array_merge( parent::getPossibleErrors(), array( array(
722 'code' => 'includeAllDenied',
723 'info' => 'Cannot view all servers info unless $wgShowHostnames is true'
724 ), ) );
725 }
726
727 public function getExamples() {
728 return array(
729 'api.php?action=query&meta=siteinfo&siprop=general|namespaces|namespacealiases|statistics',
730 'api.php?action=query&meta=siteinfo&siprop=interwikimap&sifilteriw=local',
731 'api.php?action=query&meta=siteinfo&siprop=dbrepllag&sishowalldb=',
732 );
733 }
734
735 public function getHelpUrls() {
736 return 'https://www.mediawiki.org/wiki/API:Meta#siteinfo_.2F_si';
737 }
738 }