MediaWiki  1.23.3
ResourceLoaderUserModule.php
Go to the documentation of this file.
1 <?php
29 
30  /* Protected Members */
31 
33 
34  /* Protected Methods */
35 
40  protected function getPages( ResourceLoaderContext $context ) {
41  global $wgAllowUserJs, $wgAllowUserCss;
42  $username = $context->getUser();
43 
44  if ( $username === null ) {
45  return array();
46  }
47  if ( !$wgAllowUserJs && !$wgAllowUserCss ) {
48  return array();
49  }
50 
51  // Get the normalized title of the user's user page
52  $userpageTitle = Title::makeTitleSafe( NS_USER, $username );
53 
54  if ( !$userpageTitle instanceof Title ) {
55  return array();
56  }
57 
58  $userpage = $userpageTitle->getPrefixedDBkey(); // Needed so $excludepages works
59 
60  $pages = array();
61  if ( $wgAllowUserJs ) {
62  $pages["$userpage/common.js"] = array( 'type' => 'script' );
63  $pages["$userpage/" . $context->getSkin() . '.js'] = array( 'type' => 'script' );
64  }
65  if ( $wgAllowUserCss ) {
66  $pages["$userpage/common.css"] = array( 'type' => 'style' );
67  $pages["$userpage/" . $context->getSkin() . '.css'] = array( 'type' => 'style' );
68  }
69 
70  // Hack for bug 26283: if we're on a preview page for a CSS/JS page,
71  // we need to exclude that page from this module. In that case, the excludepage
72  // parameter will be set to the name of the page we need to exclude.
73  $excludepage = $context->getRequest()->getVal( 'excludepage' );
74  if ( isset( $pages[$excludepage] ) ) {
75  // This works because $excludepage is generated with getPrefixedDBkey(),
76  // just like the keys in $pages[] above
77  unset( $pages[$excludepage] );
78  }
79  return $pages;
80  }
81 
82  /* Methods */
83 
87  public function getGroup() {
88  return 'user';
89  }
90 }
ResourceLoaderContext
Object passed around to modules which contains information about the state of a specific loader reque...
Definition: ResourceLoaderContext.php:29
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
ResourceLoaderWikiModule
Abstraction for resource loader modules which pull from wiki pages.
Definition: ResourceLoaderWikiModule.php:32
ResourceLoaderContext\getRequest
getRequest()
Definition: ResourceLoaderContext.php:129
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
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:422
ResourceLoaderModule\ORIGIN_USER_INDIVIDUAL
const ORIGIN_USER_INDIVIDUAL
Definition: ResourceLoaderModule.php:47
ResourceLoaderUserModule\getGroup
getGroup()
Definition: ResourceLoaderUserModule.php:87
ResourceLoaderContext\getSkin
getSkin()
Definition: ResourceLoaderContext.php:168
ResourceLoaderUserModule\getPages
getPages(ResourceLoaderContext $context)
Definition: ResourceLoaderUserModule.php:40
ResourceLoaderUserModule\$origin
$origin
Definition: ResourceLoaderUserModule.php:32
ResourceLoaderContext\getUser
getUser()
Definition: ResourceLoaderContext.php:175
Title
Represents a title within MediaWiki.
Definition: Title.php:35
ResourceLoaderUserModule
Module for user customizations.
Definition: ResourceLoaderUserModule.php:28
NS_USER
const NS_USER
Definition: Defines.php:81