mediawiki-extensions-Visual.../includes/VisualEditorDesktopArticleTargetInitModule.php

43 lines
1.3 KiB
PHP
Raw Normal View History

<?php
/**
* ResourceLoader module for the 'ext.visualEditor.desktopArticleTarget.init'
* module. Necessary to incorporate the VisualEditorTabMessages
* configuration setting.
*
* @file
* @ingroup Extensions
* @copyright 2011-2018 VisualEditor Team and others; see AUTHORS.txt
* @license MIT
*/
class VisualEditorDesktopArticleTargetInitModule extends ResourceLoaderFileModule {
/**
* @inheritDoc
*/
public function getMessages() {
$messages = parent::getMessages();
$veConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'visualeditor' );
$messages = array_merge(
$messages,
array_filter( $veConfig->get( 'VisualEditorTabMessages' ) )
);
// Skin-dependent messages for the edit tab (same as generated by SkinTemplate).
// We only need the message for the current skin, but we don't know which skin will be used.
// Only some skins use these (e.g. Vector), others just use default 'edit' and 'create'.
foreach ( SkinFactory::getDefaultInstance()->getSkinNames() as $skname => $unused ) {
foreach ( [ 'edit', 'create' ] as $msgKey ) {
// e.g. vector-view-edit, vector-view-create
if ( wfMessage( "$skname-view-$msgKey" )->inContentLanguage()->exists() ) {
$messages[] = "$skname-view-$msgKey";
}
}
}
return $messages;
}
}