Merge "Make message loading for 'ext.visualEditor.viewPageTarget.init' module less hacky"

This commit is contained in:
jenkins-bot 2014-09-10 19:04:39 +00:00 committed by Gerrit Code Review
commit c36ff41d4a
3 changed files with 31 additions and 11 deletions

View file

@ -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 );
}
/**

View file

@ -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(

View 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 );
}
}