* Author: Michael Vogel <https://pirati.ca/profile/heluecht>
*/
+use Friendica\Core\Cache;
use Friendica\Core\Config;
-function geocoordinates_install() {
+function geocoordinates_install()
+{
register_hook('post_local', '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_remote', 'addon/geocoordinates/geocoordinates.php', 'geocoordinates_post_hook');
}
-function geocoordinates_resolve_item(&$item) {
+function geocoordinates_resolve_item(&$item)
+{
if((!$item["coord"]) || ($item["location"]))
return;
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);
}
-function geocoordinates_plugin_admin(&$a,&$o) {
+function geocoordinates_plugin_admin(&$a, &$o)
+{
$t = get_markup_template("admin.tpl", "addon/geocoordinates/");
));
}
-function geocoordinates_plugin_admin_post(&$a) {
+function geocoordinates_plugin_admin_post(&$a)
+{
$api_key = ((x($_POST,'api_key')) ? notags(trim($_POST['api_key'])) : '');
Config::set('geocoordinates','api_key',$api_key);
*
*/
-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');
logger("installed googlemaps");
}
-function googlemaps_uninstall() {
+function googlemaps_uninstall()
+{
unregister_hook('render_location', 'addon/googlemaps/googlemaps.php', 'googlemaps_location');
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;
+ }
- if ($item['coord'] != "")
+ if ($item['coord'] != ""){
$target = "http://maps.google.com/?q=".urlencode($item['coord']);
- else
+ } else {
$target = "http://maps.google.com/?q=".urlencode($item['location']);
+ }
- if ($item['location'] != "")
+ if ($item['location'] != "") {
$title = $item['location'];
- else
+ } else {
$title = $item['coord'];
+ }
$item['html'] = '<a target="map" title="'.$title.'" href= "'.$target.'">'.$title.'</a>';
}
*
*/
-require_once('include/cache.php');
-
+use Friendica\Core\Cache;
use Friendica\Core\Config;
-function openstreetmap_install() {
+function openstreetmap_install()
+{
register_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
register_hook('generate_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_map');
register_hook('generate_named_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_named_map');
logger("installed openstreetmap");
}
-function openstreetmap_uninstall() {
+function openstreetmap_uninstall()
+{
unregister_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
unregister_hook('generate_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_map');
unregister_hook('generate_named_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_named_map');
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";
$a->page['htmlhead'] .= $addScriptTag;
}
*/
function openstreetmap_location($a, &$item) {
- if(! (strlen($item['location']) || strlen($item['coord'])))
+ if(! (strlen($item['location']) || strlen($item['coord']))) {
return;
+ }
/*
* Get the configuration variables from the config.
*/
$tmsserver = Config::get('openstreetmap', 'tmsserver');
- if(! $tmsserver)
+ if(! $tmsserver) {
$tmsserver = 'http://www.openstreetmap.org';
+ }
$nomserver = Config::get('openstreetmap', 'nomserver');
- if(! $nomserver)
+ if(! $nomserver) {
$nomserver = 'http://nominatim.openstreetmap.org/search.php';
+ }
$zoom = Config::get('openstreetmap', 'zoom');
- if(! $zoom)
+ if(! $zoom) {
$zoom = 16;
+ }
$marker = Config::get('openstreetmap', 'marker');
- if(! $marker)
+ if(! $marker) {
$marker = 0;
+ }
if ($item['coord'] != "") {
$coords = explode(' ', $item['coord']);
}
}
- if ($target == "")
+ if ($target == "") {
$target = $nomserver.'?q='.urlencode($item['location']);
+ }
- if ($item['location'] != "")
+ if ($item['location'] != "") {
$title = $item['location'];
- else
+ } else {
$title = $item['coord'];
+ }
$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');
if(! $nomserver)
$nomserver = 'http://nominatim.openstreetmap.org/search.php';
}
}
-function openstreetmap_generate_map(&$a,&$b) {
-
+function openstreetmap_generate_map(&$a, &$b)
+{
$tmsserver = Config::get('openstreetmap', 'tmsserver');
- if(! $tmsserver)
+ if(! $tmsserver) {
$tmsserver = 'http://www.openstreetmap.org';
- if(strpos(z_root(),'https:') !== false)
+ }
+ if(strpos(z_root(),'https:') !== false) {
$tmsserver = str_replace('http:','https:',$tmsserver);
+ }
$zoom = Config::get('openstreetmap', 'zoom');
- if(! $zoom)
+ if(! $zoom) {
$zoom = 16;
+ }
$marker = Config::get('openstreetmap', 'marker');
- if(! $marker)
+ if(! $marker) {
$marker = 0;
+ }
$lat = $b['lat']; // round($b['lat'], 5);
$lon = $b['lon']; // round($b['lon'], 5);
}
-function openstreetmap_plugin_admin(&$a, &$o) {
+function openstreetmap_plugin_admin(&$a, &$o)
+{
$t = get_markup_template("admin.tpl", "addon/openstreetmap/");
$tmsserver = Config::get('openstreetmap', 'tmsserver');
- if(! $tmsserver)
+ if(! $tmsserver) {
$tmsserver = 'http://www.openstreetmap.org';
+ }
$nomserver = Config::get('openstreetmap', 'nomserver');
- if(! $nomserver)
+ if(! $nomserver) {
$nomserver = 'http://nominatim.openstreetmap.org/search.php';
+ }
$zoom = Config::get('openstreetmap', 'zoom');
- if(! $zoom)
+ if(! $zoom) {
$zoom = 16;
+ }
$marker = Config::get('openstreetmap', 'marker');
- if(! $marker)
+ if(! $marker) {
$marker = 0;
+ }
$o = replace_macros($t, array(
'$submit' => t('Submit'),
'$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'])) : '');
$urlnom = ((x($_POST, 'nomserver')) ? notags(trim($_POST['nomserver'])) : '');
$zoom = ((x($_POST, 'zoom')) ? intval(trim($_POST['zoom'])) : '16');
Config::set('openstreetmap', 'marker', $marker);
info( t('Settings updated.') . EOL);
}
-
-