r75355 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75354‎ | r75355 | r75356 >
Date:15:13, 25 October 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.7.2 - added KML layer support
Modified paths:
  • /trunk/extensions/Maps/Maps.php (modified) (history)
  • /trunk/extensions/Maps/Maps_Settings.php (modified) (history)
  • /trunk/extensions/Maps/RELEASE-NOTES (modified) (history)
  • /trunk/extensions/Maps/includes/Maps_ImageLayer.php (deleted) (history)
  • /trunk/extensions/Maps/includes/layers (added) (history)
  • /trunk/extensions/Maps/includes/layers/Maps_ImageLayer.php (added) (history)
  • /trunk/extensions/Maps/includes/layers/Maps_KMLLayer.php (added) (history)

Diff [purge]

Index: trunk/extensions/Maps/Maps.php
@@ -61,7 +61,6 @@
6262 $wgAutoloadClasses['MapsGeoFunctions'] = $incDir . 'Maps_GeoFunctions.php';
6363 $wgAutoloadClasses['MapsGeocoders'] = $incDir . 'Maps_Geocoders.php';
6464 $wgAutoloadClasses['MapsGeocoder'] = $incDir . 'Maps_Geocoder.php';
65 - $wgAutoloadClasses['MapsImageLayer'] = $incDir . 'Maps_ImageLayer.php';
6665 $wgAutoloadClasses['MapsLayer'] = $incDir . 'Maps_Layer.php';
6766 $wgAutoloadClasses['MapsLayerPage'] = $incDir . 'Maps_LayerPage.php';
6867 $wgAutoloadClasses['MapsLayers'] = $incDir . 'Maps_Layers.php';
@@ -89,6 +88,11 @@
9089 $wgAutoloadClasses['MapsGoogleGeocoder'] = $geoDir . 'Maps_GoogleGeocoder.php';
9190 $wgAutoloadClasses['MapsYahooGeocoder'] = $geoDir . 'Maps_YahooGeocoder.php';
9291
 92+ // Autoload the "includes/layers/" classes.
 93+ $lyrDir = $incDir . 'layers/';
 94+ $wgAutoloadClasses['MapsImageLayer'] = $lyrDir . 'Maps_ImageLayer.php';
 95+ $wgAutoloadClasses['MapsKMLLayer'] = $lyrDir . 'Maps_KMLLayer.php';
 96+
9397 // Autoload the "includes/manipulations/" classes.
9498 $manDir = $incDir . 'manipulations/';
9599 $wgAutoloadClasses['MapsParamCoordSet'] = $manDir . 'Maps_ParamCoordSet.php';
@@ -136,9 +140,6 @@
137141 // Since 0.7.1
138142 $wgHooks['ArticleFromTitle'][] = 'MapsHooks::onArticleFromTitle';
139143
140 - // Since 0.7.2
141 - $wgHooks['MappingLayersInitialization'][] = 'MapsImageLayer::register';
142 -
143144 $egMapsFeatures = array();
144145
145146 // Include the settings file.
Index: trunk/extensions/Maps/Maps_Settings.php
@@ -66,8 +66,16 @@
6767 # Registration of the Yahoo! Geocoding service geocoder.
6868 $wgHooks['GeocoderFirstCallInit'][] = 'MapsYahooGeocoder::register';
6969
 70+ # Layers
 71+
 72+ # Registration of the image layer type.
 73+ $wgHooks['MappingLayersInitialization'][] = 'MapsImageLayer::register';
7074
 75+ # Registration of the KML layer type.
 76+ $wgHooks['MappingLayersInitialization'][] = 'MapsKMLLayer::register';
 77+
7178
 79+
7280 # Mapping services configuration
7381 # Note: You can not use aliases in the settings. Use the main service names.
7482
Index: trunk/extensions/Maps/RELEASE-NOTES
@@ -8,8 +8,12 @@
99
1010
1111 === Maps 0.7.2 ===
12 -(2010-10-2x)
 12+(2010-10-28)
1313
 14+==== Internal improvements ====
 15+
 16+* Extended the layer handling to support different types of layers, each of which can be supported by one or more mapping services.
 17+
1418 ==== Bug fixes ====
1519
1620 * Fixed incompatibility with MW 1.15.x.
@@ -18,6 +22,8 @@
1923
2024 * Fixed small layout issue with pop-ups in Google Maps.
2125
 26+* Fixed incorrect error on non-existing pages in the Layer namespace.
 27+
2228 === Maps 0.7.1 ===
2329 (2010-10-20)
2430
Index: trunk/extensions/Maps/includes/Maps_ImageLayer.php
@@ -1,82 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * Class for describing image layers.
6 - *
7 - * @since 0.7.2
8 - *
9 - * @file Maps_ImageLayer.php
10 - * @ingroup Maps
11 - *
12 - * @author Jeroen De Dauw
13 - */
14 -class MapsImageLayer extends MapsLayer {
15 -
16 - /**
17 - * Registeres the layer.
18 - *
19 - * @since 0.7.2
20 - */
21 - public static function register() {
22 - MapsLayers::registerLayer( 'image', __CLASS__, 'openlayers' );
23 - return true;
24 - }
25 -
26 - /**
27 - * @see MapsLayer::getParameterDefinitions
28 - *
29 - * @since 0.7.2
30 - *
31 - * @return array
32 - */
33 - protected function getParameterDefinitions( array $params ) {
34 - $params[] = new Parameter( 'lowerbound', Parameter::TYPE_FLOAT );
35 - $params[] = new Parameter( 'upperbound', Parameter::TYPE_FLOAT );
36 - $params[] = new Parameter( 'leftbound', Parameter::TYPE_FLOAT );
37 - $params[] = new Parameter( 'rightbound', Parameter::TYPE_FLOAT );
38 - $params[] = new Parameter( 'width', Parameter::TYPE_FLOAT );
39 - $params[] = new Parameter( 'height', Parameter::TYPE_FLOAT );
40 -
41 - $params[] = new Parameter( 'zoomlevels', Parameter::TYPE_INTEGER, false );
42 -
43 - $params['label'] = new Parameter( 'label' );
44 -
45 - $params['source'] = new Parameter( 'source' );
46 - $params['source']->addCriteria( new CriterionIsImage() );
47 - $params['source']->addManipulations( new MapsParamImage() );
48 -
49 - return $params;
50 - }
51 -
52 - /**
53 - * @see MapsLayer::getJavaScriptDefinition
54 - *
55 - * @since 0.7.1
56 - *
57 - * @return string
58 - */
59 - public function getJavaScriptDefinition() {
60 - foreach ( $this->properties as $name => $value ) {
61 - ${ $name } = MapsMapper::encodeJsVar( $value );
62 - }
63 -
64 - $options = array( 'isImage' => true );
65 -
66 - if ( $this->properties !== false ) {
67 - $options['numZoomLevels'] = $zoomlevels;
68 - }
69 -
70 - $options = Xml::encodeJsVar( (object)$options );
71 -
72 - return <<<EOT
73 - new OpenLayers.Layer.Image(
74 - $label,
75 - $source,
76 - new OpenLayers.Bounds($leftbound, $lowerbound, $rightbound, $upperbound),
77 - new OpenLayers.Size($width, $height),
78 - {$options}
79 - )
80 -EOT;
81 - }
82 -
83 -}
\ No newline at end of file
Index: trunk/extensions/Maps/includes/layers/Maps_ImageLayer.php
@@ -0,0 +1,82 @@
 2+<?php
 3+
 4+/**
 5+ * Class for describing image layers.
 6+ *
 7+ * @since 0.7.2
 8+ *
 9+ * @file Maps_ImageLayer.php
 10+ * @ingroup Maps
 11+ *
 12+ * @author Jeroen De Dauw
 13+ */
 14+class MapsImageLayer extends MapsLayer {
 15+
 16+ /**
 17+ * Registeres the layer.
 18+ *
 19+ * @since 0.7.2
 20+ */
 21+ public static function register() {
 22+ MapsLayers::registerLayer( 'image', __CLASS__, 'openlayers' );
 23+ return true;
 24+ }
 25+
 26+ /**
 27+ * @see MapsLayer::getParameterDefinitions
 28+ *
 29+ * @since 0.7.2
 30+ *
 31+ * @return array
 32+ */
 33+ protected function getParameterDefinitions( array $params ) {
 34+ $params[] = new Parameter( 'lowerbound', Parameter::TYPE_FLOAT );
 35+ $params[] = new Parameter( 'upperbound', Parameter::TYPE_FLOAT );
 36+ $params[] = new Parameter( 'leftbound', Parameter::TYPE_FLOAT );
 37+ $params[] = new Parameter( 'rightbound', Parameter::TYPE_FLOAT );
 38+ $params[] = new Parameter( 'width', Parameter::TYPE_FLOAT );
 39+ $params[] = new Parameter( 'height', Parameter::TYPE_FLOAT );
 40+
 41+ $params[] = new Parameter( 'zoomlevels', Parameter::TYPE_INTEGER, false );
 42+
 43+ $params['label'] = new Parameter( 'label' );
 44+
 45+ $params['source'] = new Parameter( 'source' );
 46+ $params['source']->addCriteria( new CriterionIsImage() );
 47+ $params['source']->addManipulations( new MapsParamImage() );
 48+
 49+ return $params;
 50+ }
 51+
 52+ /**
 53+ * @see MapsLayer::getJavaScriptDefinition
 54+ *
 55+ * @since 0.7.1
 56+ *
 57+ * @return string
 58+ */
 59+ public function getJavaScriptDefinition() {
 60+ foreach ( $this->properties as $name => $value ) {
 61+ ${ $name } = MapsMapper::encodeJsVar( $value );
 62+ }
 63+
 64+ $options = array( 'isImage' => true );
 65+
 66+ if ( $zoomlevels !== false ) {
 67+ $options['numZoomLevels'] = $zoomlevels;
 68+ }
 69+
 70+ $options = Xml::encodeJsVar( (object)$options );
 71+
 72+ return <<<EOT
 73+ new OpenLayers.Layer.Image(
 74+ $label,
 75+ $source,
 76+ new OpenLayers.Bounds($leftbound, $lowerbound, $rightbound, $upperbound),
 77+ new OpenLayers.Size($width, $height),
 78+ {$options}
 79+ )
 80+EOT;
 81+ }
 82+
 83+}
\ No newline at end of file
Property changes on: trunk/extensions/Maps/includes/layers/Maps_ImageLayer.php
___________________________________________________________________
Added: svn:eol-style
184 + native
Index: trunk/extensions/Maps/includes/layers/Maps_KMLLayer.php
@@ -0,0 +1,76 @@
 2+<?php
 3+
 4+/**
 5+ * Class for describing KML layers.
 6+ *
 7+ * @since 0.7.2
 8+ *
 9+ * @file Maps_KMLLayer.php
 10+ * @ingroup Maps
 11+ *
 12+ * @author Jeroen De Dauw
 13+ */
 14+class MapsKMLLayer extends MapsLayer {
 15+
 16+ /**
 17+ * Registeres the layer.
 18+ *
 19+ * @since 0.7.2
 20+ */
 21+ public static function register() {
 22+ MapsLayers::registerLayer( 'kml', __CLASS__, 'openlayers' );
 23+ return true;
 24+ }
 25+
 26+ /**
 27+ * @see MapsLayer::getParameterDefinitions
 28+ *
 29+ * @since 0.7.2
 30+ *
 31+ * @return array
 32+ */
 33+ protected function getParameterDefinitions( array $params ) {
 34+ $params['label'] = new Parameter( 'label' );
 35+
 36+ $params['source'] = new Parameter( 'source' );
 37+ $params['source']->addCriteria( new CriterionIsImage() );
 38+ $params['source']->addManipulations( new MapsParamImage() );
 39+
 40+ $params[] = new Parameter( 'maxdepth', Parameter::TYPE_INTEGER, 2 );
 41+
 42+ return $params;
 43+ }
 44+
 45+ /**
 46+ * @see MapsLayer::getJavaScriptDefinition
 47+ *
 48+ * @since 0.7.1
 49+ *
 50+ * @return string
 51+ */
 52+ public function getJavaScriptDefinition() {
 53+ foreach ( $this->properties as $name => $value ) {
 54+ ${ $name } = MapsMapper::encodeJsVar( $value );
 55+ }
 56+
 57+ $options = array(
 58+ 'extractStyles' => true,
 59+ 'extractAttributes' => true,
 60+ 'maxDepth' => $maxdepth
 61+ );
 62+
 63+ $options = Xml::encodeJsVar( (object)$options );
 64+
 65+ return <<<EOT
 66+ new OpenLayers.Layer.GML(
 67+ $label,
 68+ $source,
 69+ {
 70+ format: OpenLayers.Format.KML,
 71+ formatOptions: {$options}
 72+ }
 73+ )
 74+EOT;
 75+ }
 76+
 77+}
\ No newline at end of file
Property changes on: trunk/extensions/Maps/includes/layers/Maps_KMLLayer.php
___________________________________________________________________
Added: svn:eol-style
178 + native

Status & tagging log