MediaWiki REL1_34
JavaScriptContentHandler.php
Go to the documentation of this file.
1<?php
30
34 public function __construct( $modelId = CONTENT_MODEL_JAVASCRIPT ) {
35 parent::__construct( $modelId, [ CONTENT_FORMAT_JAVASCRIPT ] );
36 }
37
41 protected function getContentClass() {
42 return JavaScriptContent::class;
43 }
44
45 public function supportsRedirects() {
46 return true;
47 }
48
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}
Content handler for code content such as CSS, JavaScript, JSON, etc.
Content handler for JavaScript pages.
__construct( $modelId=CONTENT_MODEL_JAVASCRIPT)
makeRedirectContent(Title $destination, $text='')
Create a redirect that is also valid JavaScript.
supportsRedirects()
Returns true if this content model supports redirects.
Represents a title within MediaWiki.
Definition Title.php:42
getFullURL( $query='', $query2=false, $proto=PROTO_RELATIVE)
Get a real URL referring to this title, with interwiki link and fragment.
Definition Title.php:2068
const CONTENT_FORMAT_JAVASCRIPT
Definition Defines.php:241
const PROTO_RELATIVE
Definition Defines.php:210
const CONTENT_MODEL_JAVASCRIPT
Definition Defines.php:225