r64299 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64298‎ | r64299 | r64300 >
Date:19:09, 28 March 2010
Author:jeroendedauw
Status:deferred (Comments)
Tags:
Comment:
Changes for 0.6
* Changed handling of height and width parameters to allow using a %
* Rewrote map div and script output of all mapping services
* Added js min setting
Modified paths:
  • /trunk/extensions/Maps/GoogleMaps/GoogleMapFunctions.js (modified) (history)
  • /trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php (modified) (history)
  • /trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispMap.php (modified) (history)
  • /trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispPoint.php (modified) (history)
  • /trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3.php (modified) (history)
  • /trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispMap.php (modified) (history)
  • /trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispPoint.php (modified) (history)
  • /trunk/extensions/Maps/Maps.php (modified) (history)
  • /trunk/extensions/Maps/Maps_Mapper.php (modified) (history)
  • /trunk/extensions/Maps/Maps_Settings.php (modified) (history)
  • /trunk/extensions/Maps/Maps_Utils.php (modified) (history)
  • /trunk/extensions/Maps/OpenLayers/Maps_OpenLayers.php (modified) (history)
  • /trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispMap.php (modified) (history)
  • /trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispPoint.php (modified) (history)
  • /trunk/extensions/Maps/OpenStreetMap/Maps_OSM.php (modified) (history)
  • /trunk/extensions/Maps/OpenStreetMap/Maps_OSMDispMap.php (modified) (history)
  • /trunk/extensions/Maps/OpenStreetMap/Maps_OSMDispPoint.php (modified) (history)
  • /trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php (modified) (history)
  • /trunk/extensions/Maps/YahooMaps/Maps_YahooMaps.php (modified) (history)
  • /trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispMap.php (modified) (history)
  • /trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispPoint.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispPoint.php
@@ -58,28 +58,36 @@
5959 *
6060 */
6161 public function addSpecificMapHTML() {
62 - global $wgJsMimeType;
 62+ global $wgOut;
6363
64 - // TODO
65 - $this->output .= <<<EOT
66 -<div id="$this->mapName" style="width:{$this->width}px; height:{$this->height}px"></div>
67 -<script type="$wgJsMimeType"> /*<![CDATA[*/
 64+ $this->output .= Html::element(
 65+ 'div',
 66+ array(
 67+ 'id' => $this->mapName,
 68+ 'width' => $this->width,
 69+ 'height' => $this->height
 70+ ),
 71+ null
 72+ );
 73+
 74+ $wgOut->addInlineScript( <<<EOT
6875 addOnloadHook(
6976 function() {
70 - initGMap3("$this->mapName", {
71 - zoom: $this->zoom,
72 - lat: $this->centre_lat,
73 - lon: $this->centre_lon,
74 - types: [],
75 - mapTypeId: $this->type
76 - },
77 - [$this->markerString]
78 - );
 77+ initGMap3(
 78+ "$this->mapName",
 79+ {
 80+ zoom: $this->zoom,
 81+ lat: $this->centre_lat,
 82+ lon: $this->centre_lon,
 83+ types: [],
 84+ mapTypeId: $this->type
 85+ },
 86+ [$this->markerString]
 87+ );
7988 }
8089 );
81 -/*]]>*/ </script>
82 -EOT;
83 -
 90+EOT
 91+ );
8492 }
8593
8694 }
Index: trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispMap.php
@@ -56,27 +56,36 @@
5757 *
5858 */
5959 public function addSpecificMapHTML() {
60 - global $wgJsMimeType;
 60+ global $wgOut;
6161
62 - $this->output .= <<<EOT
63 -<div id="$this->mapName" style="width:{$this->width}px; height:{$this->height}px"></div>
64 -<script type="$wgJsMimeType"> /*<![CDATA[*/
 62+ $this->output .= Html::element(
 63+ 'div',
 64+ array(
 65+ 'id' => $this->mapName,
 66+ 'width' => $this->width,
 67+ 'height' => $this->height
 68+ ),
 69+ null
 70+ );
 71+
 72+ $wgOut->addInlineScript( <<<EOT
6573 addOnloadHook(
6674 function() {
67 - initGMap3("$this->mapName", {
68 - zoom: $this->zoom,
69 - lat: $this->centre_lat,
70 - lon: $this->centre_lon,
71 - types: [],
72 - mapTypeId: $this->type
73 - },
74 - []
75 - );
 75+ initGMap3(
 76+ "$this->mapName",
 77+ {
 78+ zoom: $this->zoom,
 79+ lat: $this->centre_lat,
 80+ lon: $this->centre_lon,
 81+ types: [],
 82+ mapTypeId: $this->type
 83+ },
 84+ []
 85+ );
7686 }
7787 );
78 -/*]]>*/ </script>
79 -EOT;
80 -
 88+EOT
 89+ );
8190 }
8291
8392 }
Index: trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3.php
@@ -125,12 +125,12 @@
126126 */
127127 public static function addGMap3Dependencies( &$output ) {
128128 global $wgJsMimeType, $wgLang;
129 - global $egMapsScriptPath, $egGMaps3OnThisPage, $egMapsStyleVersion;
 129+ global $egMapsScriptPath, $egGMaps3OnThisPage, $egMapsStyleVersion, $egMapsJsExt;
130130
131131 if ( empty( $egGMaps3OnThisPage ) ) {
132132 $egGMaps3OnThisPage = 0;
133133
134 - $output .= "<script type='$wgJsMimeType' src='http://maps.google.com/maps/api/js?sensor=false&amp;language={$wgLang->getCode()}'></script><script type='$wgJsMimeType' src='$egMapsScriptPath/GoogleMaps3/GoogleMap3Functions.js?$egMapsStyleVersion'></script>";
 134+ $output .= "<script type='$wgJsMimeType' src='http://maps.google.com/maps/api/js?sensor=false&amp;language={$wgLang->getCode()}'></script><script type='$wgJsMimeType' src='$egMapsScriptPath/GoogleMaps3/GoogleMap3Functions{$egMapsJsExt}?$egMapsStyleVersion'></script>";
135135 }
136136 }
137137
Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispPoint.php
@@ -13,7 +13,6 @@
1414 die( 'Not an entry point.' );
1515 }
1616
17 -
1817 /**
1918 * Class for handling the display_point(s) parser functions with OpenLayers.
2019 *
@@ -54,18 +53,37 @@
5554 *
5655 */
5756 public function addSpecificMapHTML() {
58 - global $wgJsMimeType;
59 -
 57+ global $wgOut;
 58+
6059 $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers );
6160
62 - $this->output .= "<div id='$this->mapName' style='width: {$this->width}px; height: {$this->height}px; background-color: #cccccc;'></div>
63 - <script type='$wgJsMimeType'> /*<![CDATA[*/
64 - addOnloadHook(
65 - function() {
66 - initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$this->controls],[$this->markerString], $this->height);
67 - }
68 - );
69 - /*]]>*/ </script>";
 61+ $this->output .= Html::element(
 62+ 'div',
 63+ array(
 64+ 'id' => $this->mapName,
 65+ 'width' => $this->width,
 66+ 'height' => $this->height
 67+ ),
 68+ null
 69+ );
 70+
 71+ $wgOut->addInlineScript( <<<EOT
 72+addOnloadHook(
 73+ function() {
 74+ initOpenLayer(
 75+ '$this->mapName',
 76+ $this->centre_lon,
 77+ $this->centre_lat,
 78+ $this->zoom,
 79+ [$layerItems],
 80+ [$this->controls],
 81+ [$this->markerString],
 82+ $this->height
 83+ );
7084 }
 85+);
 86+EOT
 87+ );
 88+ }
7189
7290 }
\ No newline at end of file
Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispMap.php
@@ -46,18 +46,37 @@
4747 *
4848 */
4949 public function addSpecificMapHTML() {
50 - global $wgJsMimeType;
 50+ global $wgOut;
5151
5252 $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers );
5353
54 - $this->output .= "<div id='$this->mapName' style='width: {$this->width}px; height: {$this->height}px; background-color: #cccccc;'></div>
55 - <script type='$wgJsMimeType'> /*<![CDATA[*/
56 - addOnloadHook(
57 - function() {
58 - initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$this->controls],[], $this->height);
59 - }
60 - );
61 - /*]]>*/ </script>";
 54+ $this->output .= Html::element(
 55+ 'div',
 56+ array(
 57+ 'id' => $this->mapName,
 58+ 'width' => $this->width,
 59+ 'height' => $this->height
 60+ ),
 61+ null
 62+ );
 63+
 64+ $wgOut->addInlineScript( <<<EOT
 65+addOnloadHook(
 66+ function() {
 67+ initOpenLayer(
 68+ '$this->mapName',
 69+ $this->centre_lon,
 70+ $this->centre_lat,
 71+ $this->zoom,
 72+ [$layerItems],
 73+ [$this->controls],
 74+ [],
 75+ $this->height
 76+ );
6277 }
 78+);
 79+EOT
 80+ );
 81+ }
6382
6483 }
\ No newline at end of file
Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayers.php
@@ -118,14 +118,14 @@
119119 */
120120 public static function addOLDependencies( &$output ) {
121121 global $wgJsMimeType;
122 - global $egOpenLayersOnThisPage, $egMapsScriptPath, $egMapsStyleVersion;
 122+ global $egOpenLayersOnThisPage, $egMapsScriptPath, $egMapsStyleVersion, $egMapsJsExt;
123123
124124 if ( empty( $egOpenLayersOnThisPage ) ) {
125125 $egOpenLayersOnThisPage = 0;
126126
127127 $output .= "<link rel='stylesheet' href='$egMapsScriptPath/OpenLayers/OpenLayers/theme/default/style.css' type='text/css' />
128128 <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenLayers/OpenLayers/OpenLayers.js'></script>
129 - <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenLayers/OpenLayerFunctions.js?$egMapsStyleVersion'></script>
 129+ <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenLayers/OpenLayerFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script>
130130 <script type='$wgJsMimeType'>initOLSettings(200, 100);</script>\n";
131131 }
132132 }
Index: trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php
@@ -146,8 +146,10 @@
147147 }
148148 }
149149
150 - // Return the result
151 - return $parser->insertStripItem( $output, $parser->mStripState );
 150+ // Return the result.
 151+ //return array( $parser->insertStripItem( $output, $parser->mStripState), 'noparse' => true, 'isHTML' => true );
 152+ //return $parser->insertStripItem( $output, $parser->mStripState);
 153+ return array( $output, 'noparse' => true, 'isHTML' => true );
152154 }
153155
154156 /**
Index: trunk/extensions/Maps/Maps.php
@@ -33,7 +33,7 @@
3434 echo '<b>Warning:</b> You need to have <a href="http://www.mediawiki.org/wiki/Extension:Validator">Validator</a> installed in order to use <a href="http://www.mediawiki.org/wiki/Extension:Maps">Maps</a>.';
3535 }
3636 else {
37 - define( 'Maps_VERSION', '0.6 a1' );
 37+ define( 'Maps_VERSION', '0.6 a2' );
3838
3939 // The different coordinate notations.
4040 define( 'Maps_COORDS_FLOAT', 0 );
@@ -73,7 +73,8 @@
7474 */
7575 function efMapsSetup() {
7676 global $wgExtensionCredits, $wgLang, $wgAutoloadClasses, $IP;
77 - global $egMapsDefaultService, $egMapsAvailableServices, $egMapsServices, $egMapsDefaultGeoService, $egMapsAvailableGeoServices, $egMapsDir, $egMapsAvailableFeatures;
 77+ global $egMapsDefaultService, $egMapsAvailableServices, $egMapsServices, $egMapsDefaultGeoService;
 78+ global $egMapsAvailableGeoServices, $egMapsDir, $egMapsAvailableFeatures, $egMapsJsExt;
7879
7980 // Remove all hooked in services that should not be available.
8081 foreach ( $egMapsServices as $service => $data ) {
@@ -125,6 +126,8 @@
126127 }
127128 }
128129
 130+ $egMapsJsExt = $egMapsUseMinJs ? '.min.js' : '.js';
 131+
129132 return true;
130133 }
131134
Index: trunk/extensions/Maps/OpenStreetMap/Maps_OSMDispMap.php
@@ -67,10 +67,14 @@
6868 *
6969 */
7070 public function addSpecificMapHTML() {
71 - global $wgJsMimeType;
 71+ global $wgOut;
7272
73 - $this->output .= <<<EOT
74 - <script type='$wgJsMimeType'>slippymaps['$this->mapName'] = new slippymap_map('$this->mapName', {
 73+ $wgOut->addInlineScript( <<<EOT
 74+addOnloadHook(
 75+ function() {
 76+ slippymaps['$this->mapName'] = new slippymap_map(
 77+ '$this->mapName',
 78+ {
7579 mode: '$this->mode',
7680 layer: 'osm-like',
7781 locale: '$this->lang',
@@ -81,9 +85,12 @@
8286 height: $this->height,
8387 markers: [],
8488 controls: [$this->controls]
85 - });</script>
86 -
87 -EOT;
 89+ }
 90+ );
 91+ }
 92+);
 93+EOT
 94+ );
8895
8996 $this->output .= $this->static ? $this->getStaticMap() : $this->getDynamicMap();
9097 }
@@ -94,16 +101,28 @@
95102 * @return string
96103 */
97104 private function getDynamicMap() {
98 - global $wgJsMimeType;
 105+ global $wgOut;
99106
100 - return <<<EOT
101 - <!-- map div -->
102 - <div id='$this->mapName' class='map' style='width:{$this->width}px; height:{$this->height}px;'>
103 - <script type='$wgJsMimeType'>slippymaps['$this->mapName'].init();</script>
104 - <!-- /map div -->
105 - </div>
106 -EOT;
 107+ $wgOut->addInlineScript( <<<EOT
 108+addOnloadHook(
 109+ function() {
 110+ slippymaps['$this->mapName'].init();
107111 }
 112+);
 113+EOT
 114+ );
 115+
 116+ return Html::element(
 117+ 'div',
 118+ array(
 119+ 'id' => $this->mapName,
 120+ 'width' => $this->width,
 121+ 'height' => $this->height,
 122+ 'class' => 'map'
 123+ ),
 124+ null
 125+ );
 126+ }
108127
109128 /**
110129 * Returns html for a static map.
@@ -120,28 +139,34 @@
121140 $rendering_url = $static->getUrl();
122141
123142 $alt = wfMsg( 'maps_centred_on', $this->centre_lat, $this->centre_lon );
 143+ $title = $this->activatable ? wfMsg( 'maps_click_to_activate' ) : $alt;
124144
 145+ $image = array(
 146+ 'class' => 'mapPreview',
 147+ 'src' => $rendering_url,
 148+ 'width' => $this->width,
 149+ 'height' => $this->height,
 150+ 'alt' => $alt,
 151+ 'title' => $title,
 152+ );
 153+
125154 if ( $this->activatable ) {
126 - $title = wfMsg( 'maps_click_to_activate' );
127 - $activationCode = "onclick=\"slippymaps['$this->mapName'].init();\"";
 155+ $image['onclick'] = "slippymaps['$this->mapName'].init();";
128156 }
129 - else {
130 - $activationCode = '';
131 - $title = $alt;
132 - }
133157
134 - return <<<EOT
135 - <div id="$this->mapName" class="map" style="width:{$this->width}px; height:{$this->height}px;">
136 - <img id="$this->mapName-preview"
137 - class="mapPreview"
138 - src="{$rendering_url}"
139 - width="$this->width"
140 - height="$this->height"
141 - alt="$alt"
142 - title="$title"
143 - $activationCode />
144 - </div>
145 -EOT;
 158+ return Html::element(
 159+ 'div',
 160+ array(
 161+ 'id' => $this->mapName,
 162+ 'width' => $this->width,
 163+ 'height' => $this->height,
 164+ 'class' => 'map'
 165+ ),
 166+ Html::element(
 167+ 'img',
 168+ $image
 169+ )
 170+ );
146171 }
147172
148173 }
Index: trunk/extensions/Maps/OpenStreetMap/Maps_OSM.php
@@ -149,14 +149,14 @@
150150 */
151151 public static function addOSMDependencies( &$output ) {
152152 global $wgJsMimeType;
153 - global $egOSMMapsOnThisPage, $egMapsScriptPath, $egMapsStyleVersion;
 153+ global $egOSMMapsOnThisPage, $egMapsScriptPath, $egMapsStyleVersion, $egMapsJsExt;
154154
155155 if ( empty( $egOSMMapsOnThisPage ) ) {
156156 $egOSMMapsOnThisPage = 0;
157157
158158 $output .= "<link rel='stylesheet' href='$egMapsScriptPath/OpenLayers/OpenLayers/theme/default/style.css' type='text/css' />
159159 <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenLayers/OpenLayers/OpenLayers.js'></script>
160 - <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenStreetMap/OSMFunctions.min.js?$egMapsStyleVersion'></script>
 160+ <script type='$wgJsMimeType' src='$egMapsScriptPath/OpenStreetMap/OSMFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script>
161161 <script type='$wgJsMimeType'>slippymaps = Array();</script>\n";
162162 }
163163 }
Index: trunk/extensions/Maps/OpenStreetMap/Maps_OSMDispPoint.php
@@ -53,13 +53,17 @@
5454 *
5555 */
5656 public function addSpecificMapHTML() {
57 - global $wgJsMimeType;
 57+ global $wgOut;
5858
59 - $this->output .= <<<EOT
60 - <script type='$wgJsMimeType'>slippymaps['$this->mapName'] = new slippymap_map('$this->mapName', {
61 - mode: 'osm-wm',
 59+ $wgOut->addInlineScript( <<<EOT
 60+addOnloadHook(
 61+ function() {
 62+ slippymaps['$this->mapName'] = new slippymap_map(
 63+ '$this->mapName',
 64+ {
 65+ mode: '$this->mode',
6266 layer: 'osm-like',
63 - locale: '$this->lang',
 67+ locale: '$this->lang',
6468 lat: $this->centre_lat,
6569 lon: $this->centre_lon,
6670 zoom: $this->zoom,
@@ -67,14 +71,23 @@
6872 height: $this->height,
6973 markers: [$this->markerString],
7074 controls: [$this->controls]
71 - });</script>
 75+ }
 76+ );
 77+ slippymaps['$this->mapName'].init();
 78+ }
 79+);
 80+EOT
 81+ );
7282
73 - <!-- map div -->
74 - <div id='$this->mapName' class='map' style='width:{$this->width}px; height:{$this->height}px;'>
75 - <script type='$wgJsMimeType'>slippymaps['$this->mapName'].init();</script>
76 - <!-- /map div -->
77 - </div>
78 -EOT;
 83+ $this->output .= Html::element(
 84+ 'div',
 85+ array(
 86+ 'id' => $this->mapName,
 87+ 'width' => $this->width,
 88+ 'height' => $this->height,
 89+ 'class' => 'map'
 90+ ),
 91+ null
 92+ );
7993 }
80 -
8194 }
\ No newline at end of file
Index: trunk/extensions/Maps/Maps_Mapper.php
@@ -26,31 +26,31 @@
2727 public static function initializeMainParams() {
2828 global $egMapsSizeRestrictions, $egMapsMapWidth, $egMapsMapHeight;
2929
30 - self::$mainParams = array
31 - (
 30+ Validator::addOutputFormat( 'mapdimension', array( __CLASS__, 'setMapDimension' ) );
 31+ Validator::addValidationFunction( 'is_map_dimension', array( __CLASS__, 'isMapDimension' ) );
 32+
 33+ self::$mainParams = array (
3234 'zoom' => array(
3335 'type' => 'integer',
3436 'criteria' => array(
3537 'not_empty' => array()
36 - )
37 - ),
 38+ )
 39+ ),
3840 'width' => array(
39 - 'type' => 'integer',
4041 'criteria' => array(
41 - 'not_empty' => array(),
42 - 'in_range' => $egMapsSizeRestrictions['width']
43 - ),
44 - 'default' => $egMapsMapWidth
 42+ 'is_map_dimension' => array( 'width' ),
4543 ),
 44+ 'default' => $egMapsMapWidth,
 45+ 'output-type' => array( 'mapdimension', 'width', true, $egMapsMapWidth )
 46+ ),
4647 'height' => array(
47 - 'type' => 'integer',
4848 'criteria' => array(
49 - 'not_empty' => array(),
50 - 'in_range' => $egMapsSizeRestrictions['height']
51 - ),
52 - 'default' => $egMapsMapHeight
 49+ 'is_map_dimension' => array( 'height' ),
5350 ),
54 - );
 51+ 'default' => $egMapsMapHeight,
 52+ 'output-type' => array( 'mapdimension', 'height', true, $egMapsMapHeight )
 53+ ),
 54+ );
5555 }
5656
5757 /**
@@ -147,4 +147,47 @@
148148
149149 return $service;
150150 }
 151+
 152+ public static function isMapDimension( &$value, $dimension, $correct = false, $default = 0 ) {
 153+ global $egMapsSizeRestrictions;
 154+
 155+ if ( !preg_match( '/^\d+(\.\d+)?(px|ex|em|%)?$/', $value ) ) {
 156+ if ( $correct ) {
 157+ $value = $default;
 158+ } else {
 159+ return false;
 160+ }
 161+ }
 162+
 163+ if ( !preg_match( '/^.*%$/', $value ) ) {
 164+ $number = preg_replace( '/[^0-9]/', '', $value );
 165+ if ( $number < $egMapsSizeRestrictions[$dimension][0] ) {
 166+ if ( $correct ) {
 167+ $value = $egMapsSizeRestrictions[$dimension][0];
 168+ } else {
 169+ return false;
 170+ }
 171+ } else if ( $number > $egMapsSizeRestrictions[$dimension][1] ) {
 172+ if ( $correct ) {
 173+ $value = $egMapsSizeRestrictions[$dimension][1];
 174+ } else {
 175+ return false;
 176+ }
 177+ }
 178+ }
 179+
 180+ if ( $correct ) {
 181+ if ( !preg_match( '/(px|ex|em|%)$/', $value ) ) {
 182+ $value .= 'px';
 183+ }
 184+ }
 185+
 186+ return true;
 187+ }
 188+
 189+ public static function setMapDimension( &$value, $dimension, $correct, $default ) {
 190+ global $egMapsMapWidth;
 191+ self::isMapDimension( $value, $dimension, $correct, $default );
 192+ }
 193+
151194 }
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispMap.php
@@ -63,33 +63,38 @@
6464 *
6565 */
6666 public function addSpecificMapHTML() {
67 - global $wgJsMimeType;
 67+ global $wgOut;
6868
69 - $onloadFunctions = MapsGoogleMaps::addOverlayOutput( $this->output, $this->mapName, $this->overlays, $this->controls );
 69+ MapsGoogleMaps::addOverlayOutput( $this->output, $this->mapName, $this->overlays, $this->controls );
7070
71 - $this->output .= <<<EOT
72 -<div id="$this->mapName"></div>
73 -<script type="$wgJsMimeType"> /*<![CDATA[*/
 71+ $this->output .= Html::element(
 72+ 'div',
 73+ array(
 74+ 'id' => $this->mapName,
 75+ 'width' => $this->width,
 76+ 'height' => $this->height
 77+ ),
 78+ null
 79+ );
 80+
 81+ $wgOut->addInlineScript( <<<EOT
7482 addOnloadHook(
7583 function() {
76 - initializeGoogleMap('$this->mapName',
77 - {
78 - width: $this->width,
79 - height: $this->height,
80 - lat: $this->centre_lat,
81 - lon: $this->centre_lon,
82 - zoom: $this->zoom,
83 - type: $this->type,
84 - types: [$this->types],
85 - controls: [$this->controls],
86 - scrollWheelZoom: $this->autozoom
87 - }, []);
 84+ initializeGoogleMap('$this->mapName',
 85+ {
 86+ lat: $this->centre_lat,
 87+ lon: $this->centre_lon,
 88+ zoom: $this->zoom,
 89+ type: $this->type,
 90+ types: [$this->types],
 91+ controls: [$this->controls],
 92+ scrollWheelZoom: $this->autozoom
 93+ },
 94+ []);
8895 }
8996 );
90 -/*]]>*/ </script>
91 -EOT;
92 -
93 - $this->output .= $onloadFunctions;
 97+EOT
 98+ );
9499
95100 }
96101
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php
@@ -190,14 +190,14 @@
191191 */
192192 public static function addGMapDependencies( &$output ) {
193193 global $wgJsMimeType, $wgLang;
194 - global $egGoogleMapsKey, $egMapsScriptPath, $egGoogleMapsOnThisPage, $egMapsStyleVersion;
 194+ global $egGoogleMapsKey, $egMapsScriptPath, $egGoogleMapsOnThisPage, $egMapsStyleVersion, $egMapsJsExt;
195195
196196 if ( empty( $egGoogleMapsOnThisPage ) ) {
197197 $egGoogleMapsOnThisPage = 0;
198198
199199 MapsGoogleMaps::validateGoogleMapsKey();
200200
201 - $output .= "<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=$egGoogleMapsKey&amp;hl={$wgLang->getCode()}' type='$wgJsMimeType'></script><script type='$wgJsMimeType' src='$egMapsScriptPath/GoogleMaps/GoogleMapFunctions.min.js?$egMapsStyleVersion'></script><script type='$wgJsMimeType'>window.unload = GUnload;</script>";
 201+ $output .= "<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=$egGoogleMapsKey&amp;hl={$wgLang->getCode()}' type='$wgJsMimeType'></script><script type='$wgJsMimeType' src='$egMapsScriptPath/GoogleMaps/GoogleMapFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script><script type='$wgJsMimeType'>window.unload = GUnload;</script>";
202202 }
203203 }
204204
@@ -255,7 +255,7 @@
256256 // Add the inputs for the overlays.
257257 $addedOverlays = array();
258258 $overlayHtml = '';
259 - $onloadFunctions = '';
 259+ $onloadFunctions = array();
260260 foreach ( $overlays as $overlay => $isOn ) {
261261 $overlay = strtolower( $overlay );
262262
@@ -266,7 +266,7 @@
267267 $urlNr = self::$overlayData[$overlay];
268268 $overlayHtml .= "<input id='$mapName-overlay-box-$overlay' name='$mapName-overlay-box' type='checkbox' onclick='switchGLayer(GMaps[\"$mapName\"], this.checked, GOverlays[$urlNr])' /> $label <br />";
269269 if ( $isOn ) {
270 - $onloadFunctions .= "<script type='$wgJsMimeType'>addOnloadHook( function() { initiateGOverlay('$mapName-overlay-box-$overlay', '$mapName', $urlNr) } );</script>";
 270+ $onloadFunctions .= "addOnloadHook( function() { initiateGOverlay('$mapName-overlay-box-$overlay', '$mapName', $urlNr) } );";
271271 }
272272 }
273273 }
@@ -279,7 +279,7 @@
280280 </div></form></div>
281281 EOT;
282282
283 - return $onloadFunctions;
 283+ $output .= "<script type='$wgJsMimeType'>" . implode( "\n", $onloadFunctions ) . '</script>';
284284 }
285285
286286 /**
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispPoint.php
@@ -65,36 +65,41 @@
6666 *
6767 */
6868 public function addSpecificMapHTML() {
69 - global $wgJsMimeType;
 69+ global $wgOut;
7070
71 - $onloadFunctions = MapsGoogleMaps::addOverlayOutput( $this->output, $this->mapName, $this->overlays, $this->controls );
 71+ MapsGoogleMaps::addOverlayOutput( $this->output, $this->mapName, $this->overlays, $this->controls );
7272
73 - $this->output .= <<<EOT
74 -<div id="$this->mapName"></div>
75 -<script type="$wgJsMimeType"> /*<![CDATA[*/
 73+ $this->output .= Html::element(
 74+ 'div',
 75+ array(
 76+ 'id' => $this->mapName,
 77+ 'width' => $this->width,
 78+ 'height' => $this->height
 79+ ),
 80+ null
 81+ );
 82+
 83+ $wgOut->addInlineScript(
 84+ <<<EOT
7685 addOnloadHook(
7786 function() {
78 - initializeGoogleMap('$this->mapName',
79 - {
80 - width: $this->width,
81 - height: $this->height,
82 - lat: $this->centre_lat,
83 - lon: $this->centre_lon,
84 - zoom: $this->zoom,
85 - type: $this->type,
86 - types: [$this->types],
87 - controls: [$this->controls],
88 - scrollWheelZoom: $this->autozoom
89 - },
90 - [$this->markerString]
91 - );
 87+ initializeGoogleMap('$this->mapName',
 88+ {
 89+ lat: $this->centre_lat,
 90+ lon: $this->centre_lon,
 91+ zoom: $this->zoom,
 92+ type: $this->type,
 93+ types: [$this->types],
 94+ controls: [$this->controls],
 95+ scrollWheelZoom: $this->autozoom
 96+ },
 97+ [$this->markerString]
 98+ );
9299 }
93100 );
94 -/*]]>*/ </script>
95 -EOT;
 101+EOT
 102+ );
96103
97 - $this->output .= $onloadFunctions;
98 -
99104 }
100105
101106 }
Index: trunk/extensions/Maps/GoogleMaps/GoogleMapFunctions.js
@@ -54,7 +54,7 @@
5555 function initializeGoogleMap(mapName, mapOptions, markers) {
5656 if (GBrowserIsCompatible()) {
5757 mapOptions.centre = (mapOptions.lat != null && mapOptions.lon != null) ? new GLatLng(mapOptions.lat, mapOptions.lon) : null;
58 - mapOptions.size = new GSize(mapOptions.width, mapOptions.height);
 58+ //mapOptions.size = new GSize(mapOptions.width, mapOptions.height);
5959 return createGoogleMap(mapName, mapOptions, markers);
6060 }
6161 else {
@@ -76,7 +76,7 @@
7777
7878 if (! typesContainType) mapOptions.types.push(mapOptions.type);
7979
80 - var map = new GMap2(mapElement, {size: mapOptions.size, mapTypes: mapOptions.types});
 80+ var map = new GMap2(mapElement, {mapTypes: mapOptions.types});
8181 map.name = mapName;
8282
8383 map.setMapType(mapOptions.type);
@@ -84,7 +84,7 @@
8585 // List of GControls: http://code.google.com/apis/maps/documentation/reference.html#GControl
8686 for (i in mapOptions.controls){
8787 if (mapOptions.controls[i].toLowerCase() == 'auto') {
88 - if (mapOptions.height > 75) mapOptions.controls[i] = mapOptions.height > 320 ? 'large' : 'small';
 88+ // if (mapOptions.height > 75) mapOptions.controls[i] = mapOptions.height > 320 ? 'large' : 'small';
8989 }
9090
9191 switch (mapOptions.controls[i]) {
Index: trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispPoint.php
@@ -53,19 +53,37 @@
5454 *
5555 */
5656 public function addSpecificMapHTML() {
57 - global $wgJsMimeType;
 57+ global $wgOut;
5858
59 - $this->output .= <<<EOT
60 - <div id="$this->mapName" style="width: {$this->width}px; height: {$this->height}px;"></div>
 59+ $this->output .= Html::element(
 60+ 'div',
 61+ array(
 62+ 'id' => $this->mapName,
 63+ 'width' => $this->width,
 64+ 'height' => $this->height
 65+ ),
 66+ null
 67+ );
6168
62 - <script type="$wgJsMimeType">/*<![CDATA[*/
63 - addOnloadHook(
64 - function() {
65 - initializeYahooMap('$this->mapName', $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$this->types], [$this->controls], $this->autozoom, [$this->markerString], $this->height);
66 - }
 69+ $wgOut->addInlineScript( <<<EOT
 70+addOnloadHook(
 71+ function() {
 72+ initializeYahooMap(
 73+ '$this->mapName',
 74+ $this->centre_lat,
 75+ $this->centre_lon,
 76+ $this->zoom,
 77+ $this->type,
 78+ [$this->types],
 79+ [$this->controls],
 80+ $this->autozoom,
 81+ [$this->markerString],
 82+ $this->height
6783 );
68 - /*]]>*/</script>
69 -EOT;
7084 }
 85+);
 86+EOT
 87+ );
 88+ }
7189
7290 }
Index: trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispMap.php
@@ -46,19 +46,37 @@
4747 *
4848 */
4949 public function addSpecificMapHTML() {
50 - global $wgJsMimeType;
 50+ global $wgOut;
5151
52 - $this->output .= <<<EOT
53 - <div id="$this->mapName" style="width: {$this->width}px; height: {$this->height}px;"></div>
 52+ $this->output .= Html::element(
 53+ 'div',
 54+ array(
 55+ 'id' => $this->mapName,
 56+ 'width' => $this->width,
 57+ 'height' => $this->height
 58+ ),
 59+ null
 60+ );
5461
55 - <script type="$wgJsMimeType">/*<![CDATA[*/
56 - addOnloadHook(
57 - function() {
58 - initializeYahooMap('$this->mapName', $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$this->types], [$this->controls], $this->autozoom, [], $this->height);
59 - }
 62+ $wgOut->addInlineScript( <<<EOT
 63+addOnloadHook(
 64+ function() {
 65+ initializeYahooMap(
 66+ '$this->mapName',
 67+ $this->centre_lat,
 68+ $this->centre_lon,
 69+ $this->zoom,
 70+ $this->type,
 71+ [$this->types],
 72+ [$this->controls],
 73+ $this->autozoom,
 74+ [],
 75+ $this->height
6076 );
61 - /*]]>*/</script>
62 -EOT;
6377 }
 78+);
 79+EOT
 80+ );
 81+ }
6482
6583 }
Index: trunk/extensions/Maps/YahooMaps/Maps_YahooMaps.php
@@ -149,12 +149,12 @@
150150 */
151151 public static function addYMapDependencies( &$output ) {
152152 global $wgJsMimeType;
153 - global $egYahooMapsKey, $egMapsScriptPath, $egYahooMapsOnThisPage, $egMapsStyleVersion;
 153+ global $egYahooMapsKey, $egMapsScriptPath, $egYahooMapsOnThisPage, $egMapsStyleVersion, $egMapsJsExt;
154154
155155 if ( empty( $egYahooMapsOnThisPage ) ) {
156156 $egYahooMapsOnThisPage = 0;
157157 $output .= "<script type='$wgJsMimeType' src='http://api.maps.yahoo.com/ajaxymap?v=3.8&amp;appid=$egYahooMapsKey'></script>
158 - <script type='$wgJsMimeType' src='$egMapsScriptPath/YahooMaps/YahooMapFunctions.min.js?$egMapsStyleVersion'></script>";
 158+ <script type='$wgJsMimeType' src='$egMapsScriptPath/YahooMaps/YahooMapFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script>";
159159 }
160160 }
161161
Index: trunk/extensions/Maps/Maps_Settings.php
@@ -125,6 +125,15 @@
126126
127127
128128
 129+# General configuration
 130+
 131+# Boolean. Indicates if minified js files should be used where available.
 132+$egMapsUseMinJs = false;
 133+
 134+
 135+
 136+
 137+
129138 # Coordinate configuration
130139
131140 # Enum. The default output format of coordinates.
Index: trunk/extensions/Maps/Maps_Utils.php
@@ -127,32 +127,7 @@
128128 return $decimal . "° E";
129129 }
130130 }
131 -
132 - /**
133 - * If the provided height or width do not fall within the allowed interval,
134 - * they are changed to the nearest allowed value.
135 - *
136 - * @param integer $width
137 - * @param integer $height
138 - */
139 - public static function makeMapSizeValid( &$width, &$height ) {
140 - global $egMapsSizeRestrictions;
141131
142 - if ( $width < $egMapsSizeRestrictions['width'][0] ) {
143 - $width = $egMapsSizeRestrictions['width'][0];
144 - }
145 - else if ( $width > $egMapsSizeRestrictions['width'][1] ) {
146 - $width = $egMapsSizeRestrictions['width'][1];
147 - }
148 -
149 - if ( $height < $egMapsSizeRestrictions['height'][0] ) {
150 - $height = $egMapsSizeRestrictions['height'][0];
151 - }
152 - else if ( $height > $egMapsSizeRestrictions['height'][1] ) {
153 - $height = $egMapsSizeRestrictions['height'][1];
154 - }
155 - }
156 -
157132 /**
158133 * Convert from WGS84 to spherical mercator.
159134 */

Follow-up revisions

RevisionCommit summaryAuthorDate
r64301Follow up to r64299 - fixed some forgotten JSjeroendedauw19:18, 28 March 2010
r64306Changes for 0.6 - Follow up to r64299 - Fixed issues with previouse revsjeroendedauw20:10, 28 March 2010
r64310Changes for 0.6 - Follow up to r64299 - Fixed JS inclusion and div displayjeroendedauw21:28, 28 March 2010
r64317Changes for 0.6 - Follow up to r64299 - Changed output of the maps to match t...jeroendedauw22:17, 28 March 2010
r64320Changes for 0.6 - Follow up to r64299 - Changed output of the maps to match t...jeroendedauw22:28, 28 March 2010

Comments

#Comment by Raymond (talk | contribs)   19:18, 28 March 2010

PHP Notice: Undefined variable: egMapsUseMinJs in /www/w/extensions/Maps/Maps.php on line 129

#Comment by Jeroen De Dauw (talk | contribs)   19:20, 28 March 2010

Oops - will fix in a moment.

#Comment by Raymond (talk | contribs)   19:26, 28 March 2010

Still the same error with r64301

#Comment by Jeroen De Dauw (talk | contribs)   19:36, 28 March 2010

I know, made that commit before my previous comment :) I'll make another one in a few mins.

#Comment by Raymond (talk | contribs)   20:48, 28 March 2010

Fixed with r64306

Status & tagging log