X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fresourceloader%2FResourceLoaderUserModule.php;h=8f58040a8c5906615cbb1d085b161674f09000fe;hb=ecc01d14d5a067989d2d316a410d812dfe62dcc8;hp=c38f8d8df77c0d85f4c123a3d3760540a559b0bf;hpb=b41c583e7c5d74faf6ecd838d0a4ee3f4d01066f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/resourceloader/ResourceLoaderUserModule.php b/includes/resourceloader/ResourceLoaderUserModule.php index c38f8d8df7..8f58040a8c 100644 --- a/includes/resourceloader/ResourceLoaderUserModule.php +++ b/includes/resourceloader/ResourceLoaderUserModule.php @@ -1,7 +1,5 @@ getConfig()->get( 'AllowUserJs' ); - $allowUserCss = $this->getConfig()->get( 'AllowUserCss' ); - if ( !$allowUserJs && !$allowUserCss ) { - return []; - } - + $config = $this->getConfig(); $user = $context->getUserObj(); if ( $user->isAnon() ) { return []; } - // Needed so $excludepages works + // Use localised/normalised variant to ensure $excludepage matches $userPage = $user->getUserPage()->getPrefixedDBkey(); - $pages = []; - if ( $allowUserJs ) { + + if ( $config->get( 'AllowUserJs' ) ) { $pages["$userPage/common.js"] = [ 'type' => 'script' ]; $pages["$userPage/" . $context->getSkin() . '.js'] = [ 'type' => 'script' ]; } - if ( $allowUserCss ) { - $pages["$userPage/common.css"] = [ 'type' => 'style' ]; - $pages["$userPage/" . $context->getSkin() . '.css'] = [ 'type' => 'style' ]; + + // User group pages are maintained site-wide and enabled with site JS/CSS. + if ( $config->get( 'UseSiteJs' ) ) { + foreach ( $user->getEffectiveGroups() as $group ) { + if ( $group == '*' ) { + continue; + } + $pages["MediaWiki:Group-$group.js"] = [ 'type' => 'script' ]; + } } - // Hack for bug 26283: if we're on a preview page for a CSS/JS page, - // we need to exclude that page from this module. In that case, the excludepage - // parameter will be set to the name of the page we need to exclude. + // Hack for T28283: Allow excluding pages for preview on a CSS/JS page. + // The excludepage parameter is set by OutputPage. $excludepage = $context->getRequest()->getVal( 'excludepage' ); if ( isset( $pages[$excludepage] ) ) { - // This works because $excludepage is generated with getPrefixedDBkey(), - // just like the keys in $pages[] above unset( $pages[$excludepage] ); } + return $pages; } @@ -80,4 +76,11 @@ class ResourceLoaderUserModule extends ResourceLoaderWikiModule { public function getGroup() { return 'user'; } + + /** + * @return array + */ + public function getDependencies( ResourceLoaderContext $context = null ) { + return [ 'user.styles' ]; + } }