Index: trunk/extensions/GeoData/api/ApiQueryGeoSearch.php |
— | — | @@ -26,6 +26,7 @@ |
27 | 27 | private function run( $resultPageSet = null ) { |
28 | 28 | $params = $this->extractRequestParams(); |
29 | 29 | $exclude = false; |
| 30 | + $useIndex = array(); |
30 | 31 | |
31 | 32 | $this->requireOnlyOneParameter( $params, 'coord', 'page' ); |
32 | 33 | if ( isset( $params['coord'] ) ) { |
— | — | @@ -91,8 +92,18 @@ |
92 | 93 | $primary = array_flip( $params['primary'] ); |
93 | 94 | $this->addWhereIf( array( 'gt_primary' => 1 ), isset( $primary['yes'] ) && !isset( $primary['no'] ) ); |
94 | 95 | $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'; |
96 | 97 | |
| 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 | + |
97 | 108 | $limit = $params['limit']; |
98 | 109 | |
99 | 110 | $res = $this->select( __METHOD__ ); |
— | — | @@ -173,7 +184,7 @@ |
174 | 185 | |
175 | 186 | public function getAllowedParams() { |
176 | 187 | global $wgMaxGeoSearchRadius, $wgDefaultGlobe; |
177 | | - return array ( |
| 188 | + $params = array ( |
178 | 189 | 'coord' => array( |
179 | 190 | ApiBase::PARAM_TYPE => 'string', |
180 | 191 | ), |
— | — | @@ -218,11 +229,15 @@ |
219 | 230 | ApiBase::PARAM_DFLT => 'yes', |
220 | 231 | ), |
221 | 232 | ); |
| 233 | + if ( defined( 'PAGE_IMAGES_INSTALLED' ) ) { |
| 234 | + $params['withoutphotos'] = false; |
| 235 | + } |
| 236 | + return $params; |
222 | 237 | } |
223 | 238 | |
224 | 239 | public function getParamDescription() { |
225 | 240 | global $wgDefaultGlobe; |
226 | | - return array( |
| 241 | + $params = array( |
227 | 242 | 'coord' => 'Coordinate around which to search: two floating-point values separated by pipe (|)', |
228 | 243 | 'page' => 'Title of page around which to search', |
229 | 244 | 'radius' => 'Search radius in meters', |
— | — | @@ -231,8 +246,12 @@ |
232 | 247 | 'globe' => "Globe to search on (by default ``{$wgDefaultGlobe}'')", |
233 | 248 | 'namespace' => 'Namespace(s) to search', |
234 | 249 | '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'')" |
236 | 251 | ); |
| 252 | + if ( defined( 'PAGE_IMAGES_INSTALLED' ) ) { |
| 253 | + $params['withoutphotos'] = 'Return only pages without photos'; |
| 254 | + } |
| 255 | + return $params; |
237 | 256 | } |
238 | 257 | |
239 | 258 | public function getDescription() { |