1) section editing auto-summaries are now formatted as /* foo */
[lhc/web/wiklou.git] / includes / Namespace.php
1 <?php
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 # Virtual namespaces; these don't appear in the page database:
8 define("NS_MEDIA", -2);
9 define("NS_SPECIAL", -1);
10
11 # Real namespaces:
12 define("NS_MAIN", 0);
13 define("NS_TALK", 1);
14 define("NS_USER", 2);
15 define("NS_USER_TALK", 3);
16 define("NS_WP", 4);
17 define("NS_WIKIPEDIA", 4);
18 define("NS_WP_TALK", 5);
19 define("NS_WIKIPEDIA_TALK", 5);
20 define("NS_IMAGE", 6);
21 define("NS_IMAGE_TALK", 7);
22 define("NS_MEDIAWIKI", 8);
23 define("NS_MEDIAWIKI_TALK", 9);
24 define("NS_TEMPLATE", 10);
25 define("NS_TEMPLATE_TALK", 11);
26 define("NS_HELP", 12);
27 define("NS_HELP_TALK", 13);
28
29 class Namespace {
30
31 /* These functions are deprecated */
32 function getSpecial() { return NS_SPECIAL; }
33 function getUser() { return NS_USER; }
34 function getWikipedia() { return NS_WP; }
35 function getImage() { return NS_IMAGE; }
36 function getMedia() { return NS_MEDIA; }
37
38 function isMovable( $index )
39 {
40 if ( $index < NS_MAIN || $index == NS_IMAGE ) {
41 return false;
42 }
43 return true;
44 }
45
46 function isTalk( $index )
47 {
48 if ( NS_TALK == $index || NS_USER_TALK == $index || NS_WP_TALK == $index || NS_IMAGE_TALK == $index || NS_MEDIAWIKI_TALK == $index || NS_TEMPLATE_TALK == $index || NS_HELP_TALK == $index ) {
49 return true;
50 }
51 return false;
52 }
53
54 # Get the talk namespace corresponding to the given index
55 #
56 function getTalk( $index )
57 {
58 if ( Namespace::isTalk( $index ) ) {
59 return $index;
60 } else {
61 # FIXME
62 return $index + 1;
63 }
64 }
65
66 function getSubject( $index )
67 {
68 if ( Namespace::isTalk( $index ) ) {
69 return $index - 1;
70 } else {
71 return $index;
72 }
73 }
74 }
75
76 ?>