Index: trunk/phase3/includes/Namespace.php |
— | — | @@ -44,54 +44,67 @@ |
45 | 45 | class Namespace { |
46 | 46 | |
47 | 47 | /** |
48 | | - * Check if the given namespace might be moved |
| 48 | + * Can pages in the given namespace be moved? |
| 49 | + * |
| 50 | + * @param int $index Namespace index |
49 | 51 | * @return bool |
50 | 52 | */ |
51 | | - static function isMovable( $index ) { |
| 53 | + public static function isMovable( $index ) { |
52 | 54 | return !( $index < NS_MAIN || $index == NS_IMAGE || $index == NS_CATEGORY ); |
53 | 55 | } |
54 | 56 | |
55 | 57 | /** |
56 | | - * Check if the given namespace is not a talk page |
| 58 | + * Is the given namespace is a subject (non-talk) namespace? |
| 59 | + * |
| 60 | + * @param int $index Namespace index |
57 | 61 | * @return bool |
58 | 62 | */ |
59 | | - static function isMain( $index ) { |
60 | | - return ! Namespace::isTalk( $index ); |
| 63 | + public static function isMain( $index ) { |
| 64 | + return !self::isTalk( $index ); |
61 | 65 | } |
62 | 66 | |
63 | 67 | /** |
64 | | - * Check if the give namespace is a talk page |
| 68 | + * Is the given namespace a talk namespace? |
| 69 | + * |
| 70 | + * @param int $index Namespace index |
65 | 71 | * @return bool |
66 | 72 | */ |
67 | | - static function isTalk( $index ) { |
68 | | - return ($index > NS_MAIN) // Special namespaces are negative |
69 | | - && ($index % 2); // Talk namespaces are odd-numbered |
| 73 | + public static function isTalk( $index ) { |
| 74 | + return $index > NS_MAIN |
| 75 | + && $index % 2; |
70 | 76 | } |
71 | 77 | |
72 | 78 | /** |
73 | | - * Get the talk namespace corresponding to the given index |
| 79 | + * Get the talk namespace index for a given namespace |
| 80 | + * |
| 81 | + * @param int $index Namespace index |
| 82 | + * @return int |
74 | 83 | */ |
75 | | - static function getTalk( $index ) { |
76 | | - if ( Namespace::isTalk( $index ) ) { |
77 | | - return $index; |
78 | | - } else { |
79 | | - # FIXME |
80 | | - return $index + 1; |
81 | | - } |
| 84 | + public static function getTalk( $index ) { |
| 85 | + return self::isTalk( $index ) |
| 86 | + ? $index |
| 87 | + : $index + 1; |
82 | 88 | } |
83 | 89 | |
84 | | - static function getSubject( $index ) { |
85 | | - if ( Namespace::isTalk( $index ) ) { |
86 | | - return $index - 1; |
87 | | - } else { |
88 | | - return $index; |
89 | | - } |
| 90 | + /** |
| 91 | + * Get the subject namespace index for a given namespace |
| 92 | + * |
| 93 | + * @param int $index Namespace index |
| 94 | + * @return int |
| 95 | + */ |
| 96 | + public static function getSubject( $index ) { |
| 97 | + return self::isTalk( $index ) |
| 98 | + ? $index - 1 |
| 99 | + : $index; |
90 | 100 | } |
91 | 101 | |
92 | 102 | /** |
93 | 103 | * Returns the canonical (English Wikipedia) name for a given index |
| 104 | + * |
| 105 | + * @param int $index Namespace index |
| 106 | + * @return string |
94 | 107 | */ |
95 | | - static function getCanonicalName( $index ) { |
| 108 | + public static function getCanonicalName( $index ) { |
96 | 109 | global $wgCanonicalNamespaceNames; |
97 | 110 | return $wgCanonicalNamespaceNames[$index]; |
98 | 111 | } |
— | — | @@ -99,8 +112,11 @@ |
100 | 113 | /** |
101 | 114 | * Returns the index for a given canonical name, or NULL |
102 | 115 | * The input *must* be converted to lower case first |
| 116 | + * |
| 117 | + * @param string $name Namespace name |
| 118 | + * @return int |
103 | 119 | */ |
104 | | - static function getCanonicalIndex( $name ) { |
| 120 | + public static function getCanonicalIndex( $name ) { |
105 | 121 | global $wgCanonicalNamespaceNames; |
106 | 122 | static $xNamespaces = false; |
107 | 123 | if ( $xNamespaces === false ) { |
— | — | @@ -118,10 +134,12 @@ |
119 | 135 | |
120 | 136 | /** |
121 | 137 | * Can this namespace ever have a talk namespace? |
| 138 | + * |
122 | 139 | * @param $index Namespace index |
| 140 | + * @return bool |
123 | 141 | */ |
124 | | - static function canTalk( $index ) { |
125 | | - return( $index >= NS_MAIN ); |
| 142 | + public static function canTalk( $index ) { |
| 143 | + return $index >= NS_MAIN; |
126 | 144 | } |
127 | 145 | |
128 | 146 | /** |
— | — | @@ -146,6 +164,4 @@ |
147 | 165 | return $index >= NS_MAIN; |
148 | 166 | } |
149 | 167 | |
150 | | -} |
151 | | - |
152 | | - |
| 168 | +} |
\ No newline at end of file |