r58227 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58226‎ | r58227 | r58228 >
Date:21:33, 27 October 2009
Author:ialex
Status:deferred
Tags:
Comment:
svn:eol-style native
Modified paths:
  • /trunk/extensions/Maps/OpenStreetMaps/Maps_OSM.php (modified) (history)
  • /trunk/extensions/Maps/OpenStreetMaps/Maps_OSMDispMap.php (modified) (history)
  • /trunk/extensions/Maps/OpenStreetMaps/Maps_OSMDispPoint.php (modified) (history)
  • /trunk/extensions/Maps/OpenStreetMaps/Maps_OSMUtils.php (modified) (history)
  • /trunk/extensions/Maps/OpenStreetMaps/OSMFunctions.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/OpenStreetMaps/Maps_OSMDispMap.php
@@ -1,76 +1,76 @@
2 -<?php
3 -
4 -/**
5 - * Class for handling the display_map parser function with OSM.
6 - *
7 - * @file Maps_OSMDispMap.php
8 - * @ingroup Maps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - die( 'Not an entry point.' );
15 -}
16 -
17 -class MapsOSMDispMap extends MapsBaseMap {
18 -
19 - public $serviceName = MapsOSMUtils::SERVICE_NAME;
20 -
21 - /**
22 - * @see MapsBaseMap::setMapSettings()
23 - *
24 - */
25 - protected function setMapSettings() {
26 - global $egMapsOSMZoom, $egMapsOSMPrefix;
27 -
28 - $this->defaultParams = MapsOSMUtils::getDefaultParams();
29 -
30 - $this->elementNamePrefix = $egMapsOSMPrefix;
31 - $this->defaultZoom = $egMapsOSMZoom;
32 - }
33 -
34 - /**
35 - * @see MapsBaseMap::doMapServiceLoad()
36 - *
37 - */
38 - protected function doMapServiceLoad() {
39 - global $egOSMMapsOnThisPage;
40 -
41 - MapsOSMUtils::addOSMDependencies($this->output);
42 - $egOSMMapsOnThisPage++;
43 -
44 - $this->elementNr = $egOSMMapsOnThisPage;
45 - }
46 -
47 - /**
48 - * @see MapsBaseMap::addSpecificMapHTML()
49 - *
50 - */
51 - public function addSpecificMapHTML() {
52 - global $wgJsMimeType;
53 -
54 - $this->output .= <<<EOT
55 - <script type='$wgJsMimeType'>slippymaps['$this->mapName'] = new slippymap_map('$this->mapName', {
56 - mode: 'osm-wm',
57 - layer: 'osm-like',
58 - locale: 'en',
59 - lat: $this->centre_lat,
60 - lon: $this->centre_lon,
61 - zoom: $this->zoom,
62 - width: $this->width,
63 - height: $this->height,
64 - marker: 0
65 - });</script>
66 -
67 - <!-- map div -->
68 - <div id='$this->mapName' class='map' style='width:{$this->width}px; height:{$this->height}px;'>
69 - <script type='$wgJsMimeType'>slippymaps['$this->mapName'].init();</script>
70 - <!-- /map div -->
71 - </div>
72 -EOT;
73 -
74 - }
75 -
76 -}
77 -
 2+<?php
 3+
 4+/**
 5+ * Class for handling the display_map parser function with OSM.
 6+ *
 7+ * @file Maps_OSMDispMap.php
 8+ * @ingroup Maps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+class MapsOSMDispMap extends MapsBaseMap {
 18+
 19+ public $serviceName = MapsOSMUtils::SERVICE_NAME;
 20+
 21+ /**
 22+ * @see MapsBaseMap::setMapSettings()
 23+ *
 24+ */
 25+ protected function setMapSettings() {
 26+ global $egMapsOSMZoom, $egMapsOSMPrefix;
 27+
 28+ $this->defaultParams = MapsOSMUtils::getDefaultParams();
 29+
 30+ $this->elementNamePrefix = $egMapsOSMPrefix;
 31+ $this->defaultZoom = $egMapsOSMZoom;
 32+ }
 33+
 34+ /**
 35+ * @see MapsBaseMap::doMapServiceLoad()
 36+ *
 37+ */
 38+ protected function doMapServiceLoad() {
 39+ global $egOSMMapsOnThisPage;
 40+
 41+ MapsOSMUtils::addOSMDependencies($this->output);
 42+ $egOSMMapsOnThisPage++;
 43+
 44+ $this->elementNr = $egOSMMapsOnThisPage;
 45+ }
 46+
 47+ /**
 48+ * @see MapsBaseMap::addSpecificMapHTML()
 49+ *
 50+ */
 51+ public function addSpecificMapHTML() {
 52+ global $wgJsMimeType;
 53+
 54+ $this->output .= <<<EOT
 55+ <script type='$wgJsMimeType'>slippymaps['$this->mapName'] = new slippymap_map('$this->mapName', {
 56+ mode: 'osm-wm',
 57+ layer: 'osm-like',
 58+ locale: 'en',
 59+ lat: $this->centre_lat,
 60+ lon: $this->centre_lon,
 61+ zoom: $this->zoom,
 62+ width: $this->width,
 63+ height: $this->height,
 64+ marker: 0
 65+ });</script>
 66+
 67+ <!-- map div -->
 68+ <div id='$this->mapName' class='map' style='width:{$this->width}px; height:{$this->height}px;'>
 69+ <script type='$wgJsMimeType'>slippymaps['$this->mapName'].init();</script>
 70+ <!-- /map div -->
 71+ </div>
 72+EOT;
 73+
 74+ }
 75+
 76+}
 77+
Property changes on: trunk/extensions/Maps/OpenStreetMaps/Maps_OSMDispMap.php
___________________________________________________________________
Name: svn:eol-style
7878 + native
Index: trunk/extensions/Maps/OpenStreetMaps/OSMFunctions.js
@@ -1,136 +1,136 @@
2 -/*
3 - * @file OSMFunctions.js
4 - * @ingroup Maps
5 - *
6 - * @author Harry Wood, Jens Frank, Grant Slater, Raymond Spekking, Jeroen De Dauw and others
7 - *
8 - * @description
9 - *
10 - * Javascript functions for OSM optimized Open Layers functionallity in Maps and it's extensions
11 - *
12 - * This defines what happens when <slippymap> tag is placed in the wikitext
13 - *
14 - * We show a map based on the lat/lon/zoom data passed in. This extension brings in
15 - * the OpenLayers javascript, to show a slippy map.
16 - *
17 - * Usage example:
18 - * <slippymap lat=51.485 lon=-0.15 z=11 w=300 h=200 layer=osmarender></slippymap>
19 - *
20 - * Tile images are not cached local to the wiki.
21 - * To acheive this (remove the OSM dependency) you might set up a squid proxy,
22 - * and modify the requests URLs here accordingly.
23 - *
24 - * This file should be placed in the mediawiki 'extensions' directory
25 - * ...and then it needs to be 'included' within LocalSettings.php
26 - *
27 - * This program is free software; you can redistribute it and/or modify
28 - * it under the terms of the GNU General Public License as published by
29 - * the Free Software Foundation; either version 2 of the License, or
30 - * (at your option) any later version.
31 - *
32 - * This program is distributed in the hope that it will be useful,
33 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
34 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 - * GNU General Public License for more details.
36 - *
37 - * You should have received a copy of the GNU General Public License
38 - * along with this program; if not, write to the Free Software
39 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
40 - *
41 - */
42 -
43 -var slippymaps = new Array();
44 -var mapId = 0;
45 -var layer = null;
46 -
47 -if (false) { // wgSlippyMapSlippyByDefault
48 - addOnloadHook(slippymap_init);
49 -}
50 -
51 -function slippymap_init() {
52 - for(keyName in slippymaps) {
53 - slippymaps[keyName].init();
54 - }
55 -}
56 -
57 -function slippymap_map(mapId, mapParams) {
58 - var self = this;
59 - this.mapId = mapId;
60 -
61 - for (key in mapParams)
62 - this[key] = mapParams[key];
63 -
64 - /*
65 - var buttonsPanel = new OpenLayers.Control.Panel( { displayClass: "buttonsPanel" } );
66 - buttonsPanel.addControls([ new OpenLayers.Control.Button({
67 - title: wgSlippyMapButtonCode,
68 - displayClass: "getWikiCodeButton",
69 - trigger: function() { self.getWikicode(); }
70 - }),
71 - new OpenLayers.Control.Button({
72 - title: wgSlippyMapResetview,
73 - displayClass: "resetButton",
74 - trigger: function() { self.resetPosition(); }
75 - })
76 - ]);
77 - */
78 -
79 - this.mapOptions = { controls: [ new OpenLayers.Control.Navigation(),
80 - new OpenLayers.Control.ArgParser(),
81 - new OpenLayers.Control.Attribution(),
82 - /* buttonsPanel */ ]
83 - };
84 -
85 - /* Add the zoom bar control, except if the map is only little */
86 - if (this.height > 320)
87 - this.mapOptions.controls.push(new OpenLayers.Control.PanZoomBar());
88 - else if (this.height > 140)
89 - this.mapOptions.controls.push(new OpenLayers.Control.PanZoom());
90 -}
91 -
92 -slippymap_map.prototype.init = function() {
93 - /* Swap out against the preview image */
94 - var previewImage = document.getElementById('mapPreview' + this.mapId);
95 - if (previewImage)
96 - previewImage.style.display = 'none';
97 -
98 - this.map = this.osm_create(this.mapId, this.lon, this.lat, this.zoom);
99 -
100 - if (this.marker) {
101 - var markers = new OpenLayers.Layer.Markers( "Markers" );
102 - this.map.addLayer(markers);
103 - var icon = OpenLayers.Marker.defaultIcon();
104 - markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(this.lon, this.lat).transform(new OpenLayers.Projection('EPSG:4326'), this.map.getProjectionObject()), icon));
105 - }
106 -}
107 -
108 -slippymap_map.prototype.osm_create = function(mapId, lon, lat, zoom) {
109 - var osmLayer;
110 - var map = new OpenLayers.Map(mapId, this.mapOptions /* all provided for by OSM.js */);
111 -
112 - if (this.layer == 'osm-like') {
113 - osmLayer = new OpenLayers.Layer.OSM("meh", 'http://cassini.toolserver.org/tiles/osm-like/' + this.locale + '/${z}/${x}/${y}.png');
114 - }
115 -
116 - map.addLayers([osmLayer]);
117 - map.setCenter(new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection('EPSG:4326'), map.getProjectionObject()), zoom);
118 - return map;
119 -}
120 -
121 -slippymap_map.prototype.resetPosition = function() {
122 - this.map.setCenter(new OpenLayers.LonLat(this.lon, this.lat).transform(new OpenLayers.Projection('EPSG:4326'), this.map.getProjectionObject()), this.zoom);
123 -}
124 -
125 -slippymap_map.prototype.getWikicode = function() {
126 - LL = this.map.getCenter().transform(this.map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326"));
127 - Z = this.map.getZoom();
128 - size = this.map.getSize();
129 -
130 - prompt(
131 - wgSlippyMapCode,
132 - "<slippymap lat=" + LL.lat + " lon=" + LL.lon + " zoom=" + Z + " width=" + size.w + " height=" + size.h + " mode=" + this.mode + " layer=" + this.layer + (this.marker == 0 ? "" : " marker=" + this.marker) + " />"
133 - );
134 -}
135 -
136 -
137 -
 2+/*
 3+ * @file OSMFunctions.js
 4+ * @ingroup Maps
 5+ *
 6+ * @author Harry Wood, Jens Frank, Grant Slater, Raymond Spekking, Jeroen De Dauw and others
 7+ *
 8+ * @description
 9+ *
 10+ * Javascript functions for OSM optimized Open Layers functionallity in Maps and it's extensions
 11+ *
 12+ * This defines what happens when <slippymap> tag is placed in the wikitext
 13+ *
 14+ * We show a map based on the lat/lon/zoom data passed in. This extension brings in
 15+ * the OpenLayers javascript, to show a slippy map.
 16+ *
 17+ * Usage example:
 18+ * <slippymap lat=51.485 lon=-0.15 z=11 w=300 h=200 layer=osmarender></slippymap>
 19+ *
 20+ * Tile images are not cached local to the wiki.
 21+ * To acheive this (remove the OSM dependency) you might set up a squid proxy,
 22+ * and modify the requests URLs here accordingly.
 23+ *
 24+ * This file should be placed in the mediawiki 'extensions' directory
 25+ * ...and then it needs to be 'included' within LocalSettings.php
 26+ *
 27+ * This program is free software; you can redistribute it and/or modify
 28+ * it under the terms of the GNU General Public License as published by
 29+ * the Free Software Foundation; either version 2 of the License, or
 30+ * (at your option) any later version.
 31+ *
 32+ * This program is distributed in the hope that it will be useful,
 33+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 34+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 35+ * GNU General Public License for more details.
 36+ *
 37+ * You should have received a copy of the GNU General Public License
 38+ * along with this program; if not, write to the Free Software
 39+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 40+ *
 41+ */
 42+
 43+var slippymaps = new Array();
 44+var mapId = 0;
 45+var layer = null;
 46+
 47+if (false) { // wgSlippyMapSlippyByDefault
 48+ addOnloadHook(slippymap_init);
 49+}
 50+
 51+function slippymap_init() {
 52+ for(keyName in slippymaps) {
 53+ slippymaps[keyName].init();
 54+ }
 55+}
 56+
 57+function slippymap_map(mapId, mapParams) {
 58+ var self = this;
 59+ this.mapId = mapId;
 60+
 61+ for (key in mapParams)
 62+ this[key] = mapParams[key];
 63+
 64+ /*
 65+ var buttonsPanel = new OpenLayers.Control.Panel( { displayClass: "buttonsPanel" } );
 66+ buttonsPanel.addControls([ new OpenLayers.Control.Button({
 67+ title: wgSlippyMapButtonCode,
 68+ displayClass: "getWikiCodeButton",
 69+ trigger: function() { self.getWikicode(); }
 70+ }),
 71+ new OpenLayers.Control.Button({
 72+ title: wgSlippyMapResetview,
 73+ displayClass: "resetButton",
 74+ trigger: function() { self.resetPosition(); }
 75+ })
 76+ ]);
 77+ */
 78+
 79+ this.mapOptions = { controls: [ new OpenLayers.Control.Navigation(),
 80+ new OpenLayers.Control.ArgParser(),
 81+ new OpenLayers.Control.Attribution(),
 82+ /* buttonsPanel */ ]
 83+ };
 84+
 85+ /* Add the zoom bar control, except if the map is only little */
 86+ if (this.height > 320)
 87+ this.mapOptions.controls.push(new OpenLayers.Control.PanZoomBar());
 88+ else if (this.height > 140)
 89+ this.mapOptions.controls.push(new OpenLayers.Control.PanZoom());
 90+}
 91+
 92+slippymap_map.prototype.init = function() {
 93+ /* Swap out against the preview image */
 94+ var previewImage = document.getElementById('mapPreview' + this.mapId);
 95+ if (previewImage)
 96+ previewImage.style.display = 'none';
 97+
 98+ this.map = this.osm_create(this.mapId, this.lon, this.lat, this.zoom);
 99+
 100+ if (this.marker) {
 101+ var markers = new OpenLayers.Layer.Markers( "Markers" );
 102+ this.map.addLayer(markers);
 103+ var icon = OpenLayers.Marker.defaultIcon();
 104+ markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(this.lon, this.lat).transform(new OpenLayers.Projection('EPSG:4326'), this.map.getProjectionObject()), icon));
 105+ }
 106+}
 107+
 108+slippymap_map.prototype.osm_create = function(mapId, lon, lat, zoom) {
 109+ var osmLayer;
 110+ var map = new OpenLayers.Map(mapId, this.mapOptions /* all provided for by OSM.js */);
 111+
 112+ if (this.layer == 'osm-like') {
 113+ osmLayer = new OpenLayers.Layer.OSM("meh", 'http://cassini.toolserver.org/tiles/osm-like/' + this.locale + '/${z}/${x}/${y}.png');
 114+ }
 115+
 116+ map.addLayers([osmLayer]);
 117+ map.setCenter(new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection('EPSG:4326'), map.getProjectionObject()), zoom);
 118+ return map;
 119+}
 120+
 121+slippymap_map.prototype.resetPosition = function() {
 122+ this.map.setCenter(new OpenLayers.LonLat(this.lon, this.lat).transform(new OpenLayers.Projection('EPSG:4326'), this.map.getProjectionObject()), this.zoom);
 123+}
 124+
 125+slippymap_map.prototype.getWikicode = function() {
 126+ LL = this.map.getCenter().transform(this.map.getProjectionObject(), new OpenLayers.Projection("EPSG:4326"));
 127+ Z = this.map.getZoom();
 128+ size = this.map.getSize();
 129+
 130+ prompt(
 131+ wgSlippyMapCode,
 132+ "<slippymap lat=" + LL.lat + " lon=" + LL.lon + " zoom=" + Z + " width=" + size.w + " height=" + size.h + " mode=" + this.mode + " layer=" + this.layer + (this.marker == 0 ? "" : " marker=" + this.marker) + " />"
 133+ );
 134+}
 135+
 136+
 137+
Property changes on: trunk/extensions/Maps/OpenStreetMaps/OSMFunctions.js
___________________________________________________________________
Name: svn:eol-style
138138 + native
Index: trunk/extensions/Maps/OpenStreetMaps/Maps_OSM.php
@@ -1,23 +1,23 @@
2 -<?php
3 -
4 -/**
5 - * This file holds the general information for the OSM optimized OpenLayers service
6 - *
7 - * @file Maps_OSM.php
8 - * @ingroup Maps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -$egMapsServices['osm'] = array(
14 - 'pf' => array(
15 - 'display_point' => array('class' => 'MapsOSMDispPoint', 'file' => 'OpenStreetMaps/Maps_OSMDispPoint.php', 'local' => true),
16 - 'display_map' => array('class' => 'MapsOSMDispMap', 'file' => 'OpenStreetMaps/Maps_OSMDispMap.php', 'local' => true),
17 - ),
18 - 'classes' => array(
19 - array('class' => 'MapsOSMUtils', 'file' => 'OpenStreetMaps/Maps_OSMUtils.php', 'local' => true)
20 - ),
21 - 'aliases' => array('openstreetmaps'),
22 - 'parameters' => array(
23 - )
 2+<?php
 3+
 4+/**
 5+ * This file holds the general information for the OSM optimized OpenLayers service
 6+ *
 7+ * @file Maps_OSM.php
 8+ * @ingroup Maps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+$egMapsServices['osm'] = array(
 14+ 'pf' => array(
 15+ 'display_point' => array('class' => 'MapsOSMDispPoint', 'file' => 'OpenStreetMaps/Maps_OSMDispPoint.php', 'local' => true),
 16+ 'display_map' => array('class' => 'MapsOSMDispMap', 'file' => 'OpenStreetMaps/Maps_OSMDispMap.php', 'local' => true),
 17+ ),
 18+ 'classes' => array(
 19+ array('class' => 'MapsOSMUtils', 'file' => 'OpenStreetMaps/Maps_OSMUtils.php', 'local' => true)
 20+ ),
 21+ 'aliases' => array('openstreetmaps'),
 22+ 'parameters' => array(
 23+ )
2424 );
\ No newline at end of file
Property changes on: trunk/extensions/Maps/OpenStreetMaps/Maps_OSM.php
___________________________________________________________________
Name: svn:eol-style
2525 + native
Index: trunk/extensions/Maps/OpenStreetMaps/Maps_OSMUtils.php
@@ -1,109 +1,109 @@
2 -<?php
3 -
4 -/**
5 - * A class that holds static helper functions for OSM.
6 - *
7 - * @file Maps_OSMUtils.php
8 - * @ingroup Maps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - die( 'Not an entry point.' );
15 -}
16 -
17 -final class MapsOSMUtils {
18 -
19 - const SERVICE_NAME = 'osm';
20 -
21 - private static $layers = array(
22 - 'osm-wm' => array(
23 - // First layer = default
24 - 'layers' => array( 'osm-like' ),
25 -
26 - // Default "zoom=" argument
27 - 'defaultZoomLevel' => 14,
28 -
29 - 'static_rendering' => array(
30 - 'type' => 'SlippyMapExportCgiBin',
31 - 'options' => array(
32 - 'base_url' => 'http://cassini.toolserver.org/cgi-bin/export',
33 -
34 - 'format' => 'png',
35 - 'numZoomLevels' => 19,
36 - 'maxResolution' => 156543.0339,
37 - 'unit' => 'm',
38 - 'sphericalMercator' => true,
39 -
40 - // More GET arguments
41 - 'get_args' => array(
42 - // Will use $wgContLang->getCode()
43 - 'locale' => true,
44 - 'maptype' => 'osm-like'
45 - ),
46 - ),
47 - ),
48 - ),
49 - 'osm' => array(
50 - // First layer = default
51 - 'layers' => array( 'mapnik', 'osmarender', 'maplint', 'cycle' ),
52 -
53 - // Default "zoom=" argument
54 - 'defaultZoomLevel' => 14,
55 -
56 - 'static_rendering' => array(
57 - 'type' => 'SlippyMapExportCgiBin',
58 - 'options' => array(
59 - 'base_url' => 'http://tile.openstreetmap.org/cgi-bin/export',
60 -
61 - 'format' => 'png',
62 - 'numZoomLevels' => 19,
63 - 'maxResolution' => 156543.0339,
64 - 'unit' => 'm',
65 - 'sphericalMercator' => true
66 - ),
67 - ),
68 - ),
69 - 'satellite' => array(
70 - 'layers' => array( 'urban', 'landsat', 'bluemarble' ),
71 - 'defaultZoomLevel' => 14,
72 - 'static_rendering' => null,
73 - ),
74 - );
75 -
76 - /**
77 - * Retuns an array holding the default parameters and their values.
78 - *
79 - * @return array
80 - */
81 - public static function getDefaultParams() {
82 - return array
83 - (
84 - 'layers' => array(),
85 - 'baselayer' => ''
86 - );
87 - }
88 -
89 - /**
90 - * If this is the first open layers map on the page, load the API, styles and extra JS functions
91 - *
92 - * @param string $output
93 - */
94 - public static function addOSMDependencies(&$output) {
95 - global $wgJsMimeType, $wgStyleVersion;
96 - global $egOSMMapsOnThisPage, $egMapsScriptPath;
97 -
98 - if (empty($egOSMMapsOnThisPage)) {
99 - $egOSMMapsOnThisPage = 0;
100 -
101 - $output .="<link rel='stylesheet' href='$egMapsScriptPath/OpenLayers/OpenLayers/theme/default/style.css' type='text/css' />
102 - <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenLayers/OpenLayers/OpenLayers.js'></script>
103 - <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenStreetMaps/OSMFunctions.js?$wgStyleVersion'></script>
104 - <script type='$wgJsMimeType'>slippymaps = Array();</script>\n";
105 - }
106 - }
107 -
108 -}
109 -
 2+<?php
 3+
 4+/**
 5+ * A class that holds static helper functions for OSM.
 6+ *
 7+ * @file Maps_OSMUtils.php
 8+ * @ingroup Maps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+final class MapsOSMUtils {
 18+
 19+ const SERVICE_NAME = 'osm';
 20+
 21+ private static $layers = array(
 22+ 'osm-wm' => array(
 23+ // First layer = default
 24+ 'layers' => array( 'osm-like' ),
 25+
 26+ // Default "zoom=" argument
 27+ 'defaultZoomLevel' => 14,
 28+
 29+ 'static_rendering' => array(
 30+ 'type' => 'SlippyMapExportCgiBin',
 31+ 'options' => array(
 32+ 'base_url' => 'http://cassini.toolserver.org/cgi-bin/export',
 33+
 34+ 'format' => 'png',
 35+ 'numZoomLevels' => 19,
 36+ 'maxResolution' => 156543.0339,
 37+ 'unit' => 'm',
 38+ 'sphericalMercator' => true,
 39+
 40+ // More GET arguments
 41+ 'get_args' => array(
 42+ // Will use $wgContLang->getCode()
 43+ 'locale' => true,
 44+ 'maptype' => 'osm-like'
 45+ ),
 46+ ),
 47+ ),
 48+ ),
 49+ 'osm' => array(
 50+ // First layer = default
 51+ 'layers' => array( 'mapnik', 'osmarender', 'maplint', 'cycle' ),
 52+
 53+ // Default "zoom=" argument
 54+ 'defaultZoomLevel' => 14,
 55+
 56+ 'static_rendering' => array(
 57+ 'type' => 'SlippyMapExportCgiBin',
 58+ 'options' => array(
 59+ 'base_url' => 'http://tile.openstreetmap.org/cgi-bin/export',
 60+
 61+ 'format' => 'png',
 62+ 'numZoomLevels' => 19,
 63+ 'maxResolution' => 156543.0339,
 64+ 'unit' => 'm',
 65+ 'sphericalMercator' => true
 66+ ),
 67+ ),
 68+ ),
 69+ 'satellite' => array(
 70+ 'layers' => array( 'urban', 'landsat', 'bluemarble' ),
 71+ 'defaultZoomLevel' => 14,
 72+ 'static_rendering' => null,
 73+ ),
 74+ );
 75+
 76+ /**
 77+ * Retuns an array holding the default parameters and their values.
 78+ *
 79+ * @return array
 80+ */
 81+ public static function getDefaultParams() {
 82+ return array
 83+ (
 84+ 'layers' => array(),
 85+ 'baselayer' => ''
 86+ );
 87+ }
 88+
 89+ /**
 90+ * If this is the first open layers map on the page, load the API, styles and extra JS functions
 91+ *
 92+ * @param string $output
 93+ */
 94+ public static function addOSMDependencies(&$output) {
 95+ global $wgJsMimeType, $wgStyleVersion;
 96+ global $egOSMMapsOnThisPage, $egMapsScriptPath;
 97+
 98+ if (empty($egOSMMapsOnThisPage)) {
 99+ $egOSMMapsOnThisPage = 0;
 100+
 101+ $output .="<link rel='stylesheet' href='$egMapsScriptPath/OpenLayers/OpenLayers/theme/default/style.css' type='text/css' />
 102+ <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenLayers/OpenLayers/OpenLayers.js'></script>
 103+ <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenStreetMaps/OSMFunctions.js?$wgStyleVersion'></script>
 104+ <script type='$wgJsMimeType'>slippymaps = Array();</script>\n";
 105+ }
 106+ }
 107+
 108+}
 109+
110110 ?>
\ No newline at end of file
Property changes on: trunk/extensions/Maps/OpenStreetMaps/Maps_OSMUtils.php
___________________________________________________________________
Name: svn:eol-style
111111 + native
Index: trunk/extensions/Maps/OpenStreetMaps/Maps_OSMDispPoint.php
@@ -1,80 +1,80 @@
2 -<?php
3 -
4 -/**
5 - * Class for handling the display_point(s) parser functions with OSM.
6 - *
7 - * @file Maps_OSMDispPoint.php
8 - * @ingroup Maps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - die( 'Not an entry point.' );
15 -}
16 -
17 -class MapsOSMDispPoint extends MapsBasePointMap {
18 -
19 - public $serviceName = MapsOSMUtils::SERVICE_NAME;
20 -
21 - /**
22 - * @see MapsBaseMap::setMapSettings()
23 - *
24 - */
25 - protected function setMapSettings() {
26 - global $egMapsOSMZoom, $egMapsOSMPrefix;
27 -
28 - $this->defaultParams = MapsOSMUtils::getDefaultParams();
29 -
30 - $this->elementNamePrefix = $egMapsOSMPrefix;
31 - $this->defaultZoom = $egMapsOSMZoom;
32 - }
33 -
34 - /**
35 - * @see MapsBaseMap::doMapServiceLoad()
36 - *
37 - */
38 - protected function doMapServiceLoad() {
39 - global $egOSMMapsOnThisPage;
40 -
41 - MapsOSMUtils::addOSMDependencies($this->output);
42 - $egOSMMapsOnThisPage++;
43 -
44 - $this->elementNr = $egOSMMapsOnThisPage;
45 - }
46 -
47 - /**
48 - * @see MapsBaseMap::addSpecificMapHTML()
49 - *
50 - */
51 - public function addSpecificMapHTML() {
52 - global $wgJsMimeType;
53 -
54 - $markerItems = array();
55 -
56 - // TODO: Refactor up
57 - foreach ($this->markerData as $markerData) {
58 - $lat = $markerData['lat'];
59 - $lon = $markerData['lon'];
60 -
61 - $title = array_key_exists('title', $markerData) ? $markerData['title'] : $this->title;
62 - $label = array_key_exists('label', $markerData) ? $markerData['label'] : $this->label;
63 -
64 - $title = str_replace("'", "\'", $title);
65 - $label = str_replace("'", "\'", $label);
66 -
67 - $icon = array_key_exists('icon', $markerData) ? $markerData['icon'] : '';
68 - $markerItems[] = "getOLMarkerData($lon, $lat, '$title', '$label', '$icon')";
69 - }
70 -
71 - $markersString = implode(',', $markerItems);
72 -
73 - $this->output .= "<div id='$this->mapName' style='width: {$this->width}px; height: {$this->height}px; background-color: #cccccc;'></div>
74 - <script type='$wgJsMimeType'> /*<![CDATA[*/
75 - addOnloadHook(
76 - initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$controlItems],[$markersString])
77 - );
78 - /*]]>*/ </script>";
79 - }
80 -
 2+<?php
 3+
 4+/**
 5+ * Class for handling the display_point(s) parser functions with OSM.
 6+ *
 7+ * @file Maps_OSMDispPoint.php
 8+ * @ingroup Maps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+class MapsOSMDispPoint extends MapsBasePointMap {
 18+
 19+ public $serviceName = MapsOSMUtils::SERVICE_NAME;
 20+
 21+ /**
 22+ * @see MapsBaseMap::setMapSettings()
 23+ *
 24+ */
 25+ protected function setMapSettings() {
 26+ global $egMapsOSMZoom, $egMapsOSMPrefix;
 27+
 28+ $this->defaultParams = MapsOSMUtils::getDefaultParams();
 29+
 30+ $this->elementNamePrefix = $egMapsOSMPrefix;
 31+ $this->defaultZoom = $egMapsOSMZoom;
 32+ }
 33+
 34+ /**
 35+ * @see MapsBaseMap::doMapServiceLoad()
 36+ *
 37+ */
 38+ protected function doMapServiceLoad() {
 39+ global $egOSMMapsOnThisPage;
 40+
 41+ MapsOSMUtils::addOSMDependencies($this->output);
 42+ $egOSMMapsOnThisPage++;
 43+
 44+ $this->elementNr = $egOSMMapsOnThisPage;
 45+ }
 46+
 47+ /**
 48+ * @see MapsBaseMap::addSpecificMapHTML()
 49+ *
 50+ */
 51+ public function addSpecificMapHTML() {
 52+ global $wgJsMimeType;
 53+
 54+ $markerItems = array();
 55+
 56+ // TODO: Refactor up
 57+ foreach ($this->markerData as $markerData) {
 58+ $lat = $markerData['lat'];
 59+ $lon = $markerData['lon'];
 60+
 61+ $title = array_key_exists('title', $markerData) ? $markerData['title'] : $this->title;
 62+ $label = array_key_exists('label', $markerData) ? $markerData['label'] : $this->label;
 63+
 64+ $title = str_replace("'", "\'", $title);
 65+ $label = str_replace("'", "\'", $label);
 66+
 67+ $icon = array_key_exists('icon', $markerData) ? $markerData['icon'] : '';
 68+ $markerItems[] = "getOLMarkerData($lon, $lat, '$title', '$label', '$icon')";
 69+ }
 70+
 71+ $markersString = implode(',', $markerItems);
 72+
 73+ $this->output .= "<div id='$this->mapName' style='width: {$this->width}px; height: {$this->height}px; background-color: #cccccc;'></div>
 74+ <script type='$wgJsMimeType'> /*<![CDATA[*/
 75+ addOnloadHook(
 76+ initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$controlItems],[$markersString])
 77+ );
 78+ /*]]>*/ </script>";
 79+ }
 80+
8181 }
\ No newline at end of file
Property changes on: trunk/extensions/Maps/OpenStreetMaps/Maps_OSMDispPoint.php
___________________________________________________________________
Name: svn:eol-style
8282 + native

Status & tagging log