Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -1559,6 +1559,11 @@ |
1560 | 1560 | 'RecentChange_save': called at the end of RecentChange::save() |
1561 | 1561 | $recentChange: RecentChange object |
1562 | 1562 | |
| 1563 | +'RequestContextCreateSkin': Called when RequestContext::getSkin creates a skin instance. |
| 1564 | +Can be used by an extension override what skin is used in certain contexts. |
| 1565 | +IContextSource $context: The RequestContext the skin is being created for. |
| 1566 | +&$skin: A variable reference you may set a Skin instance or string key on to override the skin that will be used for the context. |
| 1567 | + |
1563 | 1568 | 'ResourceLoaderGetConfigVars': called at the end of |
1564 | 1569 | ResourceLoaderStartUpModule::getConfig(). Use this to export static |
1565 | 1570 | configuration variables to JavaScript. Things that depend on the current |
Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -241,6 +241,8 @@ |
242 | 242 | * (bug 31759) Undefined property notice in querypages API. |
243 | 243 | * (bug 32495) API should allow purge by pageids. |
244 | 244 | * (bug 33147) API examples should explain what they do. |
| 245 | +* Extensions can use the RequestContextCreateSkin hook to override what skin is |
| 246 | + loaded in some contexts. |
245 | 247 | |
246 | 248 | === Languages updated in 1.19 === |
247 | 249 | |
Index: trunk/phase3/includes/context/RequestContext.php |
— | — | @@ -248,18 +248,34 @@ |
249 | 249 | if ( $this->skin === null ) { |
250 | 250 | wfProfileIn( __METHOD__ . '-createskin' ); |
251 | 251 | |
252 | | - global $wgHiddenPrefs; |
253 | | - if( !in_array( 'skin', $wgHiddenPrefs ) ) { |
254 | | - # get the user skin |
255 | | - $userSkin = $this->getUser()->getOption( 'skin' ); |
256 | | - $userSkin = $this->getRequest()->getVal( 'useskin', $userSkin ); |
257 | | - } else { |
258 | | - # if we're not allowing users to override, then use the default |
259 | | - global $wgDefaultSkin; |
260 | | - $userSkin = $wgDefaultSkin; |
| 252 | + $skin = null; |
| 253 | + wfRunHooks( 'RequestContextCreateSkin', array( $this, &$skin ) ); |
| 254 | + |
| 255 | + // If the hook worked try to set a skin from it |
| 256 | + if ( $skin instanceof Skin ) { |
| 257 | + $this->skin = $skin; |
| 258 | + } elseif ( is_string($skin) ) { |
| 259 | + $this->skin = Skin::newFromKey( $skin ); |
261 | 260 | } |
262 | 261 | |
263 | | - $this->skin = Skin::newFromKey( $userSkin ); |
| 262 | + // If this is still null (the hook didn't run or didn't work) |
| 263 | + // then go through the normal processing to load a skin |
| 264 | + if ( $this->skin === null ) { |
| 265 | + global $wgHiddenPrefs; |
| 266 | + if( !in_array( 'skin', $wgHiddenPrefs ) ) { |
| 267 | + # get the user skin |
| 268 | + $userSkin = $this->getUser()->getOption( 'skin' ); |
| 269 | + $userSkin = $this->getRequest()->getVal( 'useskin', $userSkin ); |
| 270 | + } else { |
| 271 | + # if we're not allowing users to override, then use the default |
| 272 | + global $wgDefaultSkin; |
| 273 | + $userSkin = $wgDefaultSkin; |
| 274 | + } |
| 275 | + |
| 276 | + $this->skin = Skin::newFromKey( $userSkin ); |
| 277 | + } |
| 278 | + |
| 279 | + // After all that set a context on whatever skin got created |
264 | 280 | $this->skin->setContext( $this ); |
265 | 281 | wfProfileOut( __METHOD__ . '-createskin' ); |
266 | 282 | } |