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