r24764 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24763‎ | r24764 | r24765 >
Date:01:14, 14 August 2007
Author:robchurch
Status:old
Tags:
Comment:
Document all methods and mark them public
Modified paths:
  • /trunk/phase3/includes/Namespace.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Namespace.php
@@ -44,54 +44,67 @@
4545 class Namespace {
4646
4747 /**
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
4951 * @return bool
5052 */
51 - static function isMovable( $index ) {
 53+ public static function isMovable( $index ) {
5254 return !( $index < NS_MAIN || $index == NS_IMAGE || $index == NS_CATEGORY );
5355 }
5456
5557 /**
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
5761 * @return bool
5862 */
59 - static function isMain( $index ) {
60 - return ! Namespace::isTalk( $index );
 63+ public static function isMain( $index ) {
 64+ return !self::isTalk( $index );
6165 }
6266
6367 /**
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
6571 * @return bool
6672 */
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;
7076 }
7177
7278 /**
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
7483 */
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;
8288 }
8389
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;
90100 }
91101
92102 /**
93103 * Returns the canonical (English Wikipedia) name for a given index
 104+ *
 105+ * @param int $index Namespace index
 106+ * @return string
94107 */
95 - static function getCanonicalName( $index ) {
 108+ public static function getCanonicalName( $index ) {
96109 global $wgCanonicalNamespaceNames;
97110 return $wgCanonicalNamespaceNames[$index];
98111 }
@@ -99,8 +112,11 @@
100113 /**
101114 * Returns the index for a given canonical name, or NULL
102115 * The input *must* be converted to lower case first
 116+ *
 117+ * @param string $name Namespace name
 118+ * @return int
103119 */
104 - static function getCanonicalIndex( $name ) {
 120+ public static function getCanonicalIndex( $name ) {
105121 global $wgCanonicalNamespaceNames;
106122 static $xNamespaces = false;
107123 if ( $xNamespaces === false ) {
@@ -118,10 +134,12 @@
119135
120136 /**
121137 * Can this namespace ever have a talk namespace?
 138+ *
122139 * @param $index Namespace index
 140+ * @return bool
123141 */
124 - static function canTalk( $index ) {
125 - return( $index >= NS_MAIN );
 142+ public static function canTalk( $index ) {
 143+ return $index >= NS_MAIN;
126144 }
127145
128146 /**
@@ -146,6 +164,4 @@
147165 return $index >= NS_MAIN;
148166 }
149167
150 -}
151 -
152 -
 168+}
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r24866Merged revisions 24755-24865 via svnmerge from...david23:08, 16 August 2007

Status & tagging log