From: Bartosz Dziewoński Date: Mon, 5 May 2014 15:59:54 +0000 (+0200) Subject: Content: Deprecate and stop using getHighlightHtml() X-Git-Tag: 1.31.0-rc.0~15797^2~1 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/?a=commitdiff_plain;h=5fea642f16cefb08d32d69013b2bc845670f2486;p=lhc%2Fweb%2Fwiklou.git Content: Deprecate and stop using getHighlightHtml() That function was clearly a bad idea, everyone should just use getHtml() instead. It was supposed to allow extensions to extend the content formatting process, but actually doesn't. A better hook-based solution follows in separate commit I979e2438. Split off from original I979e2438 and rebased with minor changes (updated documentation comments, etc.). Co-Authored-By: daniel Co-Authored-By: Bartosz Dziewoński Change-Id: I76412f9d28bb145fb5975f59e538f6560e50472f --- diff --git a/includes/content/CssContent.php b/includes/content/CssContent.php index 5fc2c9f158..2673084ebe 100644 --- a/includes/content/CssContent.php +++ b/includes/content/CssContent.php @@ -67,7 +67,7 @@ class CssContent extends TextContent { protected function getHtml() { $html = ""; $html .= "
\n";
-		$html .= $this->getHighlightHtml();
+		$html .= htmlspecialchars( $this->getNativeData() );
 		$html .= "\n
\n"; return $html; diff --git a/includes/content/JavaScriptContent.php b/includes/content/JavaScriptContent.php index 11a470e1e4..442b705282 100644 --- a/includes/content/JavaScriptContent.php +++ b/includes/content/JavaScriptContent.php @@ -66,7 +66,7 @@ class JavaScriptContent extends TextContent { protected function getHtml() { $html = ""; $html .= "
\n";
-		$html .= $this->getHighlightHtml();
+		$html .= htmlspecialchars( $this->getNativeData() );
 		$html .= "\n
\n"; return $html; diff --git a/includes/content/TextContent.php b/includes/content/TextContent.php index 0c6b06f177..4c95d3c977 100644 --- a/includes/content/TextContent.php +++ b/includes/content/TextContent.php @@ -242,10 +242,12 @@ class TextContent extends AbstractContent { * Generates an HTML version of the content, for display. Used by * getParserOutput() to construct a ParserOutput object. * - * This default implementation just calls getHighlightHtml(). Content - * models that have another mapping to HTML (as is the case for markup - * languages like wikitext) should override this method to generate the - * appropriate HTML. + * Subclasses may override this to provide a custom HTML rendering. + * If further information is to be derived from the content (such as + * categories), the getParserOutput() method can be overridden instead. + * + * For backwards-compatibility, this default implementation just calls + * getHighlightHtml(). * * @return string An HTML representation of the content */ @@ -254,13 +256,22 @@ class TextContent extends AbstractContent { } /** - * Generates a syntax-highlighted version of the content, as HTML. - * Used by the default implementation of getHtml(). + * Generates an HTML version of the content, for display. + * + * This default implementation returns an HTML-escaped version + * of the raw text content. + * + * @note: The functionality of this method should really be implemented + * in getHtml(), and subclasses should override getHtml() if needed. + * getHighlightHtml() is kept around for backward compatibility with + * extensions that already override it. * - * @return string A HTML representation of the content's markup + * @deprecated since 1.24. Use getHtml() instead. In particular, subclasses overriding + * getHighlightHtml() should override getHtml() instead. + * + * @return string An HTML representation of the content */ protected function getHighlightHtml() { - # TODO: make Highlighter interface, use highlighter here, if available return htmlspecialchars( $this->getNativeData() ); }