From b18ae822e24a06aee9921b1cead2cb168c82159e Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Wed, 20 Jun 2018 10:08:26 -0400 Subject: [PATCH] API: Use param-per-value for meta=filerepoinfo's friprop docs This avoids documenting properties that may not be valid on the local wiki, depending on which repos are actually available. This patch also documents the other values available from repo types available in MediaWiki core. Bug: T197730 Change-Id: I6bf9fbf4ac29042d9f7524c6c1a5990051150cd3 --- includes/api/ApiQueryFileRepoInfo.php | 15 +++++++++++---- includes/api/i18n/en.json | 16 +++++++++++++++- includes/api/i18n/qqq.json | 14 ++++++++++++++ 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/includes/api/ApiQueryFileRepoInfo.php b/includes/api/ApiQueryFileRepoInfo.php index 4589991191..279bc0a2f3 100644 --- a/includes/api/ApiQueryFileRepoInfo.php +++ b/includes/api/ApiQueryFileRepoInfo.php @@ -81,6 +81,7 @@ class ApiQueryFileRepoInfo extends ApiQueryBase { ApiBase::PARAM_DFLT => implode( '|', $props ), ApiBase::PARAM_ISMULTI => true, ApiBase::PARAM_TYPE => $props, + ApiBase::PARAM_HELP_MSG_PER_VALUE => [], ], ]; } @@ -100,14 +101,20 @@ class ApiQueryFileRepoInfo extends ApiQueryBase { $propValues[] = 'canUpload'; + sort( $propValues ); return $propValues; } protected function getExamplesMessages() { - return [ - 'action=query&meta=filerepoinfo&friprop=apiurl|name|displayname' - => 'apihelp-query+filerepoinfo-example-simple', - ]; + $examples = []; + + $props = array_intersect( [ 'apiurl', 'name', 'displayname' ], $this->getProps() ); + if ( $props ) { + $examples['action=query&meta=filerepoinfo&friprop=' . implode( '|', $props )] = + 'apihelp-query+filerepoinfo-example-simple'; + } + + return $examples; } public function getHelpUrls() { diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json index 94e1ac6716..74efd820ca 100644 --- a/includes/api/i18n/en.json +++ b/includes/api/i18n/en.json @@ -816,7 +816,21 @@ "apihelp-query+filearchive-example-simple": "Show a list of all deleted files.", "apihelp-query+filerepoinfo-summary": "Return meta information about image repositories configured on the wiki.", - "apihelp-query+filerepoinfo-param-prop": "Which repository properties to get (there may be more available on some wikis):\n;apiurl:URL to the repository API - helpful for getting image info from the host.\n;name:The key of the repository - used in e.g. [[mw:Special:MyLanguage/Manual:$wgForeignFileRepos|$wgForeignFileRepos]] and [[Special:ApiHelp/query+imageinfo|imageinfo]] return values.\n;displayname:The human-readable name of the repository wiki.\n;rooturl:Root URL for image paths.\n;local:Whether that repository is the local one or not.", + "apihelp-query+filerepoinfo-param-prop": "Which repository properties to get (properties available may vary on other wikis).", + "apihelp-query+filerepoinfo-paramvalue-prop-apiurl": "URL to the repository API - helpful for getting image info from the host.", + "apihelp-query+filerepoinfo-paramvalue-prop-articlepath": "Repository wiki's [[mw:Special:MyLanguage/Manual:$wgArticlePath|$wgArticlePath]] or equivalent.", + "apihelp-query+filerepoinfo-paramvalue-prop-canUpload": "Whether files can be uploaded to this repository, e.g. via CORS and shared authentication.", + "apihelp-query+filerepoinfo-paramvalue-prop-displayname": "The human-readable name of the repository wiki.", + "apihelp-query+filerepoinfo-paramvalue-prop-favicon": "Repository wiki's favicon URL, from [[mw:Special:MyLanguage/Manual:$wgFavicon|$wgFavicon]].", + "apihelp-query+filerepoinfo-paramvalue-prop-fetchDescription": "Whether file description pages are fetched from this repository when viewing local file description pages.", + "apihelp-query+filerepoinfo-paramvalue-prop-initialCapital": "Whether file names implicitly start with a capital letter.", + "apihelp-query+filerepoinfo-paramvalue-prop-local": "Whether that repository is the local one or not.", + "apihelp-query+filerepoinfo-paramvalue-prop-name": "The key of the repository - used in e.g. [[mw:Special:MyLanguage/Manual:$wgForeignFileRepos|$wgForeignFileRepos]] and [[Special:ApiHelp/query+imageinfo|imageinfo]] return values.", + "apihelp-query+filerepoinfo-paramvalue-prop-rootUrl": "Root URL path for image paths.", + "apihelp-query+filerepoinfo-paramvalue-prop-scriptDirUrl": "Root URL path for the repository wiki's MediaWiki installation.", + "apihelp-query+filerepoinfo-paramvalue-prop-server": "Repository wiki's [[mw:Special:MyLanguage/Manual:$wgServer|$wgServer]] or equivalent.", + "apihelp-query+filerepoinfo-paramvalue-prop-thumbUrl": "Root URL path for thumbnail paths.", + "apihelp-query+filerepoinfo-paramvalue-prop-url": "Public zone URL path.", "apihelp-query+filerepoinfo-example-simple": "Get information about file repositories.", "apihelp-query+fileusage-summary": "Find all pages that use the given files.", diff --git a/includes/api/i18n/qqq.json b/includes/api/i18n/qqq.json index 1680bb87b1..2b4a587a0b 100644 --- a/includes/api/i18n/qqq.json +++ b/includes/api/i18n/qqq.json @@ -764,6 +764,20 @@ "apihelp-query+filearchive-example-simple": "{{doc-apihelp-example|query+filearchive}}", "apihelp-query+filerepoinfo-summary": "{{doc-apihelp-summary|query+filerepoinfo}}", "apihelp-query+filerepoinfo-param-prop": "{{doc-apihelp-param|query+filerepoinfo|prop}}", + "apihelp-query+filerepoinfo-paramvalue-prop-apiurl": "{{doc-apihelp-paramvalue|query+filerepoinfo|prop|apiurl}}", + "apihelp-query+filerepoinfo-paramvalue-prop-articlepath": "{{doc-apihelp-paramvalue|query+filerepoinfo|prop|articlepath}}", + "apihelp-query+filerepoinfo-paramvalue-prop-canUpload": "{{doc-apihelp-paramvalue|query+filerepoinfo|prop|canUpload}}", + "apihelp-query+filerepoinfo-paramvalue-prop-displayname": "{{doc-apihelp-paramvalue|query+filerepoinfo|prop|displayname}}", + "apihelp-query+filerepoinfo-paramvalue-prop-favicon": "{{doc-apihelp-paramvalue|query+filerepoinfo|prop|favicon}}", + "apihelp-query+filerepoinfo-paramvalue-prop-fetchDescription": "{{doc-apihelp-paramvalue|query+filerepoinfo|prop|fetchDescription}}", + "apihelp-query+filerepoinfo-paramvalue-prop-initialCapital": "{{doc-apihelp-paramvalue|query+filerepoinfo|prop|initialCapital}}", + "apihelp-query+filerepoinfo-paramvalue-prop-local": "{{doc-apihelp-paramvalue|query+filerepoinfo|prop|local}}", + "apihelp-query+filerepoinfo-paramvalue-prop-name": "{{doc-apihelp-paramvalue|query+filerepoinfo|prop|name}}", + "apihelp-query+filerepoinfo-paramvalue-prop-rootUrl": "{{doc-apihelp-paramvalue|query+filerepoinfo|prop|rootUrl}}", + "apihelp-query+filerepoinfo-paramvalue-prop-scriptDirUrl": "{{doc-apihelp-paramvalue|query+filerepoinfo|prop|scriptDirUrl}}", + "apihelp-query+filerepoinfo-paramvalue-prop-server": "{{doc-apihelp-paramvalue|query+filerepoinfo|prop|server}}", + "apihelp-query+filerepoinfo-paramvalue-prop-thumbUrl": "{{doc-apihelp-paramvalue|query+filerepoinfo|prop|thumbUrl}}", + "apihelp-query+filerepoinfo-paramvalue-prop-url": "{{doc-apihelp-paramvalue|query+filerepoinfo|prop|url}}", "apihelp-query+filerepoinfo-example-simple": "{{doc-apihelp-example|query+filerepoinfo}}", "apihelp-query+fileusage-summary": "{{doc-apihelp-summary|query+fileusage}}", "apihelp-query+fileusage-param-prop": "{{doc-apihelp-param|query+fileusage|prop|paramvalues=1}}", -- 2.20.1