r72497 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72496‎ | r72497 | r72498 >
Date:16:17, 6 September 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.7 - matching changes made in Validator
Modified paths:
  • /trunk/extensions/Maps/Maps.php (modified) (history)
  • /trunk/extensions/Maps/includes/criteria (added) (history)
  • /trunk/extensions/Maps/includes/criteria/CriterionAreLocations.php (added) (history)
  • /trunk/extensions/Maps/includes/parserHooks/Maps_DisplayMap.php (modified) (history)
  • /trunk/extensions/Maps/includes/parserHooks/Maps_DisplayPoint.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Maps/Maps.php
@@ -87,7 +87,7 @@
8888 global $egMapsDefaultService, $egMapsAvailableServices;
8989 global $egMapsDir, $egMapsUseMinJs, $egMapsJsExt;
9090
91 - // Autoload the "Includes/" classes and interfaces.
 91+ // Autoload the "includes/" classes and interfaces.
9292 $incDir = dirname( __FILE__ ) . '/includes/';
9393 $wgAutoloadClasses['MapsMapper'] = $incDir . 'Maps_Mapper.php';
9494 $wgAutoloadClasses['MapsCoordinateParser'] = $incDir . 'Maps_CoordinateParser.php';
@@ -101,13 +101,22 @@
102102 $wgAutoloadClasses['MapsMappingServices'] = $incDir . 'Maps_MappingServices.php';
103103 $wgAutoloadClasses['MapsMappingService'] = $incDir . 'Maps_MappingService.php';
104104
105 - // Geocoders at "Includes/Geocoders/".
 105+ // Autoload the "includes/criteria/" classes.
 106+ $criDir = $incDir . 'criteria/';
 107+ $wgAutoloadClasses['CriterionAreLocations'] = $criDir . 'CriterionAreLocations.php';
 108+
 109+ // Autoload the "includes/features/" classes.
 110+ $ftDir = $incDir . '/features/';
 111+ $wgAutoloadClasses['MapsBaseMap'] = $ftDir . 'Maps_BaseMap.php';
 112+ $wgAutoloadClasses['MapsBasePointMap'] = $ftDir . 'Maps_BasePointMap.php';
 113+
 114+ // Autoload the "includes/geocoders/" classes.
106115 $geoDir = $incDir . 'geocoders/';
107116 $wgAutoloadClasses['MapsGeonamesGeocoder'] = $geoDir . 'Maps_GeonamesGeocoder.php';
108117 $wgAutoloadClasses['MapsGoogleGeocoder'] = $geoDir . 'Maps_GoogleGeocoder.php';
109118 $wgAutoloadClasses['MapsYahooGeocoder'] = $geoDir . 'Maps_YahooGeocoder.php';
110119
111 - // Autoload the "ParserHooks/" classes.
 120+ // Autoload the "includes/parserHooks/" classes.
112121 $phDir = $incDir . '/parserHooks/';
113122 $wgAutoloadClasses['MapsCoordinates'] = $phDir . 'Maps_Coordinates.php';
114123 $wgAutoloadClasses['MapsDisplayMap'] = $phDir . 'Maps_DisplayMap.php';
@@ -116,12 +125,7 @@
117126 $wgAutoloadClasses['MapsFinddestination'] = $phDir . 'Maps_Finddestination.php';
118127 $wgAutoloadClasses['MapsGeocode'] = $phDir . 'Maps_Geocode.php';
119128 $wgAutoloadClasses['MapsGeodistance'] = $phDir . 'Maps_Geodistance.php';
120 -
121 - // Load the "Feature/" classes.
122 - $ftDir = $incDir . '/features/';
123 - $wgAutoloadClasses['MapsBaseMap'] = $ftDir . 'Maps_BaseMap.php';
124 - $wgAutoloadClasses['MapsBasePointMap'] = $ftDir . 'Maps_BasePointMap.php';
125 -
 129+
126130 // This function has been deprecated in 1.16, but needed for earlier versions.
127131 // It's present in 1.16 as a stub, but lets check if it exists in case it gets removed at some point.
128132 if ( function_exists( 'wfLoadExtensionMessages' ) ) {
Index: trunk/extensions/Maps/includes/parserHooks/Maps_DisplayPoint.php
@@ -120,7 +120,7 @@
121121 'type' => array( 'string', 'list', ';' ),
122122 'aliases' => array( 'coords', 'location', 'locations', 'address', 'addresses' ),
123123 'criteria' => array(
124 - 'are_locations' => array( '~' )
 124+ new CriterionAreLocations( '~' )
125125 ),
126126 'output-type' => array( 'geoPoints', '~' ),
127127 ),
Index: trunk/extensions/Maps/includes/parserHooks/Maps_DisplayMap.php
@@ -75,7 +75,7 @@
7676 'tolower' => false,
7777 'aliases' => array( 'coords', 'location', 'address' ),
7878 'criteria' => array(
79 - 'is_location' => array()
 79+ new CriterionAreLocations()
8080 ),
8181 'output-type' => 'coordinateSet',
8282 ),
Index: trunk/extensions/Maps/includes/criteria/CriterionAreLocations.php
@@ -0,0 +1,49 @@
 2+<?php
 3+
 4+/**
 5+ * Parameter criterion stating that the value must be a set of coordinates or an address.
 6+ *
 7+ * @since 0.7
 8+ *
 9+ * @file CriterionAreLocations.php
 10+ * @ingroup Maps
 11+ * @ingroup Criteria
 12+ *
 13+ * @author Jeroen De Dauw
 14+ */
 15+class CriterionAreLocations extends ParameterCriterion {
 16+
 17+ protected $metaDataSeparator;
 18+
 19+ /**
 20+ * Constructor.
 21+ *
 22+ * @since 0.4
 23+ */
 24+ public function __construct( $metaDataSeparator = false ) {
 25+ parent::__construct();
 26+
 27+ $this->metaDataSeparator = $metaDataSeparator;
 28+ }
 29+
 30+ /**
 31+ * @see ParameterCriterion::validate
 32+ */
 33+ public function validate( $value ) {
 34+ if ( $this->metaDataSeparator !== false ) {
 35+ $parts = explode( $this->metaDataSeparator, $value );
 36+ $value = $parts[0];
 37+ }
 38+
 39+ if ( MapsGeocoders::canGeocode() ) {
 40+ // TODO
 41+ //$geoService = array_key_exists( 'geoservice', $parameters ) ? $parameters['geoservice']['value'] : '';
 42+ //$mappingService = array_key_exists( 'mappingservice', $parameters ) ? $parameters['mappingservice']['value'] : false;
 43+
 44+ return MapsGeocoders::isLocation( $value/*, $geoService, $mappingService */ );
 45+ } else {
 46+ return MapsCoordinateParser::areCoordinates( $value );
 47+ }
 48+ }
 49+
 50+}
\ No newline at end of file
Property changes on: trunk/extensions/Maps/includes/criteria/CriterionAreLocations.php
___________________________________________________________________
Added: svn:eol-style
151 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r72498Follow up to r72497jeroendedauw16:35, 6 September 2010
r72503Follow up to r72497jeroendedauw18:28, 6 September 2010
r72504Follow up to r72497jeroendedauw18:28, 6 September 2010

Status & tagging log