03b351f9b17fab3c214791028dada0e05b98bfd2
[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
14 function isMovable( $index )
15 {
16 if ( $index < 0 || $index > 5 ) { return false; }
17 return true;
18 }
19
20 function isTalk( $index )
21 {
22 if ( 1 == $index || 3 == $index || 5 == $index || 7 == $index ) {
23 return true;
24 }
25 return false;
26 }
27
28 # Get the talk namespace corresponding to the given index
29 #
30 function getTalk( $index )
31 {
32 if ( Namespace::isTalk( $index ) ) {
33 return $index;
34 } else {
35 return $index + 1;
36 }
37 }
38
39 function getSubject( $index )
40 {
41 if ( Namespace::isTalk( $index ) ) {
42 return $index - 1;
43 } else {
44 return $index;
45 }
46 }
47 }
48
49 ?>