Umherirrender has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/216433

Change subject: API: Add api-format-prettyprint-header-only-html
......................................................................

API: Add api-format-prettyprint-header-only-html

Setting format=rawfm suggest to set format=raw ("To see the non-HTML
representation of the RAW format, set format=raw.") which does not
exists.
Add a new message for this case which does not contains the hint.

Change-Id: I40fe0b6e52dc0c70b07b368a3eace430e0c8f68c
---
M includes/api/ApiFormatBase.php
M includes/api/i18n/en.json
M includes/api/i18n/qqq.json
3 files changed, 12 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/33/216433/1

diff --git a/includes/api/ApiFormatBase.php b/includes/api/ApiFormatBase.php
index d078dc4..2a8e0c0 100644
--- a/includes/api/ApiFormatBase.php
+++ b/includes/api/ApiFormatBase.php
@@ -173,6 +173,7 @@
                $mime = $this->getMimeType();
                if ( $this->getIsHtml() && $mime !== null ) {
                        $format = $this->getFormat();
+                       $lcformat = strtolower( $format );
                        $result = $this->getBuffer();
 
                        $context = new DerivativeContext( $this->getMain() );
@@ -184,9 +185,15 @@
                        $out->addModules( 'mediawiki.apipretty' );
                        $out->setPageTitle( $context->msg( 'api-format-title' ) 
);
 
-                       $header = $context->msg( 
'api-format-prettyprint-header' )
-                               ->params( $format, strtolower( $format ) )
-                               ->parseAsBlock();
+                       $allFormats = 
$this->getMain()->getModuleManager()->getNames( 'format' );
+                       // Search for the format without suffix 'fm', when 
found there is a non-html format
+                       if ( in_array( $lcformat, $allFormats, true ) ) {
+                               $msg = $context->msg( 
'api-format-prettyprint-header' )->params( $format, $lcformat );
+                       } else {
+                               $msg = $context->msg( 
'api-format-prettyprint-header-only-html' )->params( $format );
+                       }
+
+                       $header = $msg->parseAsBlock();
                        $out->addHTML(
                                Html::rawElement( 'div', array( 'class' => 
'api-pretty-header' ),
                                        ApiHelp::fixHelpLinks( $header )
diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json
index 2a2e855..e7fa4b4 100644
--- a/includes/api/i18n/en.json
+++ b/includes/api/i18n/en.json
@@ -1144,6 +1144,7 @@
 
        "api-format-title": "MediaWiki API result",
        "api-format-prettyprint-header": "This is the HTML representation of 
the $1 format. HTML is good for debugging, but is unsuitable for application 
use.\n\nSpecify the <var>format</var> parameter to change the output format. To 
see the non-HTML representation of the $1 format, set 
<kbd>format=$2</kbd>.\n\nSee the [[mw:API|complete documentation]], or the 
[[Special:ApiHelp/main|API help]] for more information.",
+       "api-format-prettyprint-header-only-html": "This is the $1 
format.\n\nSee the [[mw:API|complete documentation]], or the 
[[Special:ApiHelp/main|API help]] for more information.",
 
        "api-orm-param-props": "Fields to query.",
        "api-orm-param-limit": "Max amount of rows to return.",
diff --git a/includes/api/i18n/qqq.json b/includes/api/i18n/qqq.json
index 2cf7aa6..f690cf4 100644
--- a/includes/api/i18n/qqq.json
+++ b/includes/api/i18n/qqq.json
@@ -1049,6 +1049,7 @@
        "apihelp-yamlfm-description": 
"{{doc-apihelp-description|yamlfm|seealso=* 
{{msg-mw|apihelp-yaml-description}}}}",
        "api-format-title": "{{technical}}\nPage title when API output is 
pretty-printed in HTML.",
        "api-format-prettyprint-header": "{{technical}} Displayed as a header 
when API output is pretty-printed in HTML.\n\nParameters:\n* $1 - Format 
name\n* $2 - Non-pretty-printing module name",
+       "api-format-prettyprint-header-only-html": "{{technical}} Displayed as 
a header when API output is pretty-printed in HTML, but there is no non-html 
module.\n\nParameters:\n* $1 - Format name",
        "api-orm-param-props": "{{doc-apihelp-param|orm|props|description=the 
\"props\" parameter in subclasses of ApiQueryORM}}",
        "api-orm-param-limit": "{{doc-apihelp-param|orm|limit|description=the 
\"limit\" parameter in subclasses of ApiQueryORM}}",
        "api-pageset-param-titles": 
"{{doc-apihelp-param|pageset|titles|description=the \"titles\" parameter in 
pageset-using modules}}",

-- 
To view, visit https://gerrit.wikimedia.org/r/216433
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I40fe0b6e52dc0c70b07b368a3eace430e0c8f68c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to