24 private $redirectTarget =
false;
32 parent::__construct( $text, $modelId );
55 if ( $this->redirectTarget !==
false ) {
56 return $this->redirectTarget;
58 $this->redirectTarget =
null;
60 if ( str_starts_with( $text,
'/* #REDIRECT */' ) ) {
63 $text = str_replace(
'\u0026',
'&', $text );
65 if ( preg_match(
'/title=(.*?)&action=raw/', $text,
$matches ) ) {
66 $title = Title::newFromText( urldecode(
$matches[1] ) );
71 '@phan-var JavaScriptContent $expected';
72 if ( $expected->getText() === $text ) {
73 $this->redirectTarget = $title;
79 return $this->redirectTarget;
84class_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.