API: Add api-format-prettyprint-header-only-html
authorumherirrender <umherirrender_de.wp@web.de>
Sat, 6 Jun 2015 19:15:36 +0000 (21:15 +0200)
committerumherirrender <umherirrender_de.wp@web.de>
Tue, 9 Jun 2015 17:30:23 +0000 (19:30 +0200)
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

includes/api/ApiFormatBase.php
includes/api/i18n/en.json
includes/api/i18n/qqq.json

index d078dc4..47c8128 100644 (file)
@@ -173,6 +173,7 @@ abstract class ApiFormatBase extends ApiBase {
                $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,14 @@ abstract class ApiFormatBase extends ApiBase {
                        $out->addModules( 'mediawiki.apipretty' );
                        $out->setPageTitle( $context->msg( 'api-format-title' ) );
 
-                       $header = $context->msg( 'api-format-prettyprint-header' )
-                               ->params( $format, strtolower( $format ) )
-                               ->parseAsBlock();
+                       // When the format without suffix 'fm' is defined, there is a non-html version
+                       if ( $this->getMain()->getModuleManager()->isDefined( $lcformat, 'format' ) ) {
+                               $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 )
index 2a2e855..720470c 100644 (file)
 
        "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 an HTML representation intended for debugging, and is unsuitable for application use.\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.",
index 2cf7aa6..f690cf4 100644 (file)
        "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}}",