X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FMWNamespace.php;h=e03a29b80f08f68dbf59ec10f7f7c6411cfefd98;hb=c4a923d1340029cd8f6d13d4e065f3feaac84e8e;hp=bfbd557923e6681bc6e4ec360bbbf0b155cd2e96;hpb=998b8afae92ed9621eaad184e6c05c0e18859342;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/MWNamespace.php b/includes/MWNamespace.php index bfbd557923..e03a29b80f 100644 --- a/includes/MWNamespace.php +++ b/includes/MWNamespace.php @@ -254,11 +254,7 @@ class MWNamespace { */ public static function getCanonicalName( $index ) { $nslist = self::getCanonicalNamespaces(); - if ( isset( $nslist[$index] ) ) { - return $nslist[$index]; - } else { - return false; - } + return $nslist[$index] ?? false; } /** @@ -481,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 ) { @@ -544,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'; + } + } }