31 private array $textModelsToParse;
43 $this->parserFactory = $parserFactory;
44 $this->userOptionsLookup = $userOptionsLookup;
51 return JavaScriptContent::class;
73 $redirectContent =
'/* #REDIRECT */mw.loader.load('
74 . json_encode(
$url, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE )
76 return new $class( $redirectContent );
83 '@phan-var JavascriptContent $content';
87 if ( !$this->userOptionsLookup->getBoolOption( $pstParams->
getUser(),
'pst-cssjs' ) ) {
89 $parserOptions = clone $parserOptions;
90 $parserOptions->setPreSaveTransform(
false );
93 $text = $content->getText();
94 $pst = $this->parserFactory->getInstance()->preSaveTransform(
102 return new $contentClass( $pst );
126 '@phan-var JavaScriptContent $content';
127 if ( in_array( $content->
getModel(), $this->textModelsToParse ) ) {
129 $output = $this->parserFactory->getInstance()
133 WikiPage::makeParserOptionsFromTitleAndModel(
148 [
'class' => [
'mw-code',
'mw-js' ],
'dir' =>
'ltr' ],
149 "\n" . $content->getText() .
"\n"
163class_alias( JavaScriptContentHandler::class,
'JavaScriptContentHandler' );
const CONTENT_FORMAT_JAVASCRIPT
For JS pages.
Content handler for pages with source code as content (e.g.
Content handler for JavaScript pages.
makeRedirectContent(Title $destination, $text='')
Create a redirect that is also valid JavaScript.
supportsRedirects()
Returns true if this content model supports redirects.This default implementation returns false....
preSaveTransform(Content $content, PreSaveTransformParams $pstParams)
Returns a $content object with pre-save transformations applied (or the same object if no transformat...
__construct(string $modelId, Config $config, ParserFactory $parserFactory, UserOptionsLookup $userOptionsLookup)
fillParserOutput(Content $content, ContentParseParams $cpoParams, ParserOutput &$output)
Fills the provided ParserOutput object with information derived from the content.
A class containing constants representing the names of configuration variables.
const TextModelsToParse
Name constant for the TextModelsToParse setting, for use with Config::get()
Base representation for an editable wiki page.
Content objects represent page content, e.g.
getModel()
Get the content model ID.