From f11ab4263bf3646a8f08a221516ae7ae3660f511 Mon Sep 17 00:00:00 2001 From: Erik Moeller Date: Tue, 31 Aug 2004 10:23:55 +0000 Subject: [PATCH] Custom namespaces: To add a new namespace, just set $wgExtraNamespaces in LocalSettings.php. Custom namespaces must begin at 100. This is primarily intended to let us add a bunch of international versions of the "Help:" namespace on Meta, so we can finally have a single place for all documentation and easily dump/import it to other wikis. --- includes/DefaultSettings.php | 13 +++++++++++++ includes/Namespace.php | 10 +++++++++- languages/Language.php | 4 ++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 28656591d1..424d188464 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -549,6 +549,19 @@ $wgUseExternalDiffEngine = false; # Use RC Patrolling to check for vandalism $wgUseRCPatrol = true; +# Additional namespaces. If the namespaces defined in Language.php and Namespace.php are insufficient, +# you can create new ones here, for example, to import Help files in other languages. +# PLEASE NOTE: Once you delete a namespace, the pages in that namespace will no longer be accessible. +# If you rename it, then you can access them through the new namespace name. +# +# Custom namespaces should start at 100. +#$wgExtraNamespaces= +# array(100 => "Hilfe", +# 101 => "Hilfe_Diskussion", +# 102 =>"Aide", +# 103 =>"Discussion_Aide" +# ); + } else { die(); } diff --git a/includes/Namespace.php b/includes/Namespace.php index 5ae927b1ae..b02542da97 100644 --- a/includes/Namespace.php +++ b/includes/Namespace.php @@ -32,6 +32,10 @@ if( defined( 'MEDIAWIKI' ) ) { NS_CATEGORY_TALK => 'Category_talk' ); +if(isset($wgExtraNamespaces)) { + $wgCanonicalNamespaceNames=$wgCanonicalNamespaceNames+$wgExtraNamespaces; +} + class Namespace { /* These functions are deprecated */ @@ -52,10 +56,14 @@ class Namespace { function isTalk( $index ) { + global $wgExtraNamespaces; return ( $index == NS_TALK || $index == NS_USER_TALK || $index == NS_PROJECT_TALK || $index == NS_IMAGE_TALK || $index == NS_MEDIAWIKI_TALK || $index == NS_TEMPLATE_TALK || - $index == NS_HELP_TALK || $index == NS_CATEGORY_TALK ); + $index == NS_HELP_TALK || $index == NS_CATEGORY_TALK + || ( (isset($wgExtraNamespaces) && $index % 2) ) + ); + } # Get the talk namespace corresponding to the given index diff --git a/languages/Language.php b/languages/Language.php index 79eb1501f8..299a0173c2 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -46,6 +46,10 @@ if($wgMetaNamespace === FALSE) NS_CATEGORY_TALK => 'Category_talk' ); +if(isset($wgExtraNamespaces)) { + $wgNamespaceNamesEn=$wgNamespaceNamesEn+$wgExtraNamespaces; +} + /* private */ $wgDefaultUserOptionsEn = array( 'quickbar' => 1, 'underline' => 1, 'hover' => 1, 'cols' => 80, 'rows' => 25, 'searchlimit' => 20, -- 2.20.1