X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2Fapi%2FApiQuerySiteinfo.php;h=47212b321aa6e49bdcab0fc1bd6318be3dfb0ad2;hb=8918182ae2b7e4a8977e81528d4c796ba48232b8;hp=ea2f31b761cc703c60e40a7eebb5feee76e1e99b;hpb=a38f665c0bffb48dc0da410a33eb6a7c93efc3f1;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index ea2f31b761..47212b321a 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -279,30 +279,44 @@ class ApiQuerySiteinfo extends ApiQueryBase { } protected function appendNamespaces( $property ) { + $nsProtection = $this->getConfig()->get( 'NamespaceProtection' ); + $data = [ ApiResult::META_TYPE => 'assoc', ]; + $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo(); foreach ( MediaWikiServices::getInstance()->getContentLanguage()->getFormattedNamespaces() as $ns => $title ) { $data[$ns] = [ 'id' => (int)$ns, - 'case' => MWNamespace::isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive', + 'case' => $nsInfo->isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive', ]; ApiResult::setContentValue( $data[$ns], 'name', $title ); - $canonical = MWNamespace::getCanonicalName( $ns ); + $canonical = $nsInfo->getCanonicalName( $ns ); - $data[$ns]['subpages'] = MWNamespace::hasSubpages( $ns ); + $data[$ns]['subpages'] = $nsInfo->hasSubpages( $ns ); if ( $canonical ) { $data[$ns]['canonical'] = strtr( $canonical, '_', ' ' ); } - $data[$ns]['content'] = MWNamespace::isContent( $ns ); - $data[$ns]['nonincludable'] = MWNamespace::isNonincludable( $ns ); + $data[$ns]['content'] = $nsInfo->isContent( $ns ); + $data[$ns]['nonincludable'] = $nsInfo->isNonincludable( $ns ); + + if ( isset( $nsProtection[$ns] ) ) { + if ( is_array( $nsProtection[$ns] ) ) { + $specificNs = implode( "|", array_filter( $nsProtection[$ns] ) ); + } elseif ( $nsProtection[$ns] !== '' ) { + $specificNs = $nsProtection[$ns]; + } + if ( isset( $specificNs ) && $specificNs !== '' ) { + $data[$ns]['namespaceprotection'] = $specificNs; + } + } - $contentmodel = MWNamespace::getNamespaceContentModel( $ns ); + $contentmodel = $nsInfo->getNamespaceContentModel( $ns ); if ( $contentmodel ) { $data[$ns]['defaultcontentmodel'] = $contentmodel; } @@ -787,12 +801,11 @@ class ApiQuerySiteinfo extends ApiQueryBase { } public function appendExtensionTags( $property ) { - global $wgParser; $tags = array_map( function ( $item ) { return "<$item>"; }, - $wgParser->getTags() + MediaWikiServices::getInstance()->getParser()->getTags() ); ApiResult::setArrayType( $tags, 'BCarray' ); ApiResult::setIndexedTagName( $tags, 't' ); @@ -801,8 +814,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { } public function appendFunctionHooks( $property ) { - global $wgParser; - $hooks = $wgParser->getFunctionHooks(); + $hooks = MediaWikiServices::getInstance()->getParser()->getFunctionHooks(); ApiResult::setArrayType( $hooks, 'BCarray' ); ApiResult::setIndexedTagName( $hooks, 'h' );