Merge "misc style fix"
[lhc/web/wiklou.git] / includes / Namespace.php
index 2e2b8d6..46af002 100644 (file)
@@ -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;
+       }
 }