MediaWiki REL1_35
ResourceLoaderUserModule.php
Go to the documentation of this file.
1<?php
30 protected $origin = self::ORIGIN_USER_INDIVIDUAL;
31 protected $targets = [ 'desktop', 'mobile' ];
32
37 protected function getPages( ResourceLoaderContext $context ) {
38 $config = $this->getConfig();
39 $user = $context->getUserObj();
40 if ( $user->isAnon() ) {
41 return [];
42 }
43
44 // Use localised/normalised variant to ensure $excludepage matches
45 $userPage = $user->getUserPage()->getPrefixedDBkey();
46 $pages = [];
47
48 if ( $config->get( 'AllowUserJs' ) ) {
49 $pages["$userPage/common.js"] = [ 'type' => 'script' ];
50 $pages["$userPage/" . $context->getSkin() . '.js'] = [ 'type' => 'script' ];
51 }
52
53 // User group pages are maintained site-wide and enabled with site JS/CSS.
54 if ( $config->get( 'UseSiteJs' ) ) {
55 foreach ( $user->getEffectiveGroups() as $group ) {
56 if ( $group == '*' ) {
57 continue;
58 }
59 $pages["MediaWiki:Group-$group.js"] = [ 'type' => 'script' ];
60 }
61 }
62
63 // This is obsolete since 1.32 (T112474). It was formerly used by
64 // OutputPage to implement previewing of user CSS and JS.
65 // @todo: Remove it once we're sure nothing else is using the parameter
66 $excludepage = $context->getRequest()->getVal( 'excludepage' );
67 if ( isset( $pages[$excludepage] ) ) {
68 unset( $pages[$excludepage] );
69 }
70
71 return $pages;
72 }
73
79 public function getGroup() {
80 return 'user';
81 }
82}
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.
get( $name)
Get a configuration variable such as "Sitename" or "UploadMaintenance.".