getConfig(); $user = $context->getUserObj(); if ( $user->isAnon() ) { return []; } // Use localised/normalised variant to ensure $excludepage matches $userPage = $user->getUserPage()->getPrefixedDBkey(); $pages = []; if ( $config->get( 'AllowUserJs' ) ) { $pages["$userPage/common.js"] = [ 'type' => 'script' ]; $pages["$userPage/" . $context->getSkin() . '.js'] = [ 'type' => 'script' ]; } if ( $config->get( 'AllowUserCss' ) ) { $pages["$userPage/common.css"] = [ 'type' => 'style' ]; $pages["$userPage/" . $context->getSkin() . '.css'] = [ 'type' => 'style' ]; } $useSiteJs = $config->get( 'UseSiteJs' ); $useSiteCss = $config->get( 'UseSiteCss' ); // User group pages are maintained site-wide and enabled with site JS/CSS. if ( $useSiteJs || $useSiteCss ) { foreach ( $user->getEffectiveGroups() as $group ) { if ( $group == '*' ) { continue; } if ( $useSiteJs ) { $pages["MediaWiki:Group-$group.js"] = [ 'type' => 'script' ]; } if ( $useSiteCss ) { $pages["MediaWiki:Group-$group.css"] = [ 'type' => 'style' ]; } } } // 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. $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; } /** * Get group name * * @return string */ public function getGroup() { return 'user'; } }