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;
+ }
}
if ( MWNamespace::isNonincludable( $ns ) ) {
$data[$ns]['nonincludable'] = '';
}
+
+ $contentmodel = MWNamespace::getNamespaceContentModel( $ns );
+ if ( $contentmodel ) {
+ $data[$ns]['defaultcontentmodel'] = $contentmodel;
+ }
}
$this->getResult()->setIndexedTagName( $data, 'ns' );
* @return null|string default model name for the page given by $title
*/
public static function getDefaultModelFor( Title $title ) {
- global $wgNamespaceContentModels;
-
// NOTE: this method must not rely on $title->getContentModel() directly or indirectly,
// because it is used to initialize the mContentModel member.
$ext = false;
$m = null;
- $model = null;
-
- if ( !empty( $wgNamespaceContentModels[ $ns ] ) ) {
- $model = $wgNamespaceContentModels[ $ns ];
- }
+ $model = MWNamespace::getNamespaceContentModel( $ns );
// Hook can determine default model
if ( !wfRunHooks( 'ContentHandlerDefaultModelFor', array( $title, &$model ) ) ) {