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_PROJECT
=> 'Project',
22 NS_PROJECT_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'
35 if(isset($wgExtraNamespaces)) {
36 $wgCanonicalNamespaceNames=$wgCanonicalNamespaceNames+
$wgExtraNamespaces;
41 /* These functions are deprecated */
42 function getSpecial() { return NS_SPECIAL
; }
43 function getUser() { return NS_USER
; }
44 function getWikipedia() { return NS_PROJECT
; }
45 function getImage() { return NS_IMAGE
; }
46 function getMedia() { return NS_MEDIA
; }
47 function getCategory() { return NS_CATEGORY
; }
49 function isMovable( $index )
51 if ( $index < NS_MAIN ||
$index == NS_IMAGE ||
$index == NS_CATEGORY
) {
57 function isTalk( $index )
59 global $wgExtraNamespaces;
60 return ( $index == NS_TALK ||
$index == NS_USER_TALK ||
61 $index == NS_PROJECT_TALK ||
$index == NS_IMAGE_TALK ||
62 $index == NS_MEDIAWIKI_TALK ||
$index == NS_TEMPLATE_TALK ||
63 $index == NS_HELP_TALK ||
$index == NS_CATEGORY_TALK
64 ||
( (isset($wgExtraNamespaces) && $index %
2) )
69 # Get the talk namespace corresponding to the given index
71 function getTalk( $index )
73 if ( Namespace::isTalk( $index ) ) {
81 function getSubject( $index )
83 if ( Namespace::isTalk( $index ) ) {
90 # Returns the canonical (English Wikipedia) name for a given index
91 function &getCanonicalName( $index )
93 global $wgCanonicalNamespaceNames;
94 return $wgCanonicalNamespaceNames[$index];
97 # Returns the index for a given canonical name, or NULL
98 # The input *must* be converted to lower case first
99 function &getCanonicalIndex( $name )
101 global $wgCanonicalNamespaceNames;
102 static $xNamespaces = false;
103 if ( $xNamespaces === false ) {
104 $xNamespaces = array();
105 foreach ( $wgCanonicalNamespaceNames as $i => $text ) {
106 $xNamespaces[strtolower($text)] = $i;
109 if ( array_key_exists( $name, $xNamespaces ) ) {
110 return $xNamespaces[$name];