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