From: Waldir Pimenta Date: Thu, 6 Dec 2012 05:45:33 +0000 (+0000) Subject: Allow API results to wrap long lines X-Git-Tag: 1.31.0-rc.0~20645^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=f73539591b153aa7aca37f8977c02415d2aad420;p=lhc%2Fweb%2Fwiklou.git Allow API results to wrap long lines - Bug 260 provides potentally relevant discussion (also eventually settled in white-space:pre-wrap) - Wrapping isn't applied in help pages, since they rely on the monospaced font for layout purposes. - Rename $isError to the more exact $isHelp - Update documentation for ApiFormatBase::initPrinter() - Bonus: header w/ info about output formats won't show for action=help anymore (irrelevant) Change-Id: Id9cdf102e17b4c3eaf4b10f3e3f5e97233911b97 --- diff --git a/includes/api/ApiFormatBase.php b/includes/api/ApiFormatBase.php index 8ad9b8ca35..d9900521a8 100644 --- a/includes/api/ApiFormatBase.php +++ b/includes/api/ApiFormatBase.php @@ -123,11 +123,13 @@ abstract class ApiFormatBase extends ApiBase { /** * Initialize the printer function and prepare the output headers, etc. - * This method must be the first outputing method during execution. - * A help screen's header is printed for the HTML-based output - * @param $isError bool Whether an error message is printed + * This method must be the first outputting method during execution. + * A human-targeted notice about available formats is printed for the HTML-based output, + * except for help screens (caused by either an error in the API parameters, + * the calling of action=help, or requesting the root script api.php). + * @param $isHelpScreen bool Whether a help screen is going to be shown */ - function initPrinter( $isError ) { + function initPrinter( $isHelpScreen ) { if ( $this->mDisabled ) { return; } @@ -164,7 +166,7 @@ abstract class ApiFormatBase extends ApiBase {
@@ -175,15 +177,18 @@ To see the non HTML representation of the mFormat ); ?> forma See the complete documentation, or API help for more information. +
  for help screens
+			          // because these are actually formatted to rely on
+			          // the monospaced font for layout purposes
 ?>
 
 setUnescapeAmps( ( $this->mAction == 'help' || $isError )
-				&& $printer->getFormat() == 'XML' && $printer->getIsHtml() );
+		$isHelp = $isError || $this->mAction == 'help';
+		$printer->setUnescapeAmps( $isHelp && $printer->getFormat() == 'XML' && $printer->getIsHtml() );
 
-		$printer->initPrinter( $isError );
+		$printer->initPrinter( $isHelp );
 
 		$printer->execute();
 		$printer->closePrinter();