Index: trunk/extensions/Maps/Maps.i18n.magic.php |
— | — | @@ -0,0 +1,13 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +$magicWords = array(); |
| 5 | + |
| 6 | +$magicWords['en'] = array( |
| 7 | + 'display_point' => array( 0, 'display_point' ), |
| 8 | + 'display_points' => array( 0, 'display_points' ), |
| 9 | + 'display_address' => array( 0, 'display_address' ), |
| 10 | + 'display_addresses' => array( 0, 'display_addresses' ), |
| 11 | + 'geocode' => array( 0, 'geocode' ), |
| 12 | + 'geocodelat' => array( 0, 'geocodelat' ), |
| 13 | + 'geocodelng' => array( 0, 'geocodelng' ), |
| 14 | +); |
Property changes on: trunk/extensions/Maps/Maps.i18n.magic.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 15 | + native |
Name: svn:keywords |
2 | 16 | + Id |
Index: trunk/extensions/Maps/Maps.php |
— | — | @@ -13,9 +13,9 @@ |
14 | 14 | /** |
15 | 15 | * This documenation group collects source code files belonging to Maps. |
16 | 16 | * |
17 | | - * Please do not use this group name for other code. If you have an extension to |
| 17 | + * Please do not use this group name for other code. If you have an extension to |
18 | 18 | * Maps, please use your own group defenition. |
19 | | - * |
| 19 | + * |
20 | 20 | * @defgroup Maps Maps |
21 | 21 | */ |
22 | 22 | |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | die( 'Not an entry point.' ); |
25 | 25 | } |
26 | 26 | |
27 | | -define('Maps_VERSION', '0.3'); |
| 27 | +define('Maps_VERSION', '0.4'); |
28 | 28 | |
29 | 29 | $egMapsScriptPath = $wgScriptPath . '/extensions/Maps'; |
30 | 30 | $egMapsIP = $IP . '/extensions/Maps'; |
— | — | @@ -35,9 +35,10 @@ |
36 | 36 | $wgExtensionFunctions[] = 'efMapsSetup'; |
37 | 37 | |
38 | 38 | $wgExtensionMessagesFiles['Maps'] = $egMapsIP . '/Maps.i18n.php'; |
| 39 | +$wgExtensionMessagesFiles['MapsMagic'] = $egMapsIP . '/Maps.i18n.magic.php'; |
39 | 40 | |
40 | | -$wgHooks['LanguageGetMagic'][] = 'efMapsFunctionMagic'; |
41 | 41 | $wgHooks['AdminLinks'][] = 'efMapsAddToAdminLinks'; |
| 42 | +$wgHooks['ParserFirstCallInit'][] = 'efMapsAddParserHooks'; |
42 | 43 | |
43 | 44 | // Autoload the general classes |
44 | 45 | $wgAutoloadClasses['MapsMapFeature'] = $egMapsIP . '/Maps_MapFeature.php'; |
— | — | @@ -52,81 +53,79 @@ |
53 | 54 | $egMapsServices = array(); |
54 | 55 | |
55 | 56 | $egMapsServices['googlemaps'] = array( |
56 | | - 'pf' => array('class' => 'MapsGoogleMaps', 'file' => 'GoogleMaps/Maps_GoogleMaps.php', 'local' => true), |
57 | | - 'classes' => array( |
58 | | - array('class' => 'MapsGoogleMapsUtils', 'file' => 'GoogleMaps/Maps_GoogleMapsUtils.php', 'local' => true) |
59 | | - ), |
60 | | - 'aliases' => array('google', 'googlemap', 'gmap', 'gmaps'), |
61 | | - 'parameters' => array( |
62 | | - 'type' => array('map-type', 'map type'), |
63 | | - 'types' => array('map-types', 'map types'), |
64 | | - 'earth' => array(), |
65 | | - 'autozoom' => array('auto zoom', 'mouse zoom', 'mousezoom'), |
66 | | - 'class' => array(), |
67 | | - 'style' => array() |
68 | | - ) |
69 | | - ); |
70 | | - |
| 57 | + 'pf' => array('class' => 'MapsGoogleMaps', 'file' => 'GoogleMaps/Maps_GoogleMaps.php', 'local' => true), |
| 58 | + 'classes' => array( |
| 59 | + array('class' => 'MapsGoogleMapsUtils', 'file' => 'GoogleMaps/Maps_GoogleMapsUtils.php', 'local' => true) |
| 60 | + ), |
| 61 | + 'aliases' => array('google', 'googlemap', 'gmap', 'gmaps'), |
| 62 | + 'parameters' => array( |
| 63 | + 'type' => array('map-type', 'map type'), |
| 64 | + 'types' => array('map-types', 'map types'), |
| 65 | + 'earth' => array(), |
| 66 | + 'autozoom' => array('auto zoom', 'mouse zoom', 'mousezoom'), |
| 67 | + 'class' => array(), |
| 68 | + 'style' => array() |
| 69 | + ) |
| 70 | +); |
| 71 | + |
71 | 72 | $egMapsServices['openlayers'] = array( |
72 | | - 'pf' => array('class' => 'MapsOpenLayers', 'file' => 'OpenLayers/Maps_OpenLayers.php', 'local' => true), |
73 | | - 'classes' => array( |
74 | | - array('class' => 'MapsOpenLayersUtils', 'file' => 'OpenLayers/Maps_OpenLayersUtils.php', 'local' => true) |
75 | | - ), |
76 | | - 'aliases' => array('layers', 'openlayer'), |
77 | | - 'parameters' => array( |
78 | | - 'layers' => array(), |
79 | | - 'baselayer' => array() |
80 | | - ) |
81 | | - ); |
82 | | - |
| 73 | + 'pf' => array('class' => 'MapsOpenLayers', 'file' => 'OpenLayers/Maps_OpenLayers.php', 'local' => true), |
| 74 | + 'classes' => array( |
| 75 | + array('class' => 'MapsOpenLayersUtils', 'file' => 'OpenLayers/Maps_OpenLayersUtils.php', 'local' => true) |
| 76 | + ), |
| 77 | + 'aliases' => array('layers', 'openlayer'), |
| 78 | + 'parameters' => array( |
| 79 | + 'layers' => array(), |
| 80 | + 'baselayer' => array() |
| 81 | + ) |
| 82 | +); |
| 83 | + |
83 | 84 | $egMapsServices['yahoomaps'] = array( |
84 | | - 'pf' => array('class' => 'MapsYahooMaps', 'file' => 'YahooMaps/Maps_YahooMaps.php', 'local' => true), |
85 | | - 'classes' => array( |
86 | | - array('class' => 'MapsYahooMapsUtils', 'file' => 'YahooMaps/Maps_YahooMapsUtils.php', 'local' => true) |
87 | | - ), |
88 | | - 'aliases' => array('yahoo', 'yahoomap', 'ymap', 'ymaps'), |
89 | | - 'parameters' => array( |
90 | | - 'type' => array('map-type'), |
91 | | - 'types' => array('map-types', 'map types'), |
92 | | - 'autozoom' => array('auto zoom', 'mouse zoom', 'mousezoom') |
93 | | - ) |
94 | | - ); |
95 | | - |
| 85 | + 'pf' => array('class' => 'MapsYahooMaps', 'file' => 'YahooMaps/Maps_YahooMaps.php', 'local' => true), |
| 86 | + 'classes' => array( |
| 87 | + array('class' => 'MapsYahooMapsUtils', 'file' => 'YahooMaps/Maps_YahooMapsUtils.php', 'local' => true) |
| 88 | + ), |
| 89 | + 'aliases' => array('yahoo', 'yahoomap', 'ymap', 'ymaps'), |
| 90 | + 'parameters' => array( |
| 91 | + 'type' => array('map-type'), |
| 92 | + 'types' => array('map-types', 'map types'), |
| 93 | + 'autozoom' => array('auto zoom', 'mouse zoom', 'mousezoom') |
| 94 | + ) |
| 95 | +); |
| 96 | + |
| 97 | +$services_list = implode(', ', array_keys($egMapsServices)); |
| 98 | + |
| 99 | +$wgExtensionCredits['parserhook'][] = array( |
| 100 | + 'path' => __FILE__, |
| 101 | + 'name' => wfMsg('maps_name'), |
| 102 | + 'version' => Maps_VERSION, |
| 103 | + 'author' => array("[http://bn2vs.com Jeroen De Dauw]", "[http://www.mediawiki.org/wiki/User:Yaron_Koren Yaron Koren]", "Robert Buzink", "Matt Williamson", "[http://www.sergeychernyshev.com Sergey Chernyshev]"), |
| 104 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:Maps', |
| 105 | + 'description' => wfMsg( 'maps_desc', $services_list ), |
| 106 | + 'descriptionmsg' => wfMsg( 'maps_desc', $services_list ), |
| 107 | +); |
| 108 | + |
96 | 109 | /** |
97 | 110 | * Initialization function for the Maps extension |
98 | 111 | */ |
99 | 112 | function efMapsSetup() { |
100 | | - global $wgExtensionCredits, $wgOut, $wgAutoloadClasses; |
| 113 | + global $wgOut, $wgAutoloadClasses; |
101 | 114 | global $egMapsDefaultService, $egMapsAvailableServices, $egMapsServices, $egMapsScriptPath, $egMapsDefaultGeoService, $egMapsAvailableGeoServices, $egMapsIP; |
102 | 115 | |
103 | 116 | efMapsValidateGoogleMapsKey(); |
104 | | - |
| 117 | + |
105 | 118 | // Make sure the default service is one of the enabled ones |
106 | 119 | $egMapsDefaultService = in_array($egMapsDefaultService, $egMapsAvailableServices) ? $egMapsDefaultService : $egMapsAvailableServices[0]; |
107 | 120 | $egMapsDefaultGeoService = in_array($egMapsDefaultGeoService, $egMapsAvailableGeoServices) ? $egMapsDefaultGeoService : $egMapsAvailableGeoServices[0]; |
108 | | - |
109 | | - $services_list = implode(', ', array_keys($egMapsServices)); |
110 | 121 | |
111 | 122 | wfLoadExtensionMessages( 'Maps' ); |
112 | | - |
113 | | - $wgExtensionCredits['parserhook'][] = array( |
114 | | - 'path' => __FILE__, |
115 | | - 'name' => wfMsg('maps_name'), |
116 | | - 'version' => Maps_VERSION, |
117 | | - 'author' => array("[http://bn2vs.com Jeroen De Dauw]", "[http://www.mediawiki.org/wiki/User:Yaron_Koren Yaron Koren]", "Robert Buzink", "Matt Williamson", "[http://www.sergeychernyshev.com Sergey Chernyshev]"), |
118 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:Maps', |
119 | | - 'description' => wfMsg( 'maps_desc', $services_list ), |
120 | | - 'descriptionmsg' => wfMsg( 'maps_desc', $services_list ), |
121 | | - ); |
122 | 123 | |
123 | | - efMapsAddParserHooks(); |
124 | | - |
125 | 124 | $wgOut->addScriptFile($egMapsScriptPath . '/MapUtilityFunctions.js'); |
126 | | - |
| 125 | + |
127 | 126 | foreach ($egMapsServices as $serviceData) { |
128 | 127 | $file = $serviceData['pf']['local'] ? $egMapsIP . '/' . $serviceData['pf']['file'] : $serviceData['pf']['file']; |
129 | 128 | $wgAutoloadClasses[$serviceData['pf']['class']] = $file; |
130 | | - |
| 129 | + |
131 | 130 | foreach($serviceData['classes'] as $class) { |
132 | 131 | $file = $class['local'] ? $egMapsIP . '/' . $class['file'] : $class['file']; |
133 | 132 | $wgAutoloadClasses[$class['class']] = $file; |
— | — | @@ -135,48 +134,12 @@ |
136 | 135 | } |
137 | 136 | |
138 | 137 | /** |
139 | | - * Adds the parser function hooks |
140 | | - */ |
141 | | -function efMapsAddParserHooks() { |
142 | | - global $wgParser; |
143 | | - |
144 | | - // A hooks to enable the '#display_point' and '#display_points' parser functions |
145 | | - $wgParser->setFunctionHook( 'display_point', array('MapsParserFunctions', 'displayPointRender') ); |
146 | | - $wgParser->setFunctionHook( 'display_points', array('MapsParserFunctions', 'displayPointsRender') ); |
147 | | - |
148 | | - // A hooks to enable the '#display_adress' and '#display_adresses' parser functions |
149 | | - $wgParser->setFunctionHook( 'display_address', array('MapsParserFunctions', 'displayAddressRender') ); |
150 | | - $wgParser->setFunctionHook( 'display_addresses', array('MapsParserFunctions', 'displayAddressesRender') ); |
151 | | - |
152 | | - // A hook to enable the geocoder parser functions |
153 | | - $wgParser->setFunctionHook( 'geocode', array('MapsGeocoder', 'renderGeocoder') ); |
154 | | - $wgParser->setFunctionHook( 'geocodelat' , array('MapsGeocoder', 'renderGeocoderLat') ); |
155 | | - $wgParser->setFunctionHook( 'geocodelng' , array('MapsGeocoder', 'renderGeocoderLng') ); |
156 | | -} |
157 | | - |
158 | | -/** |
159 | | - * Adds the magic words for the parser functions |
160 | | - */ |
161 | | -function efMapsFunctionMagic( &$magicWords, $langCode ) { |
162 | | - $magicWords['display_point'] = array( 0, 'display_point' ); |
163 | | - $magicWords['display_points'] = array( 0, 'display_points' ); |
164 | | - $magicWords['display_address'] = array( 0, 'display_address' ); |
165 | | - $magicWords['display_addresses'] = array( 0, 'display_addresses' ); |
166 | | - |
167 | | - $magicWords['geocode'] = array( 0, 'geocode' ); |
168 | | - $magicWords['geocodelat'] = array ( 0, 'geocodelat' ); |
169 | | - $magicWords['geocodelng'] = array ( 0, 'geocodelng' ); |
170 | | - |
171 | | - return true; // Unless we return true, other parser functions won't get loaded |
172 | | -} |
173 | | - |
174 | | -/** |
175 | 138 | * This function ensures backward compatibility with Semantic Google Maps and other extensions |
176 | 139 | * using $wgGoogleMapsKey instead of $egGoogleMapsKey. |
177 | 140 | */ |
178 | 141 | function efMapsValidateGoogleMapsKey() { |
179 | 142 | global $egGoogleMapsKey, $wgGoogleMapsKey; |
180 | | - |
| 143 | + |
181 | 144 | if (strlen($egGoogleMapsKey) < 1 && isset($wgGoogleMapsKey)) $egGoogleMapsKey = $wgGoogleMapsKey; |
182 | 145 | } |
183 | 146 | |
— | — | @@ -185,15 +148,33 @@ |
186 | 149 | */ |
187 | 150 | function efMapsAddToAdminLinks(&$admin_links_tree) { |
188 | 151 | // TODO: move the documentation link to another section - and make it non dependant on SMW? |
189 | | - $displaying_data_section = $admin_links_tree->getSection(wfMsg('smw_adminlinks_displayingdata')); |
190 | | - // Escape if SMW hasn't added links |
191 | | - if (is_null($displaying_data_section)) |
192 | | - return true; |
193 | | - $smw_docu_row = $displaying_data_section->getRow('smw'); |
194 | | - wfLoadExtensionMessages('Maps'); |
195 | | - $maps_docu_label = wfMsg('adminlinks_documentation', wfMsg('maps_name')); |
196 | | - $smw_docu_row->addItem(AlItem::newFromExternalLink("http://www.mediawiki.org/wiki/Extension:Maps", $maps_docu_label)); |
197 | | - return true; |
| 152 | + $displaying_data_section = $admin_links_tree->getSection(wfMsg('smw_adminlinks_displayingdata')); |
| 153 | + // Escape if SMW hasn't added links |
| 154 | + if (is_null($displaying_data_section)) |
| 155 | + return true; |
| 156 | + $smw_docu_row = $displaying_data_section->getRow('smw'); |
| 157 | + wfLoadExtensionMessages('Maps'); |
| 158 | + $maps_docu_label = wfMsg('adminlinks_documentation', wfMsg('maps_name')); |
| 159 | + $smw_docu_row->addItem(AlItem::newFromExternalLink("http://www.mediawiki.org/wiki/Extension:Maps", $maps_docu_label)); |
| 160 | + return true; |
198 | 161 | } |
199 | 162 | |
| 163 | +/** |
| 164 | + * Add the parser function hooks |
| 165 | + */ |
| 166 | +function efMapsAddParserHooks( $parser ) { |
| 167 | + // Hooks to enable the '#display_point' and '#display_points' parser functions |
| 168 | + $parser->setFunctionHook( 'display_point', array('MapsParserFunctions', 'displayPointRender') ); |
| 169 | + $parser->setFunctionHook( 'display_points', array('MapsParserFunctions', 'displayPointsRender') ); |
200 | 170 | |
| 171 | + // Hooks to enable the '#display_adress' and '#display_adresses' parser functions |
| 172 | + $parser->setFunctionHook( 'display_address', array('MapsParserFunctions', 'displayAddressRender') ); |
| 173 | + $parser->setFunctionHook( 'display_addresses', array('MapsParserFunctions', 'displayAddressesRender') ); |
| 174 | + |
| 175 | + // Hooks to enable the geocoder parser functions |
| 176 | + $parser->setFunctionHook( 'geocode', array('MapsGeocoder', 'renderGeocoder') ); |
| 177 | + $parser->setFunctionHook( 'geocodelat' , array('MapsGeocoder', 'renderGeocoderLat') ); |
| 178 | + $parser->setFunctionHook( 'geocodelng' , array('MapsGeocoder', 'renderGeocoderLng') ); |
| 179 | + |
| 180 | + return true; |
| 181 | +} |