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