mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-23 22:13:34 +00:00
Make message loading for 'ext.visualEditor.viewPageTarget.init' module less hacky
Rather than modifying $wgResourceModules at run-time, use a subclass of ResourceLoaderFileModule to add the messages in the constructor. Change-Id: I9cf99891ed186afb6aa63501edced692117a7c50
This commit is contained in:
parent
8e84d75383
commit
11ff6096bf
|
@ -18,17 +18,6 @@ class VisualEditorHooks {
|
|||
// this should have no impact on deploying to Wikimedia's wiki cluster;
|
||||
// is fine for release tarballs because 1.22wmf11 < 1.22alpha < 1.22.0.
|
||||
wfUseMW( '1.24wmf18' );
|
||||
|
||||
$coreConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
|
||||
$veConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' );
|
||||
$resourceModules = $coreConfig->get( 'ResourceModules' );
|
||||
// Add tab messages to the init init module
|
||||
foreach ( $veConfig->get( 'VisualEditorTabMessages' ) as $msg ) {
|
||||
if ( $msg !== null ) {
|
||||
$resourceModules['ext.visualEditor.viewPageTarget.init']['messages'][] = $msg;
|
||||
}
|
||||
}
|
||||
$coreConfig->set( 'ResourceModules', $resourceModules );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,6 +39,8 @@ $wgAutoloadClasses['ApiVisualEditor'] = $dir . 'ApiVisualEditor.php';
|
|||
$wgAutoloadClasses['ApiVisualEditorEdit'] = $dir . 'ApiVisualEditorEdit.php';
|
||||
$wgAutoloadClasses['VisualEditorHooks'] = $dir . 'VisualEditor.hooks.php';
|
||||
$wgAutoloadClasses['VisualEditorDataModule'] = $dir . 'VisualEditorDataModule.php';
|
||||
$wgAutoloadClasses['VisualEditorViewPageTargetInitModule'] =
|
||||
$dir . 'VisualEditorViewPageTargetInitModule.php';
|
||||
$wgExtensionMessagesFiles['VisualEditor'] = $dir . 'VisualEditor.i18n.php';
|
||||
$wgMessagesDirs['VisualEditor'] = array(
|
||||
__DIR__ . '/lib/ve/i18n',
|
||||
|
@ -158,6 +160,7 @@ $wgResourceModules += array(
|
|||
),
|
||||
|
||||
'ext.visualEditor.viewPageTarget.init' => $wgVisualEditorResourceTemplate + array(
|
||||
'class' => 'VisualEditorViewPageTargetInitModule',
|
||||
'scripts' => 'modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.init.js',
|
||||
'styles' => 'modules/ve-mw/init/styles/ve.init.mw.ViewPageTarget.init.css',
|
||||
'dependencies' => array(
|
||||
|
|
28
VisualEditorViewPageTargetInitModule.php
Normal file
28
VisualEditorViewPageTargetInitModule.php
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* ResourceLoader module for the 'ext.visualEditor.viewPageTarget.init'
|
||||
* module. Necessary to incorporate the VisualEditorTabMessages
|
||||
* configuration setting.
|
||||
*
|
||||
* @file
|
||||
* @ingroup Extensions
|
||||
* @copyright 2014 VisualEditor Team and others; see AUTHORS.txt
|
||||
* @license The MIT License (MIT); see LICENSE.txt
|
||||
*/
|
||||
|
||||
class VisualEditorViewPageTargetInitModule extends ResourceLoaderFileModule {
|
||||
|
||||
public function __construct(
|
||||
$options = array(),
|
||||
$localBasePath = null,
|
||||
$remoteBasePath = null
|
||||
) {
|
||||
$veConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' );
|
||||
$options['messages'] = array_merge(
|
||||
$options['messages'],
|
||||
array_filter( $veConfig->get( 'VisualEditorTabMessages' ) )
|
||||
);
|
||||
|
||||
parent::__construct( $options, $localBasePath, $remoteBasePath );
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue