Index: trunk/extensions/SkinPerNamespace/SkinPerNamespace.php |
— | — | @@ -2,21 +2,21 @@ |
3 | 3 | /** |
4 | 4 | * Extension based on SkinPerPage to allow a customized skin per namespace |
5 | 5 | * |
6 | | - * Require MediaWiki 1.15.0 or greater. |
| 6 | + * Require MediaWiki 1.19.0 or greater. |
7 | 7 | * |
8 | 8 | * @file |
9 | 9 | * @author Alexandre Emsenhuber |
10 | 10 | * @license GPLv2 |
11 | 11 | */ |
12 | 12 | |
13 | | -$wgHooks['BeforePageDisplay'][] = 'efSkinPerPageBeforePageDisplayHook'; |
| 13 | +$wgHooks['RequestContextCreateSkin'][] = 'efSkinPerPageRequestContextCreateSkin'; |
14 | 14 | |
15 | 15 | // Add credits :) |
16 | 16 | $wgExtensionCredits['other'][] = array( |
17 | 17 | 'path' => __FILE__, |
18 | 18 | 'name' => 'SkinPerNamespace', |
19 | 19 | 'url' => 'https://www.mediawiki.org/wiki/Extension:SkinPerNamespace', |
20 | | - 'version' => '2011-01-10', |
| 20 | + 'version' => '2012-02-18', |
21 | 21 | 'description' => 'Allow a per-namespace skin', |
22 | 22 | 'author' => 'Alexandre Emsenhuber', |
23 | 23 | |
— | — | @@ -46,33 +46,33 @@ |
47 | 47 | // Implementation |
48 | 48 | |
49 | 49 | /** |
50 | | - * Hook function for BeforePageDisplay |
| 50 | + * Hook function for RequestContextCreateSkin |
51 | 51 | */ |
52 | | -function efSkinPerPageBeforePageDisplayHook( &$out, &$skin ){ |
| 52 | +function efSkinPerPageRequestContextCreateSkin( $context, &$skin ) { |
53 | 53 | global $wgSkinPerNamespace, $wgSkinPerSpecialPage, |
54 | | - $wgSkinPerNamespaceOverrideLoggedIn, $wgUser; |
| 54 | + $wgSkinPerNamespaceOverrideLoggedIn; |
55 | 55 | |
56 | | - if( !$wgSkinPerNamespaceOverrideLoggedIn && $wgUser->isLoggedIn() ) |
| 56 | + if ( !$wgSkinPerNamespaceOverrideLoggedIn && $context->getUser()->isLoggedIn() ) { |
57 | 57 | return true; |
| 58 | + } |
58 | 59 | |
59 | | - $title = $out->getTitle(); |
| 60 | + $title = $context->getTitle(); |
60 | 61 | $ns = $title->getNamespace(); |
61 | 62 | $skinName = null; |
62 | 63 | |
63 | | - if( $ns == NS_SPECIAL ) { |
| 64 | + if ( $ns == NS_SPECIAL ) { |
64 | 65 | list( $canonical, /* $subpage */ ) = SpecialPage::resolveAliasWithSubpage( $title->getDBkey() ); |
65 | | - if( isset( $wgSkinPerSpecialPage[$canonical] ) ) { |
| 66 | + if ( isset( $wgSkinPerSpecialPage[$canonical] ) ) { |
66 | 67 | $skinName = $wgSkinPerSpecialPage[$canonical]; |
67 | 68 | } |
68 | 69 | } |
69 | 70 | |
70 | | - if( $skinName === null && isset( $wgSkinPerNamespace[$ns] ) ) { |
| 71 | + if ( $skinName === null && isset( $wgSkinPerNamespace[$ns] ) ) { |
71 | 72 | $skinName = $wgSkinPerNamespace[$ns]; |
72 | 73 | } |
73 | 74 | |
74 | | - if( $skinName !== null ) { |
75 | | - $skin = Skin::newFromKey( $skinName ); |
76 | | - $skin->setTitle( $out->getTitle() ); |
| 75 | + if ( $skinName !== null ) { |
| 76 | + $skin = $skinName; |
77 | 77 | } |
78 | 78 | |
79 | 79 | return true; |