@@ 30-61 (lines=32) @@ | ||
27 | * @since 1.21 |
|
28 | * @ingroup Content |
|
29 | */ |
|
30 | class CssContentHandler extends CodeContentHandler { |
|
31 | ||
32 | /** |
|
33 | * @param string $modelId |
|
34 | */ |
|
35 | public function __construct( $modelId = CONTENT_MODEL_CSS ) { |
|
36 | parent::__construct( $modelId, [ CONTENT_FORMAT_CSS ] ); |
|
37 | } |
|
38 | ||
39 | protected function getContentClass() { |
|
40 | return CssContent::class; |
|
41 | } |
|
42 | ||
43 | public function supportsRedirects() { |
|
44 | return true; |
|
45 | } |
|
46 | ||
47 | /** |
|
48 | * Create a redirect that is also valid CSS |
|
49 | * |
|
50 | * @param Title $destination |
|
51 | * @param string $text ignored |
|
52 | * @return CssContent |
|
53 | */ |
|
54 | public function makeRedirectContent( Title $destination, $text = '' ) { |
|
55 | // The parameters are passed as a string so the / is not url-encoded by wfArrayToCgi |
|
56 | $url = $destination->getFullURL( 'action=raw&ctype=text/css', false, PROTO_RELATIVE ); |
|
57 | $class = $this->getContentClass(); |
|
58 | return new $class( '/* #REDIRECT */@import ' . CSSMin::buildUrlValue( $url ) . ';' ); |
|
59 | } |
|
60 | ||
61 | } |
|
62 |
@@ 29-62 (lines=34) @@ | ||
26 | * @since 1.21 |
|
27 | * @ingroup Content |
|
28 | */ |
|
29 | class JavaScriptContentHandler extends CodeContentHandler { |
|
30 | ||
31 | /** |
|
32 | * @param string $modelId |
|
33 | */ |
|
34 | public function __construct( $modelId = CONTENT_MODEL_JAVASCRIPT ) { |
|
35 | parent::__construct( $modelId, [ CONTENT_FORMAT_JAVASCRIPT ] ); |
|
36 | } |
|
37 | ||
38 | /** |
|
39 | * @return string |
|
40 | */ |
|
41 | protected function getContentClass() { |
|
42 | return JavaScriptContent::class; |
|
43 | } |
|
44 | ||
45 | public function supportsRedirects() { |
|
46 | return true; |
|
47 | } |
|
48 | ||
49 | /** |
|
50 | * Create a redirect that is also valid JavaScript |
|
51 | * |
|
52 | * @param Title $destination |
|
53 | * @param string $text ignored |
|
54 | * @return JavaScriptContent |
|
55 | */ |
|
56 | public function makeRedirectContent( Title $destination, $text = '' ) { |
|
57 | // The parameters are passed as a string so the / is not url-encoded by wfArrayToCgi |
|
58 | $url = $destination->getFullURL( 'action=raw&ctype=text/javascript', false, PROTO_RELATIVE ); |
|
59 | $class = $this->getContentClass(); |
|
60 | return new $class( '/* #REDIRECT */' . Xml::encodeJsCall( 'mw.loader.load', [ $url ] ) ); |
|
61 | } |
|
62 | } |
|
63 |