Merge "Add constant for the name of the 'main' slot for MCR"
[lhc/web/wiklou.git] / includes / MWNamespace.php
index 73fdd82..e03a29b 100644 (file)
@@ -477,7 +477,7 @@ class MWNamespace {
         *
         * @since 1.23
         * @param int $index Index to check
-        * @param User $user User to check
+        * @param User|null $user User to check
         * @return array
         */
        public static function getRestrictionLevels( $index, User $user = null ) {
@@ -540,4 +540,26 @@ class MWNamespace {
 
                return $usableLevels;
        }
+
+       /**
+        * Returns the link type to be used for categories.
+        *
+        * This determines which section of a category page titles
+        * in the namespace will appear within.
+        *
+        * @since 1.32
+        * @param int $index Namespace index
+        * @return string One of 'subcat', 'file', 'page'
+        */
+       public static function getCategoryLinkType( $index ) {
+               self::isMethodValidFor( $index, __METHOD__ );
+
+               if ( $index == NS_CATEGORY ) {
+                       return 'subcat';
+               } elseif ( $index == NS_FILE ) {
+                       return 'file';
+               } else {
+                       return 'page';
+               }
+       }
 }