mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-17 14:03:45 +00:00
add openstreetmap
This commit is contained in:
parent
41d1eb796c
commit
bb5588b5eb
4 changed files with 54 additions and 2 deletions
BIN
openstreetmap.tgz
Normal file
BIN
openstreetmap.tgz
Normal file
Binary file not shown.
51
openstreetmap/openstreetmap.php
Executable file
51
openstreetmap/openstreetmap.php
Executable file
|
@ -0,0 +1,51 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Name: Open Street Map
|
||||||
|
* Description: Use openstreetmap.org for displaying locations.
|
||||||
|
* Version: 1.0
|
||||||
|
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
function openstreetmap_install() {
|
||||||
|
|
||||||
|
register_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
|
||||||
|
|
||||||
|
logger("installed openstreetmap");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function openstreetmap_uninstall() {
|
||||||
|
|
||||||
|
unregister_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
|
||||||
|
|
||||||
|
logger("removed openstreetmap");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function openstreetmap_location($a, &$item) {
|
||||||
|
|
||||||
|
$location = '';
|
||||||
|
$coord = '';
|
||||||
|
|
||||||
|
$location = (($item['location']) ? '<a target="map" title="' . $item['location'] . '" href="http://www.openstreetmap.org/?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="http://www.openstreetmap.org/?lat=' . urlencode($coords[0]) . '&lon=' . urlencode($coords[1]) . '&zoom=10">' . $item['coord'] . '</a>' ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(strlen($coord)) {
|
||||||
|
if($location)
|
||||||
|
$location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
|
||||||
|
else
|
||||||
|
$location = '<span class="smalltext">' . $coord . '</span>';
|
||||||
|
}
|
||||||
|
$item['html'] = $location;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
BIN
randplace.tgz
BIN
randplace.tgz
Binary file not shown.
|
@ -136,6 +136,7 @@ function randplace_post_hook($a, &$item) {
|
||||||
function randplace_settings_post($a,$post) {
|
function randplace_settings_post($a,$post) {
|
||||||
if(! local_user())
|
if(! local_user())
|
||||||
return;
|
return;
|
||||||
|
if($_POST['randplace-submit'])
|
||||||
set_pconfig(local_user(),'randplace','enable',intval($_POST['randplace']));
|
set_pconfig(local_user(),'randplace','enable',intval($_POST['randplace']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,6 +176,6 @@ function randplace_settings(&$a,&$s) {
|
||||||
|
|
||||||
/* provide a submit button */
|
/* provide a submit button */
|
||||||
|
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div></div>';
|
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="randplace-submit" class="settings-submit" value="' . t('Submit') . '" /></div></div>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue