X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fapi%2FApiQuerySiteinfo.php;h=f05556eca3104228b12ddb80460bf719090e1791;hb=b4dffb4b1d8426aaecf8deafa6323159fa5afbc7;hp=196c1faf8a4bb1aa6bc8f6f9c37aa2fcaad8aa3e;hpb=e2a7988178698b4369c7963d20610ee622db3ee7;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index 196c1faf8a..f05556eca3 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -37,7 +37,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { public function execute() { $params = $this->extractRequestParams(); - $done = array(); + $done = []; $fit = false; foreach ( $params['prop'] as $p ) { switch ( $p ) { @@ -127,7 +127,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { $config = $this->getConfig(); - $data = array(); + $data = []; $mainPage = Title::newMainPage(); $data['mainpage'] = $mainPage->getPrefixedText(); $data['base'] = wfExpandUrl( $mainPage->getFullURL(), PROTO_CURRENT ); @@ -147,7 +147,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { $data['dbtype'] = $config->get( 'DBtype' ); $data['dbversion'] = $this->getDB()->getServerVersion(); - $allowFrom = array( '' ); + $allowFrom = [ '' ]; $allowException = true; if ( !$config->get( 'AllowExternalImages' ) ) { $data['imagewhitelistenabled'] = (bool)$config->get( 'EnableImageWhitelist' ); @@ -190,20 +190,20 @@ class ApiQuerySiteinfo extends ApiQueryBase { $data['case'] = $config->get( 'CapitalLinks' ) ? 'first-letter' : 'case-sensitive'; $data['lang'] = $config->get( 'LanguageCode' ); - $fallbacks = array(); + $fallbacks = []; foreach ( $wgContLang->getFallbackLanguages() as $code ) { - $fallbacks[] = array( 'code' => $code ); + $fallbacks[] = [ 'code' => $code ]; } $data['fallback'] = $fallbacks; ApiResult::setIndexedTagName( $data['fallback'], 'lang' ); if ( $wgContLang->hasVariants() ) { - $variants = array(); + $variants = []; foreach ( $wgContLang->getVariants() as $code ) { - $variants[] = array( + $variants[] = [ 'code' => $code, 'name' => $wgContLang->getVariantname( $code ), - ); + ]; } $data['variants'] = $variants; ApiResult::setIndexedTagName( $data['variants'], 'lang' ); @@ -247,11 +247,11 @@ class ApiQuerySiteinfo extends ApiQueryBase { $data['thumblimits'] = $config->get( 'ThumbLimits' ); ApiResult::setArrayType( $data['thumblimits'], 'BCassoc' ); ApiResult::setIndexedTagName( $data['thumblimits'], 'limit' ); - $data['imagelimits'] = array(); + $data['imagelimits'] = []; ApiResult::setArrayType( $data['imagelimits'], 'BCassoc' ); ApiResult::setIndexedTagName( $data['imagelimits'], 'limit' ); foreach ( $config->get( 'ImageLimits' ) as $k => $limit ) { - $data['imagelimits'][$k] = array( 'width' => $limit[0], 'height' => $limit[1] ); + $data['imagelimits'][$k] = [ 'width' => $limit[0], 'height' => $limit[1] ]; } $favicon = $config->get( 'Favicon' ); @@ -265,21 +265,21 @@ class ApiQuerySiteinfo extends ApiQueryBase { $providerIds = array_keys( $this->getConfig()->get( 'CentralIdLookupProviders' ) ); $data['allcentralidlookupproviders'] = $providerIds; - Hooks::run( 'APIQuerySiteInfoGeneralInfo', array( $this, &$data ) ); + Hooks::run( 'APIQuerySiteInfoGeneralInfo', [ $this, &$data ] ); return $this->getResult()->addValue( 'query', $property, $data ); } protected function appendNamespaces( $property ) { global $wgContLang; - $data = array( + $data = [ ApiResult::META_TYPE => 'assoc', - ); + ]; foreach ( $wgContLang->getFormattedNamespaces() as $ns => $title ) { - $data[$ns] = array( + $data[$ns] = [ 'id' => intval( $ns ), 'case' => MWNamespace::isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive', - ); + ]; ApiResult::setContentValue( $data[$ns], 'name', $title ); $canonical = MWNamespace::getCanonicalName( $ns ); @@ -309,15 +309,15 @@ class ApiQuerySiteinfo extends ApiQueryBase { $aliases = array_merge( $this->getConfig()->get( 'NamespaceAliases' ), $wgContLang->getNamespaceAliases() ); $namespaces = $wgContLang->getNamespaces(); - $data = array(); + $data = []; foreach ( $aliases as $title => $ns ) { if ( $namespaces[$ns] == $title ) { // Don't list duplicates continue; } - $item = array( + $item = [ 'id' => intval( $ns ) - ); + ]; ApiResult::setContentValue( $item, 'alias', strtr( $title, '_', ' ' ) ); $data[] = $item; } @@ -331,11 +331,11 @@ class ApiQuerySiteinfo extends ApiQueryBase { protected function appendSpecialPageAliases( $property ) { global $wgContLang; - $data = array(); + $data = []; $aliases = $wgContLang->getSpecialPageAliases(); foreach ( SpecialPageFactory::getNames() as $specialpage ) { if ( isset( $aliases[$specialpage] ) ) { - $arr = array( 'realname' => $specialpage, 'aliases' => $aliases[$specialpage] ); + $arr = [ 'realname' => $specialpage, 'aliases' => $aliases[$specialpage] ]; ApiResult::setIndexedTagName( $arr['aliases'], 'alias' ); $data[] = $arr; } @@ -347,10 +347,10 @@ class ApiQuerySiteinfo extends ApiQueryBase { protected function appendMagicWords( $property ) { global $wgContLang; - $data = array(); + $data = []; foreach ( $wgContLang->getMagicWords() as $magicword => $aliases ) { $caseSensitive = array_shift( $aliases ); - $arr = array( 'name' => $magicword, 'aliases' => $aliases ); + $arr = [ 'name' => $magicword, 'aliases' => $aliases ]; $arr['case-sensitive'] = (bool)$caseSensitive; ApiResult::setIndexedTagName( $arr['aliases'], 'alias' ); $data[] = $arr; @@ -377,11 +377,11 @@ class ApiQuerySiteinfo extends ApiQueryBase { $getPrefixes = Interwiki::getAllPrefixes( $local ); $extraLangPrefixes = $this->getConfig()->get( 'ExtraInterlanguageLinkPrefixes' ); $localInterwikis = $this->getConfig()->get( 'LocalInterwikis' ); - $data = array(); + $data = []; foreach ( $getPrefixes as $row ) { $prefix = $row['iw_prefix']; - $val = array(); + $val = []; $val['prefix'] = $prefix; if ( isset( $row['iw_local'] ) && $row['iw_local'] == '1' ) { $val['local'] = true; @@ -428,7 +428,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { } protected function appendDbReplLagInfo( $property, $includeAll ) { - $data = array(); + $data = []; $lb = wfGetLB(); $showHostnames = $this->getConfig()->get( 'ShowHostnames' ); if ( $includeAll ) { @@ -441,19 +441,19 @@ class ApiQuerySiteinfo extends ApiQueryBase { $lags = $lb->getLagTimes(); foreach ( $lags as $i => $lag ) { - $data[] = array( + $data[] = [ 'host' => $lb->getServerName( $i ), 'lag' => $lag - ); + ]; } } else { list( , $lag, $index ) = $lb->getMaxLag(); - $data[] = array( + $data[] = [ 'host' => $showHostnames ? $lb->getServerName( $index ) : '', 'lag' => intval( $lag ) - ); + ]; } ApiResult::setIndexedTagName( $data, 'db' ); @@ -462,7 +462,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { } protected function appendStatistics( $property ) { - $data = array(); + $data = []; $data['pages'] = intval( SiteStats::pages() ); $data['articles'] = intval( SiteStats::articles() ); $data['edits'] = intval( SiteStats::edits() ); @@ -472,7 +472,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { $data['admins'] = intval( SiteStats::numberingroup( 'sysop' ) ); $data['jobs'] = intval( SiteStats::jobs() ); - Hooks::run( 'APIQuerySiteInfoStatisticsInfo', array( &$data ) ); + Hooks::run( 'APIQuerySiteInfoStatisticsInfo', [ &$data ] ); return $this->getResult()->addValue( 'query', $property, $data ); } @@ -480,14 +480,14 @@ class ApiQuerySiteinfo extends ApiQueryBase { protected function appendUserGroups( $property, $numberInGroup ) { $config = $this->getConfig(); - $data = array(); + $data = []; $result = $this->getResult(); $allGroups = User::getAllGroups(); foreach ( $config->get( 'GroupPermissions' ) as $group => $permissions ) { - $arr = array( + $arr = [ 'name' => $group, 'rights' => array_keys( $permissions, true ), - ); + ]; if ( $numberInGroup ) { $autopromote = $config->get( 'Autopromote' ); @@ -500,12 +500,12 @@ class ApiQuerySiteinfo extends ApiQueryBase { } } - $groupArr = array( + $groupArr = [ 'add' => $config->get( 'AddGroups' ), 'remove' => $config->get( 'RemoveGroups' ), 'add-self' => $config->get( 'GroupsAddToSelf' ), 'remove-self' => $config->get( 'GroupsRemoveFromSelf' ) - ); + ]; foreach ( $groupArr as $type => $rights ) { if ( isset( $rights[$group] ) ) { @@ -528,9 +528,9 @@ class ApiQuerySiteinfo extends ApiQueryBase { } protected function appendFileExtensions( $property ) { - $data = array(); + $data = []; foreach ( array_unique( $this->getConfig()->get( 'FileExtensions' ) ) as $ext ) { - $data[] = array( 'ext' => $ext ); + $data[] = [ 'ext' => $ext ]; } ApiResult::setIndexedTagName( $data, 'fe' ); @@ -544,7 +544,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { return true; } - $data = array(); + $data = []; $installed = new ComposerInstalled( $path ); foreach ( $installed->getInstalledDependencies() as $name => $info ) { if ( strpos( $info['type'], 'mediawiki-' ) === 0 ) { @@ -552,10 +552,10 @@ class ApiQuerySiteinfo extends ApiQueryBase { // in their proper section continue; } - $data[] = array( + $data[] = [ 'name' => $name, 'version' => $info['version'], - ); + ]; } ApiResult::setIndexedTagName( $data, 'library' ); @@ -564,10 +564,10 @@ class ApiQuerySiteinfo extends ApiQueryBase { } protected function appendExtensions( $property ) { - $data = array(); + $data = []; foreach ( $this->getConfig()->get( 'ExtensionCredits' ) as $type => $extensions ) { foreach ( $extensions as $ext ) { - $ret = array(); + $ret = []; $ret['type'] = $type; if ( isset( $ext['name'] ) ) { $ret['name'] = $ext['name']; @@ -651,22 +651,22 @@ class ApiQuerySiteinfo extends ApiQueryBase { $text = $title->getPrefixedText(); } - $data = array( - 'url' => $url ? $url : '', - 'text' => $text ? $text : '' - ); + $data = [ + 'url' => $url ?: '', + 'text' => $text ?: '' + ]; return $this->getResult()->addValue( 'query', $property, $data ); } protected function appendRestrictions( $property ) { $config = $this->getConfig(); - $data = array( + $data = [ 'types' => $config->get( 'RestrictionTypes' ), 'levels' => $config->get( 'RestrictionLevels' ), 'cascadinglevels' => $config->get( 'CascadingRestrictionLevels' ), 'semiprotectedlevels' => $config->get( 'SemiprotectedRestrictionLevels' ), - ); + ]; ApiResult::setArrayType( $data['types'], 'BCarray' ); ApiResult::setArrayType( $data['levels'], 'BCarray' ); @@ -686,10 +686,10 @@ class ApiQuerySiteinfo extends ApiQueryBase { $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : ''; $langNames = Language::fetchLanguageNames( $langCode ); - $data = array(); + $data = []; foreach ( $langNames as $code => $name ) { - $lang = array( 'code' => $code ); + $lang = [ 'code' => $code ]; ApiResult::setContentValue( $lang, 'name', $name ); $data[] = $lang; } @@ -699,7 +699,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { } public function appendSkins( $property ) { - $data = array(); + $data = []; $allowed = Skin::getAllowedSkins(); $default = Skin::normalizeKey( 'default' ); foreach ( Skin::getSkinNames() as $name => $displayName ) { @@ -713,7 +713,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { if ( $msg->exists() ) { $displayName = $msg->text(); } - $skin = array( 'code' => $name ); + $skin = [ 'code' => $name ]; ApiResult::setContentValue( $skin, 'name', $displayName ); if ( !isset( $allowed[$name] ) ) { $skin['unusable'] = true; @@ -731,7 +731,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { public function appendExtensionTags( $property ) { global $wgParser; $wgParser->firstCallInit(); - $tags = array_map( array( $this, 'formatParserTags' ), $wgParser->getTags() ); + $tags = array_map( [ $this, 'formatParserTags' ], $wgParser->getTags() ); ApiResult::setArrayType( $tags, 'BCarray' ); ApiResult::setIndexedTagName( $tags, 't' ); @@ -780,12 +780,12 @@ class ApiQuerySiteinfo extends ApiQueryBase { $myWgHooks = $hooks; ksort( $myWgHooks ); - $data = array(); + $data = []; foreach ( $myWgHooks as $name => $subscribers ) { - $arr = array( + $arr = [ 'name' => $name, - 'subscribers' => array_map( array( 'SpecialVersion', 'arrayToString' ), $subscribers ), - ); + 'subscribers' => array_map( [ 'SpecialVersion', 'arrayToString' ], $subscribers ), + ]; ApiResult::setArrayType( $arr['subscribers'], 'array' ); ApiResult::setIndexedTagName( $arr['subscribers'], 's' ); @@ -811,11 +811,11 @@ class ApiQuerySiteinfo extends ApiQueryBase { } public function getAllowedParams() { - return array( - 'prop' => array( + return [ + 'prop' => [ ApiBase::PARAM_DFLT => 'general', ApiBase::PARAM_ISMULTI => true, - ApiBase::PARAM_TYPE => array( + ApiBase::PARAM_TYPE => [ 'general', 'namespaces', 'namespacealiases', @@ -838,30 +838,30 @@ class ApiQuerySiteinfo extends ApiQueryBase { 'variables', 'protocols', 'defaultoptions', - ), - ApiBase::PARAM_HELP_MSG_PER_VALUE => array(), - ), - 'filteriw' => array( - ApiBase::PARAM_TYPE => array( + ], + ApiBase::PARAM_HELP_MSG_PER_VALUE => [], + ], + 'filteriw' => [ + ApiBase::PARAM_TYPE => [ 'local', '!local', - ) - ), + ] + ], 'showalldb' => false, 'numberingroup' => false, 'inlanguagecode' => null, - ); + ]; } protected function getExamplesMessages() { - return array( + return [ 'action=query&meta=siteinfo&siprop=general|namespaces|namespacealiases|statistics' => 'apihelp-query+siteinfo-example-simple', 'action=query&meta=siteinfo&siprop=interwikimap&sifilteriw=local' => 'apihelp-query+siteinfo-example-interwiki', 'action=query&meta=siteinfo&siprop=dbrepllag&sishowalldb=' => 'apihelp-query+siteinfo-example-replag', - ); + ]; } public function getHelpUrls() {