3 # This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
4 if( defined( "MEDIAWIKI" ) ) {
6 # This is a utility class with only static functions
7 # for dealing with namespaces that encodes all the
8 # "magic" behaviors of them based on index. The textual
9 # names of the namespaces are handled by Language.php.
11 # Definitions of the NS_ constants are in Defines.php
13 # These are synonyms for the names given in the language file
14 # Users and translators should not change them
15 /* private */ $wgCanonicalNamespaceNames = array(
17 NS_SPECIAL
=> "Special",
20 NS_USER_TALK
=> "User_talk",
21 NS_WIKIPEDIA
=> "Project",
22 NS_WIKIPEDIA_TALK
=> "Project_talk",
24 NS_IMAGE_TALK
=> "Image_talk",
25 NS_MEDIAWIKI
=> "MediaWiki",
26 NS_MEDIAWIKI_TALK
=> "MediaWiki_talk",
27 NS_TEMPLATE
=> "Template",
28 NS_TEMPLATE_TALK
=> "Template_talk",
30 NS_HELP_TALK
=> "Help_talk",
31 NS_CATEGORY
=> "Category",
32 NS_CATEGORY_TALK
=> "Category_talk"
37 /* These functions are deprecated */
38 function getSpecial() { return NS_SPECIAL
; }
39 function getUser() { return NS_USER
; }
40 function getWikipedia() { return NS_WP
; }
41 function getImage() { return NS_IMAGE
; }
42 function getMedia() { return NS_MEDIA
; }
43 function getCategory() { return NS_CATEGORY
; }
45 function isMovable( $index )
47 if ( $index < NS_MAIN ||
$index == NS_IMAGE ||
$index == NS_CATEGORY
) {
53 function isTalk( $index )
55 if ( NS_TALK
== $index || NS_USER_TALK
== $index || NS_WP_TALK
56 == $index || NS_IMAGE_TALK
== $index || NS_MEDIAWIKI_TALK
== $index ||
57 NS_TEMPLATE_TALK
== $index || NS_HELP_TALK
== $index ||
58 NS_CATEGORY_TALK
== $index ) {
64 # Get the talk namespace corresponding to the given index
66 function getTalk( $index )
68 if ( Namespace::isTalk( $index ) ) {
76 function getSubject( $index )
78 if ( Namespace::isTalk( $index ) ) {
85 # Returns the canonical (English Wikipedia) name for a given index
86 function &getCanonicalName( $index )
88 global $wgCanonicalNamespaceNames;
89 return $wgCanonicalNamespaceNames[$index];
92 # Returns the index for a given canonical name, or NULL
93 # The input *must* be converted to lower case first
94 function &getCanonicalIndex( $name )
96 global $wgCanonicalNamespaceNames;
97 static $xNamespaces = false;
98 if ( $xNamespaces === false ) {
99 $xNamespaces = array();
100 foreach ( $wgCanonicalNamespaceNames as $i => $text ) {
101 $xNamespaces[strtolower($text)] = $i;
104 if ( array_key_exists( $name, $xNamespaces ) ) {
105 return $xNamespaces[$name];