public function execute() { global $wgUser; if (!$wgUser->isAllowed('geocode') || $wgUser->isBlocked()) { $this->dieUsageMsg(array('badaccess-groups')); } $params = $this->extractRequestParams(); $results = array(); foreach (array_unique($params['locations']) as $location) { $result = MapsGeocoders::geocode($location, $params['service']); $results[$location] = array('count' => $result === false ? 0 : 1, 'locations' => array()); if ($result !== false) { $results[$location]['locations'][] = $result; } $this->getResult()->setIndexedTagName($results[$location]['locations'], 'location'); } $this->getResult()->addValue(null, 'results', $results); }
/** * Sets the location to an address. * * @since 0.7.1 * * @param string $address * @param boolean $asActualLocation When set to false, the location is not changed, only the address string is. * * @return boolean Success indicator */ public function setAddress($address, $asActualLocation = true) { if ($asActualLocation) { $this->setCoordinates(MapsGeocoders::geocode($address)); } $this->address = $address; return $this->isValid; }