From: Dan Untenzu Date: Wed, 18 Jan 2017 18:32:37 +0000 (+0100) Subject: [FEATURE] Autogenerate prefix for absolute links X-Git-Tag: 3.0.0~25 X-Git-Url: https://git.p6c8.net/jirafeau.git/commitdiff_plain/1f063df81260072ce942d4ad28ab109997c100c1?hp=50f88df47f6d5b3cb5dc20fb2e9d3022862adbcf [FEATURE] Autogenerate prefix for absolute links Add a helping variable to build absolute links to the root of the domain without handling the URL scheme. This way all links could get rid of the host & domain part, and just build absolute links to the root instead. (Replace "[https://example.com/foo/] + [functions.js]" with "[/foo/] + [functions.js]") Refs #79 --- diff --git a/lib/settings.php b/lib/settings.php index da0d9db..33c76da 100644 --- a/lib/settings.php +++ b/lib/settings.php @@ -42,6 +42,15 @@ define ('VAR_LINKS', $cfg['var_root'] . 'links/'); define ('VAR_ASYNC', $cfg['var_root'] . 'async/'); define ('VAR_ALIAS', $cfg['var_root'] . 'alias/'); +// helping variable to build absolute link to +// root of the domain without handling the URL scheme +$absPrefix = parse_url($cfg['web_root'], PHP_URL_PATH); +if(true === empty($absPrefix)) { + // fallback if installation isnt done yet: relative links to same level on the current page + $absPrefix = './'; +} +define ('JIRAFEAU_ABSPREFIX', $absPrefix); + /* Useful constants. */ if (!defined ('NL')) { define ('NL', "\n");