-<?
-# This is a utility class with only static functions
-# for dealing with namespaces that encodes all the
-# "magic" behaviors of them based on index. The textual
-# names of the namespaces are handled by Language.php.
-
-class Namespace {
-
- function getSpecial() { return -1; }
- function getUser() { return 2; }
- function getWikipedia() { return 4; }
- function getImage() { return 6; }
- function getMedia() { return -2; }
-
- function isMovable( $index )
- {
- if ( $index < 0 || $index > 5 ) { return false; }
- return true;
- }
-
- function isTalk( $index )
- {
- if ( 1 == $index || 3 == $index || 5 == $index || 7 == $index ) {
- return true;
- }
- return false;
+<?php
+/**
+ * Provide things related to namespaces
+ * @file
+ */
+
+/**
+ * Definitions of the NS_ constants are in Defines.php
+ * @private
+ */
+$wgCanonicalNamespaceNames = array(
+ NS_MEDIA => 'Media',
+ NS_SPECIAL => 'Special',
+ NS_TALK => 'Talk',
+ NS_USER => 'User',
+ NS_USER_TALK => 'User_talk',
+ NS_PROJECT => 'Project',
+ NS_PROJECT_TALK => 'Project_talk',
+ NS_IMAGE => 'Image',
+ NS_IMAGE_TALK => 'Image_talk',
+ NS_MEDIAWIKI => 'MediaWiki',
+ NS_MEDIAWIKI_TALK => 'MediaWiki_talk',
+ NS_TEMPLATE => 'Template',
+ NS_TEMPLATE_TALK => 'Template_talk',
+ NS_HELP => 'Help',
+ NS_HELP_TALK => 'Help_talk',
+ NS_CATEGORY => 'Category',
+ NS_CATEGORY_TALK => 'Category_talk',
+);
+
+if( is_array( $wgExtraNamespaces ) ) {
+ $wgCanonicalNamespaceNames = $wgCanonicalNamespaceNames + $wgExtraNamespaces;
+}
+
+/**
+ * This is a utility class with only static functions
+ * for dealing with namespaces that encodes all the
+ * "magic" behaviors of them based on index. The textual
+ * names of the namespaces are handled by Language.php.
+ *
+ * These are synonyms for the names given in the language file
+ * Users and translators should not change them
+ *
+ */
+
+class MWNamespace {
+
+ /**
+ * Can pages in the given namespace be moved?
+ *
+ * @param $index Int: namespace index
+ * @return bool
+ */
+ public static function isMovable( $index ) {
+ global $wgAllowImageMoving;
+ return !( $index < NS_MAIN || ($index == NS_IMAGE && !$wgAllowImageMoving) || $index == NS_CATEGORY );