Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| VisualEditorDesktopArticleTargetInitModule | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
20 | |
0.00% |
0 / 1 |
| getMessages | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * ResourceLoader module for the 'ext.visualEditor.desktopArticleTarget.init' |
| 4 | * module. Necessary to incorporate the VisualEditorTabMessages |
| 5 | * configuration setting. |
| 6 | * |
| 7 | * @file |
| 8 | * @ingroup Extensions |
| 9 | * @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt |
| 10 | * @license MIT |
| 11 | */ |
| 12 | |
| 13 | namespace MediaWiki\Extension\VisualEditor; |
| 14 | |
| 15 | use MediaWiki\MediaWikiServices; |
| 16 | use MediaWiki\ResourceLoader\FileModule; |
| 17 | |
| 18 | class VisualEditorDesktopArticleTargetInitModule extends FileModule { |
| 19 | |
| 20 | /** |
| 21 | * @inheritDoc |
| 22 | */ |
| 23 | public function getMessages() { |
| 24 | $messages = parent::getMessages(); |
| 25 | $services = MediaWikiServices::getInstance(); |
| 26 | |
| 27 | $veConfig = $services->getConfigFactory()->makeConfig( 'visualeditor' ); |
| 28 | $messages = array_merge( |
| 29 | $messages, |
| 30 | array_filter( $veConfig->get( 'VisualEditorTabMessages' ) ) |
| 31 | ); |
| 32 | |
| 33 | // Some skins don't use the default 'edit' and 'create' message keys. |
| 34 | // Check the localisation cache for which skins have a custom message for this. |
| 35 | // We only need this for the current skin, but ResourceLoader's message cache |
| 36 | // does not fragment by skin. |
| 37 | foreach ( [ 'edit', 'create', 'edit-local', 'create-local' ] as $msgKey ) { |
| 38 | // MediaWiki defaults |
| 39 | $messages[] = "skin-view-$msgKey"; |
| 40 | foreach ( $services->getSkinFactory()->getInstalledSkins() as $skname => $unused ) { |
| 41 | // Per-skin overrides |
| 42 | // Messages: vector-view-edit, vector-view-create |
| 43 | // Disable database lookups for site-level message overrides as they |
| 44 | // are expensive and not needed here (T221294). We only care whether the |
| 45 | // message key is known to localisation cache at all. |
| 46 | $msg = wfMessage( "$skname-view-$msgKey" )->useDatabase( false )->inContentLanguage(); |
| 47 | if ( $msg->exists() ) { |
| 48 | $messages[] = "$skname-view-$msgKey"; |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | return $messages; |
| 54 | } |
| 55 | |
| 56 | } |