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