diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-12-20 09:00:55 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-12-20 09:00:55 +0100 |
commit | a2190ac74dd4d7080b12bab90e552d7aa81209ef (patch) | |
tree | 8b31f38de9882d18df54cf8d9e0de74167a094eb /includes/content/JavaScriptContentHandler.php | |
parent | 15e69f7b20b6596b9148030acce5b59993b95a45 (diff) | |
parent | 257401d8b2cf661adf36c84b0e3fd1cf85e33c22 (diff) |
Merge branch 'mw-1.26'
Diffstat (limited to 'includes/content/JavaScriptContentHandler.php')
-rw-r--r-- | includes/content/JavaScriptContentHandler.php | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/includes/content/JavaScriptContentHandler.php b/includes/content/JavaScriptContentHandler.php index d2218971..65e3a6f0 100644 --- a/includes/content/JavaScriptContentHandler.php +++ b/includes/content/JavaScriptContentHandler.php @@ -41,4 +41,22 @@ class JavaScriptContentHandler extends CodeContentHandler { protected function getContentClass() { return 'JavaScriptContent'; } + + public function supportsRedirects() { + return true; + } + + /** + * Create a redirect that is also valid JavaScript + * + * @param Title $destination + * @param string $text ignored + * @return JavaScriptContent + */ + public function makeRedirectContent( Title $destination, $text = '' ) { + // The parameters are passed as a string so the / is not url-encoded by wfArrayToCgi + $url = $destination->getFullURL( 'action=raw&ctype=text/javascript', false, PROTO_RELATIVE ); + $class = $this->getContentClass(); + return new $class( '/* #REDIRECT */' . Xml::encodeJsCall( 'mw.loader.load', array( $url ) ) ); + } } |