Move config vars that are global in nature to the startup module

If they're in the per-page config, we'll have to deal with caching
nightmares when changing them.

Change-Id: Ic8866500b1f20aee36c436dcc3d132c8fde0a8fc
This commit is contained in:
Catrope 2013-04-17 09:48:09 -07:00
parent fd23c9522f
commit f3b03a64f6
4 changed files with 16 additions and 5 deletions

View file

@ -59,10 +59,20 @@ class VisualEditorHooks {
* Adds extra variables to the page config.
*/
public static function onMakeGlobalVariablesScript( array &$vars, OutputPage $out ) {
global $wgVisualEditorEnableSectionEditLinks, $wgVisualEditorParsoidProblemReportURL,
$wgVisualEditorParsoidURL, $wgVisualEditorEnableExperimentalCode;
$vars['wgVisualEditor'] = array(
'isPageWatched' => $out->getUser()->isWatched( $out->getTitle() ),
);
return true;
}
/**
* Adds extra variables to the global config
*/
public static function onResourceLoaderGetConfigVars( array &$vars ) {
global $wgVisualEditorEnableSectionEditLinks, $wgVisualEditorParsoidProblemReportURL,
$wgVisualEditorParsoidURL, $wgVisualEditorEnableExperimentalCode;
$vars['wgVisualEditorConfig'] = array(
'enableSectionEditLinks' => $wgVisualEditorEnableSectionEditLinks,
'reportProblemURL' => $wgVisualEditorParsoidProblemReportURL !== null ?
$wgVisualEditorParsoidProblemReportURL :

View file

@ -513,6 +513,7 @@ $wgHooks['BeforePageDisplay'][] = 'VisualEditorHooks::onBeforePageDisplay';
$wgHooks['GetPreferences'][] = 'VisualEditorHooks::onGetPreferences';
$wgHooks['ListDefinedTags'][] = 'VisualEditorHooks::onListDefinedTags';
$wgHooks['MakeGlobalVariablesScript'][] = 'VisualEditorHooks::onMakeGlobalVariablesScript';
$wgHooks['ResourceLoaderGetConfigVars'][] = 'VisualEditorHooks::onResourceLoaderGetConfigVars';
$wgHooks['ResourceLoaderTestModules'][] = 'VisualEditorHooks::onResourceLoaderTestModules';
$wgAutoloadClasses['VisualEditorMessagesModule'] = $dir . 'VisualEditorMessagesModule.php';

View file

@ -123,7 +123,7 @@ ve.init.mw.ViewPageTarget = function VeInitMwViewPageTarget() {
}
}
this.setupSkinTabs();
if ( mw.config.get( 'wgVisualEditor' ).enableSectionEditLinks ) {
if ( mw.config.get( 'wgVisualEditorConfig' ).enableSectionEditLinks ) {
this.setupSectionEditLinks();
}
if ( this.isViewPage ) {

View file

@ -31,7 +31,7 @@ ve.init.mw.Target = function VeInitMwTarget( $container, pageName, revision ) {
this.submitUrl = ( new mw.Uri( mw.util.wikiGetlink( this.pageName ) ) )
.extend( { 'action': 'submit' } );
this.modules = [
mw.config.get( 'wgVisualEditor' ).enableExperimentalCode ?
mw.config.get( 'wgVisualEditorConfig' ).enableExperimentalCode ?
'ext.visualEditor.experimental' : 'ext.visualEditor.core',
'ext.visualEditor.specialMessages'
]
@ -602,7 +602,7 @@ ve.init.mw.Target.prototype.reportProblem = function ( message ) {
'wiki': mw.config.get( 'wgDBname' )
};
$.post(
mw.config.get( 'wgVisualEditor' ).reportProblemURL,
mw.config.get( 'wgVisualEditorConfig' ).reportProblemURL,
{ 'data': JSON.stringify( report ) },
function () {
// This space intentionally left blank