MediaWiki  1.23.6
ResourceLoaderUserGroupsModule.php
Go to the documentation of this file.
1 <?php
27 
28  /* Protected Members */
29 
31  protected $targets = array( 'desktop', 'mobile' );
32 
33  /* Protected Methods */
34 
39  protected function getPages( ResourceLoaderContext $context ) {
40  global $wgUser, $wgUseSiteJs, $wgUseSiteCss;
41 
42  $userName = $context->getUser();
43  if ( $userName === null ) {
44  return array();
45  }
46  if ( !$wgUseSiteJs && !$wgUseSiteCss ) {
47  return array();
48  }
49 
50  // Use $wgUser is possible; allows to skip a lot of code
51  if ( is_object( $wgUser ) && $wgUser->getName() == $userName ) {
52  $user = $wgUser;
53  } else {
54  $user = User::newFromName( $userName );
55  if ( !$user instanceof User ) {
56  return array();
57  }
58  }
59 
60  $pages = array();
61  foreach ( $user->getEffectiveGroups() as $group ) {
62  if ( $group == '*' ) {
63  continue;
64  }
65  if ( $wgUseSiteJs ) {
66  $pages["MediaWiki:Group-$group.js"] = array( 'type' => 'script' );
67  }
68  if ( $wgUseSiteCss ) {
69  $pages["MediaWiki:Group-$group.css"] = array( 'type' => 'style' );
70  }
71  }
72  return $pages;
73  }
74 
75  /* Methods */
76 
80  public function getGroup() {
81  return 'user';
82  }
83 }
ResourceLoaderContext
Object passed around to modules which contains information about the state of a specific loader reque...
Definition: ResourceLoaderContext.php:29
$wgUser
$wgUser
Definition: Setup.php:552
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
ResourceLoaderModule\ORIGIN_USER_SITEWIDE
const ORIGIN_USER_SITEWIDE
Definition: ResourceLoaderModule.php:44
ResourceLoaderUserGroupsModule
Module for user customizations.
Definition: ResourceLoaderUserGroupsModule.php:26
ResourceLoaderWikiModule
Abstraction for resource loader modules which pull from wiki pages.
Definition: ResourceLoaderWikiModule.php:32
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:388
ResourceLoaderUserGroupsModule\$origin
$origin
Definition: ResourceLoaderUserGroupsModule.php:30
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
ResourceLoaderUserGroupsModule\getGroup
getGroup()
Definition: ResourceLoaderUserGroupsModule.php:80
ResourceLoaderUserGroupsModule\getPages
getPages(ResourceLoaderContext $context)
Definition: ResourceLoaderUserGroupsModule.php:39
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:237
ResourceLoaderContext\getUser
getUser()
Definition: ResourceLoaderContext.php:175
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
ResourceLoaderUserGroupsModule\$targets
$targets
Definition: ResourceLoaderUserGroupsModule.php:31
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:59