http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72085
Revision: 72085
Author: jeroendedauw
Date: 2010-09-01 07:13:43 +0000 (Wed, 01 Sep 2010)
Log Message:
-----------
Changes for 0.7 - rewriting handling of display_map and display_points
Modified Paths:
--------------
trunk/extensions/Maps/Features/Maps_BaseMap.php
trunk/extensions/Maps/Features/Maps_BasePointMap.php
trunk/extensions/Maps/Maps.php
trunk/extensions/Maps/ParserHooks/Maps_DisplayMap.php
trunk/extensions/Maps/ParserHooks/Maps_DisplayPoint.php
Modified: trunk/extensions/Maps/Features/Maps_BaseMap.php
===================================================================
--- trunk/extensions/Maps/Features/Maps_BaseMap.php 2010-09-01 07:12:36 UTC
(rev 72084)
+++ trunk/extensions/Maps/Features/Maps_BaseMap.php 2010-09-01 07:13:43 UTC
(rev 72085)
@@ -10,7 +10,7 @@
*
* @author Jeroen De Dauw
*/
-abstract class MapsBaseMap implements iMappingParserFunction {
+abstract class MapsBaseMap {
/**
* @var iMappingService
@@ -21,11 +21,7 @@
protected $output = '';
- protected $parser;
-
private $specificParameters = false;
- protected $featureParameters = false;
-
/**
* Constructor.
*
@@ -79,47 +75,14 @@
}
/**
- * @return array
- */
- public function getFeatureParameters() {
- global $egMapsDefaultServices, $egMapsMapWidth,
$egMapsMapHeight;
-
- return array(
- 'width' => array(
- 'default' => $egMapsMapWidth
- ),
- 'height' => array(
- 'default' => $egMapsMapHeight
- ),
- 'mappingservice' => array(
- 'default' =>
$egMapsDefaultServices['display_map']
- ),
- 'coordinates' => array(
- 'required' => true,
- 'tolower' => false,
- 'aliases' => array( 'coords', 'location',
'address' ),
- 'criteria' => array(
- 'is_location' => array()
- ),
- 'output-type' => 'coordinateSet',
- ),
- );
- }
-
- /**
* Handles the request from the parser hook by doing the work that's
common for all
* mapping services, calling the specific methods and finally returning
the resulting output.
*
- * @param Parser $parser
* @param array $params
*
* @return html
*/
- public final function getMapHtml( Parser &$parser, array $params ) {
- $this->parser = $parser;
-
- $this->featureParameters = MapsDisplayMap::$parameters;
-
+ public final function getMapHtml( array $params ) {
$this->setMapProperties( $params );
$this->setCentre();
Modified: trunk/extensions/Maps/Features/Maps_BasePointMap.php
===================================================================
--- trunk/extensions/Maps/Features/Maps_BasePointMap.php 2010-09-01
07:12:36 UTC (rev 72084)
+++ trunk/extensions/Maps/Features/Maps_BasePointMap.php 2010-09-01
07:13:43 UTC (rev 72085)
@@ -10,7 +10,7 @@
*
* @author Jeroen De Dauw
*/
-abstract class MapsBasePointMap implements iMappingParserFunction {
+abstract class MapsBasePointMap {
/**
* @var iMappingService
@@ -22,12 +22,8 @@
protected $output = '';
- protected $featureParameters = false;
-
protected $markerString;
- protected $parser;
-
private $specificParameters = false;
private $markerData = array();
@@ -77,63 +73,14 @@
}
/**
- * @return array
- */
- public function getFeatureParameters() {
- global $egMapsDefaultServices, $egMapsDefaultTitle,
$egMapsDefaultLabel, $egMapsMapWidth, $egMapsMapHeight;
-
- return array(
- 'width' => array(
- 'default' => $egMapsMapWidth
- ),
- 'height' => array(
- 'default' => $egMapsMapHeight
- ),
- 'mappingservice' => array(
- 'default' =>
$egMapsDefaultServices['display_point']
- ),
- 'centre' => array(
- 'aliases' => array( 'center' ),
- 'tolower' => false,
- ),
- 'title' => array(
- 'default' => $egMapsDefaultTitle
- ),
- 'label' => array(
- 'default' => $egMapsDefaultLabel
- ),
- 'icon' => array(
- 'criteria' => array(
- 'not_empty' => array()
- )
- ),
- 'coordinates' => array(
- 'required' => true,
- 'tolower' => false,
- 'type' => array( 'string', 'list', ';' ),
- 'aliases' => array( 'coords', 'location',
'locations', 'address', 'addresses' ),
- 'criteria' => array(
- 'are_locations' => array( '~' )
- ),
- 'output-type' => array( 'geoPoints', '~' ),
- ),
- );
- }
-
- /**
* Handles the request from the parser hook by doing the work that's
common for all
* mapping services, calling the specific methods and finally returning
the resulting output.
*
- * @param Parser $parser
* @param array $params
*
* @return html
*/
- public final function getMapHtml( Parser &$parser, array $params ) {
- $this->parser = $parser;
-
- $this->featureParameters = MapsDisplayPoint::$parameters;
-
+ public final function getMapHtml( array $params ) {
$this->setMapProperties( $params );
$this->setMarkerData();
Modified: trunk/extensions/Maps/Maps.php
===================================================================
--- trunk/extensions/Maps/Maps.php 2010-09-01 07:12:36 UTC (rev 72084)
+++ trunk/extensions/Maps/Maps.php 2010-09-01 07:13:43 UTC (rev 72085)
@@ -125,6 +125,11 @@
$wgAutoloadClasses['MapsMappingServices'] = $srvDir .
'Maps_MappingServices.php';
$wgAutoloadClasses['MapsMappingService'] = $srvDir .
'Maps_MappingService.php';
+ // Load the "Feature/" classes.
+ $ftDir = dirname( __FILE__ ) . '/Features/';
+ $wgAutoloadClasses['MapsBaseMap'] =
$ftDir . 'Maps_BaseMap.php';
+ $wgAutoloadClasses['MapsBasePointMap'] = $ftDir .
'Maps_BasePointMap.php';
+
// This function has been deprecated in 1.16, but needed for earlier
versions.
// It's present in 1.16 as a stub, but lets check if it exists in case
it gets removed at some point.
if ( function_exists( 'wfLoadExtensionMessages' ) ) {
Modified: trunk/extensions/Maps/ParserHooks/Maps_DisplayMap.php
===================================================================
--- trunk/extensions/Maps/ParserHooks/Maps_DisplayMap.php 2010-09-01
07:12:36 UTC (rev 72084)
+++ trunk/extensions/Maps/ParserHooks/Maps_DisplayMap.php 2010-09-01
07:13:43 UTC (rev 72085)
@@ -66,7 +66,7 @@
),
'height' => array(
'default' => $egMapsMapHeight
- ),
+ ),
'mappingservice' => array(
'default' =>
$egMapsDefaultServices['display_map']
),
@@ -105,7 +105,16 @@
* @return string
*/
public function render( array $parameters ) {
- return '';//MapsParserFunctions::getMapHtml( $parser, $args,
'display_map' );
+ // Get the instance of the service class.
+ $service = MapsMappingServices::getValidServiceInstance(
$parameters['mappingservice'], $this->getName() );
+
+ /*
+ // Get an instance of the class handling the current parser
hook and service.
+ $mapClass = $service->getFeatureInstance( $this->getName() );
+
+ return $mapClass->getMapHtml( $parameters );
+ */
+ return ''; // TODO
}
}
\ No newline at end of file
Modified: trunk/extensions/Maps/ParserHooks/Maps_DisplayPoint.php
===================================================================
--- trunk/extensions/Maps/ParserHooks/Maps_DisplayPoint.php 2010-09-01
07:12:36 UTC (rev 72084)
+++ trunk/extensions/Maps/ParserHooks/Maps_DisplayPoint.php 2010-09-01
07:13:43 UTC (rev 72085)
@@ -39,6 +39,33 @@
}
/**
+ * Formats a set of points that can have meta data provided.
+ *
+ * @param string $locations
+ * @param string $name The name of the parameter.
+ * @param array $parameters Array containing data about the so far
handled parameters.
+ */
+ public static function formatGeoPoints( &$locations, $name, array
$parameters, $metaDataSeparator = false ) {
+ $locations = (array)$locations;
+ foreach ( $locations as &$location ) {
+ self::formatGeoPoint( $location, $name, $parameters,
$metaDataSeparator );
+ }
+ }
+
+ public static function formatGeoPoint( &$location, $name, array
$parameters, $metaDataSeparator = false ) {
+ if ( $metaDataSeparator !== false ) {
+ $segments = explode( $metaDataSeparator, $location );
+ }
+ else {
+ $segments = array( $location );
+ }
+
+ MapsMapper::formatLocation( $segments[0], $name, $parameters );
+
+ $location = $segments;
+ }
+
+ /**
* Gets the name of the parser hook.
* @see ParserHook::getName
*
@@ -123,34 +150,15 @@
* @return string
*/
public function render( array $parameters ) {
- return MapsParserFunctions::getMapHtml( $parser, $args,
'display_point' );
- }
-
- /**
- * Formats a set of points that can have meta data provided.
- *
- * @param string $locations
- * @param string $name The name of the parameter.
- * @param array $parameters Array containing data about the so far
handled parameters.
- */
- public static function formatGeoPoints( &$locations, $name, array
$parameters, $metaDataSeparator = false ) {
- $locations = (array)$locations;
- foreach ( $locations as &$location ) {
- self::formatGeoPoint( $location, $name, $parameters,
$metaDataSeparator );
- }
- }
-
- public static function formatGeoPoint( &$location, $name, array
$parameters, $metaDataSeparator = false ) {
- if ( $metaDataSeparator !== false ) {
- $segments = explode( $metaDataSeparator, $location );
- }
- else {
- $segments = array( $location );
- }
+ // Get the instance of the service class.
+ $service = MapsMappingServices::getValidServiceInstance(
$parameters['mappingservice'], $this->getName() );
+ /*
+ // Get an instance of the class handling the current parser
hook and service.
+ $mapClass = $service->getFeatureInstance( $this->getName() );
- MapsMapper::formatLocation( $segments[0], $name, $parameters );
-
- $location = $segments;
+ return $mapClass->getMapHtml( $parameters );
+ */
+ return ''; // TODO
}
-
+
}
\ No newline at end of file
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs