r65988 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65987‎ | r65988 | r65989 >
Date:17:12, 6 May 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
FOllow up to r65984
Modified paths:
  • /trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValue.php (modified) (history)
  • /trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValueDescription.php (modified) (history)
  • /trunk/extensions/SemanticMaps/SemanticMaps.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValue.php
@@ -81,22 +81,27 @@
8282 // TODO: parse the parts here
8383 SMWDataValue::prepareValue( $value, $comparator );
8484
85 - //$parts = preg_split( '', $value );
86 - // preg_match( '/(.*)\((.*)\)/', $user_input, $matches );
 85+ $parts = array();
 86+ preg_match( '/(.*)\((.*)\)/', $value, $parts );
8787
88 - $distance = 5;
89 - $hasDistance = false;
 88+ $coordinates = array_shift( $parts );
 89+ $distance = count( $parts ) > 0 ? array_shift( $parts ) : false;
9090
91 - $coordinates = MapsCoordinateParser::parseCoordinates( $value );
92 - if ( $coordinates ) {
93 - $this->mCoordinateSet = $coordinates;
 91+ if ( $distance !== false && !preg_match( '/^\d+(\.\d+)?$/', $distance ) ) {
 92+ $this->addError( wfMsgExt( 'semanticmaps-unrecognizeddistance', array( 'parsemag' ), $distance ) );
 93+ $distance = false;
 94+ }
 95+
 96+ $parsedCoords = MapsCoordinateParser::parseCoordinates( $coordinates );
 97+ if ( $parsedCoords ) {
 98+ $this->mCoordinateSet = $parsedCoords;
9499
95100 if ( $this->m_caption === false && !$asQuery ) {
96101 global $smgQPCoodFormat, $smgQPCoodDirectional;
97 - $this->m_caption = MapsCoordinateParser::formatCoordinates( $coordinates, $smgQPCoodFormat, $smgQPCoodDirectional );
 102+ $this->m_caption = MapsCoordinateParser::formatCoordinates( $parsedCoords, $smgQPCoodFormat, $smgQPCoodDirectional );
98103 }
99104 } else {
100 - $this->addError( wfMsgExt( 'maps_unrecognized_coords', array( 'parsemag' ), $value, 1 ) );
 105+ $this->addError( wfMsgExt( 'maps_unrecognized_coords', array( 'parsemag' ), $coordinates, 1 ) );
101106 }
102107 }
103108
@@ -107,7 +112,7 @@
108113 case !$this->isValid() :
109114 return new SMWThingDescription();
110115 break;
111 - case $hasDistance :
 116+ case $distance !== false :
112117 return new SMAreaValueDescription( $this, $distance );
113118 break;
114119 default :
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValueDescription.php
@@ -23,8 +23,6 @@
2424 class SMGeoCoordsValueDescription extends SMWValueDescription {
2525
2626 /**
27 - * TODO: re-add the coparator parameter once support for this is implemented in the query hook.
28 - *
2927 * @param SMGeoCoordsValue $dataValue
3028 */
3129 public function __construct( SMGeoCoordsValue $dataValue, $comparator ) {
Index: trunk/extensions/SemanticMaps/SemanticMaps.i18n.php
@@ -20,6 +20,7 @@
2121 'semanticmaps_name' => 'Semantic Maps',
2222 'semanticmaps_desc' => "Provides the ability to view and edit coordinate data stored through the Semantic MediaWiki extension ([http://wiki.bn2vs.com/wiki/Semantic_Maps demo]).
2323 Available map services: $1",
 24+ 'semanticmaps-unrecognizeddistance' => 'The value $1 is not a valid distance.',
2425
2526 // Forms
2627 'semanticmaps_lookupcoordinates' => 'Look up coordinates',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r65984Changes for 0.6 - partly implemented distance queryjeroendedauw13:09, 6 May 2010

Status & tagging log