abstract class ContentHandler {
public static function getContentText( Content $content = null ) {
+ global $wgContentHandlerTextFallback;
+
if ( !$content ) return '';
if ( $content instanceof TextContent ) {
- #XXX: or check by model name?
- #XXX: or define $content->allowRawData()?
- #XXX: or define $content->getDefaultWikiText()?
return $content->getNativeData();
}
- #XXX: this must not be used for editing, otherwise we may loose data:
- #XXX: e.g. if this returns the "main" text from a multipart page, all attachments would be lost
+ if ( $wgContentHandlerTextFallback == 'fail' ) throw new MWException( "Attempt to get text from Content with model " . $content->getModelName() );
+ if ( $wgContentHandlerTextFallback == 'serialize' ) return $content->serialize();
- #TODO: log this incident!
return null;
}
$wgDBtestuser = ''; //db user that has permission to create and drop the test databases only
$wgDBtestpassword = '';
+/**
+ * Associative array mapping namespace IDs to the name of the content model pages in that namespace should have by
+ * default (use the CONTENT_MODEL_XXX constants). If no special content type is defined for a given namespace,
+ * pages in that namespace will use the CONTENT_MODEL_WIKITEXT (except for the special case of JS and CS pages).
+ */
+$wgNamespaceContentModels = array();
+
+/**
+ * How to react if a plain text version of a non-text Content object is requested using ContentHandler::getContentText():
+ *
+ * * 'ignore': return null
+ * * 'fail': throw an MWException
+ * * 'serialize': serialize to default format
+ */
+$wgContentHandlerTextFallback = 'ignore';
+
/**
* For really cool vim folding this needs to be at the end:
* vim: foldmarker=@{,@} foldmethod=marker