X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoaderFileModule.php;h=7bbc9bbe6afbd00832780656833c6182383f1160;hb=c6289d013eac6194fb6631e8b0d9723f580982b0;hp=dc8b14a23e220edfb325889f53f198712d314139;hpb=33fc248ee712c58772e339b4fcb2123d83fbbe26;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/resourceloader/ResourceLoaderFileModule.php b/includes/resourceloader/ResourceLoaderFileModule.php index dc8b14a23e..7bbc9bbe6a 100644 --- a/includes/resourceloader/ResourceLoaderFileModule.php +++ b/includes/resourceloader/ResourceLoaderFileModule.php @@ -304,7 +304,9 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { // The different ways these checks are done, and their ordering, look very silly, // but were preserved for backwards-compatibility just in case. Tread lightly. - $localBasePath = $localBasePath === null ? $IP : $localBasePath; + if ( $localBasePath === null ) { + $localBasePath = $IP; + } if ( $remoteBasePath === null ) { $remoteBasePath = $wgResourceBasePath; } @@ -534,7 +536,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { $files, $this->scripts, $context->getDebug() ? $this->debugScripts : array(), - self::tryForKey( $this->languageScripts, $context->getLanguage() ), + $this->getLanguageScripts( $context->getLanguage() ), self::tryForKey( $this->skinScripts, $context->getSkin(), 'default' ), $this->loaderScripts ); @@ -698,7 +700,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { protected function getScriptFiles( ResourceLoaderContext $context ) { $files = array_merge( $this->scripts, - self::tryForKey( $this->languageScripts, $context->getLanguage() ), + $this->getLanguageScripts( $context->getLanguage() ), self::tryForKey( $this->skinScripts, $context->getSkin(), 'default' ) ); if ( $context->getDebug() ) { @@ -708,6 +710,29 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { return array_unique( $files, SORT_REGULAR ); } + /** + * Get the set of language scripts for the given language, + * possibly using a fallback language. + * + * @param string $lang + * @return array + */ + private function getLanguageScripts( $lang ) { + $scripts = self::tryForKey( $this->languageScripts, $lang ); + if ( $scripts ) { + return $scripts; + } + $fallbacks = Language::getFallbacksFor( $lang ); + foreach ( $fallbacks as $lang ) { + $scripts = self::tryForKey( $this->languageScripts, $lang ); + if ( $scripts ) { + return $scripts; + } + } + + return array(); + } + /** * Get a list of file paths for all styles in this module, in order of proper inclusion. *