MediaWiki
REL1_23
|
00001 <?php 00028 class ResourceLoaderUserModule extends ResourceLoaderWikiModule { 00029 00030 /* Protected Members */ 00031 00032 protected $origin = self::ORIGIN_USER_INDIVIDUAL; 00033 00034 /* Protected Methods */ 00035 00040 protected function getPages( ResourceLoaderContext $context ) { 00041 global $wgAllowUserJs, $wgAllowUserCss; 00042 $username = $context->getUser(); 00043 00044 if ( $username === null ) { 00045 return array(); 00046 } 00047 if ( !$wgAllowUserJs && !$wgAllowUserCss ) { 00048 return array(); 00049 } 00050 00051 // Get the normalized title of the user's user page 00052 $userpageTitle = Title::makeTitleSafe( NS_USER, $username ); 00053 00054 if ( !$userpageTitle instanceof Title ) { 00055 return array(); 00056 } 00057 00058 $userpage = $userpageTitle->getPrefixedDBkey(); // Needed so $excludepages works 00059 00060 $pages = array(); 00061 if ( $wgAllowUserJs ) { 00062 $pages["$userpage/common.js"] = array( 'type' => 'script' ); 00063 $pages["$userpage/" . $context->getSkin() . '.js'] = array( 'type' => 'script' ); 00064 } 00065 if ( $wgAllowUserCss ) { 00066 $pages["$userpage/common.css"] = array( 'type' => 'style' ); 00067 $pages["$userpage/" . $context->getSkin() . '.css'] = array( 'type' => 'style' ); 00068 } 00069 00070 // Hack for bug 26283: if we're on a preview page for a CSS/JS page, 00071 // we need to exclude that page from this module. In that case, the excludepage 00072 // parameter will be set to the name of the page we need to exclude. 00073 $excludepage = $context->getRequest()->getVal( 'excludepage' ); 00074 if ( isset( $pages[$excludepage] ) ) { 00075 // This works because $excludepage is generated with getPrefixedDBkey(), 00076 // just like the keys in $pages[] above 00077 unset( $pages[$excludepage] ); 00078 } 00079 return $pages; 00080 } 00081 00082 /* Methods */ 00083 00087 public function getGroup() { 00088 return 'user'; 00089 } 00090 }