Merge "pass codesniffer on tests/"
[lhc/web/wiklou.git] / includes / Namespace.php
index 7eba2fe..46af002 100644 (file)
@@ -48,6 +48,7 @@ class MWNamespace {
         * @param $index
         * @param $method
         *
+        * @throws MWException
         * @return bool
         */
        private static function isMethodValidFor( $index, $method ) {
@@ -65,7 +66,15 @@ class MWNamespace {
         */
        public static function isMovable( $index ) {
                global $wgAllowImageMoving;
-               return !( $index < NS_MAIN || ( $index == NS_FILE && !$wgAllowImageMoving )  || $index == NS_CATEGORY );
+
+               $result = !( $index < NS_MAIN || ( $index == NS_FILE && !$wgAllowImageMoving )  || $index == NS_CATEGORY );
+
+               /**
+                * @since 1.20
+                */
+               wfRunHooks( 'NamespaceIsMovable', array( $index, &$result ) );
+
+               return $result;
        }
 
        /**
@@ -333,6 +342,33 @@ class MWNamespace {
                        return $wgContentNamespaces;
                }
        }
+
+       /**
+        * List all namespace indices which are considered subject, aka not a talk
+        * or special namespace. See also MWNamespace::isSubject
+        *
+        * @return array of namespace indices
+        */
+       public static function getSubjectNamespaces() {
+               return array_filter(
+                       MWNamespace::getValidNamespaces(),
+                       'MWNamespace::isSubject'
+               );
+       }
+
+       /**
+        * List all namespace indices which are considered talks, aka not a subject
+        * or special namespace. See also MWNamespace::isTalk
+        *
+        * @return array of namespace indices
+        */
+       public static function getTalkNamespaces() {
+               return array_filter(
+                       MWNamespace::getValidNamespaces(),
+                       'MWNamespace::isTalk'
+               );
+       }
+
        /**
         * Is the namespace first-letter capitalized?
         *
@@ -383,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;
+       }
 }