|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Maps; |
|
4
|
|
|
|
|
5
|
|
|
use MapsMappingService; |
|
6
|
|
|
use MapsMappingServices; |
|
7
|
|
|
use SMKMLPrinter; |
|
8
|
|
|
use SMMapPrinter; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* @licence GNU GPL v2+ |
|
12
|
|
|
* @author Jeroen De Dauw < [email protected] > |
|
13
|
|
|
*/ |
|
14
|
|
|
class SemanticMaps { |
|
15
|
|
|
|
|
16
|
|
|
private $mwGlobals; |
|
17
|
|
|
|
|
18
|
|
|
public static function newFromMediaWikiGlobals( array &$mwGlobals ) { |
|
19
|
|
|
return new self( $mwGlobals ); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
private function __construct( array &$mwGlobals ) { |
|
23
|
|
|
$this->mwGlobals =& $mwGlobals; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function initExtension() { |
|
27
|
|
|
// Hook for initializing the Geographical Data types. |
|
28
|
|
|
$this->mwGlobals['wgHooks']['SMW::DataType::initTypes'][] = 'SemanticMapsHooks::initGeoDataTypes'; |
|
29
|
|
|
|
|
30
|
|
|
// Hook for defining the default query printer for queries that ask for geographical coordinates. |
|
31
|
|
|
$this->mwGlobals['wgHooks']['SMWResultFormat'][] = 'SemanticMapsHooks::addGeoCoordsDefaultFormat'; |
|
32
|
|
|
|
|
33
|
|
|
// Hook for adding a Semantic Maps links to the Admin Links extension. |
|
34
|
|
|
$this->mwGlobals['wgHooks']['AdminLinks'][] = 'SemanticMapsHooks::addToAdminLinks'; |
|
35
|
|
|
|
|
36
|
|
|
$this->registerResourceModules(); |
|
37
|
|
|
|
|
38
|
|
|
$this->registerGoogleMaps(); |
|
39
|
|
|
$this->registerLeaflet(); |
|
40
|
|
|
$this->registerOpenLayers(); |
|
41
|
|
|
|
|
42
|
|
|
$this->mwGlobals['smwgResultFormats']['kml'] = SMKMLPrinter::class; |
|
43
|
|
|
|
|
44
|
|
|
$this->mwGlobals['smwgResultAliases'][$this->mwGlobals['egMapsDefaultServices']['qp']][] = 'map'; |
|
45
|
|
|
SMMapPrinter::registerDefaultService( $this->mwGlobals['egMapsDefaultServices']['qp'] ); |
|
46
|
|
|
|
|
47
|
|
|
// Internationalization |
|
48
|
|
|
$this->mwGlobals['wgMessagesDirs']['SemanticMaps'] = __DIR__ . '/i18n'; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
private function registerResourceModules() { |
|
52
|
|
|
$moduleTemplate = [ |
|
53
|
|
|
'position' => 'bottom', |
|
54
|
|
|
'group' => 'ext.semanticmaps', |
|
55
|
|
|
]; |
|
56
|
|
|
|
|
57
|
|
|
$this->mwGlobals['wgResourceModules']['ext.sm.common'] = $moduleTemplate + [ |
|
58
|
|
|
'localBasePath' => __DIR__ . '/SemanticMaps/src', |
|
59
|
|
|
'remoteExtPath' => 'Maps/SemanticMaps/src', |
|
60
|
|
|
'scripts' => [ |
|
61
|
|
|
'ext.sm.common.js' |
|
62
|
|
|
] |
|
63
|
|
|
]; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
private function registerGoogleMaps() { |
|
67
|
|
|
$this->mwGlobals['wgResourceModules']['ext.sm.googlemaps3ajax'] = [ |
|
68
|
|
|
'localBasePath' => __DIR__ . '/SemanticMaps/src/services/GoogleMaps3', |
|
69
|
|
|
'remoteExtPath' => 'Maps/SemanticMaps/src/services/GoogleMaps3', |
|
70
|
|
|
'group' => 'ext.semanticmaps', |
|
71
|
|
|
'dependencies' => [ |
|
72
|
|
|
'ext.maps.googlemaps3', |
|
73
|
|
|
'ext.sm.common' |
|
74
|
|
|
], |
|
75
|
|
|
'scripts' => [ |
|
76
|
|
|
'ext.sm.googlemaps3ajax.js' |
|
77
|
|
|
] |
|
78
|
|
|
]; |
|
79
|
|
|
|
|
80
|
|
|
/* @var MapsMappingService $googleMaps */ |
|
81
|
|
|
$googleMaps = MapsMappingServices::getServiceInstance( 'googlemaps3' ); |
|
82
|
|
|
$googleMaps->addResourceModules( array( 'ext.sm.googlemaps3ajax' ) ); |
|
83
|
|
|
|
|
84
|
|
|
SMMapPrinter::registerService( $googleMaps ); |
|
85
|
|
|
|
|
86
|
|
|
$this->mwGlobals['smwgResultFormats'][$googleMaps->getName()] = SMMapPrinter::class; |
|
87
|
|
|
$this->mwGlobals['smwgResultAliases'][$googleMaps->getName()] = $googleMaps->getAliases(); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
private function registerLeaflet() { |
|
91
|
|
|
$this->mwGlobals['wgResourceModules']['ext.sm.fi.leafletajax'] = [ |
|
92
|
|
|
'localBasePath' => __DIR__ . '/SemanticMaps/src/services/Leaflet', |
|
93
|
|
|
'remoteExtPath' => 'Maps/SemanticMaps/src/services/Leaflet', |
|
94
|
|
|
'group' => 'ext.semanticmaps', |
|
95
|
|
|
'dependencies' => [ |
|
96
|
|
|
'ext.maps.leaflet', |
|
97
|
|
|
'ext.sm.common' |
|
98
|
|
|
], |
|
99
|
|
|
'scripts' => [ |
|
100
|
|
|
'ext.sm.leafletajax.js' |
|
101
|
|
|
] |
|
102
|
|
|
]; |
|
103
|
|
|
|
|
104
|
|
|
/* @var MapsMappingService $leaflet */ |
|
105
|
|
|
$leaflet = MapsMappingServices::getServiceInstance( 'leaflet' ); |
|
106
|
|
|
$leaflet->addResourceModules( array( 'ext.sm.fi.leafletajax' ) ); |
|
107
|
|
|
|
|
108
|
|
|
SMMapPrinter::registerService( $leaflet ); |
|
109
|
|
|
|
|
110
|
|
|
$this->mwGlobals['smwgResultFormats'][$leaflet->getName()] = SMMapPrinter::class; |
|
111
|
|
|
$this->mwGlobals['smwgResultAliases'][$leaflet->getName()] = $leaflet->getAliases(); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
private function registerOpenLayers() { |
|
115
|
|
|
$this->mwGlobals['wgResourceModules']['ext.sm.fi.openlayersajax'] = [ |
|
116
|
|
|
'localBasePath' => __DIR__ . '/SemanticMaps/src/services/OpenLayers', |
|
117
|
|
|
'remoteExtPath' => 'Maps/SemanticMaps/src/services/OpenLayers', |
|
118
|
|
|
'group' => 'ext.semanticmaps', |
|
119
|
|
|
'dependencies' => [ |
|
120
|
|
|
'ext.maps.openlayers', |
|
121
|
|
|
'ext.sm.common' |
|
122
|
|
|
], |
|
123
|
|
|
'scripts' => [ |
|
124
|
|
|
'ext.sm.openlayersajax.js' |
|
125
|
|
|
] |
|
126
|
|
|
]; |
|
127
|
|
|
|
|
128
|
|
|
/* @var MapsMappingService $openLayers */ |
|
129
|
|
|
$openLayers = MapsMappingServices::getServiceInstance( 'openlayers' ); |
|
130
|
|
|
$openLayers->addResourceModules( array( 'ext.sm.fi.openlayersajax' ) ); |
|
131
|
|
|
|
|
132
|
|
|
SMMapPrinter::registerService( $openLayers ); |
|
133
|
|
|
|
|
134
|
|
|
$this->mwGlobals['smwgResultFormats'][$openLayers->getName()] = SMMapPrinter::class; |
|
135
|
|
|
$this->mwGlobals['smwgResultAliases'][$openLayers->getName()] = $openLayers->getAliases(); |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
} |
|
139
|
|
|
|