forked from friendica/friendica-addons
commit
cdb914458b
|
@ -40,8 +40,8 @@ function geonames_install() {
|
|||
*
|
||||
*/
|
||||
|
||||
register_hook('plugin_settings', 'addon/geonames/geonames.php', 'geonames_settings');
|
||||
register_hook('plugin_settings_post', 'addon/geonames/geonames.php', 'geonames_settings_post');
|
||||
register_hook('plugin_settings', 'addon/geonames/geonames.php', 'geonames_plugin_admin');
|
||||
register_hook('plugin_settings_post', 'addon/geonames/geonames.php', 'geonames_plugin_admin_post');
|
||||
|
||||
logger("installed geonames");
|
||||
}
|
||||
|
@ -58,8 +58,8 @@ function geonames_uninstall() {
|
|||
*/
|
||||
|
||||
unregister_hook('post_local', 'addon/geonames/geonames.php', 'geonames_post_hook');
|
||||
unregister_hook('plugin_settings', 'addon/geonames/geonames.php', 'geonames_settings');
|
||||
unregister_hook('plugin_settings_post', 'addon/geonames/geonames.php', 'geonames_settings_post');
|
||||
unregister_hook('plugin_settings', 'addon/geonames/geonames.php', 'geonames_plugin_admin');
|
||||
unregister_hook('plugin_settings_post', 'addon/geonames/geonames.php', 'geonames_plugin_admin_post');
|
||||
|
||||
|
||||
logger("removed geonames");
|
||||
|
@ -135,7 +135,7 @@ function geonames_post_hook($a, &$item) {
|
|||
*
|
||||
*/
|
||||
|
||||
function geonames_settings_post($a,$post) {
|
||||
function geonames_plugin_admin_post($a,$post) {
|
||||
if(! local_user() || (! x($_POST,'geonames-submit')))
|
||||
return;
|
||||
set_pconfig(local_user(),'geonames','enable',intval($_POST['geonames']));
|
||||
|
@ -153,7 +153,7 @@ function geonames_settings_post($a,$post) {
|
|||
|
||||
|
||||
|
||||
function geonames_settings(&$a,&$s) {
|
||||
function geonames_plugin_admin(&$a,&$s) {
|
||||
|
||||
if(! local_user())
|
||||
return;
|
||||
|
|
41
openstreetmap/openstreetmap.js
Normal file
41
openstreetmap/openstreetmap.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
var toolserver = 'http://toolserver.org/~kolossos/openlayers/kml-on-ol.php';
|
||||
var startTag = '<iframe class="osmFrame" style="width: 100%; height: 350px; clear: both;" src="'+ toolserver + '?lang=de&uselang=de&params=';
|
||||
var endTag = '"></iframe>';
|
||||
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
$('.wall-item-content-wrapper').each(function(index) {
|
||||
var link = $(this).find('.wall-item-location .OSMMapLink');
|
||||
link.toggle(addIframe, removeIframe);
|
||||
});
|
||||
});
|
||||
|
||||
function addIframe(ev) {
|
||||
var coordinate = $(ev.target).attr('title');
|
||||
|
||||
var newTag = startTag + convertCoordinateString(coordinate) + endTag;
|
||||
$(ev.target).parents('.wall-item-content-wrapper').append(newTag);
|
||||
}
|
||||
|
||||
function removeIframe(ev) {
|
||||
$(ev.target).parents('.wall-item-content-wrapper').find('iframe').remove();
|
||||
|
||||
}
|
||||
|
||||
function convertCoordinateString(coordinate) {
|
||||
var locstring = coordinate.split(' ');
|
||||
var northSouth;
|
||||
var westEast;
|
||||
|
||||
if (locstring[0] < 0) {
|
||||
northSouth = '_S_';
|
||||
}else{
|
||||
northSouth = '_N_';
|
||||
}
|
||||
if (locstring[1] < 0) {
|
||||
westEast = '_W';
|
||||
}else{
|
||||
westEast = '_E';
|
||||
}
|
||||
return Math.abs(locstring[0]) + northSouth + Math.abs(locstring[1]) + westEast;
|
||||
}
|
|
@ -10,18 +10,27 @@
|
|||
|
||||
function openstreetmap_install() {
|
||||
register_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
|
||||
register_hook('page_header', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_alterheader');
|
||||
|
||||
logger("installed openstreetmap");
|
||||
}
|
||||
|
||||
function openstreetmap_uninstall() {
|
||||
unregister_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
|
||||
unregister_hook('page_header', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_alterheader');
|
||||
|
||||
logger("removed openstreetmap");
|
||||
}
|
||||
|
||||
function openstreetmap_alterheader($a, &$navHtml) {
|
||||
$addScriptTag='<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/openstreetmap/openstreetmap.js' . '"></script>' . "\r\n";
|
||||
$a->page['htmlhead'] .= $addScriptTag;
|
||||
}
|
||||
|
||||
function openstreetmap_location($a, &$item) {
|
||||
|
||||
//
|
||||
|
||||
if(! (strlen($item['location']) || strlen($item['coord'])))
|
||||
return;
|
||||
|
||||
|
@ -38,12 +47,27 @@ function openstreetmap_location($a, &$item) {
|
|||
$location = '';
|
||||
$coord = '';
|
||||
|
||||
|
||||
if($item['location'] && !$item['coord'] && true){ //if only a location is given, find the lat-lon
|
||||
$geo_account='demo';
|
||||
|
||||
$s = fetch_url('http://api.geonames.org/search?maxRows=1&fuzzy=0.8&q=' . $item['location'] . '&username=' . $geo_account);
|
||||
|
||||
if($s){
|
||||
$xml = parse_xml_string($s);
|
||||
|
||||
if($xml->geoname->lat && $xml->geoname->lng){
|
||||
$item['coord'] = $xml->geoname->lat . ' ' . $xml->geoname->lng;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$location = (($item['location']) ? '<a target="map" title="' . $item['location'] . '" href="'.$tmsserver.'?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
|
||||
|
||||
if($item['coord']) {
|
||||
$coords = explode(' ', $item['coord']);
|
||||
if(count($coords) > 1) {
|
||||
$coord = '<a target="map" title="' . $item['coord'] . '" href="'.$tmsserver.'?lat=' . urlencode($coords[0]) . '&lon=' . urlencode($coords[1]) . '&zoom='.$zoom.'">' . $item['coord'] . '</a>' ;
|
||||
$coord = '<a target="map" class="OSMMapLink" title="' . $item['coord'] . '" href="'.$tmsserver.'?lat=' . urlencode($coords[0]) . '&lon=' . urlencode($coords[1]) . '&zoom='.$zoom.'"> Map </a>' ;
|
||||
}
|
||||
}
|
||||
if(strlen($coord)) {
|
||||
|
|
Loading…
Reference in a new issue