Merging latest features from stable
[mediawiki.git] / includes / Namespace.php
blob670f880d7975b82d869783b2b357647b7ce68a49
1 <?
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 class Namespace {
9 function getSpecial() { return -1; }
10 function getUser() { return 2; }
11 function getWikipedia() { return 4; }
12 function getImage() { return 6; }
13 function getMedia() { return -2; }
15 function isMovable( $index )
17 if ( $index < 0 || $index > 5 ) { return false; }
18 return true;
21 function isTalk( $index )
23 if ( 1 == $index || 3 == $index || 5 == $index || 7 == $index ) {
24 return true;
26 return false;
29 # Get the talk namespace corresponding to the given index
31 function getTalk( $index )
33 if ( Namespace::isTalk( $index ) ) {
34 return $index;
35 } else {
36 return $index + 1;
40 function getSubject( $index )
42 if ( Namespace::isTalk( $index ) ) {
43 return $index - 1;
44 } else {
45 return $index;