r83438 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83437‎ | r83438 | r83439 >
Date:06:15, 7 March 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
rem dead code and fixes to script loading
Modified paths:
  • /branches/Maps0.8/Maps_Settings.php (modified) (history)
  • /branches/Maps0.8/includes/Maps_MappingService.php (modified) (history)
  • /branches/Maps0.8/includes/services/GoogleMaps/Maps_GoogleMaps.php (modified) (history)
  • /branches/Maps0.8/includes/services/GoogleMaps3/Maps_GoogleMaps3.php (modified) (history)
  • /branches/Maps0.8/includes/services/OSM/Maps_OSM.php (modified) (history)
  • /branches/Maps0.8/includes/services/OpenLayers/Maps_OpenLayers.php (modified) (history)
  • /branches/Maps0.8/includes/services/OpenLayers/Maps_ParamOLLayers.php (modified) (history)
  • /branches/Maps0.8/includes/services/YahooMaps/Maps_YahooMaps.php (modified) (history)

Diff [purge]

Index: branches/Maps0.8/Maps_Settings.php
@@ -422,32 +422,7 @@
423423 'osm' => array( 'osmarender', 'osm-mapnik', 'osm-cyclemap' ),
424424 );
425425
426 - # Layer dependencie (MediaWiki >= 1.17).
427 - // http://maps.google.com/maps/api/js?sensor=false
428 - $egMapsOLLayerModules = array(/*
429 - 'ext.maps.ol.osm' => array(
430 - 'scripts' => array(
431 - 'OSM/OpenStreetMap.js',
432 - ),
433 - ),
434 - 'ext.maps.ol.yahoo' => array(
435 - 'scripts' => array(
436 - 'http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers',
437 - ),
438 - ),
439 - 'ext.maps.ol.bing' => array(
440 - 'scripts' => array(
441 - 'http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1',
442 - ),
443 - ),
444 - 'ext.maps.ol.ol-wms' => array(
445 - 'scripts' => array(
446 - 'http://clients.multimap.com/API/maps/1.1/metacarta_04',
447 - ),
448 - )
449 - */);
450 -
451 - # Layer dependencies (MediaWiki < 1.17).
 426+ # Layer dependencies
452427 $egMapsOLLayerDependencies = array(
453428 'yahoo' => "<style type='text/css'> #controls {width: 512px;}</style><script src='http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers'></script>",
454429 'bing' => "<script type='$wgJsMimeType' src='http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1'></script>",
Index: branches/Maps0.8/includes/Maps_MappingService.php
@@ -67,7 +67,6 @@
6868 */
6969 private $dependencies = array();
7070
71 -
7271 /**
7372 * Constructor. Creates a new instance of MapsMappingService.
7473 *
@@ -76,7 +75,7 @@
7776 * @param string $serviceName
7877 * @param array $aliases
7978 */
80 - function __construct( $serviceName, array $aliases = array() ) {
 79+ public function __construct( $serviceName, array $aliases = array() ) {
8180 $this->serviceName = $serviceName;
8281 $this->aliases = $aliases;
8382 }
@@ -215,7 +214,7 @@
216215 *
217216 * @return array of string
218217 */
219 - protected function getResourceModules() {
 218+ public function getResourceModules() {
220219 return $this->resourceModules;
221220 }
222221
@@ -230,4 +229,13 @@
231230 $this->resourceModules = array_merge( $this->resourceModules, (array)$modules );
232231 }
233232
 233+ /**
 234+ * @see iMappingService::addDependency
 235+ *
 236+ * @since 0.6.3
 237+ */
 238+ public final function addDependency( $dependencyHtml ) {
 239+ $this->dependencies[] = $dependencyHtml;
 240+ }
 241+
234242 }
\ No newline at end of file
Index: branches/Maps0.8/includes/services/GoogleMaps3/Maps_GoogleMaps3.php
@@ -181,7 +181,7 @@
182182 *
183183 * @return array of string
184184 */
185 - protected function getResourceModules() {
 185+ public function getResourceModules() {
186186 return array_merge(
187187 parent::getResourceModules(),
188188 array( 'ext.maps.googlemaps3' )
Index: branches/Maps0.8/includes/services/YahooMaps/Maps_YahooMaps.php
@@ -114,28 +114,6 @@
115115 }
116116
117117 /**
118 - * @see MapsMappingService::createMarkersJs
119 - *
120 - * @since 0.6.5
121 - */
122 - public function createMarkersJs( array $markers ) {
123 - $markerItems = array();
124 -
125 - foreach ( $markers as $marker ) {
126 - $markerItems[] = MapsMapper::encodeJsVar( (object)array(
127 - 'lat' => $marker[0],
128 - 'lon' => $marker[1],
129 - 'title' => $marker[2],
130 - 'label' =>$marker[3],
131 - 'icon' => $marker[4]
132 - ) );
133 - }
134 -
135 - // Create a string containing the marker JS.
136 - return '[' . implode( ',', $markerItems ) . ']';
137 - }
138 -
139 - /**
140118 * @see MapsMappingService::getDependencies
141119 *
142120 * @return array
@@ -169,4 +147,5 @@
170148 return array( 'scale', 'type', 'pan', 'zoom', 'zoom-short', 'auto-zoom' );
171149 }
172150
173 -}
\ No newline at end of file
 151+}
 152+
\ No newline at end of file
Index: branches/Maps0.8/includes/services/OpenLayers/Maps_ParamOLLayers.php
@@ -90,7 +90,7 @@
9191
9292 $parameter->setValue( $layerDefs );
9393
94 - MapsMappingServices::getServiceInstance( 'openlayers' )->addResourceModules( $this->getModules( $layerNames ) );
 94+ MapsMappingServices::getServiceInstance( 'openlayers' )->addLayerDependencies( $this->getDependencies( $layerNames ) );
9595 }
9696
9797 /**
@@ -119,30 +119,4 @@
120120 return array_unique( $layerDependencies );
121121 }
122122
123 - /**
124 - * Returns the names of the resource modules for the provided layers.
125 - *
126 - * @since 0.7.3
127 - *
128 - * @param array $layerNames
129 - *
130 - * @return array
131 - */
132 - protected function getModules( array $layerNames ) {
133 - global $egMapsOLLayerModules, $egMapsOLAvailableLayers;
134 -
135 - $moduleNames = array();
136 -
137 - foreach ( $layerNames as $layerName ) {
138 - if ( array_key_exists( $layerName, $egMapsOLAvailableLayers ) // The layer must be defined in php
139 - && is_array( $egMapsOLAvailableLayers[$layerName] ) // The layer must be an array...
140 - && count( $egMapsOLAvailableLayers[$layerName] ) > 1 // ...with a second element...
141 - && array_key_exists( 'ext.maps.ol.' . $egMapsOLAvailableLayers[$layerName][1], $egMapsOLLayerModules ) ) { //...that is a dependency.
142 - $moduleNames[] = 'ext.maps.ol.' . $egMapsOLAvailableLayers[$layerName][1];
143 - }
144 - }
145 -
146 - return array_unique( $moduleNames );
147 - }
148 -
149123 }
\ No newline at end of file
Index: branches/Maps0.8/includes/services/OpenLayers/Maps_OpenLayers.php
@@ -48,8 +48,6 @@
4949 $params['layers']->setDoManipulationOfDefault( true );
5050 $params['layers']->addCriteria( new CriterionOLLayer() );
5151 $params['layers']->setDefault( $egMapsOLLayers );
52 -
53 - //$params['imagelayers'] = new ListParameter();
5452 }
5553
5654 /**
@@ -78,29 +76,6 @@
7977 }
8078
8179 /**
82 - * @see MapsMappingService::createMarkersJs
83 - *
84 - * @since 0.6.5
85 - */
86 - public function createMarkersJs( array $markers ) {
87 - $markerItems = array();
88 - $defaultGroup = wfMsg( 'maps-markers' );
89 -
90 - foreach ( $markers as $marker ) {
91 - $markerItems[] = MapsMapper::encodeJsVar( (object)array(
92 - 'lat' => $marker[0],
93 - 'lon' => $marker[1],
94 - 'title' => $marker[2],
95 - 'label' =>$marker[3],
96 - 'icon' => $marker[4]
97 - ) );
98 - }
99 -
100 - // Create a string containing the marker JS.
101 - return '[' . implode( ',', $markerItems ) . ']';
102 - }
103 -
104 - /**
10580 * Returns the names of all supported controls.
10681 * This data is a copy of the one used to actually translate the names
10782 * into the controls, since this resides client side, in OpenLayerFunctions.js.
@@ -157,7 +132,7 @@
158133 *
159134 * @return array of string
160135 */
161 - protected function getResourceModules() {
 136+ public function getResourceModules() {
162137 return array_merge(
163138 parent::getResourceModules(),
164139 array( 'ext.maps.openlayers' )
Index: branches/Maps0.8/includes/services/GoogleMaps/Maps_GoogleMaps.php
@@ -139,28 +139,6 @@
140140 }
141141
142142 /**
143 - * @see MapsMappingService::createMarkersJs
144 - *
145 - * @since 0.6.5
146 - */
147 - public function createMarkersJs( array $markers ) {
148 - $markerItems = array();
149 -
150 - foreach ( $markers as $marker ) {
151 - $markerItems[] = array(
152 - 'lat' => $marker[0],
153 - 'lon' => $marker[1],
154 - 'title' => $marker[2],
155 - 'label' =>$marker[3],
156 - 'icon' => $marker[4]
157 - );
158 - }
159 -
160 - // Return a string containing the marker JS.
161 - return json_encode( $markerItems );
162 - }
163 -
164 - /**
165143 * A list of mappings between supported map type values and their corresponding JS variable.
166144 *
167145 * http://code.google.com/apis/maps/documentation/reference.html#GMapType.G_NORMAL_MAP
@@ -333,7 +311,7 @@
334312 *
335313 * @return array of string
336314 */
337 - protected function getResourceModules() {
 315+ public function getResourceModules() {
338316 return array_merge(
339317 parent::getResourceModules(),
340318 array( 'ext.maps.googlemaps2' )
Index: branches/Maps0.8/includes/services/OSM/Maps_OSM.php
@@ -74,4 +74,4 @@
7575 );
7676 }
7777
78 -}
\ No newline at end of file
 78+}

Status & tagging log