http://www.mediawiki.org/wiki/Special:Code/MediaWiki/65327
Revision: 65327
Author: jeroendedauw
Date: 2010-04-20 15:10:46 +0000 (Tue, 20 Apr 2010)
Log Message:
-----------
Follow up to r65307
Modified Paths:
--------------
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_GoogleMaps3DispMap.php
trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispPoint.php
trunk/extensions/Maps/Maps.php
trunk/extensions/Maps/Maps_Mapper.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/ParserFunctions/DisplayMap/Maps_BaseMap.php
trunk/extensions/Maps/ParserFunctions/DisplayPoint/Maps_BasePointMap.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
Added Paths:
-----------
trunk/extensions/Maps/ParserFunctions/Maps_iMapFeature.php
Removed Paths:
-------------
trunk/extensions/Maps/Maps_MapFeature.php
trunk/extensions/Maps/ParserFunctions/Maps_iDisplayFunction.php
Modified: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php
===================================================================
--- trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php 2010-04-20
14:32:59 UTC (rev 65326)
+++ trunk/extensions/Maps/GoogleMaps/Maps_GoogleMaps.php 2010-04-20
15:10:46 UTC (rev 65327)
@@ -64,9 +64,6 @@
$allowedTypes = self::getTypeNames();
-
$egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['default'] =
$egMapsGoogleMapsZoom;
-
$egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range']
= array( 0, 20 );
-
$egMapsServices[self::SERVICE_NAME]['parameters'] = array(
'controls' => array(
'type' => array( 'string', 'list' ),
@@ -100,6 +97,9 @@
'output-type' => 'boolstr'
),
);
+
+
$egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['default'] =
$egMapsGoogleMapsZoom;
+
$egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range']
= array( 0, 20 );
}
//
http://code.google.com/apis/maps/documentation/reference.html#GMapType.G_NORMAL_MAP
Modified: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispMap.php
===================================================================
--- trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispMap.php 2010-04-20
14:32:59 UTC (rev 65326)
+++ trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispMap.php 2010-04-20
15:10:46 UTC (rev 65327)
@@ -23,7 +23,7 @@
final class MapsGoogleMapsDispMap extends MapsBaseMap {
public $serviceName = MapsGoogleMaps::SERVICE_NAME;
-
+
public function getSpecificParameterInfo() {
global $egMapsGMapOverlays;
// TODO: it'd be cool to have this static so it can be cheched
in order to only init it once.
@@ -40,19 +40,9 @@
}
/**
- * @see MapsBaseMap::setMapSettings()
- */
- protected function setMapSettings() {
- global $egMapsGoogleMapsZoom, $egMapsGoogleMapsPrefix;
-
- $this->elementNamePrefix = $egMapsGoogleMapsPrefix;
- $this->defaultZoom = $egMapsGoogleMapsZoom;
- }
-
- /**
* @see MapsBaseMap::doMapServiceLoad()
*/
- protected function doMapServiceLoad() {
+ public function doMapServiceLoad() {
global $egGoogleMapsOnThisPage;
MapsGoogleMaps::addGMapDependencies( $this->output );
@@ -65,22 +55,26 @@
* @see MapsBaseMap::addSpecificMapHTML()
*/
public function addSpecificMapHTML( Parser $parser ) {
- MapsGoogleMaps::addOverlayOutput( $this->output,
$this->mapName, $this->overlays, $this->controls );
+ global $egMapsGoogleMapsPrefix, $egGoogleMapsOnThisPage;
+ $mapName = $egMapsGoogleMapsPrefix . '_' .
$egGoogleMapsOnThisPage;
+
+ MapsGoogleMaps::addOverlayOutput( $this->output, $mapName,
$this->overlays, $this->controls );
+
$this->output .= Html::element(
'div',
array(
- 'id' => $this->mapName,
+ 'id' => $mapName,
'style' => "width: $this->width; height:
$this->height; background-color: #cccccc;",
),
- wfMsg('maps-loading-map')
+ wfMsg( 'maps-loading-map' )
);
$parser->getOutput()->addHeadItem(
Html::inlineScript( <<<EOT
addOnloadHook(
function() {
- initializeGoogleMap('$this->mapName',
+ initializeGoogleMap('$mapName',
{
lat: $this->centreLat,
lon: $this->centreLon,
Modified: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispPoint.php
===================================================================
--- trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispPoint.php
2010-04-20 14:32:59 UTC (rev 65326)
+++ trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsDispPoint.php
2010-04-20 15:10:46 UTC (rev 65327)
@@ -24,6 +24,8 @@
public $serviceName = MapsGoogleMaps::SERVICE_NAME;
+ protected $markerStringFormat = 'getGMarkerData(lat, lon, \'title\',
\'label\', "icon")';
+
public function getSpecificParameterInfo() {
global $egMapsGMapOverlays;
// TODO: it'd be cool to have this static so it can be cheched
in order to only init it once.
@@ -38,25 +40,11 @@
);
return $this->spesificParameters;
}
-
+
/**
- * @see MapsBaseMap::setMapSettings()
- *
- */
- protected function setMapSettings() {
- global $egMapsGoogleMapsZoom, $egMapsGoogleMapsPrefix;
-
- $this->elementNamePrefix = $egMapsGoogleMapsPrefix;
- $this->defaultZoom = $egMapsGoogleMapsZoom;
-
- $this->markerStringFormat = 'getGMarkerData(lat, lon,
\'title\', \'label\', "icon")';
- }
-
- /**
* @see MapsBaseMap::doMapServiceLoad()
- *
*/
- protected function doMapServiceLoad() {
+ public function doMapServiceLoad() {
global $egGoogleMapsOnThisPage;
MapsGoogleMaps::addGMapDependencies( $this->output );
@@ -67,18 +55,21 @@
/**
* @see MapsBaseMap::addSpecificMapHTML()
- *
*/
public function addSpecificMapHTML( Parser $parser ) {
- MapsGoogleMaps::addOverlayOutput( $this->output,
$this->mapName, $this->overlays, $this->controls );
+ global $egMapsGoogleMapsPrefix, $egGoogleMapsOnThisPage;
+ $mapName = $egMapsGoogleMapsPrefix . '_' .
$egGoogleMapsOnThisPage;
+
+ MapsGoogleMaps::addOverlayOutput( $this->output, $mapName,
$this->overlays, $this->controls );
+
$this->output .= Html::element(
'div',
array(
- 'id' => $this->mapName,
+ 'id' => $mapName,
'style' => "width: $this->width; height:
$this->height; background-color: #cccccc;",
),
- wfMsg('maps-loading-map')
+ wfMsg( 'maps-loading-map' )
);
$parser->getOutput()->addHeadItem(
@@ -86,7 +77,7 @@
<<<EOT
addOnloadHook(
function() {
- initializeGoogleMap('$this->mapName',
+ initializeGoogleMap('$mapName',
{
lat: $this->centreLat,
lon: $this->centreLon,
Modified: trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispMap.php
===================================================================
--- trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispMap.php
2010-04-20 14:32:59 UTC (rev 65326)
+++ trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispMap.php
2010-04-20 15:10:46 UTC (rev 65327)
@@ -23,20 +23,6 @@
final class MapsGoogleMaps3DispMap extends MapsBaseMap {
public $serviceName = MapsGoogleMaps3::SERVICE_NAME;
-
- /**
- * @see MapsBaseMap::setMapSettings()
- *
- */
- protected function setMapSettings() {
- global $egMapsGMaps3Zoom, $egMapsGMaps3Prefix;
-
- $this->elementNamePrefix = $egMapsGMaps3Prefix;
- $this->defaultZoom = $egMapsGMaps3Zoom;
-
- $this->spesificParameters = array(
- );
- }
/**
* @see MapsBaseMap::doMapServiceLoad()
@@ -56,21 +42,26 @@
*
*/
public function addSpecificMapHTML( Parser $parser ) {
+ global $egMapsGMaps3Prefix, $egGMaps3OnThisPage;
+
+ $mapName = $egMapsGMaps3Prefix . '_' . $egGMaps3OnThisPage;
+
$this->output .= Html::element(
'div',
array(
- 'id' => $this->mapName,
+ 'id' => $mapName,
'width' => $this->width,
'height' => $this->height
),
null
);
- $wgOut->addInlineScript( <<<EOT
+ $parser->getOutput()->addHeadItem(
+ Html::inlineScript( <<<EOT
addOnloadHook(
function() {
initGMap3(
- "$this->mapName",
+ '$mapName',
{
zoom: $this->zoom,
lat: $this->centreLat,
@@ -83,6 +74,7 @@
}
);
EOT
+ )
);
}
Modified: trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispPoint.php
===================================================================
--- trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispPoint.php
2010-04-20 14:32:59 UTC (rev 65326)
+++ trunk/extensions/Maps/GoogleMaps3/Maps_GoogleMaps3DispPoint.php
2010-04-20 15:10:46 UTC (rev 65327)
@@ -24,21 +24,7 @@
public $serviceName = MapsGoogleMaps3::SERVICE_NAME;
- /**
- * @see MapsBaseMap::setMapSettings()
- *
- */
- protected function setMapSettings() {
- global $egMapsGMaps3Zoom, $egMapsGMaps3Prefix;
-
- $this->elementNamePrefix = $egMapsGMaps3Prefix;
- $this->defaultZoom = $egMapsGMaps3Zoom;
-
- $this->markerStringFormat = 'getGMaps3MarkerData(lat, lon,
\'title\', \'label\', "icon")';
-
- $this->spesificParameters = array(
- );
- }
+ protected $markerStringFormat = 'getGMaps3MarkerData(lat, lon,
\'title\', \'label\', "icon")';
/**
* @see MapsBaseMap::doMapServiceLoad()
@@ -58,21 +44,26 @@
*
*/
public function addSpecificMapHTML( Parser $parser ) {
+ global $egMapsGMaps3Prefix, $egGMaps3OnThisPage;
+
+ $mapName = $egMapsGMaps3Prefix . '_' . $egGMaps3OnThisPage;
+
$this->output .= Html::element(
'div',
array(
- 'id' => $this->mapName,
+ 'id' => $mapName,
'width' => $this->width,
'height' => $this->height
),
null
);
- $wgOut->addInlineScript( <<<EOT
+ $parser->getOutput()->addHeadItem(
+ Html::inlineScript( <<<EOT
addOnloadHook(
function() {
initGMap3(
- "$this->mapName",
+ '$mapName',
{
zoom: $this->zoom,
lat: $this->centreLat,
@@ -85,6 +76,7 @@
}
);
EOT
+ )
);
}
Modified: trunk/extensions/Maps/Maps.php
===================================================================
--- trunk/extensions/Maps/Maps.php 2010-04-20 14:32:59 UTC (rev 65326)
+++ trunk/extensions/Maps/Maps.php 2010-04-20 15:10:46 UTC (rev 65327)
@@ -84,7 +84,6 @@
// Autoload the general classes
$wgAutoloadClasses['MapsCoordinateParser'] = $egMapsDir .
'Maps_CoordinateParser.php';
- $wgAutoloadClasses['MapsMapFeature'] = $egMapsDir .
'Maps_MapFeature.php';
$wgAutoloadClasses['MapsMapper'] =
$egMapsDir . 'Maps_Mapper.php';
wfLoadExtensionMessages( 'Maps' );
Deleted: trunk/extensions/Maps/Maps_MapFeature.php
===================================================================
--- trunk/extensions/Maps/Maps_MapFeature.php 2010-04-20 14:32:59 UTC (rev
65326)
+++ trunk/extensions/Maps/Maps_MapFeature.php 2010-04-20 15:10:46 UTC (rev
65327)
@@ -1,128 +0,0 @@
-<?php
-
-/**
- * File holding class MapsMapFeature.
- *
- * @file Maps_MapFeature.php
- * @ingroup Maps
- *
- * @author Jeroen De Dauw
- */
-
-if ( !defined( 'MEDIAWIKI' ) ) {
- die( 'Not an entry point.' );
-}
-
-/**
- * MapsMapFeature bundles base functionallity for all general mapping feature
classes.
- *
- * @ingroup Maps
- *
- * @author Jeroen De Dauw
- *
- * TODO: refactor this and subclasses to follow mw conventions and simply have
a better design pattern.
- */
-abstract class MapsMapFeature {
-
- /**
- * Set the map service specific element name and the javascript
function handling the displaying of an address
- */
- protected abstract function setMapSettings();
-
- /**
- * Map service specific map count and loading of dependencies
- */
- protected abstract function doMapServiceLoad();
-
- /**
- * Adds the HTML specific to the mapping service to the output
- */
- protected abstract function addSpecificMapHTML( Parser $parser );
-
- public $serviceName;
-
- protected $elementNr;
- protected $elementNamePrefix;
-
- protected $mapName;
-
- protected $centreLat, $centreLon;
-
- protected $output = '';
-
- protected $spesificParameters = false;
- protected $featureParameters = false;
-
- /**
- * Sets the map properties as class fields.
- *
- * @param array $mapProperties
- * @param string $className
- */
- protected function setMapProperties( array $mapProperties, $className )
{
- foreach ( $mapProperties as $paramName => $paramValue ) {
- if ( !property_exists( $className, $paramName ) ) {
- $this-> { $paramName } = $paramValue;
- }
- else {
- // If this happens in any way, it could be a
big vunerability, so throw an exception.
- throw new Exception( 'Attempt to override a
class field during map property assignment. Field name: ' . $paramName );
- }
- }
- }
-
- /**
- * Sets the $mapName field, using the $elementNamePrefix and $elementNr.
- */
- protected function setMapName() {
- $this->mapName = $this->elementNamePrefix . '_' .
$this->elementNr;
- }
-
- /**
- * @return array
- */
- public function getSpecificParameterInfo() {
- return array();
- }
-
- /**
- * @return array
- */
- public function getFeatureParameters() {
- global $egMapsAvailableServices, $egMapsAvailableGeoServices,
$egMapsDefaultGeoService, $egMapsMapWidth, $egMapsMapHeight;
-
- return array(
- 'service' => array(
- 'criteria' => array(
- 'in_array' => $egMapsAvailableServices
- ),
- ),
- 'geoservice' => array(
- 'criteria' => array(
- 'in_array' =>
$egMapsAvailableGeoServices
- ),
- 'default' => $egMapsDefaultGeoService
- ),
- 'zoom' => array(
- 'type' => 'integer',
- 'criteria' => array(
- 'not_empty' => array()
- )
- ),
- 'width' => array(
- 'criteria' => array(
- 'is_map_dimension' => array( 'width' ),
- ),
- 'default' => $egMapsMapWidth,
- 'output-type' => array( 'mapdimension',
'width', $egMapsMapWidth )
- ),
- 'height' => array(
- 'criteria' => array(
- 'is_map_dimension' => array( 'height' ),
- ),
- 'default' => $egMapsMapHeight,
- 'output-type' => array( 'mapdimension',
'height', $egMapsMapHeight )
- ),
- );
- }
-}
\ No newline at end of file
Modified: trunk/extensions/Maps/Maps_Mapper.php
===================================================================
--- trunk/extensions/Maps/Maps_Mapper.php 2010-04-20 14:32:59 UTC (rev
65326)
+++ trunk/extensions/Maps/Maps_Mapper.php 2010-04-20 15:10:46 UTC (rev
65327)
@@ -201,6 +201,49 @@
public static function geocoderIsAvailable() {
global $wgAutoloadClasses;
return array_key_exists( 'MapsGeocoder', $wgAutoloadClasses );
+ }
+
+ /**
+ * This function returns the definitions for the parameters used by
every map feature.
+ *
+ * @return array
+ */
+ public static function getCommonParameters() {
+ global $egMapsAvailableServices, $egMapsAvailableGeoServices,
$egMapsDefaultGeoService, $egMapsMapWidth, $egMapsMapHeight;
+
+ return array(
+ 'service' => array(
+ 'criteria' => array(
+ 'in_array' => $egMapsAvailableServices
+ ),
+ ),
+ 'geoservice' => array(
+ 'criteria' => array(
+ 'in_array' =>
$egMapsAvailableGeoServices
+ ),
+ 'default' => $egMapsDefaultGeoService
+ ),
+ 'zoom' => array(
+ 'type' => 'integer',
+ 'criteria' => array(
+ 'not_empty' => array()
+ )
+ ),
+ 'width' => array(
+ 'criteria' => array(
+ 'is_map_dimension' => array( 'width' ),
+ ),
+ 'default' => $egMapsMapWidth,
+ 'output-type' => array( 'mapdimension',
'width', $egMapsMapWidth )
+ ),
+ 'height' => array(
+ 'criteria' => array(
+ 'is_map_dimension' => array( 'height' ),
+ ),
+ 'default' => $egMapsMapHeight,
+ 'output-type' => array( 'mapdimension',
'height', $egMapsMapHeight )
+ ),
+ );
}
}
Modified: trunk/extensions/Maps/OpenLayers/Maps_OpenLayers.php
===================================================================
--- trunk/extensions/Maps/OpenLayers/Maps_OpenLayers.php 2010-04-20
14:32:59 UTC (rev 65326)
+++ trunk/extensions/Maps/OpenLayers/Maps_OpenLayers.php 2010-04-20
15:10:46 UTC (rev 65327)
@@ -61,31 +61,31 @@
private static function initializeParams() {
global $egMapsServices, $egMapsOLLayers, $egMapsOLControls,
$egMapsOpenLayersZoom;
+ $egMapsServices[self::SERVICE_NAME]['parameters'] = array(
+ 'controls' => array(
+ 'type' => array( 'string', 'list' ),
+ 'criteria' => array(
+ 'in_array' => self::getControlNames()
+ ),
+ 'default' => $egMapsOLControls,
+ 'output-type' => array( 'list', ',', '\'' )
+ ),
+ 'layers' => array(
+ 'type' => array( 'string', 'list' ),
+ 'criteria' => array(
+ 'in_array' => self::getLayerNames( true
)
+ ),
+ 'default' => $egMapsOLLayers,
+ 'output-types' => array(
+ 'unique_items',
+ 'olgroups',
+ array( 'filtered_array',
self::getLayerNames() ),
+ )
+ ),
+ );
+
$egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['default'] =
$egMapsOpenLayersZoom;
-
$egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range']
= array( 0, 19 );
-
- $egMapsServices[self::SERVICE_NAME]['parameters'] = array(
-
'controls' => array(
-
'type' => array( 'string', 'list' ),
-
'criteria' => array(
-
'in_array' => self::getControlNames()
-
),
-
'default' => $egMapsOLControls,
-
'output-type' => array( 'list', ',', '\'' )
-
),
-
'layers' => array(
-
'type' => array( 'string', 'list' ),
-
'criteria' => array(
-
'in_array' => self::getLayerNames( true )
-
),
-
'default' => $egMapsOLLayers,
-
'output-types' => array(
-
'unique_items',
-
'olgroups',
-
array( 'filtered_array', self::getLayerNames() ),
-
)
-
),
- );
+
$egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range']
= array( 0, 19 );
}
/**
@@ -97,15 +97,15 @@
*/
public static function getControlNames() {
return array(
- 'argparser', 'attribution', 'button',
'dragfeature', 'dragpan',
- 'drawfeature', 'editingtoolbar', 'getfeature',
'keyboarddefaults', 'layerswitcher',
- 'measure', 'modifyfeature', 'mousedefaults',
'mouseposition', 'mousetoolbar',
- 'navigation', 'navigationhistory', 'navtoolbar',
'overviewmap', 'pan',
- 'panel', 'panpanel', 'panzoom', 'panzoombar',
'autopanzoom', 'permalink',
- 'scale', 'scaleline', 'selectfeature', 'snapping',
'split',
- 'wmsgetfeatureinfo', 'zoombox', 'zoomin', 'zoomout',
'zoompanel',
- 'zoomtomaxextent'
- );
+ 'argparser', 'attribution', 'button', 'dragfeature',
'dragpan',
+ 'drawfeature', 'editingtoolbar', 'getfeature',
'keyboarddefaults', 'layerswitcher',
+ 'measure', 'modifyfeature', 'mousedefaults',
'mouseposition', 'mousetoolbar',
+ 'navigation', 'navigationhistory', 'navtoolbar',
'overviewmap', 'pan',
+ 'panel', 'panpanel', 'panzoom', 'panzoombar',
'autopanzoom', 'permalink',
+ 'scale', 'scaleline', 'selectfeature', 'snapping',
'split',
+ 'wmsgetfeatureinfo', 'zoombox', 'zoomin', 'zoomout',
'zoompanel',
+ 'zoomtomaxextent'
+ );
}
/**
Modified: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispMap.php
===================================================================
--- trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispMap.php 2010-04-20
14:32:59 UTC (rev 65326)
+++ trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispMap.php 2010-04-20
15:10:46 UTC (rev 65327)
@@ -18,16 +18,6 @@
public $serviceName = MapsOpenLayers::SERVICE_NAME;
/**
- * @see MapsBaseMap::setMapSettings()
- */
- protected function setMapSettings() {
- global $egMapsOpenLayersZoom, $egMapsOpenLayersPrefix;
-
- $this->elementNamePrefix = $egMapsOpenLayersPrefix;
- $this->defaultZoom = $egMapsOpenLayersZoom;
- }
-
- /**
* @see MapsBaseMap::doMapServiceLoad()
*/
protected function doMapServiceLoad() {
@@ -43,23 +33,27 @@
* @see MapsBaseMap::addSpecificMapHTML()
*/
public function addSpecificMapHTML( Parser $parser ) {
+ global $egMapsOpenLayersPrefix, $egOpenLayersOnThisPage;
+
$layerItems =
MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output,
$this->layers );
+
+ $mapName = $egMapsOpenLayersPrefix . '_' .
$egOpenLayersOnThisPage;
$this->output .= Html::element(
'div',
array(
- 'id' => $this->mapName,
+ 'id' => $mapName,
'style' => "width: $this->width; height:
$this->height; background-color: #cccccc;",
),
wfMsg('maps-loading-map')
);
- $parser->getOutput()->addHeadItem(
+ $parser->getOutput()->addHeadItem(
Html::inlineScript( <<<EOT
addOnloadHook(
function() {
initOpenLayer(
- '$this->mapName',
+ '$mapName',
$this->centreLon,
$this->centreLat,
$this->zoom,
Modified: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispPoint.php
===================================================================
--- trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispPoint.php
2010-04-20 14:32:59 UTC (rev 65326)
+++ trunk/extensions/Maps/OpenLayers/Maps_OpenLayersDispPoint.php
2010-04-20 15:10:46 UTC (rev 65327)
@@ -22,20 +22,9 @@
public $serviceName = MapsOpenLayers::SERVICE_NAME;
+ protected $markerStringFormat = 'getOLMarkerData(lon, lat, \'title\',
\'label\', "icon")';
+
/**
- * @see MapsBaseMap::setMapSettings()
- *
- */
- protected function setMapSettings() {
- global $egMapsOpenLayersZoom, $egMapsOpenLayersPrefix;
-
- $this->elementNamePrefix = $egMapsOpenLayersPrefix;
- $this->defaultZoom = $egMapsOpenLayersZoom;
-
- $this->markerStringFormat = 'getOLMarkerData(lon, lat,
\'title\', \'label\', "icon")';
- }
-
- /**
* @see MapsBaseMap::doMapServiceLoad()
*
*/
@@ -53,12 +42,16 @@
*
*/
public function addSpecificMapHTML( Parser $parser ) {
+ global $egMapsOpenLayersPrefix, $egOpenLayersOnThisPage;
+
$layerItems =
MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output,
$this->layers );
+ $mapName = $egMapsOpenLayersPrefix . '_' .
$egOpenLayersOnThisPage;
+
$this->output .= Html::element(
'div',
array(
- 'id' => $this->mapName,
+ 'id' => $mapName,
'style' => "width: $this->width; height:
$this->height; background-color: #cccccc;",
),
wfMsg('maps-loading-map')
@@ -69,7 +62,7 @@
addOnloadHook(
function() {
initOpenLayer(
- '$this->mapName',
+ '$mapName',
$this->centreLon,
$this->centreLat,
$this->zoom,
Modified: trunk/extensions/Maps/ParserFunctions/DisplayMap/Maps_BaseMap.php
===================================================================
--- trunk/extensions/Maps/ParserFunctions/DisplayMap/Maps_BaseMap.php
2010-04-20 14:32:59 UTC (rev 65326)
+++ trunk/extensions/Maps/ParserFunctions/DisplayMap/Maps_BaseMap.php
2010-04-20 15:10:46 UTC (rev 65327)
@@ -22,29 +22,59 @@
*
* @author Jeroen De Dauw
*/
-abstract class MapsBaseMap extends MapsMapFeature implements iDisplayFunction {
+abstract class MapsBaseMap implements iMapFeature {
+ public $serviceName;
+
+ protected $centreLat, $centreLon;
+
+ protected $output = '';
+
+ protected $spesificParameters = false;
+ protected $featureParameters = false;
+
/**
+ * Sets the map properties as class fields.
+ *
+ * @param array $mapProperties
+ */
+ protected function setMapProperties( array $mapProperties ) {
+ foreach ( $mapProperties as $paramName => $paramValue ) {
+ if ( !property_exists( __CLASS__, $paramName ) ) {
+ $this-> { $paramName } = $paramValue;
+ }
+ else {
+ // If this happens in any way, it could be a
big vunerability, so throw an exception.
+ throw new Exception( 'Attempt to override a
class field during map property assignment. Field name: ' . $paramName );
+ }
+ }
+ }
+
+ /**
* @return array
+ */
+ public function getSpecificParameterInfo() {
+ return array();
+ }
+
+ /**
+ * @return array
*/
public function getFeatureParameters() {
global $egMapsDefaultServices;
- return array_merge(
- parent::getFeatureParameters(),
- array(
- 'service' => array(
- 'default' =>
$egMapsDefaultServices['display_map']
+ return array(
+ 'service' => array(
+ 'default' =>
$egMapsDefaultServices['display_map']
+ ),
+ 'coordinates' => array(
+ 'required' => true,
+ 'aliases' => array( 'coords', 'location',
'locations' ),
+ 'criteria' => array(
+ 'is_location' => array()
),
- 'coordinates' => array(
- 'required' => true,
- 'aliases' => array( 'coords',
'location', 'locations' ),
- 'criteria' => array(
- 'is_location' => array()
- ),
- 'output-type' => 'coordinateSet',
- ),
- )
+ 'output-type' => 'coordinateSet',
+ ),
);
}
@@ -58,18 +88,12 @@
* @return html
*/
public final function displayMap( Parser &$parser, array $params ) {
- $this->setMapSettings();
-
$this->featureParameters = MapsDisplayMap::$parameters;
$this->doMapServiceLoad();
- parent::setMapProperties( $params, __CLASS__ );
+ $this->setMapProperties( $params );
- $this->setMapName();
-
- $this->setZoom();
-
$this->setCentre();
$this->addSpecificMapHTML( $parser );
@@ -78,16 +102,6 @@
}
/**
- * Sets the zoom level to the provided value. When no zoom is provided,
set
- * it to the default when there is only one location, or the best
fitting soom when
- * there are multiple locations.
- *
- */
- private function setZoom() {
- if ( empty( $this->zoom ) ) $this->zoom = $this->defaultZoom;
- }
-
- /**
* Sets the $centre_lat and $centre_lon fields.
*/
private function setCentre() {
Modified:
trunk/extensions/Maps/ParserFunctions/DisplayPoint/Maps_BasePointMap.php
===================================================================
--- trunk/extensions/Maps/ParserFunctions/DisplayPoint/Maps_BasePointMap.php
2010-04-20 14:32:59 UTC (rev 65326)
+++ trunk/extensions/Maps/ParserFunctions/DisplayPoint/Maps_BasePointMap.php
2010-04-20 15:10:46 UTC (rev 65327)
@@ -21,48 +21,80 @@
* @ingroup Maps
*
* @author Jeroen De Dauw
+ *
+ * TODO: fix zoom - should default to 'null' when no value given and multiple
points
*/
-abstract class MapsBasePointMap extends MapsMapFeature implements
iDisplayFunction {
+abstract class MapsBasePointMap implements iMapFeature {
+ public $serviceName;
+
+ protected $centreLat, $centreLon;
+
+ protected $output = '';
+
+ protected $spesificParameters = false;
+ protected $featureParameters = false;
+
private $markerData = array();
protected $markerString;
/**
+ * Sets the map properties as class fields.
+ *
+ * @param array $mapProperties
+ */
+ protected function setMapProperties( array $mapProperties ) {
+ foreach ( $mapProperties as $paramName => $paramValue ) {
+ if ( !property_exists( __CLASS__, $paramName ) ) {
+ $this-> { $paramName } = $paramValue;
+ }
+ else {
+ // If this happens in any way, it could be a
big vunerability, so throw an exception.
+ throw new Exception( 'Attempt to override a
class field during map property assignment. Field name: ' . $paramName );
+ }
+ }
+ }
+
+ /**
* @return array
+ */
+ public function getSpecificParameterInfo() {
+ return array();
+ }
+
+ /**
+ * @return array
*/
public function getFeatureParameters() {
global $egMapsDefaultServices, $egMapsDefaultTitle,
$egMapsDefaultLabel;
- return array_merge(
- parent::getFeatureParameters(),
- array(
- 'service' => array(
- 'default' =>
$egMapsDefaultServices['display_point']
+ return array(
+ 'service' => array(
+ 'default' =>
$egMapsDefaultServices['display_point']
+ ),
+ 'centre' => array(
+ 'aliases' => array( 'center' ),
+ ),
+ 'title' => array(
+ 'default' => $egMapsDefaultTitle
+ ),
+ 'label' => array(
+ 'default' => $egMapsDefaultLabel
+ ),
+ 'icon' => array(
+ 'criteria' => array(
+ 'not_empty' => array()
+ )
+ ),
+ 'coordinates' => array(
+ 'required' => true,
+ 'type' => array( 'string', 'list', ';' ),
+ 'aliases' => array( 'coords', 'location',
'locations' ),
+ 'criteria' => array(
+ 'are_locations' => array()
),
- 'centre' => array(
- 'aliases' => array( 'center' ),
- ),
- 'title' => array(
- 'default' => $egMapsDefaultTitle
- ),
- 'label' => array(
- 'default' => $egMapsDefaultLabel
- ),
- 'icon' => array(
- 'criteria' => array(
- 'not_empty' => array()
- )
- ),
- 'coordinates' => array(
- 'required' => true,
- 'type' => array( 'string', 'list', ';'
),
- 'aliases' => array( 'coords',
'location', 'locations' ),
- 'criteria' => array(
- 'are_locations' => array()
- ),
- 'output-type' => 'coordinateSets',
- ),
- )
+ 'output-type' => 'coordinateSets',
+ ),
);
}
@@ -75,23 +107,17 @@
*
* @return html
*/
- public final function displayMap( Parser &$parser, array $params ) {
- $this->setMapSettings();
-
+ public final function displayMap( Parser &$parser, array $params ) {
$this->featureParameters = MapsDisplayPoint::$parameters;
$this->doMapServiceLoad();
- parent::setMapProperties( $params, __CLASS__ );
+ $this->setMapProperties( $params );
- $this->setMapName();
-
$this->setMarkerData( $parser );
$this->createMarkerString();
- $this->setZoom();
-
$this->setCentre();
$this->addSpecificMapHTML( $parser );
@@ -100,23 +126,6 @@
}
/**
- * Sets the zoom level to the provided value. When no zoom is provided,
set
- * it to the default when there is only one location, or the best
fitting soom when
- * there are multiple locations.
- *
- */
- private function setZoom() {
- if ( strlen( $this->zoom ) < 1 ) {
- if ( count( $this->markerData ) > 1 ) {
- $this->zoom = 'null';
- }
- else {
- $this->zoom = $this->defaultZoom;
- }
- }
- }
-
- /**
* Fills the $markerData array with the locations and their meta data.
*
* @param unknown_type $parser
Modified: trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php
===================================================================
--- trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php
2010-04-20 14:32:59 UTC (rev 65326)
+++ trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php
2010-04-20 15:10:46 UTC (rev 65327)
@@ -24,8 +24,6 @@
*/
final class MapsParserFunctions {
- public static $parameters = array();
-
/**
* Initialize the parser functions feature. This function handles the
parser function hook,
* and will load the required classes.
@@ -33,7 +31,7 @@
public static function initialize() {
global $egMapsDir, $egMapsFeatures;
- include_once $egMapsDir .
'ParserFunctions/Maps_iDisplayFunction.php';
+ include_once $egMapsDir .
'ParserFunctions/Maps_iMapFeature.php';
// This runs a small hook that enables parser functions to run
initialization code.
foreach ( $egMapsFeatures['pf'] as $hook ) {
@@ -66,7 +64,7 @@
foreach( $args as $arg ) {
$split = explode( '=', $arg );
$name = strtolower( trim( array_shift( $split ) ) );
- if ( count( $split ) > 1 && self::inParamAliases(
$name, 'service', self::$parameters ) ) {
+ if ( count( $split ) > 1 && self::inParamAliases(
$name, 'service', MapsMapper::getCommonParameters() ) ) {
if ( !$setService ) {
$service = implode( '=', $split );
$parameters = 'service=' . $service;
@@ -90,7 +88,7 @@
* again overidden by the service parameters (the ones spesific
to the service),
* and finally by the spesific parameters (the ones spesific to
a service-feature combination).
*/
- $parameterInfo = array_merge( self::$parameters,
$mapClass->getFeatureParameters() );
+ $parameterInfo = array_merge(
MapsMapper::getCommonParameters(), $mapClass->getFeatureParameters() );
$parameterInfo = array_merge( $parameterInfo,
$egMapsServices[$service]['parameters'] );
$parameterInfo = array_merge( $parameterInfo,
$mapClass->getSpecificParameterInfo() );
Deleted: trunk/extensions/Maps/ParserFunctions/Maps_iDisplayFunction.php
===================================================================
--- trunk/extensions/Maps/ParserFunctions/Maps_iDisplayFunction.php
2010-04-20 14:32:59 UTC (rev 65326)
+++ trunk/extensions/Maps/ParserFunctions/Maps_iDisplayFunction.php
2010-04-20 15:10:46 UTC (rev 65327)
@@ -1,23 +0,0 @@
-<?php
-
-/**
- * File holding interface iDisplayFunction.
- *
- * @file Maps_iDisplayFunction.php
- * @ingroup Maps
- *
- * @author Jeroen De Dauw
- */
-
-if ( !defined( 'MEDIAWIKI' ) ) {
- die( 'Not an entry point.' );
-}
-
-/**
- * Interface that should be implemented by all display_ parser functions.
- *
- * @author Jeroen De Dauw
- */
-interface iDisplayFunction {
- public function displayMap( Parser &$parser, array $params );
-}
\ No newline at end of file
Added: trunk/extensions/Maps/ParserFunctions/Maps_iMapFeature.php
===================================================================
--- trunk/extensions/Maps/ParserFunctions/Maps_iMapFeature.php
(rev 0)
+++ trunk/extensions/Maps/ParserFunctions/Maps_iMapFeature.php 2010-04-20
15:10:46 UTC (rev 65327)
@@ -0,0 +1,34 @@
+<?php
+
+/**
+ * File holding interface iMapFeature.
+ *
+ * @file Maps_iMapFeature.php
+ * @ingroup Maps
+ *
+ * @author Jeroen De Dauw
+ */
+
+if ( !defined( 'MEDIAWIKI' ) ) {
+ die( 'Not an entry point.' );
+}
+
+/**
+ * Interface that should be implemented by all mapping feature classes.
+ *
+ * @author Jeroen De Dauw
+ */
+interface iMapFeature {
+ function displayMap( Parser &$parser, array $params );
+
+ /**
+ * Map service specific map count and loading of dependencies.
+ */
+ function doMapServiceLoad();
+
+ /**
+ * Adds the HTML specific to the mapping service to the output.
+ */
+ function addSpecificMapHTML( Parser $parser );
+}
+
Property changes on: trunk/extensions/Maps/ParserFunctions/Maps_iMapFeature.php
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: trunk/extensions/Maps/YahooMaps/Maps_YahooMaps.php
===================================================================
--- trunk/extensions/Maps/YahooMaps/Maps_YahooMaps.php 2010-04-20 14:32:59 UTC
(rev 65326)
+++ trunk/extensions/Maps/YahooMaps/Maps_YahooMaps.php 2010-04-20 15:10:46 UTC
(rev 65327)
@@ -62,50 +62,50 @@
$allowedTypes = MapsYahooMaps::getTypeNames();
+ $egMapsServices[self::SERVICE_NAME]['parameters'] = array(
+ 'controls' => array(
+ 'type' => array( 'string', 'list' ),
+ 'criteria' => array(
+ 'in_array' => self::getControlNames()
+ ),
+ 'default' => $egMapsYMapControls,
+ 'output-type' => array( 'list', ',', '\'' )
+ ),
+ 'type' => array (
+ 'aliases' => array( 'map-type', 'map type' ),
+ 'criteria' => array(
+ 'in_array' => $allowedTypes
+ ),
+ 'default' => $egMapsYahooMapsType, // FIXME:
default value should not be used when not present in types parameter.
+ 'output-type' => 'ymaptype'
+ ),
+ 'types' => array (
+ 'type' => array( 'string', 'list' ),
+ 'aliases' => array( 'map-types', 'map types' ),
+ 'criteria' => array(
+ 'in_array' => $allowedTypes
+ ),
+ 'default' => $egMapsYahooMapsTypes,
+ 'output-types' => array( 'ymaptypes', 'list' )
+ ),
+ 'autozoom' => array(
+ 'type' => 'boolean',
+ 'aliases' => array( 'auto zoom', 'mouse zoom',
'mousezoom' ),
+ 'default' => $egMapsYahooAutozoom,
+ 'output-type' => 'boolstr'
+ ),
+ );
+
$egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['default'] =
$egMapsYahooMapsZoom;
-
$egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range']
= array( 1, 13 );
-
- $egMapsServices[self::SERVICE_NAME]['parameters'] = array(
- 'controls' => array(
- 'type' => array( 'string', 'list' ),
- 'criteria' => array(
- 'in_array' =>
self::getControlNames()
- ),
- 'default' => $egMapsYMapControls,
- 'output-type' => array( 'list', ',',
'\'' )
- ),
- 'type' => array (
- 'aliases' => array( 'map-type', 'map
type' ),
- 'criteria' => array(
- 'in_array' => $allowedTypes
- ),
- 'default' => $egMapsYahooMapsType, //
FIXME: default value should not be used when not present in types parameter.
- 'output-type' => 'ymaptype'
- ),
- 'types' => array (
- 'type' => array( 'string', 'list' ),
- 'aliases' => array( 'map-types', 'map
types' ),
- 'criteria' => array(
- 'in_array' => $allowedTypes
- ),
- 'default' => $egMapsYahooMapsTypes,
- 'output-types' => array( 'ymaptypes',
'list' )
- ),
- 'autozoom' => array(
- 'type' => 'boolean',
- 'aliases' => array( 'auto zoom', 'mouse
zoom', 'mousezoom' ),
- 'default' => $egMapsYahooAutozoom,
- 'output-type' => 'boolstr'
- ),
- );
+
$egMapsServices[self::SERVICE_NAME]['parameters']['zoom']['criteria']['in_range']
= array( 1, 13 );
}
// http://developer.yahoo.com/maps/ajax
private static $mapTypes = array(
- 'normal' => 'YAHOO_MAP_REG',
- 'satellite' => 'YAHOO_MAP_SAT',
- 'hybrid' => 'YAHOO_MAP_HYB',
- );
+ 'normal' => 'YAHOO_MAP_REG',
+ 'satellite' => 'YAHOO_MAP_SAT',
+ 'hybrid' => 'YAHOO_MAP_HYB',
+ );
/**
* Returns the names of all supported map types.
Modified: trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispMap.php
===================================================================
--- trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispMap.php 2010-04-20
14:32:59 UTC (rev 65326)
+++ trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispMap.php 2010-04-20
15:10:46 UTC (rev 65327)
@@ -18,21 +18,9 @@
public $serviceName = MapsYahooMaps::SERVICE_NAME;
/**
- * @see MapsBaseMap::setFormInputSettings()
- *
- */
- protected function setMapSettings() {
- global $egMapsYahooMapsZoom, $egMapsYahooMapsPrefix;
-
- $this->elementNamePrefix = $egMapsYahooMapsPrefix;
- $this->defaultZoom = $egMapsYahooMapsZoom;
- }
-
- /**
* @see MapsBaseMap::doMapServiceLoad()
- *
*/
- protected function doMapServiceLoad() {
+ public function doMapServiceLoad() {
global $egYahooMapsOnThisPage;
MapsYahooMaps::addYMapDependencies( $this->output );
@@ -43,13 +31,16 @@
/**
* @see MapsBaseMap::addSpecificMapHTML()
- *
*/
public function addSpecificMapHTML( Parser $parser ) {
+ global $egMapsYahooMapsPrefix, $egYahooMapsOnThisPage;
+
+ $mapName = $egMapsYahooMapsPrefix . '_' .
$egYahooMapsOnThisPage;
+
$this->output .= Html::element(
'div',
array(
- 'id' => $this->mapName,
+ 'id' => $mapName,
'style' => "width: $this->width; height:
$this->height; background-color: #cccccc;",
),
wfMsg('maps-loading-map')
@@ -60,7 +51,7 @@
addOnloadHook(
function() {
initializeYahooMap(
- '$this->mapName',
+ '$mapName',
$this->centreLat,
$this->centreLon,
$this->zoom,
Modified: trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispPoint.php
===================================================================
--- trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispPoint.php 2010-04-20
14:32:59 UTC (rev 65326)
+++ trunk/extensions/Maps/YahooMaps/Maps_YahooMapsDispPoint.php 2010-04-20
15:10:46 UTC (rev 65327)
@@ -22,18 +22,7 @@
public $serviceName = MapsYahooMaps::SERVICE_NAME;
- /**
- * @see MapsBaseMap::setFormInputSettings()
- *
- */
- protected function setMapSettings() {
- global $egMapsYahooMapsZoom, $egMapsYahooMapsPrefix;
-
- $this->elementNamePrefix = $egMapsYahooMapsPrefix;
- $this->defaultZoom = $egMapsYahooMapsZoom;
-
- $this->markerStringFormat = 'getYMarkerData(lat, lon,
\'title\', \'label\', "icon")';
- }
+ protected $markerStringFormat = 'getYMarkerData(lat, lon, \'title\',
\'label\', "icon")';
/**
* @see MapsBaseMap::doMapServiceLoad()
@@ -53,10 +42,14 @@
*
*/
public function addSpecificMapHTML( Parser $parser ) {
+ global $egMapsYahooMapsPrefix, $egYahooMapsOnThisPage;
+
+ $mapName = $egMapsYahooMapsPrefix . '_' .
$egYahooMapsOnThisPage;
+
$this->output .= Html::element(
'div',
array(
- 'id' => $this->mapName,
+ 'id' => $mapName,
'style' => "width: $this->width; height:
$this->height; background-color: #cccccc;",
),
wfMsg('maps-loading-map')
@@ -67,7 +60,7 @@
addOnloadHook(
function() {
initializeYahooMap(
- '$this->mapName',
+ '$mapName',
$this->centreLat,
$this->centreLon,
$this->zoom,
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs