From: umherirrender Date: Sat, 6 Jun 2015 19:15:36 +0000 (+0200) Subject: API: Add api-format-prettyprint-header-only-html X-Git-Tag: 1.31.0-rc.0~11127^2 X-Git-Url: https://git.heureux-cyclage.org/?a=commitdiff_plain;h=da0fb511729b6d4d31c296bd49fa427c4b0142bb;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/includes/api/ApiFormatBase.php b/includes/api/ApiFormatBase.php index d078dc453f..47c8128cc7 100644 --- a/includes/api/ApiFormatBase.php +++ b/includes/api/ApiFormatBase.php @@ -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 ) diff --git a/includes/api/i18n/en.json b/includes/api/i18n/en.json index 2a2e855a06..720470c88b 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 format parameter to change the output format. To see the non-HTML representation of the $1 format, set format=$2.\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.", diff --git a/includes/api/i18n/qqq.json b/includes/api/i18n/qqq.json index 2cf7aa6945..f690cf4d85 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}}",