Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -569,6 +569,9 @@ |
570 | 570 | 'BookInformation': Before information output on Special:Booksources |
571 | 571 | $isbn: ISBN to show information for |
572 | 572 | $output: OutputPage object in use |
| 573 | + |
| 574 | +'CanonicalNamespaces': For extensions adding their own namespaces or altering the defaults |
| 575 | +&$namespaces: Array of namespace numbers with they canonical names |
573 | 576 | |
574 | 577 | 'CategoryPageView': before viewing a categorypage in CategoryPage::view |
575 | 578 | $catpage: CategoryPage instance |
Index: trunk/phase3/includes/Namespace.php |
— | — | @@ -135,6 +135,7 @@ |
136 | 136 | $namespaces = $wgCanonicalNamespaceNames; |
137 | 137 | } |
138 | 138 | $namespaces[NS_MAIN] = ''; |
| 139 | + wfRunHooks( 'CanonicalNamespaces', array( &$namespaces ) ); |
139 | 140 | } |
140 | 141 | return $namespaces; |
141 | 142 | } |
Index: trunk/extensions/LiquidThreads/LiquidThreads.php |
— | — | @@ -21,14 +21,18 @@ |
22 | 22 | define( 'LQT_NEWEST_THREADS', 'nt' ); |
23 | 23 | define( 'LQT_OLDEST_THREADS', 'ot' ); |
24 | 24 | |
25 | | -$wgExtensionFunctions[] = 'wgLqtSetupCanonicalNamespces'; |
| 25 | +if ( version_compare( $wgVersion, '1.17alpha', '>=' ) ) { |
| 26 | + $wgHooks['CanonicalNamespaces'][] = 'wgLqtSetupCanonicalNamespaces'; |
| 27 | +} else { |
| 28 | + wgLqtSetupCanonicalNamespaces( &$wgExtraNamespaces ); |
| 29 | +} |
26 | 30 | |
27 | | -function wgLqtSetupCanonicalNamespces() { |
28 | | - global $wgCanonicalNamespaceNames; |
29 | | - $wgCanonicalNamespaceNames[NS_LQT_THREAD] = 'Thread'; |
30 | | - $wgCanonicalNamespaceNames[NS_LQT_THREAD_TALK] = 'Thread_talk'; |
31 | | - $wgCanonicalNamespaceNames[NS_LQT_SUMMARY] = 'Summary'; |
32 | | - $wgCanonicalNamespaceNames[NS_LQT_SUMMARY_TALK] = 'Summary_talk'; |
| 31 | +function wgLqtSetupCanonicalNamespaces( &$list ) { |
| 32 | + $list[NS_LQT_THREAD] = 'Thread'; |
| 33 | + $list[NS_LQT_THREAD_TALK] = 'Thread_talk'; |
| 34 | + $list[NS_LQT_SUMMARY] = 'Summary'; |
| 35 | + $list[NS_LQT_SUMMARY_TALK] = 'Summary_talk'; |
| 36 | + return true; |
33 | 37 | } |
34 | 38 | |
35 | 39 | // Localisation |
Index: trunk/extensions/Translate/Translate.php |
— | — | @@ -49,6 +49,7 @@ |
50 | 50 | |
51 | 51 | // Register initialization hook |
52 | 52 | $wgExtensionFunctions[] = 'efTranslateInit'; |
| 53 | +$wgHooks['CanonicalNamespaces'][] = 'efTranslateNamespaces'; |
53 | 54 | |
54 | 55 | // Register special pages into MediaWiki |
55 | 56 | $wgSpecialPages['Translate'] = 'SpecialTranslate'; |
— | — | @@ -401,6 +402,12 @@ |
402 | 403 | |
403 | 404 | # Startup code |
404 | 405 | |
| 406 | +function efTranslateNamespaces( &$list ) { |
| 407 | + $list[NS_TRANSLATIONS] = 'Translations'; |
| 408 | + $list[NS_TRANSLATIONS_TALK] = 'Translations_talk'; |
| 409 | + return true; |
| 410 | +} |
| 411 | + |
405 | 412 | /** |
406 | 413 | * Initialises the extension. |
407 | 414 | * @private |
— | — | @@ -459,24 +466,19 @@ |
460 | 467 | $wgJobClasses['RenderJob'] = 'RenderJob'; |
461 | 468 | $wgJobClasses['MoveJob'] = 'MoveJob'; |
462 | 469 | |
463 | | - /** |
464 | | - * Namespaces |
465 | | - */ |
466 | | - global $wgPageTranslationNamespace, $wgCanonicalNamespaceNames; |
| 470 | + // Namespaces |
| 471 | + global $wgPageTranslationNamespace, $wgExtraNamespaces; |
467 | 472 | global $wgNamespacesWithSubpages, $wgNamespaceProtection; |
468 | | - global $wgTranslateMessageNamespaces; |
| 473 | + global $wgTranslateMessageNamespaces, $wgVersion; |
469 | 474 | |
470 | | - /** |
471 | | - * Defines for nice usage |
472 | | - */ |
| 475 | + // Define constants for more readable core |
473 | 476 | define ( 'NS_TRANSLATIONS', $wgPageTranslationNamespace ); |
474 | 477 | define ( 'NS_TRANSLATIONS_TALK', $wgPageTranslationNamespace + 1 ); |
475 | 478 | |
476 | | - /** |
477 | | - * Register them as namespaces |
478 | | - */ |
479 | | - $wgCanonicalNamespaceNames[NS_TRANSLATIONS] = 'Translations'; |
480 | | - $wgCanonicalNamespaceNames[NS_TRANSLATIONS_TALK] = 'Translations_talk'; |
| 479 | + if ( version_compare( $wgVersion, '1.17alpha', '<' ) ) { |
| 480 | + efTranslateNamespaces( &$wgExtraNamespaces ); |
| 481 | + } |
| 482 | + |
481 | 483 | $wgNamespacesWithSubpages[NS_TRANSLATIONS] = true; |
482 | 484 | $wgNamespacesWithSubpages[NS_TRANSLATIONS_TALK] = true; |
483 | 485 | |