From: Trevor Parscal Date: Tue, 12 Oct 2010 21:19:51 +0000 (+0000) Subject: Improves on r72776 by adding documentation about the limitations of ResourceLoaderWik... X-Git-Tag: 1.31.0-rc.0~34529 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=6a823e053e48a35cba3548a04b45fc10dfc0dc92;p=lhc%2Fweb%2Fwiklou.git Improves on r72776 by adding documentation about the limitations of ResourceLoaderWikiModule and making use of the MWNamespace::getCanonicalName method rather than depending on $wgCanonicalNamespaceNames. --- diff --git a/includes/ResourceLoaderModule.php b/includes/ResourceLoaderModule.php index b5ab2d686d..4faadf8099 100644 --- a/includes/ResourceLoaderModule.php +++ b/includes/ResourceLoaderModule.php @@ -739,6 +739,9 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { /** * Abstraction for resource loader modules which pull from wiki pages + * + * This can only be used for wiki pages in the MediaWiki and User namespaces, because of it's dependence on the + * functionality of Title::isValidCssJsSubpage. */ abstract class ResourceLoaderWikiModule extends ResourceLoaderModule { @@ -768,13 +771,11 @@ abstract class ResourceLoaderWikiModule extends ResourceLoaderModule { /* Methods */ public function getScript( ResourceLoaderContext $context ) { - global $wgCanonicalNamespaceNames; - $scripts = ''; foreach ( $this->getPages( $context ) as $page => $options ) { if ( $options['type'] === 'script' ) { if ( $script = $this->getContent( $page, $options['ns'] ) ) { - $ns = $wgCanonicalNamespaceNames[$options['ns']]; + $ns = MWNamespace::getCanonicalName( $options['ns'] ); $scripts .= "/*$ns:$page */\n$script\n"; } } @@ -783,7 +784,6 @@ abstract class ResourceLoaderWikiModule extends ResourceLoaderModule { } public function getStyles( ResourceLoaderContext $context ) { - global $wgCanonicalNamespaceNames; $styles = array(); foreach ( $this->getPages( $context ) as $page => $options ) { @@ -793,7 +793,7 @@ abstract class ResourceLoaderWikiModule extends ResourceLoaderModule { if ( !isset( $styles[$media] ) ) { $styles[$media] = ''; } - $ns = $wgCanonicalNamespaceNames[$options['ns']]; + $ns = MWNamespace::getCanonicalName( $options['ns'] ); $styles[$media] .= "/* $ns:$page */\n$style\n"; } }