MediaWiki REL1_39
CssContent.php
Go to the documentation of this file.
1<?php
34class CssContent extends TextContent {
35
39 private $redirectTarget = false;
40
46 public function __construct( $text, $modelId = CONTENT_MODEL_CSS ) {
47 parent::__construct( $text, $modelId );
48 }
49
54 public function updateRedirect( Title $target ) {
55 if ( !$this->isRedirect() ) {
56 return $this;
57 }
58
59 // @phan-suppress-next-line PhanTypeMismatchReturnSuperType False positive
60 return $this->getContentHandler()->makeRedirectContent( $target );
61 }
62
66 public function getRedirectTarget() {
67 if ( $this->redirectTarget !== false ) {
68 return $this->redirectTarget;
69 }
70 $this->redirectTarget = null;
71 $text = $this->getText();
72 if ( strpos( $text, '/* #REDIRECT */' ) === 0 ) {
73 // Extract the title from the url
74 if ( preg_match( '/title=(.*?)&action=raw/', $text, $matches ) ) {
75 $title = Title::newFromText( urldecode( $matches[1] ) );
76 if ( $title ) {
77 // Have a title, check that the current content equals what
78 // the redirect content should be
79 if ( $this->equals( $this->getContentHandler()->makeRedirectContent( $title ) ) ) {
80 $this->redirectTarget = $title;
81 }
82 }
83 }
84 }
85
86 return $this->redirectTarget;
87 }
88
89}
const CONTENT_MODEL_CSS
Definition Defines.php:213
equals(Content $that=null)
Decides whether two Content objects are equal.
Content object for CSS pages.
__construct( $text, $modelId=CONTENT_MODEL_CSS)
updateRedirect(Title $target)
getRedirectTarget()
Content object implementation for representing flat text.
getText()
Returns the text represented by this Content object, as a string.
Represents a title within MediaWiki.
Definition Title.php:49