9 * @author Craig Andrews <candrews@integralblue.com>
10 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
11 * @link http://status.net/
13 * StatusNet - the distributed open-source microblogging tool
14 * Copyright (C) 2008, 2009, StatusNet, Inc.
16 * This program is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU Affero General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU Affero General Public License for more details.
26 * You should have received a copy of the GNU Affero General Public License
27 * along with this program. If not, see <http://www.gnu.org/licenses/>.
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
35 * Geocode action class
39 * @author Craig Andrews <candrews@integralblue.com>
40 * @copyright 2009 Free Software Foundation, Inc http://www.fsf.org
41 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
42 * @link http://status.net/
44 class GeocodeAction extends Action
50 function prepare($args)
52 parent::prepare($args);
53 $token = $this->trimmed('token');
54 if (!$token || $token != common_session_token()) {
55 $this->clientError(_('There was a problem with your session token. '.
56 'Try again, please.'));
58 $this->lat = $this->trimmed('lat');
59 $this->lon = $this->trimmed('lon');
60 $this->location = Location::fromLatLon($this->lat, $this->lon);
67 * @param array $args query arguments
72 function handle($args)
74 header('Content-Type: application/json; charset=utf-8');
75 $location_object = array();
76 $location_object['lat']=$this->lat;
77 $location_object['lon']=$this->lon;
79 $location_object['location_id']=$this->location->location_id;
80 $location_object['location_ns']=$this->location->location_ns;
81 $location_object['name']=$this->location->getName();
82 $location_object['url']=$this->location->getUrl();
84 print(json_encode($location_object));
88 * Is this action read-only?
90 * @return boolean true
92 function isReadOnly($args)