Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValue.php |
— | — | @@ -81,22 +81,27 @@ |
82 | 82 | // TODO: parse the parts here |
83 | 83 | SMWDataValue::prepareValue( $value, $comparator ); |
84 | 84 | |
85 | | - //$parts = preg_split( '', $value ); |
86 | | - // preg_match( '/(.*)\((.*)\)/', $user_input, $matches ); |
| 85 | + $parts = array(); |
| 86 | + preg_match( '/(.*)\((.*)\)/', $value, $parts ); |
87 | 87 | |
88 | | - $distance = 5; |
89 | | - $hasDistance = false; |
| 88 | + $coordinates = array_shift( $parts ); |
| 89 | + $distance = count( $parts ) > 0 ? array_shift( $parts ) : false; |
90 | 90 | |
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; |
94 | 99 | |
95 | 100 | if ( $this->m_caption === false && !$asQuery ) { |
96 | 101 | global $smgQPCoodFormat, $smgQPCoodDirectional; |
97 | | - $this->m_caption = MapsCoordinateParser::formatCoordinates( $coordinates, $smgQPCoodFormat, $smgQPCoodDirectional ); |
| 102 | + $this->m_caption = MapsCoordinateParser::formatCoordinates( $parsedCoords, $smgQPCoodFormat, $smgQPCoodDirectional ); |
98 | 103 | } |
99 | 104 | } else { |
100 | | - $this->addError( wfMsgExt( 'maps_unrecognized_coords', array( 'parsemag' ), $value, 1 ) ); |
| 105 | + $this->addError( wfMsgExt( 'maps_unrecognized_coords', array( 'parsemag' ), $coordinates, 1 ) ); |
101 | 106 | } |
102 | 107 | } |
103 | 108 | |
— | — | @@ -107,7 +112,7 @@ |
108 | 113 | case !$this->isValid() : |
109 | 114 | return new SMWThingDescription(); |
110 | 115 | break; |
111 | | - case $hasDistance : |
| 116 | + case $distance !== false : |
112 | 117 | return new SMAreaValueDescription( $this, $distance ); |
113 | 118 | break; |
114 | 119 | default : |
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValueDescription.php |
— | — | @@ -23,8 +23,6 @@ |
24 | 24 | class SMGeoCoordsValueDescription extends SMWValueDescription { |
25 | 25 | |
26 | 26 | /** |
27 | | - * TODO: re-add the coparator parameter once support for this is implemented in the query hook. |
28 | | - * |
29 | 27 | * @param SMGeoCoordsValue $dataValue |
30 | 28 | */ |
31 | 29 | public function __construct( SMGeoCoordsValue $dataValue, $comparator ) { |
Index: trunk/extensions/SemanticMaps/SemanticMaps.i18n.php |
— | — | @@ -20,6 +20,7 @@ |
21 | 21 | 'semanticmaps_name' => 'Semantic Maps', |
22 | 22 | '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]). |
23 | 23 | Available map services: $1", |
| 24 | + 'semanticmaps-unrecognizeddistance' => 'The value $1 is not a valid distance.', |
24 | 25 | |
25 | 26 | // Forms |
26 | 27 | 'semanticmaps_lookupcoordinates' => 'Look up coordinates', |