r74691 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74690‎ | r74691 | r74692 >
Date:21:19, 12 October 2010
Author:tparscal
Status:ok
Tags:
Comment:
Improves on r72776 by adding documentation about the limitations of ResourceLoaderWikiModule and making use of the MWNamespace::getCanonicalName method rather than depending on $wgCanonicalNamespaceNames.
Modified paths:
  • /trunk/phase3/includes/ResourceLoaderModule.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ResourceLoaderModule.php
@@ -739,6 +739,9 @@
740740
741741 /**
742742 * Abstraction for resource loader modules which pull from wiki pages
 743+ *
 744+ * This can only be used for wiki pages in the MediaWiki and User namespaces, because of it's dependence on the
 745+ * functionality of Title::isValidCssJsSubpage.
743746 */
744747 abstract class ResourceLoaderWikiModule extends ResourceLoaderModule {
745748
@@ -768,13 +771,11 @@
769772 /* Methods */
770773
771774 public function getScript( ResourceLoaderContext $context ) {
772 - global $wgCanonicalNamespaceNames;
773 -
774775 $scripts = '';
775776 foreach ( $this->getPages( $context ) as $page => $options ) {
776777 if ( $options['type'] === 'script' ) {
777778 if ( $script = $this->getContent( $page, $options['ns'] ) ) {
778 - $ns = $wgCanonicalNamespaceNames[$options['ns']];
 779+ $ns = MWNamespace::getCanonicalName( $options['ns'] );
779780 $scripts .= "/*$ns:$page */\n$script\n";
780781 }
781782 }
@@ -783,7 +784,6 @@
784785 }
785786
786787 public function getStyles( ResourceLoaderContext $context ) {
787 - global $wgCanonicalNamespaceNames;
788788
789789 $styles = array();
790790 foreach ( $this->getPages( $context ) as $page => $options ) {
@@ -793,7 +793,7 @@
794794 if ( !isset( $styles[$media] ) ) {
795795 $styles[$media] = '';
796796 }
797 - $ns = $wgCanonicalNamespaceNames[$options['ns']];
 797+ $ns = MWNamespace::getCanonicalName( $options['ns'] );
798798 $styles[$media] .= "/* $ns:$page */\n$style\n";
799799 }
800800 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r72776Fixed user scripts/styles and site scripts/styles - they were totally broken ...tparscal07:33, 11 September 2010

Status & tagging log