r55017 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55016‎ | r55017 | r55018 >
Date:14:11, 14 August 2009
Author:siebrand
Status:deferred
Tags:
Comment:
Revert changes from r55014 in Maps.php at request of Jeroen. He was planning a release for today and this is crossing that release. Leaving Maps.i18n.magic.php in place to magic word localisation can be activated at a later time, while localisation can continue.
Modified paths:
  • /trunk/extensions/Maps/Maps.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/Maps.php
@@ -13,9 +13,9 @@
1414 /**
1515 * This documenation group collects source code files belonging to Maps.
1616 *
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
1818 * Maps, please use your own group defenition.
19 - *
 19+ *
2020 * @defgroup Maps Maps
2121 */
2222
@@ -23,7 +23,7 @@
2424 die( 'Not an entry point.' );
2525 }
2626
27 -define('Maps_VERSION', '0.4');
 27+define('Maps_VERSION', '0.3');
2828
2929 $egMapsScriptPath = $wgScriptPath . '/extensions/Maps';
3030 $egMapsIP = $IP . '/extensions/Maps';
@@ -35,10 +35,9 @@
3636 $wgExtensionFunctions[] = 'efMapsSetup';
3737
3838 $wgExtensionMessagesFiles['Maps'] = $egMapsIP . '/Maps.i18n.php';
39 -$wgExtensionMessagesFiles['MapsMagic'] = $egMapsIP . '/Maps.i18n.magic.php';
4039
 40+$wgHooks['LanguageGetMagic'][] = 'efMapsFunctionMagic';
4141 $wgHooks['AdminLinks'][] = 'efMapsAddToAdminLinks';
42 -$wgHooks['ParserFirstCallInit'][] = 'efMapsAddParserHooks';
4342
4443 // Autoload the general classes
4544 $wgAutoloadClasses['MapsMapFeature'] = $egMapsIP . '/Maps_MapFeature.php';
@@ -53,79 +52,81 @@
5453 $egMapsServices = array();
5554
5655 $egMapsServices['googlemaps'] = array(
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 -
 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+
7271 $egMapsServices['openlayers'] = array(
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 -
 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+
8483 $egMapsServices['yahoomaps'] = array(
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 -
 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+
10996 /**
11097 * Initialization function for the Maps extension
11198 */
11299 function efMapsSetup() {
113 - global $wgOut, $wgAutoloadClasses;
 100+ global $wgExtensionCredits, $wgOut, $wgAutoloadClasses;
114101 global $egMapsDefaultService, $egMapsAvailableServices, $egMapsServices, $egMapsScriptPath, $egMapsDefaultGeoService, $egMapsAvailableGeoServices, $egMapsIP;
115102
116103 efMapsValidateGoogleMapsKey();
117 -
 104+
118105 // Make sure the default service is one of the enabled ones
119106 $egMapsDefaultService = in_array($egMapsDefaultService, $egMapsAvailableServices) ? $egMapsDefaultService : $egMapsAvailableServices[0];
120107 $egMapsDefaultGeoService = in_array($egMapsDefaultGeoService, $egMapsAvailableGeoServices) ? $egMapsDefaultGeoService : $egMapsAvailableGeoServices[0];
 108+
 109+ $services_list = implode(', ', array_keys($egMapsServices));
121110
122111 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+ );
123122
 123+ efMapsAddParserHooks();
 124+
124125 $wgOut->addScriptFile($egMapsScriptPath . '/MapUtilityFunctions.js');
125 -
 126+
126127 foreach ($egMapsServices as $serviceData) {
127128 $file = $serviceData['pf']['local'] ? $egMapsIP . '/' . $serviceData['pf']['file'] : $serviceData['pf']['file'];
128129 $wgAutoloadClasses[$serviceData['pf']['class']] = $file;
129 -
 130+
130131 foreach($serviceData['classes'] as $class) {
131132 $file = $class['local'] ? $egMapsIP . '/' . $class['file'] : $class['file'];
132133 $wgAutoloadClasses[$class['class']] = $file;
@@ -134,12 +135,48 @@
135136 }
136137
137138 /**
 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+/**
138175 * This function ensures backward compatibility with Semantic Google Maps and other extensions
139176 * using $wgGoogleMapsKey instead of $egGoogleMapsKey.
140177 */
141178 function efMapsValidateGoogleMapsKey() {
142179 global $egGoogleMapsKey, $wgGoogleMapsKey;
143 -
 180+
144181 if (strlen($egGoogleMapsKey) < 1 && isset($wgGoogleMapsKey)) $egGoogleMapsKey = $wgGoogleMapsKey;
145182 }
146183
@@ -148,33 +185,15 @@
149186 */
150187 function efMapsAddToAdminLinks(&$admin_links_tree) {
151188 // TODO: move the documentation link to another section - and make it non dependant on SMW?
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;
 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;
161198 }
162199
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') );
170200
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 -}

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r55014* new style magic words support for Maps...siebrand12:46, 14 August 2009

Status & tagging log