forked from friendica/friendica-addons
commit
6cda95870e
|
@ -13,6 +13,7 @@ require_once('include/network.php');
|
||||||
require_once("mod/proxy.php");
|
require_once("mod/proxy.php");
|
||||||
require_once('include/text.php');
|
require_once('include/text.php');
|
||||||
|
|
||||||
|
use Friendica\Core\Cache;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
use Friendica\Core\PConfig;
|
use Friendica\Core\PConfig;
|
||||||
|
|
||||||
|
|
|
@ -6,20 +6,24 @@
|
||||||
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Friendica\Core\Cache;
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
function geocoordinates_install() {
|
function geocoordinates_install()
|
||||||
|
{
|
||||||
register_hook('post_local', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
|
register_hook('post_local', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
|
||||||
register_hook('post_remote', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
|
register_hook('post_remote', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function geocoordinates_uninstall() {
|
function geocoordinates_uninstall()
|
||||||
|
{
|
||||||
unregister_hook('post_local', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
|
unregister_hook('post_local', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
|
||||||
unregister_hook('post_remote', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
|
unregister_hook('post_remote', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
|
||||||
}
|
}
|
||||||
|
|
||||||
function geocoordinates_resolve_item(&$item) {
|
function geocoordinates_resolve_item(&$item)
|
||||||
|
{
|
||||||
if((!$item["coord"]) || ($item["location"]))
|
if((!$item["coord"]) || ($item["location"]))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -72,11 +76,13 @@ function geocoordinates_resolve_item(&$item) {
|
||||||
Cache::set("geocoordinates:".$language.":".$coords[0]."-".$coords[1], $item["location"]);
|
Cache::set("geocoordinates:".$language.":".$coords[0]."-".$coords[1], $item["location"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function geocoordinates_post_hook($a, &$item) {
|
function geocoordinates_post_hook($a, &$item)
|
||||||
|
{
|
||||||
geocoordinates_resolve_item($item);
|
geocoordinates_resolve_item($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
function geocoordinates_plugin_admin(&$a,&$o) {
|
function geocoordinates_plugin_admin(&$a, &$o)
|
||||||
|
{
|
||||||
|
|
||||||
$t = get_markup_template("admin.tpl", "addon/geocoordinates/");
|
$t = get_markup_template("admin.tpl", "addon/geocoordinates/");
|
||||||
|
|
||||||
|
@ -87,7 +93,8 @@ function geocoordinates_plugin_admin(&$a,&$o) {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
function geocoordinates_plugin_admin_post(&$a) {
|
function geocoordinates_plugin_admin_post(&$a)
|
||||||
|
{
|
||||||
$api_key = ((x($_POST,'api_key')) ? notags(trim($_POST['api_key'])) : '');
|
$api_key = ((x($_POST,'api_key')) ? notags(trim($_POST['api_key'])) : '');
|
||||||
Config::set('geocoordinates','api_key',$api_key);
|
Config::set('geocoordinates','api_key',$api_key);
|
||||||
|
|
||||||
|
|
|
@ -7,35 +7,40 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once('include/cache.php');
|
use Friendica\Core\Cache;
|
||||||
|
|
||||||
|
function googlemaps_install()
|
||||||
function googlemaps_install() {
|
{
|
||||||
register_hook('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
|
register_hook('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
|
||||||
|
|
||||||
logger("installed googlemaps");
|
logger("installed googlemaps");
|
||||||
}
|
}
|
||||||
|
|
||||||
function googlemaps_uninstall() {
|
function googlemaps_uninstall()
|
||||||
|
{
|
||||||
unregister_hook('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
|
unregister_hook('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
|
||||||
|
|
||||||
logger("removed googlemaps");
|
logger("removed googlemaps");
|
||||||
}
|
}
|
||||||
|
|
||||||
function googlemaps_location($a, &$item) {
|
function googlemaps_location($a, &$item)
|
||||||
|
{
|
||||||
|
|
||||||
if(! (strlen($item['location']) || strlen($item['coord'])))
|
if(! (strlen($item['location']) || strlen($item['coord']))) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($item['coord'] != "")
|
if ($item['coord'] != ""){
|
||||||
$target = "http://maps.google.com/?q=".urlencode($item['coord']);
|
$target = "http://maps.google.com/?q=".urlencode($item['coord']);
|
||||||
else
|
} else {
|
||||||
$target = "http://maps.google.com/?q=".urlencode($item['location']);
|
$target = "http://maps.google.com/?q=".urlencode($item['location']);
|
||||||
|
}
|
||||||
|
|
||||||
if ($item['location'] != "")
|
if ($item['location'] != "") {
|
||||||
$title = $item['location'];
|
$title = $item['location'];
|
||||||
else
|
} else {
|
||||||
$title = $item['coord'];
|
$title = $item['coord'];
|
||||||
|
}
|
||||||
|
|
||||||
$item['html'] = '<a target="map" title="'.$title.'" href= "'.$target.'">'.$title.'</a>';
|
$item['html'] = '<a target="map" title="'.$title.'" href= "'.$target.'">'.$title.'</a>';
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once('include/cache.php');
|
use Friendica\Core\Cache;
|
||||||
|
|
||||||
use Friendica\Core\Config;
|
use Friendica\Core\Config;
|
||||||
|
|
||||||
|
|
||||||
function openstreetmap_install() {
|
function openstreetmap_install()
|
||||||
|
{
|
||||||
register_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
|
register_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
|
||||||
register_hook('generate_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_map');
|
register_hook('generate_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_map');
|
||||||
register_hook('generate_named_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_named_map');
|
register_hook('generate_named_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_named_map');
|
||||||
|
@ -23,7 +23,8 @@ function openstreetmap_install() {
|
||||||
logger("installed openstreetmap");
|
logger("installed openstreetmap");
|
||||||
}
|
}
|
||||||
|
|
||||||
function openstreetmap_uninstall() {
|
function openstreetmap_uninstall()
|
||||||
|
{
|
||||||
unregister_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
|
unregister_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
|
||||||
unregister_hook('generate_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_map');
|
unregister_hook('generate_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_map');
|
||||||
unregister_hook('generate_named_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_named_map');
|
unregister_hook('generate_named_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_named_map');
|
||||||
|
@ -32,7 +33,8 @@ function openstreetmap_uninstall() {
|
||||||
logger("removed openstreetmap");
|
logger("removed openstreetmap");
|
||||||
}
|
}
|
||||||
|
|
||||||
function openstreetmap_alterheader($a, &$navHtml) {
|
function openstreetmap_alterheader($a, &$navHtml)
|
||||||
|
{
|
||||||
$addScriptTag = '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/openstreetmap/openstreetmap.js"></script>' . "\r\n";
|
$addScriptTag = '<script type="text/javascript" src="' . $a->get_baseurl() . '/addon/openstreetmap/openstreetmap.js"></script>' . "\r\n";
|
||||||
$a->page['htmlhead'] .= $addScriptTag;
|
$a->page['htmlhead'] .= $addScriptTag;
|
||||||
}
|
}
|
||||||
|
@ -48,8 +50,9 @@ function openstreetmap_alterheader($a, &$navHtml) {
|
||||||
*/
|
*/
|
||||||
function openstreetmap_location($a, &$item) {
|
function openstreetmap_location($a, &$item) {
|
||||||
|
|
||||||
if(! (strlen($item['location']) || strlen($item['coord'])))
|
if(! (strlen($item['location']) || strlen($item['coord']))) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the configuration variables from the config.
|
* Get the configuration variables from the config.
|
||||||
|
@ -60,20 +63,24 @@ function openstreetmap_location($a, &$item) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$tmsserver = Config::get('openstreetmap', 'tmsserver');
|
$tmsserver = Config::get('openstreetmap', 'tmsserver');
|
||||||
if(! $tmsserver)
|
if(! $tmsserver) {
|
||||||
$tmsserver = 'http://www.openstreetmap.org';
|
$tmsserver = 'http://www.openstreetmap.org';
|
||||||
|
}
|
||||||
|
|
||||||
$nomserver = Config::get('openstreetmap', 'nomserver');
|
$nomserver = Config::get('openstreetmap', 'nomserver');
|
||||||
if(! $nomserver)
|
if(! $nomserver) {
|
||||||
$nomserver = 'http://nominatim.openstreetmap.org/search.php';
|
$nomserver = 'http://nominatim.openstreetmap.org/search.php';
|
||||||
|
}
|
||||||
|
|
||||||
$zoom = Config::get('openstreetmap', 'zoom');
|
$zoom = Config::get('openstreetmap', 'zoom');
|
||||||
if(! $zoom)
|
if(! $zoom) {
|
||||||
$zoom = 16;
|
$zoom = 16;
|
||||||
|
}
|
||||||
|
|
||||||
$marker = Config::get('openstreetmap', 'marker');
|
$marker = Config::get('openstreetmap', 'marker');
|
||||||
if(! $marker)
|
if(! $marker) {
|
||||||
$marker = 0;
|
$marker = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ($item['coord'] != "") {
|
if ($item['coord'] != "") {
|
||||||
$coords = explode(' ', $item['coord']);
|
$coords = explode(' ', $item['coord']);
|
||||||
|
@ -87,21 +94,22 @@ function openstreetmap_location($a, &$item) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($target == "")
|
if ($target == "") {
|
||||||
$target = $nomserver.'?q='.urlencode($item['location']);
|
$target = $nomserver.'?q='.urlencode($item['location']);
|
||||||
|
}
|
||||||
|
|
||||||
if ($item['location'] != "")
|
if ($item['location'] != "") {
|
||||||
$title = $item['location'];
|
$title = $item['location'];
|
||||||
else
|
} else {
|
||||||
$title = $item['coord'];
|
$title = $item['coord'];
|
||||||
|
}
|
||||||
|
|
||||||
$item['html'] = '<a target="map" title="'.$title.'" href= "'.$target.'">'.$title.'</a>';
|
$item['html'] = '<a target="map" title="'.$title.'" href= "'.$target.'">'.$title.'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function openstreetmap_generate_named_map(&$a,&$b) {
|
function openstreetmap_generate_named_map(&$a, &$b)
|
||||||
|
{
|
||||||
|
|
||||||
$nomserver = Config::get('openstreetmap', 'nomserver');
|
$nomserver = Config::get('openstreetmap', 'nomserver');
|
||||||
if(! $nomserver)
|
if(! $nomserver)
|
||||||
$nomserver = 'http://nominatim.openstreetmap.org/search.php';
|
$nomserver = 'http://nominatim.openstreetmap.org/search.php';
|
||||||
|
@ -119,22 +127,26 @@ function openstreetmap_generate_named_map(&$a,&$b) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function openstreetmap_generate_map(&$a,&$b) {
|
function openstreetmap_generate_map(&$a, &$b)
|
||||||
|
{
|
||||||
$tmsserver = Config::get('openstreetmap', 'tmsserver');
|
$tmsserver = Config::get('openstreetmap', 'tmsserver');
|
||||||
if(! $tmsserver)
|
if(! $tmsserver) {
|
||||||
$tmsserver = 'http://www.openstreetmap.org';
|
$tmsserver = 'http://www.openstreetmap.org';
|
||||||
if(strpos(z_root(),'https:') !== false)
|
}
|
||||||
|
if(strpos(z_root(),'https:') !== false) {
|
||||||
$tmsserver = str_replace('http:','https:',$tmsserver);
|
$tmsserver = str_replace('http:','https:',$tmsserver);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$zoom = Config::get('openstreetmap', 'zoom');
|
$zoom = Config::get('openstreetmap', 'zoom');
|
||||||
if(! $zoom)
|
if(! $zoom) {
|
||||||
$zoom = 16;
|
$zoom = 16;
|
||||||
|
}
|
||||||
|
|
||||||
$marker = Config::get('openstreetmap', 'marker');
|
$marker = Config::get('openstreetmap', 'marker');
|
||||||
if(! $marker)
|
if(! $marker) {
|
||||||
$marker = 0;
|
$marker = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$lat = $b['lat']; // round($b['lat'], 5);
|
$lat = $b['lat']; // round($b['lat'], 5);
|
||||||
$lon = $b['lon']; // round($b['lon'], 5);
|
$lon = $b['lon']; // round($b['lon'], 5);
|
||||||
|
@ -151,20 +163,25 @@ function openstreetmap_generate_map(&$a,&$b) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function openstreetmap_plugin_admin(&$a, &$o) {
|
function openstreetmap_plugin_admin(&$a, &$o)
|
||||||
|
{
|
||||||
$t = get_markup_template("admin.tpl", "addon/openstreetmap/");
|
$t = get_markup_template("admin.tpl", "addon/openstreetmap/");
|
||||||
$tmsserver = Config::get('openstreetmap', 'tmsserver');
|
$tmsserver = Config::get('openstreetmap', 'tmsserver');
|
||||||
if(! $tmsserver)
|
if(! $tmsserver) {
|
||||||
$tmsserver = 'http://www.openstreetmap.org';
|
$tmsserver = 'http://www.openstreetmap.org';
|
||||||
|
}
|
||||||
$nomserver = Config::get('openstreetmap', 'nomserver');
|
$nomserver = Config::get('openstreetmap', 'nomserver');
|
||||||
if(! $nomserver)
|
if(! $nomserver) {
|
||||||
$nomserver = 'http://nominatim.openstreetmap.org/search.php';
|
$nomserver = 'http://nominatim.openstreetmap.org/search.php';
|
||||||
|
}
|
||||||
$zoom = Config::get('openstreetmap', 'zoom');
|
$zoom = Config::get('openstreetmap', 'zoom');
|
||||||
if(! $zoom)
|
if(! $zoom) {
|
||||||
$zoom = 16;
|
$zoom = 16;
|
||||||
|
}
|
||||||
$marker = Config::get('openstreetmap', 'marker');
|
$marker = Config::get('openstreetmap', 'marker');
|
||||||
if(! $marker)
|
if(! $marker) {
|
||||||
$marker = 0;
|
$marker = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$o = replace_macros($t, array(
|
$o = replace_macros($t, array(
|
||||||
'$submit' => t('Submit'),
|
'$submit' => t('Submit'),
|
||||||
|
@ -174,7 +191,9 @@ function openstreetmap_plugin_admin(&$a, &$o) {
|
||||||
'$marker' => array('marker', t('Include marker on map'), $marker, t('Include a marker on the map.')),
|
'$marker' => array('marker', t('Include marker on map'), $marker, t('Include a marker on the map.')),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
function openstreetmap_plugin_admin_post(&$a) {
|
|
||||||
|
function openstreetmap_plugin_admin_post(&$a)
|
||||||
|
{
|
||||||
$urltms = ((x($_POST, 'tmsserver')) ? notags(trim($_POST['tmsserver'])) : '');
|
$urltms = ((x($_POST, 'tmsserver')) ? notags(trim($_POST['tmsserver'])) : '');
|
||||||
$urlnom = ((x($_POST, 'nomserver')) ? notags(trim($_POST['nomserver'])) : '');
|
$urlnom = ((x($_POST, 'nomserver')) ? notags(trim($_POST['nomserver'])) : '');
|
||||||
$zoom = ((x($_POST, 'zoom')) ? intval(trim($_POST['zoom'])) : '16');
|
$zoom = ((x($_POST, 'zoom')) ? intval(trim($_POST['zoom'])) : '16');
|
||||||
|
@ -185,5 +204,3 @@ function openstreetmap_plugin_admin_post(&$a) {
|
||||||
Config::set('openstreetmap', 'marker', $marker);
|
Config::set('openstreetmap', 'marker', $marker);
|
||||||
info( t('Settings updated.') . EOL);
|
info( t('Settings updated.') . EOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue