Merge branch '0.9.x' of git://gitorious.org/statusnet/mainline into 0.9.x
This commit is contained in:
commit
93f6981b71
|
@ -164,7 +164,7 @@ class LoginAction extends Action
|
||||||
} else {
|
} else {
|
||||||
$url = common_local_url('all',
|
$url = common_local_url('all',
|
||||||
array('nickname' =>
|
array('nickname' =>
|
||||||
$nickname));
|
$user->nickname));
|
||||||
}
|
}
|
||||||
|
|
||||||
common_redirect($url, 303);
|
common_redirect($url, 303);
|
||||||
|
|
|
@ -164,6 +164,11 @@ class NewnoticeAction extends Action
|
||||||
$replyto = 'false';
|
$replyto = 'false';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$lat = $this->trimmed('lat');
|
||||||
|
$lon = $this->trimmed('lon');
|
||||||
|
$location_id = $this->trimmed('location_id');
|
||||||
|
$location_ns = $this->trimmed('location_ns');
|
||||||
|
|
||||||
$upload = null;
|
$upload = null;
|
||||||
$upload = MediaFile::fromUpload('attach');
|
$upload = MediaFile::fromUpload('attach');
|
||||||
|
|
||||||
|
@ -183,7 +188,9 @@ class NewnoticeAction extends Action
|
||||||
}
|
}
|
||||||
|
|
||||||
$notice = Notice::saveNew($user->id, $content_shortened, 'web', 1,
|
$notice = Notice::saveNew($user->id, $content_shortened, 'web', 1,
|
||||||
($replyto == 'false') ? null : $replyto);
|
($replyto == 'false') ? null : $replyto,
|
||||||
|
null, null,
|
||||||
|
$lat, $lon, $location_id, $location_ns);
|
||||||
|
|
||||||
if (isset($upload)) {
|
if (isset($upload)) {
|
||||||
$upload->attachToNotice($notice);
|
$upload->attachToNotice($notice);
|
||||||
|
|
216
js/geometa.js
Normal file
216
js/geometa.js
Normal file
|
@ -0,0 +1,216 @@
|
||||||
|
// A shim to implement the W3C Geolocation API Specification using Gears or the Ajax API
|
||||||
|
if ( typeof navigator.geolocation == "undefined" || navigator.geolocation.shim ) (function(){
|
||||||
|
|
||||||
|
// -- BEGIN GEARS_INIT
|
||||||
|
(function() {
|
||||||
|
// We are already defined. Hooray!
|
||||||
|
if (window.google && google.gears) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var factory = null;
|
||||||
|
|
||||||
|
// Firefox
|
||||||
|
if (typeof GearsFactory != 'undefined') {
|
||||||
|
factory = new GearsFactory();
|
||||||
|
} else {
|
||||||
|
// IE
|
||||||
|
try {
|
||||||
|
factory = new ActiveXObject('Gears.Factory');
|
||||||
|
// privateSetGlobalObject is only required and supported on WinCE.
|
||||||
|
if (factory.getBuildInfo().indexOf('ie_mobile') != -1) {
|
||||||
|
factory.privateSetGlobalObject(this);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Safari
|
||||||
|
if ((typeof navigator.mimeTypes != 'undefined')
|
||||||
|
&& navigator.mimeTypes["application/x-googlegears"]) {
|
||||||
|
factory = document.createElement("object");
|
||||||
|
factory.style.display = "none";
|
||||||
|
factory.width = 0;
|
||||||
|
factory.height = 0;
|
||||||
|
factory.type = "application/x-googlegears";
|
||||||
|
document.documentElement.appendChild(factory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// *Do not* define any objects if Gears is not installed. This mimics the
|
||||||
|
// behavior of Gears defining the objects in the future.
|
||||||
|
if (!factory) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now set up the objects, being careful not to overwrite anything.
|
||||||
|
//
|
||||||
|
// Note: In Internet Explorer for Windows Mobile, you can't add properties to
|
||||||
|
// the window object. However, global objects are automatically added as
|
||||||
|
// properties of the window object in all browsers.
|
||||||
|
if (!window.google) {
|
||||||
|
google = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!google.gears) {
|
||||||
|
google.gears = {factory: factory};
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
// -- END GEARS_INIT
|
||||||
|
|
||||||
|
var GearsGeoLocation = (function() {
|
||||||
|
// -- PRIVATE
|
||||||
|
var geo = google.gears.factory.create('beta.geolocation');
|
||||||
|
|
||||||
|
var wrapSuccess = function(callback, self) { // wrap it for lastPosition love
|
||||||
|
return function(position) {
|
||||||
|
callback(position);
|
||||||
|
self.lastPosition = position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- PUBLIC
|
||||||
|
return {
|
||||||
|
shim: true,
|
||||||
|
|
||||||
|
type: "Gears",
|
||||||
|
|
||||||
|
lastPosition: null,
|
||||||
|
|
||||||
|
getCurrentPosition: function(successCallback, errorCallback, options) {
|
||||||
|
var self = this;
|
||||||
|
var sc = wrapSuccess(successCallback, self);
|
||||||
|
geo.getCurrentPosition(sc, errorCallback, options);
|
||||||
|
},
|
||||||
|
|
||||||
|
watchPosition: function(successCallback, errorCallback, options) {
|
||||||
|
geo.watchPosition(successCallback, errorCallback, options);
|
||||||
|
},
|
||||||
|
|
||||||
|
clearWatch: function(watchId) {
|
||||||
|
geo.clearWatch(watchId);
|
||||||
|
},
|
||||||
|
|
||||||
|
getPermission: function(siteName, imageUrl, extraMessage) {
|
||||||
|
geo.getPermission(siteName, imageUrl, extraMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
var AjaxGeoLocation = (function() {
|
||||||
|
// -- PRIVATE
|
||||||
|
var loading = false;
|
||||||
|
var loadGoogleLoader = function() {
|
||||||
|
if (!hasGoogleLoader() && !loading) {
|
||||||
|
loading = true;
|
||||||
|
var s = document.createElement('script');
|
||||||
|
s.src = 'http://www.google.com/jsapi?callback=_google_loader_apiLoaded';
|
||||||
|
s.type = "text/javascript";
|
||||||
|
document.getElementsByTagName('body')[0].appendChild(s);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var queue = [];
|
||||||
|
var addLocationQueue = function(callback) {
|
||||||
|
queue.push(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
var runLocationQueue = function() {
|
||||||
|
if (hasGoogleLoader()) {
|
||||||
|
while (queue.length > 0) {
|
||||||
|
var call = queue.pop();
|
||||||
|
call();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window['_google_loader_apiLoaded'] = function() {
|
||||||
|
runLocationQueue();
|
||||||
|
}
|
||||||
|
|
||||||
|
var hasGoogleLoader = function() {
|
||||||
|
return (window['google'] && google['loader']);
|
||||||
|
}
|
||||||
|
|
||||||
|
var checkGoogleLoader = function(callback) {
|
||||||
|
if (hasGoogleLoader()) return true;
|
||||||
|
|
||||||
|
addLocationQueue(callback);
|
||||||
|
|
||||||
|
loadGoogleLoader();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
loadGoogleLoader(); // start to load as soon as possible just in case
|
||||||
|
|
||||||
|
// -- PUBLIC
|
||||||
|
return {
|
||||||
|
shim: true,
|
||||||
|
|
||||||
|
type: "ClientLocation",
|
||||||
|
|
||||||
|
lastPosition: null,
|
||||||
|
|
||||||
|
getCurrentPosition: function(successCallback, errorCallback, options) {
|
||||||
|
var self = this;
|
||||||
|
if (!checkGoogleLoader(function() {
|
||||||
|
self.getCurrentPosition(successCallback, errorCallback, options);
|
||||||
|
})) return;
|
||||||
|
|
||||||
|
if (google.loader.ClientLocation) {
|
||||||
|
var cl = google.loader.ClientLocation;
|
||||||
|
|
||||||
|
var position = {
|
||||||
|
latitude: cl.latitude,
|
||||||
|
longitude: cl.longitude,
|
||||||
|
altitude: null,
|
||||||
|
accuracy: 43000, // same as Gears accuracy over wifi?
|
||||||
|
altitudeAccuracy: null,
|
||||||
|
heading: null,
|
||||||
|
velocity: null,
|
||||||
|
timestamp: new Date(),
|
||||||
|
|
||||||
|
// extra info that is outside of the bounds of the core API
|
||||||
|
address: {
|
||||||
|
city: cl.address.city,
|
||||||
|
country: cl.address.country,
|
||||||
|
country_code: cl.address.country_code,
|
||||||
|
region: cl.address.region
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
successCallback(position);
|
||||||
|
|
||||||
|
this.lastPosition = position;
|
||||||
|
} else if (errorCallback === "function") {
|
||||||
|
errorCallback({ code: 3, message: "Using the Google ClientLocation API and it is not able to calculate a location."});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
watchPosition: function(successCallback, errorCallback, options) {
|
||||||
|
this.getCurrentPosition(successCallback, errorCallback, options);
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
var watchId = setInterval(function() {
|
||||||
|
self.getCurrentPosition(successCallback, errorCallback, options);
|
||||||
|
}, 10000);
|
||||||
|
|
||||||
|
return watchId;
|
||||||
|
},
|
||||||
|
|
||||||
|
clearWatch: function(watchId) {
|
||||||
|
clearInterval(watchId);
|
||||||
|
},
|
||||||
|
|
||||||
|
getPermission: function(siteName, imageUrl, extraMessage) {
|
||||||
|
// for now just say yes :)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
|
// If you have Gears installed use that, else use Ajax ClientLocation
|
||||||
|
navigator.geolocation = (window.google && google.gears) ? GearsGeoLocation : AjaxGeoLocation;
|
||||||
|
|
||||||
|
})();
|
14
js/util.js
14
js/util.js
|
@ -46,7 +46,11 @@ var SN = { // StatusNet
|
||||||
NoticeInReplyTo: 'notice_in-reply-to',
|
NoticeInReplyTo: 'notice_in-reply-to',
|
||||||
NoticeDataAttach: 'notice_data-attach',
|
NoticeDataAttach: 'notice_data-attach',
|
||||||
NoticeDataAttachSelected: 'notice_data-attach_selected',
|
NoticeDataAttachSelected: 'notice_data-attach_selected',
|
||||||
NoticeActionSubmit: 'notice_action-submit'
|
NoticeActionSubmit: 'notice_action-submit',
|
||||||
|
NoticeLat: 'notice_data-lat',
|
||||||
|
NoticeLon: 'notice_data-lon',
|
||||||
|
NoticeLocationId: 'notice_data-location_id',
|
||||||
|
NoticeLocationNs: 'notice_data-location_ns'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -351,6 +355,13 @@ var SN = { // StatusNet
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
NoticeLocationAttach: function() {
|
||||||
|
if(navigator.geolocation) navigator.geolocation.watchPosition(function(position) {
|
||||||
|
$('#'+SN.C.S.NoticeLat).val(position.coords.latitude);
|
||||||
|
$('#'+SN.C.S.NoticeLon).val(position.coords.longitude);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
NewDirectMessage: function() {
|
NewDirectMessage: function() {
|
||||||
NDM = $('.entity_send-a-message a');
|
NDM = $('.entity_send-a-message a');
|
||||||
NDM.attr({'href':NDM.attr('href')+'&ajax=1'});
|
NDM.attr({'href':NDM.attr('href')+'&ajax=1'});
|
||||||
|
@ -387,6 +398,7 @@ var SN = { // StatusNet
|
||||||
});
|
});
|
||||||
|
|
||||||
SN.U.NoticeDataAttach();
|
SN.U.NoticeDataAttach();
|
||||||
|
SN.U.NoticeLocationAttach();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -259,6 +259,7 @@ class Action extends HTMLOutputter // lawsuit
|
||||||
Event::handle('StartShowLaconicaScripts', array($this))) {
|
Event::handle('StartShowLaconicaScripts', array($this))) {
|
||||||
$this->script('js/xbImportNode.js');
|
$this->script('js/xbImportNode.js');
|
||||||
$this->script('js/util.js');
|
$this->script('js/util.js');
|
||||||
|
$this->script('js/geometa.js');
|
||||||
// Frame-busting code to avoid clickjacking attacks.
|
// Frame-busting code to avoid clickjacking attacks.
|
||||||
$this->element('script', array('type' => 'text/javascript'),
|
$this->element('script', array('type' => 'text/javascript'),
|
||||||
'if (window.top !== window.self) { window.top.location.href = window.self.location.href; }');
|
'if (window.top !== window.self) { window.top.location.href = window.self.location.href; }');
|
||||||
|
|
|
@ -75,6 +75,15 @@ class NoticeForm extends Form
|
||||||
|
|
||||||
var $inreplyto = null;
|
var $inreplyto = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pre-filled location content of the form
|
||||||
|
*/
|
||||||
|
|
||||||
|
var $lat;
|
||||||
|
var $lon;
|
||||||
|
var $location_id;
|
||||||
|
var $location_ns;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
@ -83,13 +92,17 @@ class NoticeForm extends Form
|
||||||
* @param string $content content to pre-fill
|
* @param string $content content to pre-fill
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function __construct($out=null, $action=null, $content=null, $user=null, $inreplyto=null)
|
function __construct($out=null, $action=null, $content=null, $user=null, $inreplyto=null, $lat=null, $lon=null, $location_id=null, $location_ns=null)
|
||||||
{
|
{
|
||||||
parent::__construct($out);
|
parent::__construct($out);
|
||||||
|
|
||||||
$this->action = $action;
|
$this->action = $action;
|
||||||
$this->content = $content;
|
$this->content = $content;
|
||||||
$this->inreplyto = $inreplyto;
|
$this->inreplyto = $inreplyto;
|
||||||
|
$this->lat = $lat;
|
||||||
|
$this->lon = $lon;
|
||||||
|
$this->location_id = $location_id;
|
||||||
|
$this->location_ns = $location_ns;
|
||||||
|
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
|
@ -188,6 +201,10 @@ class NoticeForm extends Form
|
||||||
$this->out->hidden('notice_return-to', $this->action, 'returnto');
|
$this->out->hidden('notice_return-to', $this->action, 'returnto');
|
||||||
}
|
}
|
||||||
$this->out->hidden('notice_in-reply-to', $this->inreplyto, 'inreplyto');
|
$this->out->hidden('notice_in-reply-to', $this->inreplyto, 'inreplyto');
|
||||||
|
$this->out->hidden('notice_data-lat', empty($this->lat) ? null : $this->lat, 'lat');
|
||||||
|
$this->out->hidden('notice_data-lon', empty($this->lon) ? null : $this->lon, 'lon');
|
||||||
|
$this->out->hidden('notice_data-location_id', empty($this->location_id) ? null : $this->location_id, 'location_id');
|
||||||
|
$this->out->hidden('notice_data-location_ns', empty($this->location_ns) ? null : $this->location_ns, 'location_ns');
|
||||||
|
|
||||||
Event::handle('StartShowNoticeFormData', array($this));
|
Event::handle('StartShowNoticeFormData', array($this));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user