forked from WikimapsAtlas/mediawiki-extensions-Graph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraph.php
More file actions
97 lines (87 loc) · 2.66 KB
/
Graph.php
File metadata and controls
97 lines (87 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/**
* Graph extension, visualizes arbitrary datasets in arbitrary ways in MediaWiki.
*
* @license MIT
* @file
* @ingroup Extensions
*
* @author Dan Andreescu, Yuri Astrakhan
*/
if ( !defined( 'MEDIAWIKI' ) ) {
echo( "This file is an extension to the MediaWiki software and cannot be used on its own.\n" );
die( 1 );
}
if ( version_compare( $wgVersion, '1.21', '<' ) ) {
die( "This extension requires MediaWiki 1.21+\n" );
}
$wgExtensionCredits['other'][] = array(
'path' => __FILE__,
'name' => 'Graph',
'author' => array( 'Dan Andreescu', 'Yuri Astrakhan' ),
);
$graphBodyFile = __DIR__ . DIRECTORY_SEPARATOR . 'Graph.body.php';
$wgAutoloadClasses['Graph\Singleton'] = $graphBodyFile;
$wgAutoloadClasses['Graph\Content'] = $graphBodyFile;
$wgAutoloadClasses['Graph\ContentView'] = $graphBodyFile;
unset( $graphBodyFile );
/**
* @var bool Set to true to enable <graph> tag in wiki markup
*/
$wgEnableGraphParserTag = false;
/**
* @var false|string[] a list of domains that the vega code is allowed to pull data from.
* If false, there are no restrictions. An empty list disables any external data (inline only).
* NOTE: Setting this value to anything other than 'false' will also enable safe mode formula/filter evaluation
*/
$wgGraphDataDomains = array();
$wgHooks['ParserFirstCallInit'][] = 'Graph\Singleton::onParserFirstCallInit';
// ResourceLoader modules
/**
* A boilerplate for resource loader modules
*/
$extGraphBoilerplate = array(
'localBasePath' => __DIR__,
'remoteExtPath' => 'Graph',
'targets' => array( 'mobile', 'desktop' ),
);
$wgResourceModules['mediawiki.libs.d3'] = array(
'scripts' => array(
'lib/d3.js',
//'lib/d3.geo.projection.min.js',
),
) + $extGraphBoilerplate;
$wgResourceModules['mediawiki.libs.topojson'] = array(
'scripts' => array(
'lib/topojson.js',
),
) + $extGraphBoilerplate;
$wgResourceModules['mediawiki.libs.vega'] = array(
'dependencies' => array(
'mediawiki.libs.d3',
'mediawiki.libs.topojson',
),
'scripts' => array(
'lib/vega.js',
),
) + $extGraphBoilerplate;
$wgResourceModules['ext.graph'] = array(
// TODO: dependencies don't work. Symptoms:
// * Firefox works
// * Chrome works in debug mode
// * Chrome does not work in production mode (debug=false)
//'dependencies' => array(
//'mediawiki.libs.vega',
//),
'scripts' => array(
'lib/d3.js',
// 'lib/d3.geo.projection.min.js',
'lib/topojson.js',
'lib/vega.js',
'js/graph.js',
),
'styles' => array(
'styles/common.less',
),
) + $extGraphBoilerplate;
unset( $extGraphBoilerplate );