51 return JavaScriptContent::class;
72 $redirectContent =
'/* #REDIRECT */mw.loader.load('
73 . json_encode( $url, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE )
75 return new $class( $redirectContent );
82 '@phan-var JavascriptContent $content';
86 $services = MediaWikiServices::getInstance();
87 if ( !$services->getUserOptionsLookup()->getBoolOption( $pstParams->
getUser(),
'pst-cssjs' ) ) {
89 $parserOptions = clone $parserOptions;
90 $parserOptions->setPreSaveTransform(
false );
93 $text = $content->getText();
94 $pst = $services->getParserFactory()->getInstance()->preSaveTransform(
101 $contentClass = $this->getContentClass();
102 return new $contentClass( $pst );
126 $textModelsToParse = MediaWikiServices::getInstance()->getMainConfig()->get(
127 MainConfigNames::TextModelsToParse );
128 '@phan-var JavaScriptContent $content';
129 if ( in_array( $content->
getModel(), $textModelsToParse ) ) {
131 $output = MediaWikiServices::getInstance()->getParserFactory()->getInstance()
135 WikiPage::makeParserOptionsFromTitleAndModel(
148 $html = Html::element(
150 [
'class' =>
'mw-code mw-js',
'dir' =>
'ltr' ],
151 "\n" . $content->getText() .
"\n"
const CONTENT_FORMAT_JAVASCRIPT
For JS pages.
const CONTENT_MODEL_JAVASCRIPT
Content handler for code content such as CSS, JavaScript, JSON, etc.
Content handler for JavaScript pages.
__construct( $modelId=CONTENT_MODEL_JAVASCRIPT)
fillParserOutput(Content $content, ContentParseParams $cpoParams, ParserOutput &$output)
Fills the provided ParserOutput object with information derived from the content.
preSaveTransform(Content $content, PreSaveTransformParams $pstParams)
Returns a $content object with pre-save transformations applied (or the same object if no transformat...
makeRedirectContent(Title $destination, $text='')
Create a redirect that is also valid JavaScript.
supportsRedirects()
Returns true if this content model supports redirects.
A class containing constants representing the names of configuration variables.
Base interface for representing page content.
getModel()
Returns the ID of the content model used by this Content object.