Browse Source
- New widget ProfileData
- New widget ProfileData
- Fix some UI bug - Fix add/remove contact error in the RosterList - Fix contact name displayedpull/16/head
12 changed files with 203 additions and 45 deletions
-
2system/Datas/Contact.php
-
33system/Widget/widgets/ContactInfo/ContactInfo.php
-
18system/Widget/widgets/ContactSummary/ContactSummary.php
-
27system/Widget/widgets/Notifs/Notifs.php
-
2system/Widget/widgets/Poller/poller.js
-
7system/Widget/widgets/Profile/Profile.php
-
80system/Widget/widgets/ProfileData/ProfileData.php
-
67system/Widget/widgets/ProfileData/profiledata.js
-
4system/Widget/widgets/Roster/Roster.php
-
4system/Widget/widgets/Vcard/Vcard.php
-
2themes/movim/main.tpl
-
2themes/movim/page.tpl
@ -0,0 +1,80 @@ |
|||
<?php |
|||
|
|||
/** |
|||
* @package Widgets |
|||
* |
|||
* @file Profile.php |
|||
* This file is part of MOVIM. |
|||
* |
|||
* @brief The Profile widget |
|||
* |
|||
* @author Timothée Jaussoin <edhelas_at_gmail_dot_com> |
|||
* |
|||
* @version 1.0 |
|||
* @date 20 October 2010 |
|||
* |
|||
* Copyright (C)2010 MOVIM project |
|||
* |
|||
* See COPYING for licensing information. |
|||
*/ |
|||
|
|||
class ProfileData extends WidgetBase |
|||
{ |
|||
function WidgetLoad() |
|||
{ |
|||
$this->addjs('profiledata.js'); |
|||
} |
|||
|
|||
function ajaxLocationPublish($pos) |
|||
{ |
|||
movim_log($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')
|
|||
); |
|||
movim_log($geo); |
|||
|
|||
$p = new moxl\LocationPublish(); |
|||
$p->setTo($this->user->getLogin()) |
|||
->setGeo($geo) |
|||
->request(); |
|||
} else { |
|||
$html = ' |
|||
<div class="message error">'.t('Wrong position').'</div>'; |
|||
RPC::call('movim_fill', 'maperror', RPC::cdata($html)); |
|||
RPC::commit(); |
|||
} |
|||
} |
|||
|
|||
function prepareProfileData() |
|||
{ |
|||
$submit = $this->genCallAjax('ajaxLocationPublish', "getMyPositionData()"); |
|||
|
|||
$html = ''; |
|||
|
|||
$html .= ' |
|||
<h2>'.t('Location').'</h2> |
|||
<div id="maperror"></div> |
|||
<div id="mapdata"></div> |
|||
<div id="mapdiv" style="width: auto; height: 250px; display: none;"></div><br /> |
|||
<a class="button tiny icon add" onclick="getMyPosition(); this.style.display = \'none\';">'.t('Get my position').'</a> |
|||
<a id="mypossubmit" style="display: none;" class="button tiny icon yes merged left" onclick="'.$submit.'">'.t('Accept').'</a><a style="display: none;" id="myposrefuse" class="button tiny icon yes merged right">'.t('Cancel').'</a>'; |
|||
return $html; |
|||
} |
|||
|
|||
function build() |
|||
{ |
|||
echo $this->prepareProfileData(); |
|||
} |
|||
} |
@ -0,0 +1,67 @@ |
|||
var myposition = 0; |
|||
|
|||
function getMyPositionData() { return myposition; }//return myposition.latitude; }
|
|||
|
|||
window.cb = function cb(json) { |
|||
document.getElementById('mapdata').innerHTML = json.display_name + ',' + json.address.city; |
|||
myposition = JSON.stringify(json); |
|||
} |
|||
|
|||
function getMyPosition() { |
|||
if (navigator.geolocation) { |
|||
navigator.geolocation.getCurrentPosition( |
|||
function (position) { |
|||
|
|||
document.querySelector("#mapdiv").style.display = 'block'; |
|||
|
|||
map = new OpenLayers.Map("mapdiv"); |
|||
map.addLayer(new OpenLayers.Layer.OSM()); |
|||
|
|||
var lonLat = new OpenLayers.LonLat( position.coords.longitude ,position.coords.latitude ) |
|||
.transform( |
|||
new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
|
|||
map.getProjectionObject() // to Spherical Mercator Projection
|
|||
); |
|||
|
|||
var zoom=11; |
|||
|
|||
var markers = new OpenLayers.Layer.Markers( "Markers" ); |
|||
map.addLayer(markers); |
|||
|
|||
markers.addMarker(new OpenLayers.Marker(lonLat)); |
|||
|
|||
map.setCenter (lonLat, zoom); |
|||
|
|||
|
|||
var s = document.createElement('script'); |
|||
s.src = 'http://nominatim.openstreetmap.org/reverse?json_callback=cb&format=json&lat='+position.coords.latitude+'&lon='+position.coords.longitude+'&zoom=27&addressdetails=1'; |
|||
document.getElementsByTagName('head')[0].appendChild(s); |
|||
|
|||
document.querySelector("#mypossubmit").style.display = 'inline-block'; |
|||
document.querySelector("#myposrefuse").style.display = 'inline-block'; |
|||
}, |
|||
// next function is the error callback
|
|||
function (error) |
|||
{ |
|||
switch(error.code) |
|||
{ |
|||
case error.TIMEOUT: |
|||
alert ('Timeout'); |
|||
break; |
|||
case error.POSITION_UNAVAILABLE: |
|||
alert ('Position unavailable'); |
|||
break; |
|||
case error.PERMISSION_DENIED: |
|||
alert ('Permission denied'); |
|||
break; |
|||
case error.UNKNOWN_ERROR: |
|||
alert ('Unknown error'); |
|||
break; |
|||
} |
|||
} |
|||
); |
|||
} |
|||
else { |
|||
|
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue