* * @version 1.0 * @date 20 October 2010 * * Copyright (C)2010 MOVIM project * * See COPYING for licensing information. */ use Moxl\Xec\Action\Location\Publish; class Location extends WidgetBase { function load() { $this->addjs('location.js'); $this->registerEvent('locationpublished', 'onLocationPublished'); $this->registerEvent('locationpublisherror', 'onLocationPublishError'); } function ajaxLocationPublish($pos) { $pos = json_decode($pos); if($pos->place_id) { $geo = array( 'latitude' => (string)$pos->lat, 'longitude' => (string)$pos->lon, 'altitude' => (string)$pos->alt, 'country' => (string)$pos->address->country, 'countrycode' => (string)$pos->address->country_code, 'region' => (string)$pos->address->county, 'postalcode' => (string)$pos->address->postcode, 'locality' => (string)$pos->address->city, 'street' => (string)$pos->address->path, 'building' => (string)$pos->address->building, 'text' => (string)$pos->display_name, 'uri' => ''//'http://www.openstreetmap.org/'.urlencode('?lat='.(string)$pos->lat.'&lon='.(string)$pos->lon.'&zoom=10') ); $p = new Publish; $p->setTo($this->user->getLogin()) ->setGeo($geo) ->request(); } else { Notification::append(null, $this->__('location.wrong_postition')); } } function onLocationPublished($me) { $html = $me->getPlace(); RPC::call('movim_fill', 'mapdata', $html); Notification::append(null, $this->__('location.updated')); RPC::commit(); } function onLocationPublishError($error) { Notification::append(null, $error); RPC::call('movim_delete', 'mapdiv'); RPC::call('movim_delete', 'mapdata'); RPC::commit(); } function prepareProfileData() { $submit = $this->call('ajaxLocationPublish', "getMyPositionData()"); $cd = new \Modl\ContactDAO(); $c = $cd->get($this->user->getLogin()); if($c->loctimestamp) { $data = prepareDate(strtotime($c->loctimestamp)).'

'; $data .= $c->getPlace(); } else { $data = ''; } $html = ''; $html .= '
'.$data.'
'.$this->__('location.update').'
'; return $html; } }