r66485 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66484‎ | r66485 | r66486 >
Date:17:59, 15 May 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Follow up to r66484
Modified paths:
  • /trunk/extensions/SemanticMaps/GeoCoords/SM_AreaValueDescription.php (modified) (history)
  • /trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValueDescription.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/GeoCoords/SM_GeoCoordsValueDescription.php
@@ -47,11 +47,12 @@
4848 * @see SMWDescription::getSQLCondition
4949 *
5050 * @param string $tableName
 51+ * @param array $fieldNames
5152 * @param DatabaseBase $dbs
5253 *
5354 * @return true
5455 */
55 - public function getSQLCondition( $tableName, DatabaseBase $dbs ) {
 56+ public function getSQLCondition( $tableName, array $fieldNames, DatabaseBase $dbs ) {
5657 $dataValue = $this->getDatavalue();
5758
5859 // Only execute the query when the description's type is geographical coordinates,
@@ -72,10 +73,13 @@
7374 if ( $comparator ) {
7475 $coordinates = $dataValue->getCoordinateSet();
7576
 77+ $lat = $dbs->addQuotes( $coordinates['lat'] );
 78+ $lon = $dbs->addQuotes( $coordinates['lon'] );
 79+
7680 // 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.
7781 $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";
8084
8185 return implode( ' && ', $conditions );
8286 }
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_AreaValueDescription.php
@@ -141,11 +141,12 @@
142142 * @see SMWDescription::getSQLCondition
143143 *
144144 * @param string $tableName
 145+ * @param array $fieldNames
145146 * @param DatabaseBase $dbs
146147 *
147148 * @return true
148149 */
149 - public function getSQLCondition( $tableName, DatabaseBase $dbs ) {
 150+ public function getSQLCondition( $tableName, array $fieldNames, DatabaseBase $dbs ) {
150151 $dataValue = $this->getDatavalue();
151152
152153 // Only execute the query when the description's type is geographical coordinates,
@@ -172,10 +173,10 @@
173174
174175 // 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.
175176 $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";
180181
181182 return implode( " $joinCond ", $conditions );
182183 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r66484Changes for 1.5.1 - now passing an array of field names to getSQLCondition ho...jeroendedauw17:58, 15 May 2010

Status & tagging log