[openstreetmaps] Add addon config

- Update mentions of .htconfig.php
This commit is contained in:
Hypolite Petovan 2018-06-27 23:18:19 -04:00
parent 88278dbe19
commit d9808fecdf
3 changed files with 44 additions and 12 deletions

View file

@ -32,15 +32,17 @@ zoom level available.
___ Alternative Configuration ___ ___ Alternative Configuration ___
Open the .htconfig.php file and add "openstreetmap" to the list of activated Open the config/local.ini.php file and add "openstreetmap" to the list of activated
addons. addons.
$a->config['system']['addon'] = "openstreetmap, ..." [system]
addon = ...,openstreetmap
You have to add two configuration variables for the addon: You can change two configuration variables for the addon:
$a->config['openstreetmap']['tmsserver'] = 'http://www.openstreetmap.org/'; [openstreetmap]
$a->config['openstreetmap']['zoom'] = '18'; tmsserver = https://www.openstreetmap.org
zoom = 18
The *tmsserver* points to the tile server you want to use. Use the full URL, The *tmsserver* points to the tile server you want to use. Use the full URL,
with protocol (http/s) and trailing slash. You can configure the default zoom with protocol (http/s) and trailing slash. You can configure the default zoom

View file

@ -0,0 +1,23 @@
<?php return <<<INI
; Warning: Don't change this file! It only holds the default config values for this addon.
; Instead overwrite these config values in config/local.ini.php in your Friendica directory
[openstreetmap]
; tmsserver (String)
; This points to the tile server you want to use. Use the full URL, with protocol (http/s) and trailing slash.
tmsserver = https://www.openstreetmap.org
; nomserver (String)
nomserver = https://nominatim.openstreetmap.org/search.php
; zoom (Integer)
; The default zoom level on the map.
; 1 will show the whole world and 18 is the highest zoom level available.
zoom = 16
; marker (Integer)
marker = 0
INI;
//Keep this line

View file

@ -15,13 +15,14 @@ use Friendica\Core\L10n;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Util\Network; use Friendica\Util\Network;
const OSM_TMS = 'http://www.openstreetmap.org'; const OSM_TMS = 'https://www.openstreetmap.org';
const OSM_NOM = 'http://nominatim.openstreetmap.org/search.php'; const OSM_NOM = 'https://nominatim.openstreetmap.org/search.php';
const OSM_ZOOM = 16; const OSM_ZOOM = 16;
const OSM_MARKER = 0; const OSM_MARKER = 0;
function openstreetmap_install() function openstreetmap_install()
{ {
Addon::registerHook('load_config', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_load_config');
Addon::registerHook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location'); Addon::registerHook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
Addon::registerHook('generate_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_map'); Addon::registerHook('generate_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_map');
Addon::registerHook('generate_named_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_named_map'); Addon::registerHook('generate_named_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_named_map');
@ -33,6 +34,7 @@ function openstreetmap_install()
function openstreetmap_uninstall() function openstreetmap_uninstall()
{ {
Addon::unregisterHook('load_config', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_load_config');
Addon::unregisterHook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location'); Addon::unregisterHook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
Addon::unregisterHook('generate_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_map'); Addon::unregisterHook('generate_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_map');
Addon::unregisterHook('generate_named_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_named_map'); Addon::unregisterHook('generate_named_map', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_generate_named_map');
@ -42,6 +44,11 @@ function openstreetmap_uninstall()
logger("removed openstreetmap"); logger("removed openstreetmap");
} }
function openstreetmap_load_config(\Friendica\App $a)
{
$a->loadConfigFile(__DIR__. '/config/openstreetmap.ini.php');
}
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";