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