MediaWiki
1.34.0
CiteDataModule.php
Go to the documentation of this file.
1
<?php
2
11
class
CiteDataModule
extends
ResourceLoaderModule
{
12
13
protected
$targets
= [
'desktop'
,
'mobile'
];
14
16
public
function
getScript
(
ResourceLoaderContext
$context
) {
17
$citationDefinition = json_decode(
18
$context
->msg(
'cite-tool-definition.json'
)
19
->inContentLanguage()
20
->plain()
21
);
22
23
if
( $citationDefinition ===
null
) {
24
$citationDefinition = json_decode(
25
$context
->msg(
'visualeditor-cite-tool-definition.json'
)
26
->inContentLanguage()
27
->plain()
28
);
29
}
30
31
$citationTools = [];
32
if
( is_array( $citationDefinition ) ) {
33
foreach
( $citationDefinition as $tool ) {
34
if
( !isset( $tool->title ) ) {
35
$tool->title =
$context
->msg(
'visualeditor-cite-tool-name-'
. $tool->name )
36
->text();
37
}
38
$citationTools[] = $tool;
39
}
40
}
41
42
return
've.init.platform.addMessages('
.
FormatJson::encode
(
43
[
44
'cite-tool-definition.json'
=> json_encode( $citationTools )
45
],
46
ResourceLoader::inDebugMode()
47
) .
');'
;
48
}
49
51
public
function
getDependencies
(
ResourceLoaderContext
$context
=
null
) {
52
return
[
53
'ext.visualEditor.base'
,
54
'ext.visualEditor.mediawiki'
,
55
];
56
}
57
59
public
function
getDefinitionSummary
(
ResourceLoaderContext
$context
) {
60
$summary = parent::getDefinitionSummary(
$context
);
61
$summary[] = [
62
'script'
=> $this->
getScript
( $context ),
63
];
64
return
$summary;
65
}
66
67
}
ResourceLoaderContext
Context object that contains information about the state of a specific ResourceLoader web request.
Definition:
ResourceLoaderContext.php:33
CiteDataModule
Resource loader module providing extra data from the server to Cite.
Definition:
CiteDataModule.php:11
FormatJson\encode
static encode( $value, $pretty=false, $escaping=0)
Returns the JSON representation of a value.
Definition:
FormatJson.php:115
CiteDataModule\$targets
$targets
Definition:
CiteDataModule.php:13
CiteDataModule\getDependencies
getDependencies(ResourceLoaderContext $context=null)
Get a list of modules this module depends on.Dependency information is taken into account when loadin...
Definition:
CiteDataModule.php:51
$context
$context
Definition:
load.php:45
ResourceLoaderModule
Abstraction for ResourceLoader modules, with name registration and maxage functionality.
Definition:
ResourceLoaderModule.php:37
CiteDataModule\getScript
getScript(ResourceLoaderContext $context)
Get all JS for this module for a given language and skin.Includes all relevant JS except loader scrip...
Definition:
CiteDataModule.php:16
CiteDataModule\getDefinitionSummary
getDefinitionSummary(ResourceLoaderContext $context)
Get the definition summary for this module.This is the method subclasses are recommended to use to tr...
Definition:
CiteDataModule.php:59
extensions
Cite
includes
CiteDataModule.php
Generated on Thu Dec 19 2019 14:53:52 for MediaWiki by
1.8.16