diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:12:12 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:12:12 -0400 |
commit | c9aa36da061816dee256a979c2ff8d2ee41824d9 (patch) | |
tree | 29f7002b80ee984b488bd047dbbd80b36bf892e9 /includes/content/JavaScriptContent.php | |
parent | b4274e0e33eafb5e9ead9d949ebf031a9fb8363b (diff) | |
parent | d1ba966140d7a60cd5ae4e8667ceb27c1a138592 (diff) |
Merge branch 'archwiki'
# Conflicts:
# skins/ArchLinux.php
# skins/ArchLinux/archlogo.gif
Diffstat (limited to 'includes/content/JavaScriptContent.php')
-rw-r--r-- | includes/content/JavaScriptContent.php | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/includes/content/JavaScriptContent.php b/includes/content/JavaScriptContent.php index 2ae572be..c0194c2e 100644 --- a/includes/content/JavaScriptContent.php +++ b/includes/content/JavaScriptContent.php @@ -31,8 +31,13 @@ * @ingroup Content */ class JavaScriptContent extends TextContent { - public function __construct( $text ) { - parent::__construct( $text, CONTENT_MODEL_JAVASCRIPT ); + + /** + * @param string $text JavaScript code. + * @param string $modelId the content model name + */ + public function __construct( $text, $modelId = CONTENT_MODEL_JAVASCRIPT ) { + parent::__construct( $text, $modelId ); } /** @@ -42,7 +47,8 @@ class JavaScriptContent extends TextContent { * @param Title $title * @param User $user * @param ParserOptions $popts - * @return Content + * + * @return JavaScriptContent */ public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) { global $wgParser; @@ -52,15 +58,19 @@ class JavaScriptContent extends TextContent { $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; } + } |