2003-04-14 23:10:40 +00:00
|
|
|
<?
|
|
|
|
|
# This is a utility class with only static functions
|
|
|
|
|
# for dealing with namespaces that encodes all the
|
|
|
|
|
# "magic" behaviors of them based on index. The textual
|
|
|
|
|
# names of the namespaces are handled by Language.php.
|
|
|
|
|
|
2003-11-15 12:53:17 +00:00
|
|
|
# Virtual namespaces; these don't appear in the page database:
|
|
|
|
|
define("NS_MEDIA", -2);
|
|
|
|
|
define("NS_SPECIAL", -1);
|
|
|
|
|
|
|
|
|
|
# Real namespaces:
|
|
|
|
|
define("NS_MAIN", 0);
|
|
|
|
|
define("NS_TALK", 1);
|
|
|
|
|
define("NS_USER", 2);
|
|
|
|
|
define("NS_USER_TALK", 3);
|
|
|
|
|
define("NS_WP", 4);
|
|
|
|
|
define("NS_WP_TALK", 5);
|
|
|
|
|
define("NS_IMAGE", 6);
|
|
|
|
|
define("NS_IMAGE_TALK", 7);
|
|
|
|
|
define("NS_MEDIAWIKI", 8);
|
|
|
|
|
define("NS_MEDIAWIKI_TALK", 9);
|
|
|
|
|
|
2003-04-14 23:10:40 +00:00
|
|
|
class Namespace {
|
|
|
|
|
|
2003-11-15 12:53:17 +00:00
|
|
|
/* These functions are deprecated */
|
|
|
|
|
function getSpecial() { return NS_SPECIAL; }
|
|
|
|
|
function getUser() { return NS_USER; }
|
|
|
|
|
function getWikipedia() { return NS_WP; }
|
|
|
|
|
function getImage() { return NS_IMAGE; }
|
|
|
|
|
function getMedia() { return NS_MEDIA; }
|
2003-04-14 23:10:40 +00:00
|
|
|
|
|
|
|
|
function isMovable( $index )
|
|
|
|
|
{
|
2003-12-14 14:29:35 +00:00
|
|
|
if ( $index < NS_MAIN || $index == NS_IMAGE ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2003-04-14 23:10:40 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function isTalk( $index )
|
|
|
|
|
{
|
2003-11-15 12:53:17 +00:00
|
|
|
if ( NS_TALK == $index || NS_USER_TALK == $index || NS_WP_TALK == $index || NS_IMAGE_TALK == $index || NS_MEDIAWIKI_TALK == $index ) {
|
2003-04-14 23:10:40 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Get the talk namespace corresponding to the given index
|
|
|
|
|
#
|
|
|
|
|
function getTalk( $index )
|
|
|
|
|
{
|
|
|
|
|
if ( Namespace::isTalk( $index ) ) {
|
|
|
|
|
return $index;
|
|
|
|
|
} else {
|
2003-11-15 12:53:17 +00:00
|
|
|
# FIXME
|
2003-04-14 23:10:40 +00:00
|
|
|
return $index + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getSubject( $index )
|
|
|
|
|
{
|
|
|
|
|
if ( Namespace::isTalk( $index ) ) {
|
|
|
|
|
return $index - 1;
|
|
|
|
|
} else {
|
|
|
|
|
return $index;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|