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