* @ingroup Content
*/
class JavaScriptContent extends TextContent {
+
+ /**
+ * @param string $text JavaScript code.
+ */
public function __construct( $text ) {
parent::__construct( $text, CONTENT_MODEL_JAVASCRIPT );
}
* @param Title $title
* @param User $user
* @param ParserOptions $popts
- * @return Content
+ *
+ * @return JavaScriptContent
*/
public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) {
global $wgParser;
$text = $this->getNativeData();
$pst = $wgParser->preSaveTransform( $text, $title, $user, $popts );
- return new JavaScriptContent( $pst );
+ return new static( $pst );
}
+ /**
+ * @return string JavaScript wrapped in a <pre> tag.
+ */
protected function getHtml() {
$html = "";
$html .= "<pre class=\"mw-code mw-js\" dir=\"ltr\">\n";
- $html .= $this->getHighlightHtml();
+ $html .= htmlspecialchars( $this->getNativeData() );
$html .= "\n</pre>\n";
return $html;
}
+
}