Nov. branch merge. Various features backported from stable, various bug fixes.
[lhc/web/wiklou.git] / includes / Namespace.php
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.
6
7 class Namespace {
8
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; }
14
15 function isMovable( $index )
16 {
17 if ( $index < 0 || $index > 5 ) { return false; }
18 return true;
19 }
20
21 function isTalk( $index )
22 {
23 if ( 1 == $index || 3 == $index || 5 == $index || 7 == $index ) {
24 return true;
25 }
26 return false;
27 }
28
29 # Get the talk namespace corresponding to the given index
30 #
31 function getTalk( $index )
32 {
33 if ( Namespace::isTalk( $index ) ) {
34 return $index;
35 } else {
36 return $index + 1;
37 }
38 }
39
40 function getSubject( $index )
41 {
42 if ( Namespace::isTalk( $index ) ) {
43 return $index - 1;
44 } else {
45 return $index;
46 }
47 }
48 }
49
50 ?>