Index: trunk/extensions/Maps/Maps.php |
— | — | @@ -87,7 +87,7 @@ |
88 | 88 | global $egMapsDefaultService, $egMapsAvailableServices; |
89 | 89 | global $egMapsDir, $egMapsUseMinJs, $egMapsJsExt; |
90 | 90 | |
91 | | - // Autoload the "Includes/" classes and interfaces. |
| 91 | + // Autoload the "includes/" classes and interfaces. |
92 | 92 | $incDir = dirname( __FILE__ ) . '/includes/'; |
93 | 93 | $wgAutoloadClasses['MapsMapper'] = $incDir . 'Maps_Mapper.php'; |
94 | 94 | $wgAutoloadClasses['MapsCoordinateParser'] = $incDir . 'Maps_CoordinateParser.php'; |
— | — | @@ -101,13 +101,22 @@ |
102 | 102 | $wgAutoloadClasses['MapsMappingServices'] = $incDir . 'Maps_MappingServices.php'; |
103 | 103 | $wgAutoloadClasses['MapsMappingService'] = $incDir . 'Maps_MappingService.php'; |
104 | 104 | |
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. |
106 | 115 | $geoDir = $incDir . 'geocoders/'; |
107 | 116 | $wgAutoloadClasses['MapsGeonamesGeocoder'] = $geoDir . 'Maps_GeonamesGeocoder.php'; |
108 | 117 | $wgAutoloadClasses['MapsGoogleGeocoder'] = $geoDir . 'Maps_GoogleGeocoder.php'; |
109 | 118 | $wgAutoloadClasses['MapsYahooGeocoder'] = $geoDir . 'Maps_YahooGeocoder.php'; |
110 | 119 | |
111 | | - // Autoload the "ParserHooks/" classes. |
| 120 | + // Autoload the "includes/parserHooks/" classes. |
112 | 121 | $phDir = $incDir . '/parserHooks/'; |
113 | 122 | $wgAutoloadClasses['MapsCoordinates'] = $phDir . 'Maps_Coordinates.php'; |
114 | 123 | $wgAutoloadClasses['MapsDisplayMap'] = $phDir . 'Maps_DisplayMap.php'; |
— | — | @@ -116,12 +125,7 @@ |
117 | 126 | $wgAutoloadClasses['MapsFinddestination'] = $phDir . 'Maps_Finddestination.php'; |
118 | 127 | $wgAutoloadClasses['MapsGeocode'] = $phDir . 'Maps_Geocode.php'; |
119 | 128 | $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 | + |
126 | 130 | // This function has been deprecated in 1.16, but needed for earlier versions. |
127 | 131 | // It's present in 1.16 as a stub, but lets check if it exists in case it gets removed at some point. |
128 | 132 | if ( function_exists( 'wfLoadExtensionMessages' ) ) { |
Index: trunk/extensions/Maps/includes/parserHooks/Maps_DisplayPoint.php |
— | — | @@ -120,7 +120,7 @@ |
121 | 121 | 'type' => array( 'string', 'list', ';' ), |
122 | 122 | 'aliases' => array( 'coords', 'location', 'locations', 'address', 'addresses' ), |
123 | 123 | 'criteria' => array( |
124 | | - 'are_locations' => array( '~' ) |
| 124 | + new CriterionAreLocations( '~' ) |
125 | 125 | ), |
126 | 126 | 'output-type' => array( 'geoPoints', '~' ), |
127 | 127 | ), |
Index: trunk/extensions/Maps/includes/parserHooks/Maps_DisplayMap.php |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | 'tolower' => false, |
77 | 77 | 'aliases' => array( 'coords', 'location', 'address' ), |
78 | 78 | 'criteria' => array( |
79 | | - 'is_location' => array() |
| 79 | + new CriterionAreLocations() |
80 | 80 | ), |
81 | 81 | 'output-type' => 'coordinateSet', |
82 | 82 | ), |
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 |
1 | 51 | + native |