2 if( defined( "MEDIAWIKI" ) ) {
4 # This is a utility class with only static functions
5 # for dealing with namespaces that encodes all the
6 # "magic" behaviors of them based on index. The textual
7 # names of the namespaces are handled by Language.php.
9 # Definitions of the NS_ constants are in Defines.php
11 # These are synonyms for the names given in the language file
12 # Users and translators should not change them
13 /* private */ $wgCanonicalNamespaceNames = array(
15 NS_SPECIAL
=> "Special",
18 NS_USER_TALK
=> "User_talk",
19 NS_WIKIPEDIA
=> "Project",
20 NS_WIKIPEDIA_TALK
=> "Project_talk",
22 NS_IMAGE_TALK
=> "Image_talk",
23 NS_MEDIAWIKI
=> "MediaWiki",
24 NS_MEDIAWIKI_TALK
=> "MediaWiki_talk",
25 NS_TEMPLATE
=> "Template",
26 NS_TEMPLATE_TALK
=> "Template_talk",
28 NS_HELP_TALK
=> "Help_talk",
29 NS_CATEGORY
=> "Category",
30 NS_CATEGORY_TALK
=> "Category_talk"
35 /* These functions are deprecated */
36 function getSpecial() { return NS_SPECIAL
; }
37 function getUser() { return NS_USER
; }
38 function getWikipedia() { return NS_WP
; }
39 function getImage() { return NS_IMAGE
; }
40 function getMedia() { return NS_MEDIA
; }
41 function getCategory() { return NS_CATEGORY
; }
43 function isMovable( $index )
45 if ( $index < NS_MAIN ||
$index == NS_IMAGE ||
$index == NS_CATEGORY
) {
51 function isTalk( $index )
53 if ( NS_TALK
== $index || NS_USER_TALK
== $index || NS_WP_TALK
54 == $index || NS_IMAGE_TALK
== $index || NS_MEDIAWIKI_TALK
== $index ||
55 NS_TEMPLATE_TALK
== $index || NS_HELP_TALK
== $index ||
56 NS_CATEGORY_TALK
== $index ) {
62 # Get the talk namespace corresponding to the given index
64 function getTalk( $index )
66 if ( Namespace::isTalk( $index ) ) {
74 function getSubject( $index )
76 if ( Namespace::isTalk( $index ) ) {
83 # Returns the canonical (English Wikipedia) name for a given index
84 function &getCanonicalName( $index )
86 global $wgCanonicalNamespaceNames;
87 return $wgCanonicalNamespaceNames[$index];
90 # Returns the index for a given canonical name, or NULL
91 # The input *must* be converted to lower case first
92 function &getCanonicalIndex( $name )
94 global $wgCanonicalNamespaceNames;
95 static $xNamespaces = false;
96 if ( $xNamespaces === false ) {
97 $xNamespaces = array();
98 foreach ( $wgCanonicalNamespaceNames as $i => $text ) {
99 $xNamespaces[strtolower($text)] = $i;
102 if ( array_key_exists( $name, $xNamespaces ) ) {
103 return $xNamespaces[$name];