MediaWiki REL1_37
ResourceLoaderUserModule.php
Go to the documentation of this file.
1<?php
24
32 protected $origin = self::ORIGIN_USER_INDIVIDUAL;
33 protected $targets = [ 'desktop', 'mobile' ];
34
39 protected function getPages( ResourceLoaderContext $context ) {
40 $config = $this->getConfig();
41 $user = $context->getUserObj();
42 if ( $user->isAnon() ) {
43 return [];
44 }
45
46 // Use localised/normalised variant to ensure $excludepage matches
47 $userPage = $user->getUserPage()->getPrefixedDBkey();
48 $pages = [];
49
50 if ( $config->get( 'AllowUserJs' ) ) {
51 $pages["$userPage/common.js"] = [ 'type' => 'script' ];
52 $pages["$userPage/" . $context->getSkin() . '.js'] = [ 'type' => 'script' ];
53 }
54
55 // User group pages are maintained site-wide and enabled with site JS/CSS.
56 if ( $config->get( 'UseSiteJs' ) ) {
57 $userGroupManager = MediaWikiServices::getInstance()->getUserGroupManager();
58 foreach ( $userGroupManager->getUserEffectiveGroups( $user ) as $group ) {
59 if ( $group == '*' ) {
60 continue;
61 }
62 $pages["MediaWiki:Group-$group.js"] = [ 'type' => 'script' ];
63 }
64 }
65
66 // This is obsolete since 1.32 (T112474). It was formerly used by
67 // OutputPage to implement previewing of user CSS and JS.
68 // @todo: Remove it once we're sure nothing else is using the parameter
69 $excludepage = $context->getRequest()->getVal( 'excludepage' );
70 unset( $pages[$excludepage] );
71
72 return $pages;
73 }
74
80 public function getGroup() {
81 return 'user';
82 }
83}
MediaWikiServices is the service locator for the application scope of MediaWiki.
Context object that contains information about the state of a specific ResourceLoader web request.
getUserObj()
Get the possibly-cached User object for the specified username.
Module for user customizations scripts.
getPages(ResourceLoaderContext $context)
Abstraction for ResourceLoader modules which pull from wiki pages.
string null $group
Group of module.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".