Display JSON configuration options in NS_MEDIAWIKI as JSON

Change-Id: Ie033b8bd42beda769dd499a9d02d488bfffb0fa0
This commit is contained in:
Kunal Mehta 2014-10-06 12:02:55 -07:00
parent 70fe9aac4d
commit 0121c68b50
2 changed files with 23 additions and 0 deletions

View file

@ -35,6 +35,28 @@ class VisualEditorHooks {
return true;
}
/**
* Convert the content model of messages that are actually JSON to JSON.
* This only affects validation and UI when saving and editing, not
* loading the content.
*
* @param Title $title
* @param string $model
* @return bool
*/
public static function onContentHandlerDefaultModelFor( Title $title, &$model ) {
$messages = array(
'Visualeditor-cite-tool-definition.json',
'Visualeditor-specialcharinspector-characterlist-insert'
);
if ( $title->inNamespace( NS_MEDIAWIKI ) && in_array( $title->getText(), $messages ) ) {
$model = CONTENT_MODEL_JSON;
}
return true;
}
/**
* Changes the Edit tab and adds the VisualEditor tab.
*

View file

@ -74,6 +74,7 @@ $wgConfigRegistry['visualeditor'] = 'GlobalVarConfig::newInstance';
// Register Hooks
$wgHooks['BeforePageDisplay'][] = 'VisualEditorHooks::onBeforePageDisplay';
$wgHooks['ContentHandlerDefaultModelFor'][] = 'VisualEditorHooks::onContentHandlerDefaultModelFor';
$wgHooks['DoEditSectionLink'][] = 'VisualEditorHooks::onDoEditSectionLink';
$wgHooks['GetBetaFeaturePreferences'][] = 'VisualEditorHooks::onGetBetaPreferences';
$wgHooks['GetPreferences'][] = 'VisualEditorHooks::onGetPreferences';