getUserOptionsLookup()->getBoolOption( $user, 'pst-cssjs' ) ) { // Allow bot users to disable the pre-save transform for CSS/JS (T236828). $popts = clone $popts; $popts->setPreSaveTransform( false ); } $text = $this->getText(); $pst = MediaWikiServices::getInstance()->getParser() ->preSaveTransform( $text, $title, $user, $popts ); return new static( $pst ); } /** * @return string JavaScript wrapped in a
tag.
*/
protected function getHtml() {
return Html::element( 'pre',
[ 'class' => 'mw-code mw-js', 'dir' => 'ltr' ],
"\n" . $this->getText() . "\n"
) . "\n";
}
/**
* If this page is a redirect, return the content
* if it should redirect to $target instead
*
* @param Title $target
* @return JavaScriptContent
*/
public function updateRedirect( Title $target ) {
if ( !$this->isRedirect() ) {
return $this;
}
return $this->getContentHandler()->makeRedirectContent( $target );
}
/**
* @return Title|null
*/
public function getRedirectTarget() {
if ( $this->redirectTarget !== false ) {
return $this->redirectTarget;
}
$this->redirectTarget = null;
$text = $this->getText();
if ( strpos( $text, '/* #REDIRECT */' ) === 0 ) {
// Extract the title from the url
if ( preg_match( '/title=(.*?)\\\\u0026action=raw/', $text, $matches ) ) {
$title = Title::newFromText( urldecode( $matches[1] ) );
if ( $title ) {
// Have a title, check that the current content equals what
// the redirect content should be
if ( $this->equals( $this->getContentHandler()->makeRedirectContent( $title ) ) ) {
$this->redirectTarget = $title;
}
}
}
}
return $this->redirectTarget;
}
}