r66018 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66017‎ | r66018 | r66019 >
Date:14:08, 7 May 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Follow up to r66017
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
@@ -48,13 +48,13 @@
4949 *
5050 * @param string $whereSQL The SQL where condition to expand.
5151 * @param SMWDescription $description
52 - * @param string $tablename
53 - * @param string $fieldname
 52+ * @param string $tableName
 53+ * @param array $fieldNames
5454 * @param DatabaseBase $dbs
5555 *
5656 * @return true
5757 */
58 - public static function getSQLCondition( &$whereSQL, SMWDescription $description, $tablename, $fieldname, DatabaseBase $dbs ) {
 58+ public static function getSQLCondition( &$whereSQL, SMWDescription $description, $tableName, array $fieldNames, DatabaseBase $dbs ) {
5959 $dataValue = $description->getDatavalue();
6060
6161 // Only execute the query when the description's type is geographical coordinates,
@@ -69,11 +69,13 @@
7070
7171 $comparator = $description->getComparator() == SMW_CMP_EQ ? '=' : '!=';
7272
73 - // TODO: The field names are hardcoded in, since SMW offers no support for selection based on multiple fields.
74 - // Ideally SMW's setup should be changed to allow for this. Now the query can break when other extensions
75 - // add their own semantic tables with similar signatures.
76 - $whereSQL .= "{$tablename}.lat {$comparator} {$coordinates['lat']} && {$tablename}.lon {$comparator} {$coordinates['lon']}";
 73+ // 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.
 74+ $conditions = array();
 75+ $conditions[] = "{$tableName}.{$fieldNames[0]} {$comparator} {$coordinates['lat']}";
 76+ $conditions[] = "{$tableName}.{$fieldNames[1]} {$comparator} {$coordinates['lon']}";
7777
 78+ $whereSQL .= implode( ' && ', $conditions );
 79+
7880 return true;
7981 }
8082
Index: trunk/extensions/SemanticMaps/GeoCoords/SM_AreaValueDescription.php
@@ -116,13 +116,13 @@
117117 *
118118 * @param string $whereSQL The SQL where condition to expand.
119119 * @param SMWDescription $description
120 - * @param string $tablename
121 - * @param string $fieldname
 120+ * @param string $tableName
 121+ * @param array $fieldNames
122122 * @param DatabaseBase $dbs
123123 *
124124 * @return true
125125 */
126 - public static function getSQLCondition( &$whereSQL, SMWDescription $description, $tablename, $fieldname, DatabaseBase $dbs ) {
 126+ public static function getSQLCondition( &$whereSQL, SMWDescription $description, $tableName, array $fieldNames, DatabaseBase $dbs ) {
127127 $dataValue = $description->getDatavalue();
128128
129129 // Only execute the query when the description's type is geographical coordinates,
@@ -139,11 +139,15 @@
140140 $south = $dbs->addQuotes( $boundingBox['south'] );
141141 $west = $dbs->addQuotes( $boundingBox['west'] );
142142
143 - // TODO: The field names are hardcoded in, since SMW offers no support for selection based on multiple fields.
144 - // Ideally SMW's setup should be changed to allow for this. Now the query can break when other extensions
145 - // add their own semantic tables with similar signatures.
146 - $whereSQL .= "{$tablename}.lat < $north && {$tablename}.lat > $south && {$tablename}.lon < $east && {$tablename}.lon > $west";
147 -var_dump($whereSQL);exit;
 143+ // 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.
 144+ $conditions = array();
 145+ $conditions[] = "{$tableName}.{$fieldNames[0]} < $north";
 146+ $conditions[] = "{$tableName}.{$fieldNames[0]} > $south";
 147+ $conditions[] = "{$tableName}.{$fieldNames[1]} < $east";
 148+ $conditions[] = "{$tableName}.{$fieldNames[1]} > $west";
 149+
 150+ $whereSQL .= implode( ' && ', $conditions );
 151+
148152 return true;
149153 }
150154 }
\ No newline at end of file

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r66017Changes for 1.5.1...jeroendedauw14:07, 7 May 2010

Status & tagging log