* (bug 11275) Enable descending sort in categorymembers
* (bug 11308) Allow the API to output the image metadata
+* (bug 11296) Temporary fix for escaping of ampersands inside links in pretty-printed
+ help document.
=== Languages updated in 1.12 ===
*/
abstract class ApiFormatBase extends ApiBase {
- private $mIsHtml, $mFormat;
+ private $mIsHtml, $mFormat, $mUnescapeAmps;
/**
* Create a new instance of the formatter.
return false;
}
+ /**
+ * Specify whether or not ampersands should be escaped to '&' when rendering. This
+ * should only be set to true for the help message when rendered in the default (xmlfm)
+ * format. This is a temporary special-case fix that should be removed once the help
+ * has been reworked to use a fully html interface.
+ *
+ * @param boolean Whether or not ampersands should be escaped.
+ */
+ public function setUnescapeAmps ( $b ) {
+ $this->mUnescapeAmps = $b;
+ }
+
/**
* Returns true when an HTML filtering printer should be used.
* The default implementation assumes that formats ending with 'fm'
// Escape everything first for full coverage
$text = htmlspecialchars($text);
+ /* Temporary fix for bad links in help messages. As a special case, ampersands
+ * are not escaped in the help message. Should be removed once we have completed
+ * a fully-html version of the help message. */
+ if ( $this->mUnescapeAmps )
+ $text = ereg_replace ( '&', '&', $text );
+
// encode all comments or tags as safe blue strings
$text = preg_replace('/\<(!--.*?--|.*?)\>/', '<span style="color:blue;"><\1></span>', $text);
// identify URLs
$printer = $this->mPrinter;
$printer->profileIn();
$printer->initPrinter($isError);
+
+ /* If the help message is requested in the default (xmlfm) format,
+ * tell the printer not to escape ampersands so that our links do
+ * not break. */
+ $params = $this->extractRequestParams();
+ $printer->setUnescapeAmps ( $this->mAction == 'help'
+ && $params['format'] = ApiMain::API_DEFAULT_FORMAT );
+
$printer->execute();
$printer->closePrinter();
$printer->profileOut();