5 * Created on Sep 25, 2006
7 * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
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.
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.
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
28 * A query action to return meta information about the wiki site.
32 class ApiQuerySiteinfo
extends ApiQueryBase
{
34 public function __construct( ApiQuery
$query, $moduleName ) {
35 parent
::__construct( $query, $moduleName, 'si' );
38 public function execute() {
39 $params = $this->extractRequestParams();
42 foreach ( $params['prop'] as $p ) {
45 $fit = $this->appendGeneralInfo( $p );
48 $fit = $this->appendNamespaces( $p );
50 case 'namespacealiases':
51 $fit = $this->appendNamespaceAliases( $p );
53 case 'specialpagealiases':
54 $fit = $this->appendSpecialPageAliases( $p );
57 $fit = $this->appendMagicWords( $p );
60 $filteriw = isset( $params['filteriw'] ) ?
$params['filteriw'] : false;
61 $fit = $this->appendInterwikiMap( $p, $filteriw );
64 $fit = $this->appendDbReplLagInfo( $p, $params['showalldb'] );
67 $fit = $this->appendStatistics( $p );
70 $fit = $this->appendUserGroups( $p, $params['numberingroup'] );
73 $fit = $this->appendInstalledLibraries( $p );
76 $fit = $this->appendExtensions( $p );
78 case 'fileextensions':
79 $fit = $this->appendFileExtensions( $p );
82 $fit = $this->appendRightsInfo( $p );
85 $fit = $this->appendRestrictions( $p );
88 $fit = $this->appendLanguages( $p );
91 $fit = $this->appendSkins( $p );
94 $fit = $this->appendExtensionTags( $p );
97 $fit = $this->appendFunctionHooks( $p );
100 $fit = $this->appendSubscribedHooks( $p );
103 $fit = $this->appendVariables( $p );
106 $fit = $this->appendProtocols( $p );
108 case 'defaultoptions':
109 $fit = $this->appendDefaultOptions( $p );
112 $fit = $this->appendUploadDialog( $p );
115 ApiBase
::dieDebug( __METHOD__
, "Unknown prop=$p" );
118 // Abuse siprop as a query-continue parameter
119 // and set it to all unprocessed props
120 $this->setContinueEnumParameter( 'prop', implode( '|',
121 array_diff( $params['prop'], $done ) ) );
128 protected function appendGeneralInfo( $property ) {
131 $config = $this->getConfig();
134 $mainPage = Title
::newMainPage();
135 $data['mainpage'] = $mainPage->getPrefixedText();
136 $data['base'] = wfExpandUrl( $mainPage->getFullURL(), PROTO_CURRENT
);
137 $data['sitename'] = $config->get( 'Sitename' );
139 // wgLogo can either be a relative or an absolute path
140 // make sure we always return an absolute path
141 $data['logo'] = wfExpandUrl( $config->get( 'Logo' ), PROTO_RELATIVE
);
143 $data['generator'] = "MediaWiki {$config->get( 'Version' )}";
145 $data['phpversion'] = PHP_VERSION
;
146 $data['phpsapi'] = PHP_SAPI
;
147 if ( defined( 'HHVM_VERSION' ) ) {
148 $data['hhvmversion'] = HHVM_VERSION
;
150 $data['dbtype'] = $config->get( 'DBtype' );
151 $data['dbversion'] = $this->getDB()->getServerVersion();
154 $allowException = true;
155 if ( !$config->get( 'AllowExternalImages' ) ) {
156 $data['imagewhitelistenabled'] = (bool)$config->get( 'EnableImageWhitelist' );
157 $allowFrom = $config->get( 'AllowExternalImagesFrom' );
158 $allowException = !empty( $allowFrom );
160 if ( $allowException ) {
161 $data['externalimages'] = (array)$allowFrom;
162 ApiResult
::setIndexedTagName( $data['externalimages'], 'prefix' );
165 $data['langconversion'] = !$config->get( 'DisableLangConversion' );
166 $data['titleconversion'] = !$config->get( 'DisableTitleConversion' );
168 if ( $wgContLang->linkPrefixExtension() ) {
169 $linkPrefixCharset = $wgContLang->linkPrefixCharset();
170 $data['linkprefixcharset'] = $linkPrefixCharset;
171 // For backwards compatibility
172 $data['linkprefix'] = "/^((?>.*[^$linkPrefixCharset]|))(.+)$/sDu";
174 $data['linkprefixcharset'] = '';
175 $data['linkprefix'] = '';
178 $linktrail = $wgContLang->linkTrail();
179 $data['linktrail'] = $linktrail ?
: '';
181 $data['legaltitlechars'] = Title
::legalChars();
182 $data['invalidusernamechars'] = $config->get( 'InvalidUsernameCharacters' );
185 $git = SpecialVersion
::getGitHeadSha1( $IP );
187 $data['git-hash'] = $git;
188 $data['git-branch'] =
189 SpecialVersion
::getGitCurrentBranch( $GLOBALS['IP'] );
192 // 'case-insensitive' option is reserved for future
193 $data['case'] = $config->get( 'CapitalLinks' ) ?
'first-letter' : 'case-sensitive';
194 $data['lang'] = $config->get( 'LanguageCode' );
197 foreach ( $wgContLang->getFallbackLanguages() as $code ) {
198 $fallbacks[] = [ 'code' => $code ];
200 $data['fallback'] = $fallbacks;
201 ApiResult
::setIndexedTagName( $data['fallback'], 'lang' );
203 if ( $wgContLang->hasVariants() ) {
205 foreach ( $wgContLang->getVariants() as $code ) {
208 'name' => $wgContLang->getVariantname( $code ),
211 $data['variants'] = $variants;
212 ApiResult
::setIndexedTagName( $data['variants'], 'lang' );
215 $data['rtl'] = $wgContLang->isRTL();
216 $data['fallback8bitEncoding'] = $wgContLang->fallback8bitEncoding();
218 $data['readonly'] = wfReadOnly();
219 if ( $data['readonly'] ) {
220 $data['readonlyreason'] = wfReadOnlyReason();
222 $data['writeapi'] = (bool)$config->get( 'EnableWriteAPI' );
224 $tz = $config->get( 'Localtimezone' );
225 $offset = $config->get( 'LocalTZoffset' );
226 if ( is_null( $tz ) ) {
229 } elseif ( is_null( $offset ) ) {
232 $data['timezone'] = $tz;
233 $data['timeoffset'] = intval( $offset );
234 $data['articlepath'] = $config->get( 'ArticlePath' );
235 $data['scriptpath'] = $config->get( 'ScriptPath' );
236 $data['script'] = $config->get( 'Script' );
237 $data['variantarticlepath'] = $config->get( 'VariantArticlePath' );
238 $data[ApiResult
::META_BC_BOOLS
][] = 'variantarticlepath';
239 $data['server'] = $config->get( 'Server' );
240 $data['servername'] = $config->get( 'ServerName' );
241 $data['wikiid'] = wfWikiID();
242 $data['time'] = wfTimestamp( TS_ISO_8601
, time() );
244 $data['misermode'] = (bool)$config->get( 'MiserMode' );
246 $data['uploadsenabled'] = UploadBase
::isEnabled();
247 $data['maxuploadsize'] = UploadBase
::getMaxUploadSize();
248 $data['minuploadchunksize'] = (int)$config->get( 'MinUploadChunkSize' );
250 $data['thumblimits'] = $config->get( 'ThumbLimits' );
251 ApiResult
::setArrayType( $data['thumblimits'], 'BCassoc' );
252 ApiResult
::setIndexedTagName( $data['thumblimits'], 'limit' );
253 $data['imagelimits'] = [];
254 ApiResult
::setArrayType( $data['imagelimits'], 'BCassoc' );
255 ApiResult
::setIndexedTagName( $data['imagelimits'], 'limit' );
256 foreach ( $config->get( 'ImageLimits' ) as $k => $limit ) {
257 $data['imagelimits'][$k] = [ 'width' => $limit[0], 'height' => $limit[1] ];
260 $favicon = $config->get( 'Favicon' );
261 if ( !empty( $favicon ) ) {
262 // wgFavicon can either be a relative or an absolute path
263 // make sure we always return an absolute path
264 $data['favicon'] = wfExpandUrl( $favicon, PROTO_RELATIVE
);
267 $data['centralidlookupprovider'] = $config->get( 'CentralIdLookupProvider' );
268 $providerIds = array_keys( $config->get( 'CentralIdLookupProviders' ) );
269 $data['allcentralidlookupproviders'] = $providerIds;
271 $data['interwikimagic'] = (bool)$config->get( 'InterwikiMagic' );
273 Hooks
::run( 'APIQuerySiteInfoGeneralInfo', [ $this, &$data ] );
275 return $this->getResult()->addValue( 'query', $property, $data );
278 protected function appendNamespaces( $property ) {
281 ApiResult
::META_TYPE
=> 'assoc',
283 foreach ( $wgContLang->getFormattedNamespaces() as $ns => $title ) {
285 'id' => intval( $ns ),
286 'case' => MWNamespace
::isCapitalized( $ns ) ?
'first-letter' : 'case-sensitive',
288 ApiResult
::setContentValue( $data[$ns], 'name', $title );
289 $canonical = MWNamespace
::getCanonicalName( $ns );
291 $data[$ns]['subpages'] = MWNamespace
::hasSubpages( $ns );
294 $data[$ns]['canonical'] = strtr( $canonical, '_', ' ' );
297 $data[$ns]['content'] = MWNamespace
::isContent( $ns );
298 $data[$ns]['nonincludable'] = MWNamespace
::isNonincludable( $ns );
300 $contentmodel = MWNamespace
::getNamespaceContentModel( $ns );
301 if ( $contentmodel ) {
302 $data[$ns]['defaultcontentmodel'] = $contentmodel;
306 ApiResult
::setArrayType( $data, 'assoc' );
307 ApiResult
::setIndexedTagName( $data, 'ns' );
309 return $this->getResult()->addValue( 'query', $property, $data );
312 protected function appendNamespaceAliases( $property ) {
314 $aliases = array_merge( $this->getConfig()->get( 'NamespaceAliases' ),
315 $wgContLang->getNamespaceAliases() );
316 $namespaces = $wgContLang->getNamespaces();
318 foreach ( $aliases as $title => $ns ) {
319 if ( $namespaces[$ns] == $title ) {
320 // Don't list duplicates
324 'id' => intval( $ns )
326 ApiResult
::setContentValue( $item, 'alias', strtr( $title, '_', ' ' ) );
332 ApiResult
::setIndexedTagName( $data, 'ns' );
334 return $this->getResult()->addValue( 'query', $property, $data );
337 protected function appendSpecialPageAliases( $property ) {
340 $aliases = $wgContLang->getSpecialPageAliases();
341 foreach ( SpecialPageFactory
::getNames() as $specialpage ) {
342 if ( isset( $aliases[$specialpage] ) ) {
343 $arr = [ 'realname' => $specialpage, 'aliases' => $aliases[$specialpage] ];
344 ApiResult
::setIndexedTagName( $arr['aliases'], 'alias' );
348 ApiResult
::setIndexedTagName( $data, 'specialpage' );
350 return $this->getResult()->addValue( 'query', $property, $data );
353 protected function appendMagicWords( $property ) {
356 foreach ( $wgContLang->getMagicWords() as $magicword => $aliases ) {
357 $caseSensitive = array_shift( $aliases );
358 $arr = [ 'name' => $magicword, 'aliases' => $aliases ];
359 $arr['case-sensitive'] = (bool)$caseSensitive;
360 ApiResult
::setIndexedTagName( $arr['aliases'], 'alias' );
363 ApiResult
::setIndexedTagName( $data, 'magicword' );
365 return $this->getResult()->addValue( 'query', $property, $data );
368 protected function appendInterwikiMap( $property, $filter ) {
370 if ( $filter === 'local' ) {
372 } elseif ( $filter === '!local' ) {
374 } elseif ( $filter ) {
375 ApiBase
::dieDebug( __METHOD__
, "Unknown filter=$filter" );
378 $params = $this->extractRequestParams();
379 $langCode = isset( $params['inlanguagecode'] ) ?
$params['inlanguagecode'] : '';
380 $langNames = Language
::fetchLanguageNames( $langCode );
382 $getPrefixes = Interwiki
::getAllPrefixes( $local );
383 $extraLangPrefixes = $this->getConfig()->get( 'ExtraInterlanguageLinkPrefixes' );
384 $localInterwikis = $this->getConfig()->get( 'LocalInterwikis' );
387 foreach ( $getPrefixes as $row ) {
388 $prefix = $row['iw_prefix'];
390 $val['prefix'] = $prefix;
391 if ( isset( $row['iw_local'] ) && $row['iw_local'] == '1' ) {
392 $val['local'] = true;
394 if ( isset( $row['iw_trans'] ) && $row['iw_trans'] == '1' ) {
395 $val['trans'] = true;
398 if ( isset( $langNames[$prefix] ) ) {
399 $val['language'] = $langNames[$prefix];
401 if ( in_array( $prefix, $localInterwikis ) ) {
402 $val['localinterwiki'] = true;
404 if ( in_array( $prefix, $extraLangPrefixes ) ) {
405 $val['extralanglink'] = true;
407 $linktext = wfMessage( "interlanguage-link-$prefix" );
408 if ( !$linktext->isDisabled() ) {
409 $val['linktext'] = $linktext->text();
412 $sitename = wfMessage( "interlanguage-link-sitename-$prefix" );
413 if ( !$sitename->isDisabled() ) {
414 $val['sitename'] = $sitename->text();
418 $val['url'] = wfExpandUrl( $row['iw_url'], PROTO_CURRENT
);
419 $val['protorel'] = substr( $row['iw_url'], 0, 2 ) == '//';
420 if ( isset( $row['iw_wikiid'] ) && $row['iw_wikiid'] !== '' ) {
421 $val['wikiid'] = $row['iw_wikiid'];
423 if ( isset( $row['iw_api'] ) && $row['iw_api'] !== '' ) {
424 $val['api'] = $row['iw_api'];
430 ApiResult
::setIndexedTagName( $data, 'iw' );
432 return $this->getResult()->addValue( 'query', $property, $data );
435 protected function appendDbReplLagInfo( $property, $includeAll ) {
438 $showHostnames = $this->getConfig()->get( 'ShowHostnames' );
440 if ( !$showHostnames ) {
442 'Cannot view all servers info unless $wgShowHostnames is true',
447 $lags = $lb->getLagTimes();
448 foreach ( $lags as $i => $lag ) {
450 'host' => $lb->getServerName( $i ),
455 list( , $lag, $index ) = $lb->getMaxLag();
457 'host' => $showHostnames
458 ?
$lb->getServerName( $index )
460 'lag' => intval( $lag )
464 ApiResult
::setIndexedTagName( $data, 'db' );
466 return $this->getResult()->addValue( 'query', $property, $data );
469 protected function appendStatistics( $property ) {
471 $data['pages'] = intval( SiteStats
::pages() );
472 $data['articles'] = intval( SiteStats
::articles() );
473 $data['edits'] = intval( SiteStats
::edits() );
474 $data['images'] = intval( SiteStats
::images() );
475 $data['users'] = intval( SiteStats
::users() );
476 $data['activeusers'] = intval( SiteStats
::activeUsers() );
477 $data['admins'] = intval( SiteStats
::numberingroup( 'sysop' ) );
478 $data['jobs'] = intval( SiteStats
::jobs() );
480 Hooks
::run( 'APIQuerySiteInfoStatisticsInfo', [ &$data ] );
482 return $this->getResult()->addValue( 'query', $property, $data );
485 protected function appendUserGroups( $property, $numberInGroup ) {
486 $config = $this->getConfig();
489 $result = $this->getResult();
490 $allGroups = array_values( User
::getAllGroups() );
491 foreach ( $config->get( 'GroupPermissions' ) as $group => $permissions ) {
494 'rights' => array_keys( $permissions, true ),
497 if ( $numberInGroup ) {
498 $autopromote = $config->get( 'Autopromote' );
500 if ( $group == 'user' ) {
501 $arr['number'] = SiteStats
::users();
502 // '*' and autopromote groups have no size
503 } elseif ( $group !== '*' && !isset( $autopromote[$group] ) ) {
504 $arr['number'] = SiteStats
::numberingroup( $group );
509 'add' => $config->get( 'AddGroups' ),
510 'remove' => $config->get( 'RemoveGroups' ),
511 'add-self' => $config->get( 'GroupsAddToSelf' ),
512 'remove-self' => $config->get( 'GroupsRemoveFromSelf' )
515 foreach ( $groupArr as $type => $rights ) {
516 if ( isset( $rights[$group] ) ) {
517 if ( $rights[$group] === true ) {
518 $groups = $allGroups;
520 $groups = array_intersect( $rights[$group], $allGroups );
523 $arr[$type] = $groups;
524 ApiResult
::setArrayType( $arr[$type], 'BCarray' );
525 ApiResult
::setIndexedTagName( $arr[$type], 'group' );
530 ApiResult
::setIndexedTagName( $arr['rights'], 'permission' );
534 ApiResult
::setIndexedTagName( $data, 'group' );
536 return $result->addValue( 'query', $property, $data );
539 protected function appendFileExtensions( $property ) {
541 foreach ( array_unique( $this->getConfig()->get( 'FileExtensions' ) ) as $ext ) {
542 $data[] = [ 'ext' => $ext ];
544 ApiResult
::setIndexedTagName( $data, 'fe' );
546 return $this->getResult()->addValue( 'query', $property, $data );
549 protected function appendInstalledLibraries( $property ) {
551 $path = "$IP/vendor/composer/installed.json";
552 if ( !file_exists( $path ) ) {
557 $installed = new ComposerInstalled( $path );
558 foreach ( $installed->getInstalledDependencies() as $name => $info ) {
559 if ( strpos( $info['type'], 'mediawiki-' ) === 0 ) {
560 // Skip any extensions or skins since they'll be listed
561 // in their proper section
566 'version' => $info['version'],
569 ApiResult
::setIndexedTagName( $data, 'library' );
571 return $this->getResult()->addValue( 'query', $property, $data );
575 protected function appendExtensions( $property ) {
577 foreach ( $this->getConfig()->get( 'ExtensionCredits' ) as $type => $extensions ) {
578 foreach ( $extensions as $ext ) {
580 $ret['type'] = $type;
581 if ( isset( $ext['name'] ) ) {
582 $ret['name'] = $ext['name'];
584 if ( isset( $ext['namemsg'] ) ) {
585 $ret['namemsg'] = $ext['namemsg'];
587 if ( isset( $ext['description'] ) ) {
588 $ret['description'] = $ext['description'];
590 if ( isset( $ext['descriptionmsg'] ) ) {
591 // Can be a string or array( key, param1, param2, ... )
592 if ( is_array( $ext['descriptionmsg'] ) ) {
593 $ret['descriptionmsg'] = $ext['descriptionmsg'][0];
594 $ret['descriptionmsgparams'] = array_slice( $ext['descriptionmsg'], 1 );
595 ApiResult
::setIndexedTagName( $ret['descriptionmsgparams'], 'param' );
597 $ret['descriptionmsg'] = $ext['descriptionmsg'];
600 if ( isset( $ext['author'] ) ) {
601 $ret['author'] = is_array( $ext['author'] ) ?
602 implode( ', ', $ext['author'] ) : $ext['author'];
604 if ( isset( $ext['url'] ) ) {
605 $ret['url'] = $ext['url'];
607 if ( isset( $ext['version'] ) ) {
608 $ret['version'] = $ext['version'];
610 if ( isset( $ext['path'] ) ) {
611 $extensionPath = dirname( $ext['path'] );
612 $gitInfo = new GitInfo( $extensionPath );
613 $vcsVersion = $gitInfo->getHeadSHA1();
614 if ( $vcsVersion !== false ) {
615 $ret['vcs-system'] = 'git';
616 $ret['vcs-version'] = $vcsVersion;
617 $ret['vcs-url'] = $gitInfo->getHeadViewUrl();
618 $vcsDate = $gitInfo->getHeadCommitDate();
619 if ( $vcsDate !== false ) {
620 $ret['vcs-date'] = wfTimestamp( TS_ISO_8601
, $vcsDate );
624 if ( SpecialVersion
::getExtLicenseFileName( $extensionPath ) ) {
625 $ret['license-name'] = isset( $ext['license-name'] ) ?
$ext['license-name'] : '';
626 $ret['license'] = SpecialPage
::getTitleFor(
628 "License/{$ext['name']}"
632 if ( SpecialVersion
::getExtAuthorsFileName( $extensionPath ) ) {
633 $ret['credits'] = SpecialPage
::getTitleFor(
635 "Credits/{$ext['name']}"
643 ApiResult
::setIndexedTagName( $data, 'ext' );
645 return $this->getResult()->addValue( 'query', $property, $data );
648 protected function appendRightsInfo( $property ) {
649 $config = $this->getConfig();
650 $rightsPage = $config->get( 'RightsPage' );
651 if ( is_string( $rightsPage ) ) {
652 $title = Title
::newFromText( $rightsPage );
653 $url = wfExpandUrl( $title, PROTO_CURRENT
);
656 $url = $config->get( 'RightsUrl' );
658 $text = $config->get( 'RightsText' );
659 if ( !$text && $title ) {
660 $text = $title->getPrefixedText();
665 'text' => $text ?
: ''
668 return $this->getResult()->addValue( 'query', $property, $data );
671 protected function appendRestrictions( $property ) {
672 $config = $this->getConfig();
674 'types' => $config->get( 'RestrictionTypes' ),
675 'levels' => $config->get( 'RestrictionLevels' ),
676 'cascadinglevels' => $config->get( 'CascadingRestrictionLevels' ),
677 'semiprotectedlevels' => $config->get( 'SemiprotectedRestrictionLevels' ),
680 ApiResult
::setArrayType( $data['types'], 'BCarray' );
681 ApiResult
::setArrayType( $data['levels'], 'BCarray' );
682 ApiResult
::setArrayType( $data['cascadinglevels'], 'BCarray' );
683 ApiResult
::setArrayType( $data['semiprotectedlevels'], 'BCarray' );
685 ApiResult
::setIndexedTagName( $data['types'], 'type' );
686 ApiResult
::setIndexedTagName( $data['levels'], 'level' );
687 ApiResult
::setIndexedTagName( $data['cascadinglevels'], 'level' );
688 ApiResult
::setIndexedTagName( $data['semiprotectedlevels'], 'level' );
690 return $this->getResult()->addValue( 'query', $property, $data );
693 public function appendLanguages( $property ) {
694 $params = $this->extractRequestParams();
695 $langCode = isset( $params['inlanguagecode'] ) ?
$params['inlanguagecode'] : '';
696 $langNames = Language
::fetchLanguageNames( $langCode );
700 foreach ( $langNames as $code => $name ) {
701 $lang = [ 'code' => $code ];
702 ApiResult
::setContentValue( $lang, 'name', $name );
705 ApiResult
::setIndexedTagName( $data, 'lang' );
707 return $this->getResult()->addValue( 'query', $property, $data );
710 public function appendSkins( $property ) {
712 $allowed = Skin
::getAllowedSkins();
713 $default = Skin
::normalizeKey( 'default' );
714 foreach ( Skin
::getSkinNames() as $name => $displayName ) {
715 $msg = $this->msg( "skinname-{$name}" );
716 $code = $this->getParameter( 'inlanguagecode' );
717 if ( $code && Language
::isValidCode( $code ) ) {
718 $msg->inLanguage( $code );
720 $msg->inContentLanguage();
722 if ( $msg->exists() ) {
723 $displayName = $msg->text();
725 $skin = [ 'code' => $name ];
726 ApiResult
::setContentValue( $skin, 'name', $displayName );
727 if ( !isset( $allowed[$name] ) ) {
728 $skin['unusable'] = true;
730 if ( $name === $default ) {
731 $skin['default'] = true;
735 ApiResult
::setIndexedTagName( $data, 'skin' );
737 return $this->getResult()->addValue( 'query', $property, $data );
740 public function appendExtensionTags( $property ) {
742 $wgParser->firstCallInit();
743 $tags = array_map( [ $this, 'formatParserTags' ], $wgParser->getTags() );
744 ApiResult
::setArrayType( $tags, 'BCarray' );
745 ApiResult
::setIndexedTagName( $tags, 't' );
747 return $this->getResult()->addValue( 'query', $property, $tags );
750 public function appendFunctionHooks( $property ) {
752 $wgParser->firstCallInit();
753 $hooks = $wgParser->getFunctionHooks();
754 ApiResult
::setArrayType( $hooks, 'BCarray' );
755 ApiResult
::setIndexedTagName( $hooks, 'h' );
757 return $this->getResult()->addValue( 'query', $property, $hooks );
760 public function appendVariables( $property ) {
761 $variables = MagicWord
::getVariableIDs();
762 ApiResult
::setArrayType( $variables, 'BCarray' );
763 ApiResult
::setIndexedTagName( $variables, 'v' );
765 return $this->getResult()->addValue( 'query', $property, $variables );
768 public function appendProtocols( $property ) {
769 // Make a copy of the global so we don't try to set the _element key of it - bug 45130
770 $protocols = array_values( $this->getConfig()->get( 'UrlProtocols' ) );
771 ApiResult
::setArrayType( $protocols, 'BCarray' );
772 ApiResult
::setIndexedTagName( $protocols, 'p' );
774 return $this->getResult()->addValue( 'query', $property, $protocols );
777 public function appendDefaultOptions( $property ) {
778 $options = User
::getDefaultOptions();
779 $options[ApiResult
::META_BC_BOOLS
] = array_keys( $options );
780 return $this->getResult()->addValue( 'query', $property, $options );
783 public function appendUploadDialog( $property ) {
784 $config = $this->getConfig()->get( 'UploadDialog' );
785 return $this->getResult()->addValue( 'query', $property, $config );
788 private function formatParserTags( $item ) {
792 public function appendSubscribedHooks( $property ) {
793 $hooks = $this->getConfig()->get( 'Hooks' );
798 foreach ( $myWgHooks as $name => $subscribers ) {
801 'subscribers' => array_map( [ 'SpecialVersion', 'arrayToString' ], $subscribers ),
804 ApiResult
::setArrayType( $arr['subscribers'], 'array' );
805 ApiResult
::setIndexedTagName( $arr['subscribers'], 's' );
809 ApiResult
::setIndexedTagName( $data, 'hook' );
811 return $this->getResult()->addValue( 'query', $property, $data );
814 public function getCacheMode( $params ) {
815 // Messages for $wgExtraInterlanguageLinkPrefixes depend on user language
817 count( $this->getConfig()->get( 'ExtraInterlanguageLinkPrefixes' ) ) &&
818 !is_null( $params['prop'] ) &&
819 in_array( 'interwikimap', $params['prop'] )
821 return 'anon-public-user-private';
827 public function getAllowedParams() {
830 ApiBase
::PARAM_DFLT
=> 'general',
831 ApiBase
::PARAM_ISMULTI
=> true,
832 ApiBase
::PARAM_TYPE
=> [
836 'specialpagealiases',
857 ApiBase
::PARAM_HELP_MSG_PER_VALUE
=> [],
860 ApiBase
::PARAM_TYPE
=> [
865 'showalldb' => false,
866 'numberingroup' => false,
867 'inlanguagecode' => null,
871 protected function getExamplesMessages() {
873 'action=query&meta=siteinfo&siprop=general|namespaces|namespacealiases|statistics'
874 => 'apihelp-query+siteinfo-example-simple',
875 'action=query&meta=siteinfo&siprop=interwikimap&sifilteriw=local'
876 => 'apihelp-query+siteinfo-example-interwiki',
877 'action=query&meta=siteinfo&siprop=dbrepllag&sishowalldb='
878 => 'apihelp-query+siteinfo-example-replag',
882 public function getHelpUrls() {
883 return 'https://www.mediawiki.org/wiki/API:Siteinfo';