Squid branch merge. Calls to purge functions in Article.php and special pages.
[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 # 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_WP_TALK", 5);
18 define("NS_IMAGE", 6);
19 define("NS_IMAGE_TALK", 7);
20 define("NS_MEDIAWIKI", 8);
21 define("NS_MEDIAWIKI_TALK", 9);
22
23 class Namespace {
24
25 /* These functions are deprecated */
26 function getSpecial() { return NS_SPECIAL; }
27 function getUser() { return NS_USER; }
28 function getWikipedia() { return NS_WP; }
29 function getImage() { return NS_IMAGE; }
30 function getMedia() { return NS_MEDIA; }
31
32 function isMovable( $index )
33 {
34 if ( $index < NS_MAIN || $index == NS_IMAGE ) {
35 return false;
36 }
37 return true;
38 }
39
40 function isTalk( $index )
41 {
42 if ( NS_TALK == $index || NS_USER_TALK == $index || NS_WP_TALK == $index || NS_IMAGE_TALK == $index || NS_MEDIAWIKI_TALK == $index ) {
43 return true;
44 }
45 return false;
46 }
47
48 # Get the talk namespace corresponding to the given index
49 #
50 function getTalk( $index )
51 {
52 if ( Namespace::isTalk( $index ) ) {
53 return $index;
54 } else {
55 # FIXME
56 return $index + 1;
57 }
58 }
59
60 function getSubject( $index )
61 {
62 if ( Namespace::isTalk( $index ) ) {
63 return $index - 1;
64 } else {
65 return $index;
66 }
67 }
68 }
69
70 ?>