X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQuerySiteinfo.php;h=6b896c95ad9f6196d42d7b72a088a23a6011e4fb;hb=953667476d69cc503246ba7816d2bb0bb7f41e77;hp=0bb7ff8ef1b71a34750d4f32a032075c8e734207;hpb=34fe90ac52644c3a543ca8adf89900c0fb2de70b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index 0bb7ff8ef1..6b896c95ad 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -23,6 +23,7 @@ * * @file */ +use MediaWiki\MediaWikiServices; /** * A query action to return meta information about the wiki site. @@ -87,6 +88,9 @@ class ApiQuerySiteinfo extends ApiQueryBase { case 'languages': $fit = $this->appendLanguages( $p ); break; + case 'languagevariants': + $fit = $this->appendLanguageVariants( $p ); + break; case 'skins': $fit = $this->appendSkins( $p ); break; @@ -253,6 +257,8 @@ class ApiQuerySiteinfo extends ApiQueryBase { $data['maxuploadsize'] = UploadBase::getMaxUploadSize(); $data['minuploadchunksize'] = (int)$config->get( 'MinUploadChunkSize' ); + $data['galleryoptions'] = $config->get( 'GalleryOptions' ); + $data['thumblimits'] = $config->get( 'ThumbLimits' ); ApiResult::setArrayType( $data['thumblimits'], 'BCassoc' ); ApiResult::setIndexedTagName( $data['thumblimits'], 'limit' ); @@ -386,7 +392,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : ''; $langNames = Language::fetchLanguageNames( $langCode ); - $getPrefixes = Interwiki::getAllPrefixes( $local ); + $getPrefixes = MediaWikiServices::getInstance()->getInterwikiLookup()->getAllPrefixes( $local ); $extraLangPrefixes = $this->getConfig()->get( 'ExtraInterlanguageLinkPrefixes' ); $localInterwikis = $this->getConfig()->get( 'LocalInterwikis' ); $data = []; @@ -445,10 +451,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { $showHostnames = $this->getConfig()->get( 'ShowHostnames' ); if ( $includeAll ) { if ( !$showHostnames ) { - $this->dieUsage( - 'Cannot view all servers info unless $wgShowHostnames is true', - 'includeAllDenied' - ); + $this->dieWithError( 'apierror-siteinfo-includealldenied', 'includeAllDenied' ); } $lags = $lb->getLagTimes(); @@ -713,6 +716,49 @@ class ApiQuerySiteinfo extends ApiQueryBase { return $this->getResult()->addValue( 'query', $property, $data ); } + // Export information about which page languages will trigger + // language conversion. (T153341) + public function appendLanguageVariants( $property ) { + $langNames = LanguageConverter::$languagesWithVariants; + if ( $this->getConfig()->get( 'DisableLangConversion' ) ) { + // Ensure result is empty if language conversion is disabled. + $langNames = []; + } + sort( $langNames ); + + $data = []; + foreach ( $langNames as $langCode ) { + $lang = Language::factory( $langCode ); + if ( $lang->getConverter() instanceof FakeConverter ) { + // Only languages which do not return instances of + // FakeConverter implement language conversion. + continue; + } + $data[$langCode] = []; + ApiResult::setIndexedTagName( $data[$langCode], 'variant' ); + ApiResult::setArrayType( $data[$langCode], 'kvp', 'code' ); + + $variants = $lang->getVariants(); + sort( $variants ); + foreach ( $variants as $v ) { + $fallbacks = $lang->getConverter()->getVariantFallbacks( $v ); + if ( !is_array( $fallbacks ) ) { + $fallbacks = [ $fallbacks ]; + } + $data[$langCode][$v] = [ + 'fallbacks' => $fallbacks, + ]; + ApiResult::setIndexedTagName( + $data[$langCode][$v]['fallbacks'], 'variant' + ); + } + } + ApiResult::setIndexedTagName( $data, 'lang' ); + ApiResult::setArrayType( $data, 'kvp', 'code' ); + + return $this->getResult()->addValue( 'query', $property, $data ); + } + public function appendSkins( $property ) { $data = []; $allowed = Skin::getAllowedSkins(); @@ -772,7 +818,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { } public function appendProtocols( $property ) { - // Make a copy of the global so we don't try to set the _element key of it - bug 45130 + // Make a copy of the global so we don't try to set the _element key of it - T47130 $protocols = array_values( $this->getConfig()->get( 'UrlProtocols' ) ); ApiResult::setArrayType( $protocols, 'BCarray' ); ApiResult::setIndexedTagName( $protocols, 'p' ); @@ -851,6 +897,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { 'rightsinfo', 'restrictions', 'languages', + 'languagevariants', 'skins', 'extensiontags', 'functionhooks', @@ -886,6 +933,6 @@ class ApiQuerySiteinfo extends ApiQueryBase { } public function getHelpUrls() { - return 'https://www.mediawiki.org/wiki/API:Siteinfo'; + return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Siteinfo'; } }