1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This groupe contains all Google Maps v3 related files of the Maps extension. |
5
|
|
|
* |
6
|
|
|
* @defgroup MapsGoogleMaps3 Google Maps v3 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* This file holds the hook and initialization for the Google Maps v3 service. |
11
|
|
|
* |
12
|
|
|
* @licence GNU GPL v2+ |
13
|
|
|
* @author Jeroen De Dauw < [email protected] > |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
if ( !defined( 'MEDIAWIKI' ) ) { |
17
|
|
|
die( 'Not an entry point.' ); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
call_user_func( function() { |
21
|
|
|
global $wgResourceModules, $wgHooks; |
22
|
|
|
|
23
|
|
|
$pathParts = ( explode( DIRECTORY_SEPARATOR . 'extensions' . DIRECTORY_SEPARATOR, __DIR__, 2 ) ); |
24
|
|
|
|
25
|
|
|
$wgResourceModules['ext.maps.googlemaps3'] = [ |
26
|
|
|
'dependencies' => [ 'ext.maps.common' ], |
27
|
|
|
'localBasePath' => __DIR__, |
28
|
|
|
'remoteExtPath' => end( $pathParts ), |
29
|
|
|
'group' => 'ext.maps', |
30
|
|
|
'targets' => [ |
31
|
|
|
'mobile', |
32
|
|
|
'desktop' |
33
|
|
|
], |
34
|
|
|
'scripts' => [ |
35
|
|
|
'jquery.googlemap.js', |
36
|
|
|
'ext.maps.googlemaps3.js' |
37
|
|
|
], |
38
|
|
|
'messages' => [ |
39
|
|
|
'maps-googlemaps3-incompatbrowser', |
40
|
|
|
'maps-copycoords-prompt', |
41
|
|
|
'maps-searchmarkers-text', |
42
|
|
|
'maps-fullscreen-button', |
43
|
|
|
'maps-fullscreen-button-tooltip', |
44
|
|
|
] |
45
|
|
|
]; |
46
|
|
|
|
47
|
|
|
$wgResourceModules['ext.maps.gm3.markercluster'] = [ |
48
|
|
|
'localBasePath' => __DIR__ . '/gm3-util-library', |
49
|
|
|
'remoteExtPath' => end( $pathParts ), |
50
|
|
|
'group' => 'ext.maps', |
51
|
|
|
'targets' => [ |
52
|
|
|
'mobile', |
53
|
|
|
'desktop' |
54
|
|
|
], |
55
|
|
|
'scripts' => [ |
56
|
|
|
'markerclusterer.js', |
57
|
|
|
], |
58
|
|
|
]; |
59
|
|
|
|
60
|
|
|
$wgResourceModules['ext.maps.gm3.markerwithlabel'] = [ |
61
|
|
|
'localBasePath' => __DIR__ . '/gm3-util-library', |
62
|
|
|
'remoteExtPath' => end( $pathParts ), |
63
|
|
|
'group' => 'ext.maps', |
64
|
|
|
'targets' => [ |
65
|
|
|
'mobile', |
66
|
|
|
'desktop' |
67
|
|
|
], |
68
|
|
|
'scripts' => [ |
69
|
|
|
'markerwithlabel.js', |
70
|
|
|
], |
71
|
|
|
'styles' => [ |
72
|
|
|
'markerwithlabel.css', |
73
|
|
|
], |
74
|
|
|
]; |
75
|
|
|
|
76
|
|
|
$wgResourceModules['ext.maps.gm3.geoxml'] = [ |
77
|
|
|
'localBasePath' => __DIR__ . '/geoxml3', |
78
|
|
|
'remoteExtPath' => end( $pathParts ), |
79
|
|
|
'group' => 'ext.maps', |
80
|
|
|
'targets' => [ |
81
|
|
|
'mobile', |
82
|
|
|
'desktop' |
83
|
|
|
], |
84
|
|
|
'scripts' => [ |
85
|
|
|
'geoxml3.js', |
86
|
|
|
'ZipFile.complete.js', //kmz handling |
87
|
|
|
'ProjectedOverlay.js', //Overlay handling |
88
|
|
|
], |
89
|
|
|
]; |
90
|
|
|
|
91
|
|
|
$wgResourceModules['ext.maps.gm3.earth'] = [ |
92
|
|
|
'localBasePath' => __DIR__ . '/gm3-util-library', |
93
|
|
|
'remoteExtPath' => end( $pathParts ), |
94
|
|
|
'group' => 'ext.maps', |
95
|
|
|
'targets' => [ |
96
|
|
|
'mobile', |
97
|
|
|
'desktop' |
98
|
|
|
], |
99
|
|
|
'scripts' => [ |
100
|
|
|
'googleearth-compiled.js', |
101
|
|
|
], |
102
|
|
|
]; |
103
|
|
|
|
104
|
|
|
$wgHooks['MappingServiceLoad'][] = 'efMapsInitGoogleMaps3'; |
105
|
|
|
} ); |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Initialization function for the Google Maps v3 service. |
109
|
|
|
* |
110
|
|
|
* @since 0.6.3 |
111
|
|
|
* @ingroup MapsGoogleMaps3 |
112
|
|
|
* |
113
|
|
|
* @return boolean true |
114
|
|
|
*/ |
115
|
|
|
function efMapsInitGoogleMaps3() { |
116
|
|
|
global $wgAutoloadClasses; |
117
|
|
|
|
118
|
|
|
$wgAutoloadClasses['MapsGoogleMaps3'] = __DIR__ . '/Maps_GoogleMaps3.php'; |
119
|
|
|
|
120
|
|
|
MapsMappingServices::registerService( 'googlemaps3', 'MapsGoogleMaps3' ); |
121
|
|
|
|
122
|
|
|
// TODO: kill below code |
123
|
|
|
$googleMaps = MapsMappingServices::getServiceInstance( 'googlemaps3' ); |
124
|
|
|
$googleMaps->addFeature( 'display_map', 'MapsDisplayMapRenderer' ); |
125
|
|
|
|
126
|
|
|
return true; |
127
|
|
|
} |
128
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.