MediaWiki
REL1_24
|
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 $username = $context->getUser(); 00042 00043 if ( $username === null ) { 00044 return array(); 00045 } 00046 00047 $allowUserJs = $this->getConfig()->get( 'AllowUserJs' ); 00048 $allowUserCss = $this->getConfig()->get( 'AllowUserCss' ); 00049 00050 if ( !$allowUserJs && !$allowUserCss ) { 00051 return array(); 00052 } 00053 00054 // Get the normalized title of the user's user page 00055 $userpageTitle = Title::makeTitleSafe( NS_USER, $username ); 00056 00057 if ( !$userpageTitle instanceof Title ) { 00058 return array(); 00059 } 00060 00061 $userpage = $userpageTitle->getPrefixedDBkey(); // Needed so $excludepages works 00062 00063 $pages = array(); 00064 if ( $allowUserJs ) { 00065 $pages["$userpage/common.js"] = array( 'type' => 'script' ); 00066 $pages["$userpage/" . $context->getSkin() . '.js'] = array( 'type' => 'script' ); 00067 } 00068 if ( $allowUserCss ) { 00069 $pages["$userpage/common.css"] = array( 'type' => 'style' ); 00070 $pages["$userpage/" . $context->getSkin() . '.css'] = array( 'type' => 'style' ); 00071 } 00072 00073 // Hack for bug 26283: if we're on a preview page for a CSS/JS page, 00074 // we need to exclude that page from this module. In that case, the excludepage 00075 // parameter will be set to the name of the page we need to exclude. 00076 $excludepage = $context->getRequest()->getVal( 'excludepage' ); 00077 if ( isset( $pages[$excludepage] ) ) { 00078 // This works because $excludepage is generated with getPrefixedDBkey(), 00079 // just like the keys in $pages[] above 00080 unset( $pages[$excludepage] ); 00081 } 00082 return $pages; 00083 } 00084 00085 /* Methods */ 00086 00090 public function getGroup() { 00091 return 'user'; 00092 } 00093 }