From c4d5be53c2ae503c00da3cfe6b28d0ce9d2ca7f5 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sun, 17 May 2020 14:16:32 +0200 Subject: Process Daily RSS feed through Slim controller The daily RSS template has been entirely rewritten to handle the whole feed through the template engine. --- application/http/HttpUtils.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'application/http/HttpUtils.php') diff --git a/application/http/HttpUtils.php b/application/http/HttpUtils.php index 2ea9195d..f00c4336 100644 --- a/application/http/HttpUtils.php +++ b/application/http/HttpUtils.php @@ -369,7 +369,7 @@ function server_url($server) */ function index_url($server) { - $scriptname = $server['SCRIPT_NAME']; + $scriptname = $server['SCRIPT_NAME'] ?? ''; if (endsWith($scriptname, 'index.php')) { $scriptname = substr($scriptname, 0, -9); } @@ -377,7 +377,7 @@ function index_url($server) } /** - * Returns the absolute URL of the current script, with the query + * Returns the absolute URL of the current script, with current route and query * * If the resource is "index.php", then it is removed (for better-looking URLs) * @@ -387,10 +387,17 @@ function index_url($server) */ function page_url($server) { + $scriptname = $server['SCRIPT_NAME'] ?? ''; + if (endsWith($scriptname, 'index.php')) { + $scriptname = substr($scriptname, 0, -9); + } + + $route = ltrim($server['REQUEST_URI'] ?? '', $scriptname); if (! empty($server['QUERY_STRING'])) { - return index_url($server).'?'.$server['QUERY_STRING']; + return index_url($server) . $route . '?' . $server['QUERY_STRING']; } - return index_url($server); + + return index_url($server) . $route; } /** -- cgit v1.2.3