38 private $redirectTarget =
false;
46 parent::__construct( $text, $modelId );
69 if ( $this->redirectTarget !==
false ) {
70 return $this->redirectTarget;
72 $this->redirectTarget =
null;
74 if ( str_starts_with( $text,
'/* #REDIRECT */' ) ) {
77 $text = str_replace(
'\u0026',
'&', $text );
79 if ( preg_match(
'/title=(.*?)&action=raw/', $text,
$matches ) ) {
80 $title = Title::newFromText( urldecode(
$matches[1] ) );
85 '@phan-var JavaScriptContent $expected';
86 if ( $expected->getText() === $text ) {
87 $this->redirectTarget = $title;
93 return $this->redirectTarget;
98class_alias( JavaScriptContent::class,
'JavaScriptContent' );
const CONTENT_MODEL_JAVASCRIPT
Content for JavaScript pages.
__construct( $text, $modelId=CONTENT_MODEL_JAVASCRIPT)
updateRedirect(Title $target)
If this page is a redirect, return the content if it should redirect to $target instead.
Content object implementation for representing flat text.
getText()
Returns the text represented by this Content object, as a string.