MediaWiki  master
CssContentHandler.php
Go to the documentation of this file.
1 <?php
23 use Wikimedia\Minify\CSSMin;
24 
32 
36  public function __construct( $modelId = CONTENT_MODEL_CSS ) {
37  parent::__construct( $modelId, [ CONTENT_FORMAT_CSS ] );
38  }
39 
40  protected function getContentClass() {
41  return CssContent::class;
42  }
43 
44  public function supportsRedirects() {
45  return true;
46  }
47 
55  public function makeRedirectContent( Title $destination, $text = '' ) {
56  // The parameters are passed as a string so the / is not url-encoded by wfArrayToCgi
57  $url = $destination->getFullURL( 'action=raw&ctype=text/css', false, PROTO_RELATIVE );
58  $class = $this->getContentClass();
59  return new $class( '/* #REDIRECT */@import ' . CSSMin::buildUrlValue( $url ) . ';' );
60  }
61 
62 }
CssContentHandler\getContentClass
getContentClass()
Definition: CssContentHandler.php:40
CssContentHandler\makeRedirectContent
makeRedirectContent(Title $destination, $text='')
Create a redirect that is also valid CSS.
Definition: CssContentHandler.php:55
CssContentHandler\__construct
__construct( $modelId=CONTENT_MODEL_CSS)
Definition: CssContentHandler.php:36
CodeContentHandler
Content handler for code content such as CSS, JavaScript, JSON, etc.
Definition: CodeContentHandler.php:33
CONTENT_FORMAT_CSS
const CONTENT_FORMAT_CSS
For CSS pages.
Definition: Defines.php:228
PROTO_RELATIVE
const PROTO_RELATIVE
Definition: Defines.php:194
CssContentHandler
Content handler for CSS pages.
Definition: CssContentHandler.php:31
CssContentHandler\supportsRedirects
supportsRedirects()
Returns true if this content model supports redirects.
Definition: CssContentHandler.php:44
Title\getFullURL
getFullURL( $query='', $query2=false, $proto=PROTO_RELATIVE)
Get a real URL referring to this title, with interwiki link and fragment.
Definition: Title.php:2228
Title
Represents a title within MediaWiki.
Definition: Title.php:49
CONTENT_MODEL_CSS
const CONTENT_MODEL_CSS
Definition: Defines.php:210