Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValueDescription.php |
— | — | @@ -47,11 +47,12 @@ |
48 | 48 | * @see SMWDescription::getSQLCondition |
49 | 49 | * |
50 | 50 | * @param string $tableName |
| 51 | + * @param array $fieldNames |
51 | 52 | * @param DatabaseBase $dbs |
52 | 53 | * |
53 | 54 | * @return true |
54 | 55 | */ |
55 | | - public function getSQLCondition( $tableName, DatabaseBase $dbs ) { |
| 56 | + public function getSQLCondition( $tableName, array $fieldNames, DatabaseBase $dbs ) { |
56 | 57 | $dataValue = $this->getDatavalue(); |
57 | 58 | |
58 | 59 | // Only execute the query when the description's type is geographical coordinates, |
— | — | @@ -72,10 +73,13 @@ |
73 | 74 | if ( $comparator ) { |
74 | 75 | $coordinates = $dataValue->getCoordinateSet(); |
75 | 76 | |
| 77 | + $lat = $dbs->addQuotes( $coordinates['lat'] ); |
| 78 | + $lon = $dbs->addQuotes( $coordinates['lon'] ); |
| 79 | + |
76 | 80 | // TODO: Would be safer to have a solid way of determining what's the lat and lon field, instead of assuming it's in this order. |
77 | 81 | $conditions = array(); |
78 | | - $conditions[] = "{$tableName}.lat {$comparator} {$coordinates['lat']}"; |
79 | | - $conditions[] = "{$tableName}.lon {$comparator} {$coordinates['lon']}"; |
| 82 | + $conditions[] = "{$tableName}.$fieldNames[0] $comparator $lat"; |
| 83 | + $conditions[] = "{$tableName}.$fieldNames[1] $comparator $lon"; |
80 | 84 | |
81 | 85 | return implode( ' && ', $conditions ); |
82 | 86 | } |
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_AreaValueDescription.php |
— | — | @@ -141,11 +141,12 @@ |
142 | 142 | * @see SMWDescription::getSQLCondition |
143 | 143 | * |
144 | 144 | * @param string $tableName |
| 145 | + * @param array $fieldNames |
145 | 146 | * @param DatabaseBase $dbs |
146 | 147 | * |
147 | 148 | * @return true |
148 | 149 | */ |
149 | | - public function getSQLCondition( $tableName, DatabaseBase $dbs ) { |
| 150 | + public function getSQLCondition( $tableName, array $fieldNames, DatabaseBase $dbs ) { |
150 | 151 | $dataValue = $this->getDatavalue(); |
151 | 152 | |
152 | 153 | // Only execute the query when the description's type is geographical coordinates, |
— | — | @@ -172,10 +173,10 @@ |
173 | 174 | |
174 | 175 | // TODO: Would be safer to have a solid way of determining what's the lat and lon field, instead of assuming it's in this order. |
175 | 176 | $conditions = array(); |
176 | | - $conditions[] = "{$tableName}.lat $smallerThen $north"; |
177 | | - $conditions[] = "{$tableName}.lat $biggerThen $south"; |
178 | | - $conditions[] = "{$tableName}.lon $smallerThen $east"; |
179 | | - $conditions[] = "{$tableName}.lon $biggerThen $west"; |
| 177 | + $conditions[] = "{$tableName}.$fieldNames[0] $smallerThen $north"; |
| 178 | + $conditions[] = "{$tableName}.$fieldNames[0] $biggerThen $south"; |
| 179 | + $conditions[] = "{$tableName}.$fieldNames[1] $smallerThen $east"; |
| 180 | + $conditions[] = "{$tableName}.$fieldNames[1] $biggerThen $west"; |
180 | 181 | |
181 | 182 | return implode( " $joinCond ", $conditions ); |
182 | 183 | } |