r113618 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113617‎ | r113618 | r113619 >
Date:13:05, 12 March 2012
Author:maxsem
Status:deferred
Tags:
Comment:
Support for geosearches for pages w/o photos
Modified paths:
  • /trunk/extensions/GeoData/api/ApiQueryGeoSearch.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GeoData/api/ApiQueryGeoSearch.php
@@ -26,6 +26,7 @@
2727 private function run( $resultPageSet = null ) {
2828 $params = $this->extractRequestParams();
2929 $exclude = false;
 30+ $useIndex = array();
3031
3132 $this->requireOnlyOneParameter( $params, 'coord', 'page' );
3233 if ( isset( $params['coord'] ) ) {
@@ -91,8 +92,18 @@
9293 $primary = array_flip( $params['primary'] );
9394 $this->addWhereIf( array( 'gt_primary' => 1 ), isset( $primary['yes'] ) && !isset( $primary['no'] ) );
9495 $this->addWhereIf( array( 'gt_primary' => 0 ), !isset( $primary['yes'] ) && isset( $primary['no'] ) );
95 - $this->addOption( 'USE INDEX', 'gt_spatial' );
 96+ $useIndex['geo_tags'] = 'gt_spatial';
9697
 98+ // Use information from PageImages
 99+ if ( defined( 'PAGE_IMAGES_INSTALLED' ) && $params['withoutphotos'] ) {
 100+ $this->addTables( 'page_props' );
 101+ $this->addJoinConds( array( 'page_props' => array( 'LEFT JOIN',
 102+ "gt_page_id=pp_page AND pp_propname='has_photos'" )
 103+ ) );
 104+ $this->addWhere( 'pp_page IS NULL' );
 105+ }
 106+ $this->addOption( 'USE INDEX', $useIndex );
 107+
97108 $limit = $params['limit'];
98109
99110 $res = $this->select( __METHOD__ );
@@ -173,7 +184,7 @@
174185
175186 public function getAllowedParams() {
176187 global $wgMaxGeoSearchRadius, $wgDefaultGlobe;
177 - return array (
 188+ $params = array (
178189 'coord' => array(
179190 ApiBase::PARAM_TYPE => 'string',
180191 ),
@@ -218,11 +229,15 @@
219230 ApiBase::PARAM_DFLT => 'yes',
220231 ),
221232 );
 233+ if ( defined( 'PAGE_IMAGES_INSTALLED' ) ) {
 234+ $params['withoutphotos'] = false;
 235+ }
 236+ return $params;
222237 }
223238
224239 public function getParamDescription() {
225240 global $wgDefaultGlobe;
226 - return array(
 241+ $params = array(
227242 'coord' => 'Coordinate around which to search: two floating-point values separated by pipe (|)',
228243 'page' => 'Title of page around which to search',
229244 'radius' => 'Search radius in meters',
@@ -231,8 +246,12 @@
232247 'globe' => "Globe to search on (by default ``{$wgDefaultGlobe}'')",
233248 'namespace' => 'Namespace(s) to search',
234249 'prop' => 'What additional coordinate properties to return',
235 - 'primary' => "Whether to return only primary coordinates (``yes''), secondary (``no'') or both (``yes|no'')",
 250+ 'primary' => "Whether to return only primary coordinates (``yes''), secondary (``no'') or both (``yes|no'')"
236251 );
 252+ if ( defined( 'PAGE_IMAGES_INSTALLED' ) ) {
 253+ $params['withoutphotos'] = 'Return only pages without photos';
 254+ }
 255+ return $params;
237256 }
238257
239258 public function getDescription() {

Status & tagging log