Merge "Removed READ_LATEST default from Revision::newFromPageId()."
[lhc/web/wiklou.git] / includes / content / JavaScriptContent.php
1 <?php
2
3 /**
4 * @since 1.21
5 */
6 class JavaScriptContent extends TextContent {
7 public function __construct( $text ) {
8 parent::__construct( $text, CONTENT_MODEL_JAVASCRIPT );
9 }
10
11 /**
12 * Returns a Content object with pre-save transformations applied using
13 * Parser::preSaveTransform().
14 *
15 * @param Title $title
16 * @param User $user
17 * @param ParserOptions $popts
18 * @return Content
19 */
20 public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) {
21 global $wgParser;
22 // @todo: make pre-save transformation optional for script pages
23 // See bug #32858
24
25 $text = $this->getNativeData();
26 $pst = $wgParser->preSaveTransform( $text, $title, $user, $popts );
27
28 return new JavaScriptContent( $pst );
29 }
30
31
32 protected function getHtml( ) {
33 $html = "";
34 $html .= "<pre class=\"mw-code mw-js\" dir=\"ltr\">\n";
35 $html .= $this->getHighlightHtml( );
36 $html .= "\n</pre>\n";
37
38 return $html;
39 }
40 }