r63846 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63845‎ | r63846 | r63847 >
Date:23:25, 16 March 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Moved proximity query from SMW to SM
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Record.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_TestStore.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Record.php
@@ -25,8 +25,8 @@
2626 }
2727
2828 protected function parseUserValueOrQuery( $value, $querymode ) {
29 - if ( $value == '' ) { // / TODO internalionalize
30 - $this->addError( 'No values specified.' );
 29+ if ( $value == '' ) {
 30+ $this->addError( wfMsg( 'smw_novalues' ) );
3131 return $querymode ? new SMWThingDescription():$this->m_data;
3232 }
3333
@@ -64,8 +64,8 @@
6565 }
6666 }
6767 }
68 - if ( $empty ) { // / TODO internalionalize
69 - $this->addError( 'No values specified.' );
 68+ if ( $empty ) {
 69+ $this->addError( wfMsg( 'smw_novalues' ) );
7070 }
7171 if ( $querymode ) {
7272 return $empty ? new SMWThingDescription():new SMWRecordDescription( $subdescriptions );
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_TestStore.php
@@ -40,7 +40,7 @@
4141 return array( SMWDataValueFactory::newTypeIDValue( '__typ', 'Float' ) );
4242 } elseif ( mb_substr_count( $name, 'DATE' ) > 0 ) {
4343 return array( SMWDataValueFactory::newTypeIDValue( '__typ', 'Date' ) );
44 - } elseif ( mb_substr_count( $name, 'COORD' ) > 0 ) {
 44+ } elseif ( mb_substr_count( $name, 'COORD' ) > 0 ) { // TODO: Move this to Semantic Maps?
4545 return array( SMWDataValueFactory::newTypeIDValue( '__typ', 'Geographic coordinate' ) );
4646 } elseif ( mb_substr_count( $name, 'ENUM' ) > 0 ) {
4747 return array( SMWDataValueFactory::newTypeIDValue( '__typ', 'Enumeration' ) );
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php
@@ -106,8 +106,6 @@
107107
108108 $wgHooks['ParserTestTables'][] = 'smwfOnParserTestTables';
109109 $wgHooks['AdminLinks'][] = 'smwfAddToAdminLinks';
110 - // this will move to Semantic Maps in future releases:
111 - $wgHooks['smwGetSQLConditionForValue'][] = 'smwfGetGeoProximitySQLCondition';
112110
113111 // Register special pages aliases file
114112 $wgExtensionAliasesFiles['SemanticMediaWiki'] = $smwgIP . '/languages/SMW_Aliases.php';
@@ -331,28 +329,6 @@
332330 return true;
333331 }
334332
335 -/**
336 - * Custom SQL query extension for matching geographic coordinates.
337 - * This hook will be moved to Semantic Maps in the next release.
338 - * @todo Parsing latitude and longitude from the DB key of the coordinates
339 - * value is cleary not a good approach. Instead, the geographic coordinate
340 - * value object should provide functions to access this data directly.
341 - */
342 -function smwfGetGeoProximitySQLCondition( &$where, $description, $tablename, $fieldname, $dbs ) {
343 - $where = '';
344 - $dv = $description->getDatavalue();
345 - if ( ( $dv->getTypeID() != '_geo' ) || ( !$dv->isValid() ) || ( $description->getComparator() != SMW_CMP_LIKE ) ) return true; // only act on certain query conditions
346 - $keys = $dv->getDBkeys();
347 - $geoarray = explode( ",", $keys[0] );
348 - if ( ( count( $geoarray ) != 2 ) || ( $geoarray[0] == '' ) || ( $geoarray[1] == '' ) ) return true; // something went wrong
349 - $latitude = $dbs->addQuotes( $geoarray[0] );
350 - $longitude = $dbs->addQuotes( $geoarray[1] );
351 - // compute distances in miles:
352 - $distance = "ROUND(((ACOS( SIN({$latitude} * PI()/180 ) * SIN(SUBSTRING_INDEX({$tablename}.{$fieldname}, ',',1) * PI()/180 ) + COS({$latitude} * PI()/180 ) * COS(SUBSTRING_INDEX({$tablename}.{$fieldname}, ',',1) * PI()/180 ) * COS(({$longitude} - SUBSTRING_INDEX({$tablename}.{$fieldname}, ',',-1)) * PI()/180))*180/PI())*60*1.1515),6)";
353 - $where = "{$distance} <= " . $dbs->addQuotes( "5" );
354 - return true;
355 -}
356 -
357333 /**********************************************/
358334 /***** namespace settings *****/
359335 /**********************************************/
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php
@@ -105,6 +105,7 @@
106106 'smw_nofloat' => '"$1" is not a number.',
107107 'smw_infinite' => 'Numbers as large as "$1" are not supported.',
108108 'smw_infinite_unit' => 'Conversion into unit "$1" resulted in a number that is too large.',
 109+ 'smw_novalues' => 'No values specified.',
109110
110111 // Currently unused, floats silently store units. 'smw_unexpectedunit' => 'this property supports no unit conversion',
111112 'smw_unsupportedprefix' => 'Prefixes for numbers ("$1") are not supported.',

Status & tagging log