http://www.mediawiki.org/wiki/Special:Code/MediaWiki/64299

Revision: 64299
Author:   jeroendedauw
Date:     2010-03-28 19:09:00 +0000 (Sun, 28 Mar 2010)

Log Message:
-----------
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
    trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php
    trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispMap.php
    trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispPoint.php
    trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3.php
    trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispMap.php
    trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispPoint.php
    trunk/extensions/Maps/Maps.php
    trunk/extensions/Maps/Maps_Mapper.php
    trunk/extensions/Maps/Maps_Settings.php
    trunk/extensions/Maps/Maps_Utils.php
    trunk/extensions/Maps/OpenLayers/Maps_OpenLayers.php
    trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispMap.php
    trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispPoint.php
    trunk/extensions/Maps/OpenStreetMap/Maps_OSM.php
    trunk/extensions/Maps/OpenStreetMap/Maps_OSMDispMap.php
    trunk/extensions/Maps/OpenStreetMap/Maps_OSMDispPoint.php
    trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php
    trunk/extensions/Maps/YahooMaps/Maps_YahooMaps.php
    trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispMap.php
    trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispPoint.php

Modified: trunk/extensions/Maps/GoogleMaps/GoogleMapFunctions.js
===================================================================
--- trunk/extensions/Maps/GoogleMaps/GoogleMapFunctions.js      2010-03-28 
17:33:53 UTC (rev 64298)
+++ trunk/extensions/Maps/GoogleMaps/GoogleMapFunctions.js      2010-03-28 
19:09:00 UTC (rev 64299)
@@ -54,7 +54,7 @@
 function initializeGoogleMap(mapName, mapOptions, markers) {
        if (GBrowserIsCompatible()) {
                mapOptions.centre = (mapOptions.lat != null && mapOptions.lon 
!= null) ? new GLatLng(mapOptions.lat, mapOptions.lon) : null;
-               mapOptions.size = new GSize(mapOptions.width, 
mapOptions.height);       
+               //mapOptions.size = new GSize(mapOptions.width, 
mapOptions.height);     
                return createGoogleMap(mapName, mapOptions, markers);   
        }
        else {
@@ -76,7 +76,7 @@
 
        if (! typesContainType) mapOptions.types.push(mapOptions.type);
 
-       var map = new GMap2(mapElement, {size: mapOptions.size, mapTypes: 
mapOptions.types});
+       var map = new GMap2(mapElement, {mapTypes: mapOptions.types});
        map.name = mapName;
 
        map.setMapType(mapOptions.type);        
@@ -84,7 +84,7 @@
        // List of GControls: 
http://code.google.com/apis/maps/documentation/reference.html#GControl
        for (i in mapOptions.controls){
                if (mapOptions.controls[i].toLowerCase() == 'auto') {
-                       if (mapOptions.height > 75) mapOptions.controls[i] = 
mapOptions.height > 320 ? 'large' : 'small';
+                       // if (mapOptions.height > 75) mapOptions.controls[i] = 
mapOptions.height > 320 ? 'large' : 'small';
                }                       
                
                switch (mapOptions.controls[i]) {

Modified: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php
===================================================================
--- trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php        2010-03-28 
17:33:53 UTC (rev 64298)
+++ trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php        2010-03-28 
19:09:00 UTC (rev 64299)
@@ -190,14 +190,14 @@
         */
        public static function addGMapDependencies( &$output ) {
                global $wgJsMimeType, $wgLang;
-               global $egGoogleMapsKey, $egMapsScriptPath, 
$egGoogleMapsOnThisPage, $egMapsStyleVersion;
+               global $egGoogleMapsKey, $egMapsScriptPath, 
$egGoogleMapsOnThisPage, $egMapsStyleVersion, $egMapsJsExt;
 
                if ( empty( $egGoogleMapsOnThisPage ) ) {
                        $egGoogleMapsOnThisPage = 0;
 
                        MapsGoogleMaps::validateGoogleMapsKey();
 
-                       $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>";
+                       $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>";
                }
        }
        
@@ -255,7 +255,7 @@
                // Add the inputs for the overlays.
                $addedOverlays = array();
                $overlayHtml = '';
-               $onloadFunctions = '';
+               $onloadFunctions = array();
                foreach ( $overlays as $overlay => $isOn ) {
                        $overlay = strtolower( $overlay );
                        
@@ -266,7 +266,7 @@
                                        $urlNr = self::$overlayData[$overlay];
                                        $overlayHtml .= "<input 
id='$mapName-overlay-box-$overlay' name='$mapName-overlay-box' type='checkbox' 
onclick='switchGLayer(GMaps[\"$mapName\"], this.checked, GOverlays[$urlNr])' /> 
$label <br />";
                                        if ( $isOn ) {
-                                               $onloadFunctions .= "<script 
type='$wgJsMimeType'>addOnloadHook( function() { 
initiateGOverlay('$mapName-overlay-box-$overlay', '$mapName', $urlNr) } 
);</script>";
+                                               $onloadFunctions .= 
"addOnloadHook( function() { initiateGOverlay('$mapName-overlay-box-$overlay', 
'$mapName', $urlNr) } );";
                                        }
                                }
                        }
@@ -279,7 +279,7 @@
 </div></form></div>            
 EOT;
 
-       return $onloadFunctions;
+       $output .= "<script type='$wgJsMimeType'>" . implode( "\n", 
$onloadFunctions ) . '</script>';
        }
        
        /**

Modified: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispMap.php
===================================================================
--- trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispMap.php 2010-03-28 
17:33:53 UTC (rev 64298)
+++ trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispMap.php 2010-03-28 
19:09:00 UTC (rev 64299)
@@ -63,33 +63,38 @@
         *
         */
        public function addSpecificMapHTML() {
-               global $wgJsMimeType;
+               global $wgOut;
                
-               $onloadFunctions = MapsGoogleMaps::addOverlayOutput( 
$this->output, $this->mapName, $this->overlays, $this->controls );
+               MapsGoogleMaps::addOverlayOutput( $this->output, 
$this->mapName, $this->overlays, $this->controls );
                
-               $this->output .= <<<EOT
-<div id="$this->mapName"></div>
-<script type="$wgJsMimeType"> /*<![CDATA[*/
+               $this->output .= Html::element(
+                       'div',
+                       array(
+                               'id' => $this->mapName,
+                               'width' => $this->width,
+                               'height' => $this->height
+                       ),
+                       null
+               );
+               
+               $wgOut->addInlineScript( <<<EOT
 addOnloadHook(
        function() {
-       initializeGoogleMap('$this->mapName', 
-               {
-               width: $this->width,
-               height: $this->height,
-               lat: $this->centre_lat,
-               lon: $this->centre_lon,
-               zoom: $this->zoom,
-               type: $this->type,
-               types: [$this->types],
-               controls: [$this->controls],
-               scrollWheelZoom: $this->autozoom
-               }, []);
+               initializeGoogleMap('$this->mapName', 
+                       {
+                       lat: $this->centre_lat,
+                       lon: $this->centre_lon,
+                       zoom: $this->zoom,
+                       type: $this->type,
+                       types: [$this->types],
+                       controls: [$this->controls],
+                       scrollWheelZoom: $this->autozoom
+                       },
+               []);
        }
 );
-/*]]>*/ </script>
-EOT;
-
-       $this->output .= $onloadFunctions;
+EOT
+               );
                
        }
        

Modified: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispPoint.php
===================================================================
--- trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispPoint.php       
2010-03-28 17:33:53 UTC (rev 64298)
+++ trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispPoint.php       
2010-03-28 19:09:00 UTC (rev 64299)
@@ -65,36 +65,41 @@
         *
         */
        public function addSpecificMapHTML() {
-               global $wgJsMimeType;
+               global $wgOut;
                
-               $onloadFunctions = MapsGoogleMaps::addOverlayOutput( 
$this->output, $this->mapName, $this->overlays, $this->controls );
+               MapsGoogleMaps::addOverlayOutput( $this->output, 
$this->mapName, $this->overlays, $this->controls );
                
-               $this->output .= <<<EOT
-<div id="$this->mapName"></div>
-<script type="$wgJsMimeType"> /*<![CDATA[*/
+               $this->output .= Html::element(
+                       'div',
+                       array(
+                               'id' => $this->mapName,
+                               'width' => $this->width,
+                               'height' => $this->height
+                       ),
+                       null
+               );
+               
+               $wgOut->addInlineScript(
+                       <<<EOT
 addOnloadHook(
        function() {
-       initializeGoogleMap('$this->mapName', 
-               {
-               width: $this->width,
-               height: $this->height,
-               lat: $this->centre_lat,
-               lon: $this->centre_lon,
-               zoom: $this->zoom,
-               type: $this->type,
-               types: [$this->types],
-               controls: [$this->controls],
-               scrollWheelZoom: $this->autozoom
-               },
-               [$this->markerString]
-       );
+               initializeGoogleMap('$this->mapName', 
+                       {
+                       lat: $this->centre_lat,
+                       lon: $this->centre_lon,
+                       zoom: $this->zoom,
+                       type: $this->type,
+                       types: [$this->types],
+                       controls: [$this->controls],
+                       scrollWheelZoom: $this->autozoom
+                       },
+                       [$this->markerString]
+               );
        }
 );
-/*]]>*/ </script>
-EOT;
+EOT
+               );
 
-       $this->output .= $onloadFunctions;
-
        }
        
 }

Modified: trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3.php
===================================================================
--- trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3.php      2010-03-28 
17:33:53 UTC (rev 64298)
+++ trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3.php      2010-03-28 
19:09:00 UTC (rev 64299)
@@ -125,12 +125,12 @@
         */
        public static function addGMap3Dependencies( &$output ) {
                global $wgJsMimeType, $wgLang;
-               global $egMapsScriptPath, $egGMaps3OnThisPage, 
$egMapsStyleVersion;
+               global $egMapsScriptPath, $egGMaps3OnThisPage, 
$egMapsStyleVersion, $egMapsJsExt;
 
                if ( empty( $egGMaps3OnThisPage ) ) {
                        $egGMaps3OnThisPage = 0;
 
-                       $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>";
+                       $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>";
                }
        }
        

Modified: trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispMap.php
===================================================================
--- trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispMap.php       
2010-03-28 17:33:53 UTC (rev 64298)
+++ trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispMap.php       
2010-03-28 19:09:00 UTC (rev 64299)
@@ -56,27 +56,36 @@
         *
         */
        public function addSpecificMapHTML() {
-               global $wgJsMimeType;
+               global $wgOut;
                
-               $this->output .= <<<EOT
-<div id="$this->mapName" style="width:{$this->width}px; 
height:{$this->height}px"></div>
-<script type="$wgJsMimeType"> /*<![CDATA[*/
+               $this->output .= Html::element(
+                       'div',
+                       array(
+                               'id' => $this->mapName,
+                               'width' => $this->width,
+                               'height' => $this->height
+                       ),
+                       null
+               );
+               
+               $wgOut->addInlineScript( <<<EOT
 addOnloadHook(
        function() {
-       initGMap3("$this->mapName", {
-                       zoom: $this->zoom,
-                       lat: $this->centre_lat,
-                       lon: $this->centre_lon, 
-                       types: [],
-                       mapTypeId: $this->type
-               },
-               []
-       );
+               initGMap3(
+                       "$this->mapName",
+                       {
+                               zoom: $this->zoom,
+                               lat: $this->centre_lat,
+                               lon: $this->centre_lon, 
+                               types: [],
+                               mapTypeId: $this->type
+                       },
+                       []
+               );
        }
 );
-/*]]>*/ </script>
-EOT;
-               
+EOT
+               );
        }
        
 }

Modified: trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispPoint.php
===================================================================
--- trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispPoint.php     
2010-03-28 17:33:53 UTC (rev 64298)
+++ trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispPoint.php     
2010-03-28 19:09:00 UTC (rev 64299)
@@ -58,28 +58,36 @@
         *
         */
        public function addSpecificMapHTML() {
-               global $wgJsMimeType;
+               global $wgOut;
                
-               // TODO
-               $this->output .= <<<EOT
-<div id="$this->mapName" style="width:{$this->width}px; 
height:{$this->height}px"></div>
-<script type="$wgJsMimeType"> /*<![CDATA[*/
+               $this->output .= Html::element(
+                       'div',
+                       array(
+                               'id' => $this->mapName,
+                               'width' => $this->width,
+                               'height' => $this->height
+                       ),
+                       null
+               );
+               
+               $wgOut->addInlineScript( <<<EOT
 addOnloadHook(
        function() {
-       initGMap3("$this->mapName", {
-                       zoom: $this->zoom,
-                       lat: $this->centre_lat,
-                       lon: $this->centre_lon, 
-                       types: [],
-                       mapTypeId: $this->type
-               },
-               [$this->markerString]
-       );
+               initGMap3(
+                       "$this->mapName",
+                       {
+                               zoom: $this->zoom,
+                               lat: $this->centre_lat,
+                               lon: $this->centre_lon, 
+                               types: [],
+                               mapTypeId: $this->type
+                       },
+                       [$this->markerString]
+               );
        }
 );
-/*]]>*/ </script>
-EOT;
-
+EOT
+               );
        }
        
 }

Modified: trunk/extensions/Maps/Maps.php
===================================================================
--- trunk/extensions/Maps/Maps.php      2010-03-28 17:33:53 UTC (rev 64298)
+++ trunk/extensions/Maps/Maps.php      2010-03-28 19:09:00 UTC (rev 64299)
@@ -33,7 +33,7 @@
        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>.';
 }
 else {
-       define( 'Maps_VERSION', '0.6 a1' );
+       define( 'Maps_VERSION', '0.6 a2' );
        
        // The different coordinate notations.
        define( 'Maps_COORDS_FLOAT', 0 );
@@ -73,7 +73,8 @@
  */
 function efMapsSetup() {
        global $wgExtensionCredits, $wgLang, $wgAutoloadClasses, $IP;
-       global $egMapsDefaultService, $egMapsAvailableServices, 
$egMapsServices, $egMapsDefaultGeoService, $egMapsAvailableGeoServices, 
$egMapsDir, $egMapsAvailableFeatures;
+       global $egMapsDefaultService, $egMapsAvailableServices, 
$egMapsServices, $egMapsDefaultGeoService;
+       global $egMapsAvailableGeoServices, $egMapsDir, 
$egMapsAvailableFeatures, $egMapsJsExt;
 
        // Remove all hooked in services that should not be available.
        foreach ( $egMapsServices as $service => $data ) {
@@ -125,6 +126,8 @@
                }
        }
        
+       $egMapsJsExt = $egMapsUseMinJs ? '.min.js' : '.js';
+       
        return true;
 }
 

Modified: trunk/extensions/Maps/Maps_Mapper.php
===================================================================
--- trunk/extensions/Maps/Maps_Mapper.php       2010-03-28 17:33:53 UTC (rev 
64298)
+++ trunk/extensions/Maps/Maps_Mapper.php       2010-03-28 19:09:00 UTC (rev 
64299)
@@ -26,31 +26,31 @@
        public static function initializeMainParams() {
                global $egMapsSizeRestrictions, $egMapsMapWidth, 
$egMapsMapHeight;
 
-               self::$mainParams = array
-                       (
+               Validator::addOutputFormat( 'mapdimension', array( __CLASS__, 
'setMapDimension' ) );
+               Validator::addValidationFunction( 'is_map_dimension', array( 
__CLASS__, 'isMapDimension' ) );                   
+               
+               self::$mainParams = array (
                        'zoom' => array(
                                'type' => 'integer',
                                'criteria' => array(
                                        'not_empty' => array()
-                                       )
-                               ),
+                               )
+                       ),
                        'width' => array(
-                               'type' => 'integer',
                                'criteria' => array(
-                                       'not_empty' => array(),
-                                       'in_range' => 
$egMapsSizeRestrictions['width']
-                                       ),
-                               'default' => $egMapsMapWidth
+                                       'is_map_dimension' => array( 'width' ),
                                ),
+                               'default' => $egMapsMapWidth,
+                               'output-type' => array( 'mapdimension', 
'width', true, $egMapsMapWidth )
+                       ),
                        'height' => array(
-                               'type' => 'integer',
                                'criteria' => array(
-                                       'not_empty' => array(),
-                                       'in_range' => 
$egMapsSizeRestrictions['height']
-                                       ),
-                               'default' => $egMapsMapHeight
+                                       'is_map_dimension' => array( 'height' ),
                                ),
-                       );
+                               'default' => $egMapsMapHeight,
+                               'output-type' => array( 'mapdimension', 
'height', true, $egMapsMapHeight )
+                       ),
+               );
        }
 
        /**
@@ -147,4 +147,47 @@
                
                return $service;
        }
+       
+       public static function isMapDimension( &$value, $dimension, $correct = 
false, $default = 0 ) {
+               global $egMapsSizeRestrictions;
+               
+               if ( !preg_match( '/^\d+(\.\d+)?(px|ex|em|%)?$/', $value ) ) {
+                       if ( $correct ) {
+                               $value = $default;
+                       } else {
+                               return false;
+                       }
+               }
+               
+               if ( !preg_match( '/^.*%$/', $value ) ) {
+                       $number = preg_replace( '/[^0-9]/', '', $value );
+                       if ( $number < $egMapsSizeRestrictions[$dimension][0] ) 
{
+                               if ( $correct ) {
+                                       $value = 
$egMapsSizeRestrictions[$dimension][0];
+                               } else {
+                                       return false;
+                               }
+                       } else if ( $number > 
$egMapsSizeRestrictions[$dimension][1] ) {
+                               if ( $correct ) {
+                                       $value = 
$egMapsSizeRestrictions[$dimension][1];
+                               } else {
+                                       return false;
+                               }
+                       }
+               }
+               
+               if ( $correct ) {
+                       if ( !preg_match( '/(px|ex|em|%)$/', $value ) ) {
+                               $value .= 'px';
+                       }                       
+               }
+               
+               return true;            
+       }
+       
+       public static function setMapDimension( &$value, $dimension, $correct, 
$default ) {
+               global $egMapsMapWidth;
+               self::isMapDimension( $value, $dimension, $correct, $default ); 
+       }
+
 }

Modified: trunk/extensions/Maps/Maps_Settings.php
===================================================================
--- trunk/extensions/Maps/Maps_Settings.php     2010-03-28 17:33:53 UTC (rev 
64298)
+++ trunk/extensions/Maps/Maps_Settings.php     2010-03-28 19:09:00 UTC (rev 
64299)
@@ -125,6 +125,15 @@
 
 
 
+# General configuration
+
+# Boolean. Indicates if minified js files should be used where available.
+$egMapsUseMinJs = false; 
+
+
+
+
+
 # Coordinate configuration
 
 # Enum. The default output format of coordinates.

Modified: trunk/extensions/Maps/Maps_Utils.php
===================================================================
--- trunk/extensions/Maps/Maps_Utils.php        2010-03-28 17:33:53 UTC (rev 
64298)
+++ trunk/extensions/Maps/Maps_Utils.php        2010-03-28 19:09:00 UTC (rev 
64299)
@@ -127,32 +127,7 @@
                        return $decimal . "° E";
                }
        }
-       
-       /**
-        * If the provided height or width do not fall within the allowed 
interval,
-        * they are changed to the nearest allowed value.
-        * 
-        * @param integer $width
-        * @param integer $height
-        */
-       public static function makeMapSizeValid( &$width, &$height ) {
-               global $egMapsSizeRestrictions;
 
-               if ( $width < $egMapsSizeRestrictions['width'][0] )  {
-                       $width = $egMapsSizeRestrictions['width'][0];
-               }
-               else if ( $width > $egMapsSizeRestrictions['width'][1] ) {
-                       $width = $egMapsSizeRestrictions['width'][1];
-               }
-               
-               if ( $height < $egMapsSizeRestrictions['height'][0] )  {
-                       $height = $egMapsSizeRestrictions['height'][0];
-               }
-               else if ( $height > $egMapsSizeRestrictions['height'][1] ) {
-                       $height = $egMapsSizeRestrictions['height'][1];
-               }
-       }
-
        /**
         * Convert from WGS84 to spherical mercator.
         */

Modified: trunk/extensions/Maps/OpenLayers/Maps_OpenLayers.php
===================================================================
--- trunk/extensions/Maps/OpenLayers/Maps_OpenLayers.php        2010-03-28 
17:33:53 UTC (rev 64298)
+++ trunk/extensions/Maps/OpenLayers/Maps_OpenLayers.php        2010-03-28 
19:09:00 UTC (rev 64299)
@@ -118,14 +118,14 @@
         */
        public static function addOLDependencies( &$output ) {
                global $wgJsMimeType;
-               global $egOpenLayersOnThisPage, $egMapsScriptPath, 
$egMapsStyleVersion;
+               global $egOpenLayersOnThisPage, $egMapsScriptPath, 
$egMapsStyleVersion, $egMapsJsExt;
                
                if ( empty( $egOpenLayersOnThisPage ) ) {
                        $egOpenLayersOnThisPage = 0;
                        
                        $output .= "<link rel='stylesheet' 
href='$egMapsScriptPath/OpenLayers/OpenLayers/theme/default/style.css' 
type='text/css' />
                        <script type='$wgJsMimeType' 
src='$egMapsScriptPath/OpenLayers/OpenLayers/OpenLayers.js'></script>           
   
-                       <script type='$wgJsMimeType' 
src='$egMapsScriptPath/OpenLayers/OpenLayerFunctions.js?$egMapsStyleVersion'></script>
+                       <script type='$wgJsMimeType' 
src='$egMapsScriptPath/OpenLayers/OpenLayerFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script>
                        <script type='$wgJsMimeType'>initOLSettings(200, 
100);</script>\n";
                }
        }

Modified: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispMap.php
===================================================================
--- trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispMap.php 2010-03-28 
17:33:53 UTC (rev 64298)
+++ trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispMap.php 2010-03-28 
19:09:00 UTC (rev 64299)
@@ -46,18 +46,37 @@
         *
         */
        public function addSpecificMapHTML() {
-               global $wgJsMimeType;
+               global $wgOut;
                
                $layerItems = 
MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, 
$this->layers );
                
-               $this->output .= "<div id='$this->mapName' style='width: 
{$this->width}px; height: {$this->height}px; background-color: #cccccc;'></div>
-               <script type='$wgJsMimeType'> /*<![CDATA[*/
-                       addOnloadHook(
-                               function() {
-                                       initOpenLayer('$this->mapName', 
$this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], 
[$this->controls],[], $this->height);
-                               }
-                       );
-               /*]]>*/ </script>";
+               $this->output .= Html::element(
+                       'div',
+                       array(
+                               'id' => $this->mapName,
+                               'width' => $this->width,
+                               'height' => $this->height
+                       ),
+                       null
+               );
+               
+               $wgOut->addInlineScript( <<<EOT
+addOnloadHook(
+       function() {
+               initOpenLayer(
+                       '$this->mapName',
+                       $this->centre_lon,
+                       $this->centre_lat,
+                       $this->zoom,
+                       [$layerItems],
+                       [$this->controls],
+                       [],
+                       $this->height
+               );
        }
+);
+EOT
+               );
+       }
 
 }
\ No newline at end of file

Modified: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispPoint.php
===================================================================
--- trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispPoint.php       
2010-03-28 17:33:53 UTC (rev 64298)
+++ trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispPoint.php       
2010-03-28 19:09:00 UTC (rev 64299)
@@ -13,7 +13,6 @@
        die( 'Not an entry point.' );
 }
 
-
 /**
  * Class for handling the display_point(s) parser functions with OpenLayers.
  *
@@ -54,18 +53,37 @@
         *
         */
        public function addSpecificMapHTML() {
-               global $wgJsMimeType;
-
+               global $wgOut;
+               
                $layerItems = 
MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, 
$this->layers );
                
-               $this->output .= "<div id='$this->mapName' style='width: 
{$this->width}px; height: {$this->height}px; background-color: #cccccc;'></div>
-               <script type='$wgJsMimeType'> /*<![CDATA[*/
-                       addOnloadHook(
-                               function() {
-                                       initOpenLayer('$this->mapName', 
$this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], 
[$this->controls],[$this->markerString], $this->height);
-                               }
-                       );
-               /*]]>*/ </script>";
+               $this->output .= Html::element(
+                       'div',
+                       array(
+                               'id' => $this->mapName,
+                               'width' => $this->width,
+                               'height' => $this->height
+                       ),
+                       null
+               );
+               
+               $wgOut->addInlineScript( <<<EOT
+addOnloadHook(
+       function() {
+               initOpenLayer(
+                       '$this->mapName',
+                       $this->centre_lon,
+                       $this->centre_lat,
+                       $this->zoom,
+                       [$layerItems],
+                       [$this->controls],
+                       [$this->markerString],
+                       $this->height
+               );
        }
+);
+EOT
+               );
+       }
 
 }
\ No newline at end of file

Modified: trunk/extensions/Maps/OpenStreetMap/Maps_OSM.php
===================================================================
--- trunk/extensions/Maps/OpenStreetMap/Maps_OSM.php    2010-03-28 17:33:53 UTC 
(rev 64298)
+++ trunk/extensions/Maps/OpenStreetMap/Maps_OSM.php    2010-03-28 19:09:00 UTC 
(rev 64299)
@@ -149,14 +149,14 @@
         */
        public static function addOSMDependencies( &$output ) {
                global $wgJsMimeType;
-               global $egOSMMapsOnThisPage, $egMapsScriptPath, 
$egMapsStyleVersion;
+               global $egOSMMapsOnThisPage, $egMapsScriptPath, 
$egMapsStyleVersion, $egMapsJsExt;
                
                if ( empty( $egOSMMapsOnThisPage ) ) {
                        $egOSMMapsOnThisPage = 0;
                        
                        $output .= "<link rel='stylesheet' 
href='$egMapsScriptPath/OpenLayers/OpenLayers/theme/default/style.css' 
type='text/css' />
                        <script type='$wgJsMimeType' 
src='$egMapsScriptPath/OpenLayers/OpenLayers/OpenLayers.js'></script>           
   
-                       <script type='$wgJsMimeType' 
src='$egMapsScriptPath/OpenStreetMap/OSMFunctions.min.js?$egMapsStyleVersion'></script>
+                       <script type='$wgJsMimeType' 
src='$egMapsScriptPath/OpenStreetMap/OSMFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script>
                        <script type='$wgJsMimeType'>slippymaps = 
Array();</script>\n";
                }
        }

Modified: trunk/extensions/Maps/OpenStreetMap/Maps_OSMDispMap.php
===================================================================
--- trunk/extensions/Maps/OpenStreetMap/Maps_OSMDispMap.php     2010-03-28 
17:33:53 UTC (rev 64298)
+++ trunk/extensions/Maps/OpenStreetMap/Maps_OSMDispMap.php     2010-03-28 
19:09:00 UTC (rev 64299)
@@ -67,10 +67,14 @@
         *
         */
        public function addSpecificMapHTML() {
-               global $wgJsMimeType;
+               global $wgOut;
                
-               $this->output .= <<<EOT
-                       <script 
type='$wgJsMimeType'>slippymaps['$this->mapName'] = new 
slippymap_map('$this->mapName', {
+               $wgOut->addInlineScript( <<<EOT
+addOnloadHook(
+       function() {            
+               slippymaps['$this->mapName'] = new slippymap_map(
+                       '$this->mapName',
+                       {
                                mode: '$this->mode',
                                layer: 'osm-like',
                                locale: '$this->lang',
@@ -81,9 +85,12 @@
                                height: $this->height,
                                markers: [],
                                controls: [$this->controls]
-                       });</script>
-
-EOT;
+                       }
+               );
+       }
+);                     
+EOT
+               );              
        
                $this->output .= $this->static ? $this->getStaticMap() : 
$this->getDynamicMap();
        }
@@ -94,16 +101,28 @@
         * @return string
         */
        private function getDynamicMap() {
-               global $wgJsMimeType;
+               global $wgOut;
                
-               return <<<EOT
-                               <!-- map div -->
-                               <div id='$this->mapName' class='map' 
style='width:{$this->width}px; height:{$this->height}px;'>
-                                       <script 
type='$wgJsMimeType'>slippymaps['$this->mapName'].init();</script>
-                               <!-- /map div -->
-                               </div>
-EOT;
+               $wgOut->addInlineScript( <<<EOT
+addOnloadHook(
+       function() {            
+               slippymaps['$this->mapName'].init();
        }
+);     
+EOT
+               );
+               
+               return Html::element(
+                       'div',
+                       array(
+                               'id' => $this->mapName,
+                               'width' => $this->width,
+                               'height' => $this->height,
+                               'class' => 'map'
+                       ),
+                       null
+               );
+       }
        
        /**
         * Returns html for a static map.
@@ -120,28 +139,34 @@
                $rendering_url  = $static->getUrl();
                
                $alt = wfMsg( 'maps_centred_on', $this->centre_lat, 
$this->centre_lon );
+               $title = $this->activatable ? wfMsg( 'maps_click_to_activate' ) 
: $alt;
                
+               $image = array(
+                       'class' => 'mapPreview',
+                       'src' => $rendering_url,
+                       'width' => $this->width,
+                       'height' => $this->height,
+                       'alt' => $alt,
+                       'title' => $title,
+               );
+               
                if ( $this->activatable ) {
-                       $title = wfMsg( 'maps_click_to_activate' );
-                       $activationCode = 
"onclick=\"slippymaps['$this->mapName'].init();\"";
+                       $image['onclick'] = 
"slippymaps['$this->mapName'].init();";
                }
-               else {
-                       $activationCode = '';
-                       $title = $alt;
-               }
                
-               return <<<EOT
-                               <div id="$this->mapName" class="map" 
style="width:{$this->width}px; height:{$this->height}px;">
-                                       <img id="$this->mapName-preview"
-                                               class="mapPreview"
-                                               src="{$rendering_url}" 
-                                               width="$this->width"
-                                               height="$this->height"
-                                               alt="$alt"
-                                               title="$title"
-                                               $activationCode />
-                               </div>
-EOT;
+               return Html::element(
+                       'div',
+                       array(
+                               'id' => $this->mapName,
+                               'width' => $this->width,
+                               'height' => $this->height,
+                               'class' => 'map'
+                       ),
+                       Html::element(
+                               'img',
+                               $image
+                       )
+               );
        }
        
 }

Modified: trunk/extensions/Maps/OpenStreetMap/Maps_OSMDispPoint.php
===================================================================
--- trunk/extensions/Maps/OpenStreetMap/Maps_OSMDispPoint.php   2010-03-28 
17:33:53 UTC (rev 64298)
+++ trunk/extensions/Maps/OpenStreetMap/Maps_OSMDispPoint.php   2010-03-28 
19:09:00 UTC (rev 64299)
@@ -53,13 +53,17 @@
         *
         */
        public function addSpecificMapHTML() {
-               global $wgJsMimeType;
+               global $wgOut;
                
-               $this->output .= <<<EOT
-                       <script 
type='$wgJsMimeType'>slippymaps['$this->mapName'] = new 
slippymap_map('$this->mapName', {
-                               mode: 'osm-wm',
+               $wgOut->addInlineScript( <<<EOT
+addOnloadHook(
+       function() {            
+               slippymaps['$this->mapName'] = new slippymap_map(
+                       '$this->mapName',
+                       {
+                               mode: '$this->mode',
                                layer: 'osm-like',
-                               locale: '$this->lang',                          
+                               locale: '$this->lang',
                                lat: $this->centre_lat,
                                lon: $this->centre_lon,
                                zoom: $this->zoom,
@@ -67,14 +71,23 @@
                                height: $this->height,
                                markers: [$this->markerString],
                                controls: [$this->controls]
-                       });</script>
+                       }
+               );
+               slippymaps['$this->mapName'].init();
+       }
+);     
+EOT
+               );
                
-                               <!-- map div -->
-                               <div id='$this->mapName' class='map' 
style='width:{$this->width}px; height:{$this->height}px;'>
-                                       <script 
type='$wgJsMimeType'>slippymaps['$this->mapName'].init();</script>
-                               <!-- /map div -->
-                               </div>
-EOT;
+               $this->output .= Html::element(
+                       'div',
+                       array(
+                               'id' => $this->mapName,
+                               'width' => $this->width,
+                               'height' => $this->height,
+                               'class' => 'map'
+                       ),
+                       null
+               );
        }
-
 }
\ No newline at end of file

Modified: trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php
===================================================================
--- trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php      
2010-03-28 17:33:53 UTC (rev 64298)
+++ trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php      
2010-03-28 19:09:00 UTC (rev 64299)
@@ -146,8 +146,10 @@
                }
         }
         
-        // Return the result
-        return $parser->insertStripItem( $output, $parser->mStripState );
+        // Return the result.
+        //return array( $parser->insertStripItem( $output, 
$parser->mStripState), 'noparse' => true, 'isHTML' => true );
+        //return $parser->insertStripItem( $output, $parser->mStripState);
+        return array( $output, 'noparse' => true, 'isHTML' => true );
        }
        
        /**

Modified: trunk/extensions/Maps/YahooMaps/Maps_YahooMaps.php
===================================================================
--- trunk/extensions/Maps/YahooMaps/Maps_YahooMaps.php  2010-03-28 17:33:53 UTC 
(rev 64298)
+++ trunk/extensions/Maps/YahooMaps/Maps_YahooMaps.php  2010-03-28 19:09:00 UTC 
(rev 64299)
@@ -149,12 +149,12 @@
         */
        public static function addYMapDependencies( &$output ) {
                global $wgJsMimeType;
-               global $egYahooMapsKey, $egMapsScriptPath, 
$egYahooMapsOnThisPage, $egMapsStyleVersion;
+               global $egYahooMapsKey, $egMapsScriptPath, 
$egYahooMapsOnThisPage, $egMapsStyleVersion, $egMapsJsExt;
                
                if ( empty( $egYahooMapsOnThisPage ) ) {
                        $egYahooMapsOnThisPage = 0;
                        $output .= "<script type='$wgJsMimeType' 
src='http://api.maps.yahoo.com/ajaxymap?v=3.8&amp;appid=$egYahooMapsKey'></script>
-                       <script type='$wgJsMimeType' 
src='$egMapsScriptPath/YahooMaps/YahooMapFunctions.min.js?$egMapsStyleVersion'></script>";
+                       <script type='$wgJsMimeType' 
src='$egMapsScriptPath/YahooMaps/YahooMapFunctions{$egMapsJsExt}?$egMapsStyleVersion'></script>";
                }
        }
        

Modified: trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispMap.php
===================================================================
--- trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispMap.php   2010-03-28 
17:33:53 UTC (rev 64298)
+++ trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispMap.php   2010-03-28 
19:09:00 UTC (rev 64299)
@@ -46,19 +46,37 @@
         *
         */
        public function addSpecificMapHTML() {
-               global $wgJsMimeType;
+               global $wgOut;
                
-               $this->output .= <<<EOT
-               <div id="$this->mapName" style="width: {$this->width}px; 
height: {$this->height}px;"></div>  
+               $this->output .= Html::element(
+                       'div',
+                       array(
+                               'id' => $this->mapName,
+                               'width' => $this->width,
+                               'height' => $this->height
+                       ),
+                       null
+               );
                
-               <script type="$wgJsMimeType">/*<![CDATA[*/
-               addOnloadHook(
-                       function() {
-                               initializeYahooMap('$this->mapName', 
$this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$this->types], 
[$this->controls], $this->autozoom, [], $this->height);
-                       }
+               $wgOut->addInlineScript( <<<EOT
+addOnloadHook(
+       function() {
+               initializeYahooMap(
+                       '$this->mapName',
+                       $this->centre_lat,
+                       $this->centre_lon,
+                       $this->zoom,
+                       $this->type,
+                       [$this->types],
+                       [$this->controls],
+                       $this->autozoom,
+                       [],
+                       $this->height
                );
-                       /*]]>*/</script>
-EOT;
        }
+);
+EOT
+               );              
+       }
 
 }

Modified: trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispPoint.php
===================================================================
--- trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispPoint.php 2010-03-28 
17:33:53 UTC (rev 64298)
+++ trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispPoint.php 2010-03-28 
19:09:00 UTC (rev 64299)
@@ -53,19 +53,37 @@
         *
         */
        public function addSpecificMapHTML() {
-               global $wgJsMimeType;
+               global $wgOut;
                
-               $this->output .= <<<EOT
-               <div id="$this->mapName" style="width: {$this->width}px; 
height: {$this->height}px;"></div>  
+               $this->output .= Html::element(
+                       'div',
+                       array(
+                               'id' => $this->mapName,
+                               'width' => $this->width,
+                               'height' => $this->height
+                       ),
+                       null
+               );
                
-               <script type="$wgJsMimeType">/*<![CDATA[*/
-               addOnloadHook(
-                       function() {
-                               initializeYahooMap('$this->mapName', 
$this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$this->types], 
[$this->controls], $this->autozoom, [$this->markerString], $this->height);
-                       }
+               $wgOut->addInlineScript( <<<EOT
+addOnloadHook(
+       function() {
+               initializeYahooMap(
+                       '$this->mapName',
+                       $this->centre_lat,
+                       $this->centre_lon,
+                       $this->zoom,
+                       $this->type,
+                       [$this->types],
+                       [$this->controls],
+                       $this->autozoom,
+                       [$this->markerString],
+                       $this->height
                );
-                       /*]]>*/</script>
-EOT;
        }
+);
+EOT
+               );
+       }
 
 }



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to