mediawiki-extensions-Cite/CiteDataModule.php
Kunal Mehta 4bbd227702 build: Updating mediawiki/mediawiki-codesniffer to 0.7.1
Also added "composer fix" command.

Change-Id: I3cdaa7aac81fc3f9b3e284b049a2dd07b1abf0f3
2016-05-09 16:36:49 -07:00

64 lines
1.5 KiB
PHP

<?php
/**
* Resource loader module providing extra data from the server to Cite.
*
* Temporary hack for T93800
*
* @file
* @ingroup Extensions
* @copyright 2011-2016 Cite VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see MIT-LICENSE.txt
*/
class CiteDataModule extends ResourceLoaderModule {
/* Protected Members */
protected $origin = self::ORIGIN_USER_SITEWIDE;
protected $targets = [ 'desktop', 'mobile' ];
/* Methods */
public function getScript( ResourceLoaderContext $context ) {
$citationDefinition = json_decode(
$context->msg( 'visualeditor-cite-tool-definition.json' )
->inContentLanguage()
->plain()
);
$citationTools = [];
if ( is_array( $citationDefinition ) ) {
foreach ( $citationDefinition as $tool ) {
if ( !isset( $tool->title ) ) {
$tool->title = $context->msg( 'visualeditor-cite-tool-name-' . $tool->name )
->text();
}
$citationTools[] = $tool;
}
}
return
've.init.platform.addMessages(' . FormatJson::encode(
[
'visualeditor-cite-tool-definition.json' => json_encode( $citationTools )
],
ResourceLoader::inDebugMode()
) . ');';
}
public function getDependencies( ResourceLoaderContext $context = null ) {
return [
'ext.visualEditor.base',
'ext.visualEditor.mediawiki',
];
}
public function getDefinitionSummary( ResourceLoaderContext $context ) {
$summary = parent::getDefinitionSummary( $context );
$summary[] = [
'script' => $this->getScript( $context ),
];
return $summary;
}
}