2014-09-08 06:54:54 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2015-07-29 13:41:30 +00:00
|
|
|
* ResourceLoader module for the 'ext.visualEditor.desktopArticleTarget.init'
|
2014-09-08 06:54:54 +00:00
|
|
|
* module. Necessary to incorporate the VisualEditorTabMessages
|
|
|
|
* configuration setting.
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @ingroup Extensions
|
2019-01-01 13:24:23 +00:00
|
|
|
* @copyright 2011-2019 VisualEditor Team and others; see AUTHORS.txt
|
2018-03-28 19:47:04 +00:00
|
|
|
* @license MIT
|
2014-09-08 06:54:54 +00:00
|
|
|
*/
|
|
|
|
|
2019-05-04 21:02:29 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
2015-07-29 13:41:30 +00:00
|
|
|
class VisualEditorDesktopArticleTargetInitModule extends ResourceLoaderFileModule {
|
2014-09-08 06:54:54 +00:00
|
|
|
|
2018-03-28 19:47:04 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2018-10-13 01:01:36 +00:00
|
|
|
public function getMessages() {
|
|
|
|
$messages = parent::getMessages();
|
2019-05-04 21:02:29 +00:00
|
|
|
$services = MediaWikiServices::getInstance();
|
2018-10-13 01:01:36 +00:00
|
|
|
|
2019-05-04 21:02:29 +00:00
|
|
|
$veConfig = $services->getConfigFactory()->makeConfig( 'visualeditor' );
|
2018-10-13 01:01:36 +00:00
|
|
|
$messages = array_merge(
|
|
|
|
$messages,
|
2014-09-08 06:54:54 +00:00
|
|
|
array_filter( $veConfig->get( 'VisualEditorTabMessages' ) )
|
|
|
|
);
|
|
|
|
|
2019-04-17 21:13:31 +00:00
|
|
|
// Some skins don't use the default 'edit' and 'create' message keys.
|
|
|
|
// Check the localisation cache for which skins have a custom message for this.
|
|
|
|
// We only need this for the current skin, but ResourceLoader's message cache
|
|
|
|
// does not fragment by skin.
|
2019-05-04 21:02:29 +00:00
|
|
|
foreach ( $services->getSkinFactory()->getSkinNames() as $skname => $unused ) {
|
2018-10-13 01:01:36 +00:00
|
|
|
foreach ( [ 'edit', 'create' ] as $msgKey ) {
|
2019-04-17 21:13:31 +00:00
|
|
|
// Messages: vector-view-edit, vector-view-create
|
|
|
|
// Disable database lookups for site-level message overrides as they
|
|
|
|
// are expensive and not needed here (T221294). We only care whether the
|
|
|
|
// message key is known to localisation cache at all.
|
|
|
|
$msg = wfMessage( "$skname-view-$msgKey" )->useDatabase( false )->inContentLanguage();
|
|
|
|
if ( $msg->exists() ) {
|
2018-10-13 01:01:36 +00:00
|
|
|
$messages[] = "$skname-view-$msgKey";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $messages;
|
2014-09-08 06:54:54 +00:00
|
|
|
}
|
2018-10-13 01:01:36 +00:00
|
|
|
|
2014-09-08 06:54:54 +00:00
|
|
|
}
|