X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FNamespace.php;h=46af0029a2f4bee33e283b897aafb934dd6c0e06;hb=75ef257c2986ffc9ddab85800367932b7fdb1fa1;hp=2e2b8d618880702e964540b58d5740167b3cd8e7;hpb=938d6ec732ab8c38e223ddbf1cd8c695654fa007;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Namespace.php b/includes/Namespace.php index 2e2b8d6188..46af0029a2 100644 --- a/includes/Namespace.php +++ b/includes/Namespace.php @@ -48,6 +48,7 @@ class MWNamespace { * @param $index * @param $method * + * @throws MWException * @return bool */ private static function isMethodValidFor( $index, $method ) { @@ -209,12 +210,14 @@ class MWNamespace { * Returns array of all defined namespaces with their canonical * (English) names. * + * @param bool $rebuild rebuild namespace list (default = false). Used for testing. + * * @return array * @since 1.17 */ - public static function getCanonicalNamespaces() { + public static function getCanonicalNamespaces( $rebuild = false ) { static $namespaces = null; - if ( $namespaces === null ) { + if ( $namespaces === null || $rebuild ) { global $wgExtraNamespaces, $wgCanonicalNamespaceNames; $namespaces = array( NS_MAIN => '' ) + $wgCanonicalNamespaceNames; if ( is_array( $wgExtraNamespaces ) ) { @@ -416,4 +419,18 @@ class MWNamespace { return $wgNonincludableNamespaces && in_array( $index, $wgNonincludableNamespaces ); } + /** + * Get the default content model for a namespace + * This does not mean that all pages in that namespace have the model + * + * @since 1.21 + * @param $index int Index to check + * @return null|string default model name for the given namespace, if set + */ + public static function getNamespaceContentModel( $index ) { + global $wgNamespaceContentModels; + return isset( $wgNamespaceContentModels[$index] ) + ? $wgNamespaceContentModels[$index] + : null; + } }