r111831 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111830‎ | r111831 | r111832 >
Date:15:29, 18 February 2012
Author:ialex
Status:deferred
Tags:
Comment:
Per request on my talk page: make this extension work with current versions of MediaWiki.

It now uses the RequestContextCreateSkin hook so it requires MW 1.19 to work.
Modified paths:
  • /trunk/extensions/SkinPerNamespace/SkinPerNamespace.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SkinPerNamespace/SkinPerNamespace.php
@@ -2,21 +2,21 @@
33 /**
44 * Extension based on SkinPerPage to allow a customized skin per namespace
55 *
6 - * Require MediaWiki 1.15.0 or greater.
 6+ * Require MediaWiki 1.19.0 or greater.
77 *
88 * @file
99 * @author Alexandre Emsenhuber
1010 * @license GPLv2
1111 */
1212
13 -$wgHooks['BeforePageDisplay'][] = 'efSkinPerPageBeforePageDisplayHook';
 13+$wgHooks['RequestContextCreateSkin'][] = 'efSkinPerPageRequestContextCreateSkin';
1414
1515 // Add credits :)
1616 $wgExtensionCredits['other'][] = array(
1717 'path' => __FILE__,
1818 'name' => 'SkinPerNamespace',
1919 'url' => 'https://www.mediawiki.org/wiki/Extension:SkinPerNamespace',
20 - 'version' => '2011-01-10',
 20+ 'version' => '2012-02-18',
2121 'description' => 'Allow a per-namespace skin',
2222 'author' => 'Alexandre Emsenhuber',
2323
@@ -46,33 +46,33 @@
4747 // Implementation
4848
4949 /**
50 - * Hook function for BeforePageDisplay
 50+ * Hook function for RequestContextCreateSkin
5151 */
52 -function efSkinPerPageBeforePageDisplayHook( &$out, &$skin ){
 52+function efSkinPerPageRequestContextCreateSkin( $context, &$skin ) {
5353 global $wgSkinPerNamespace, $wgSkinPerSpecialPage,
54 - $wgSkinPerNamespaceOverrideLoggedIn, $wgUser;
 54+ $wgSkinPerNamespaceOverrideLoggedIn;
5555
56 - if( !$wgSkinPerNamespaceOverrideLoggedIn && $wgUser->isLoggedIn() )
 56+ if ( !$wgSkinPerNamespaceOverrideLoggedIn && $context->getUser()->isLoggedIn() ) {
5757 return true;
 58+ }
5859
59 - $title = $out->getTitle();
 60+ $title = $context->getTitle();
6061 $ns = $title->getNamespace();
6162 $skinName = null;
6263
63 - if( $ns == NS_SPECIAL ) {
 64+ if ( $ns == NS_SPECIAL ) {
6465 list( $canonical, /* $subpage */ ) = SpecialPage::resolveAliasWithSubpage( $title->getDBkey() );
65 - if( isset( $wgSkinPerSpecialPage[$canonical] ) ) {
 66+ if ( isset( $wgSkinPerSpecialPage[$canonical] ) ) {
6667 $skinName = $wgSkinPerSpecialPage[$canonical];
6768 }
6869 }
6970
70 - if( $skinName === null && isset( $wgSkinPerNamespace[$ns] ) ) {
 71+ if ( $skinName === null && isset( $wgSkinPerNamespace[$ns] ) ) {
7172 $skinName = $wgSkinPerNamespace[$ns];
7273 }
7374
74 - if( $skinName !== null ) {
75 - $skin = Skin::newFromKey( $skinName );
76 - $skin->setTitle( $out->getTitle() );
 75+ if ( $skinName !== null ) {
 76+ $skin = $skinName;
7777 }
7878
7979 return true;

Follow-up revisions

RevisionCommit summaryAuthorDate
r111853r111831: Add i18n fileraymond08:46, 19 February 2012
r111854r111831: Register extension for translatewiki.net.raymond08:48, 19 February 2012

Status & tagging log