From af8e81ed5ad64221bb2f5a9a79e92a5c0abead4b Mon Sep 17 00:00:00 2001
From: Thijs Kinkhorst <thijs@kinkhorst.com>
Date: Thu, 7 Mar 2019 16:20:12 +0000
Subject: [PATCH] baseurlpath variable was missing from templates.

re-add it and fix all templates that depended on it being unset
---
 lib/SimpleSAML/XHTML/Template.php                   |  1 +
 modules/adfs/templates/postResponse.twig            |  2 +-
 modules/authYubiKey/templates/yubikeylogin.twig     |  4 ++--
 modules/consent/templates/consentform.twig          |  2 +-
 modules/consentAdmin/templates/consentadmin.twig    |  6 +++---
 modules/cron/templates/croninfo.twig                |  2 +-
 modules/discopower/templates/disco.twig             | 11 +++++------
 modules/memcacheMonitor/templates/memcachestat.twig |  2 +-
 modules/negotiate/templates/redirect.twig           |  2 +-
 modules/statistics/templates/statistics.twig        | 10 +++++-----
 modules/statistics/templates/statmeta.twig          |  4 ++--
 templates/base.twig                                 |  6 +++---
 12 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php
index 43127d9a0..097015dd9 100644
--- a/lib/SimpleSAML/XHTML/Template.php
+++ b/lib/SimpleSAML/XHTML/Template.php
@@ -297,6 +297,7 @@ class Template extends Response
         $twig->addGlobal('queryParams', $queryParams);
         $twig->addGlobal('templateId', str_replace('.twig', '', $this->normalizeTemplateName($this->template)));
         $twig->addGlobal('isProduction', $this->configuration->getBoolean('production', true));
+        $twig->addGlobal('baseurlpath', ltrim($this->configuration->getBasePath(), '/'));
 
         // add a filter for translations out of arrays
         $twig->addFilter(
diff --git a/modules/adfs/templates/postResponse.twig b/modules/adfs/templates/postResponse.twig
index 857aa8d7a..16f0eab18 100644
--- a/modules/adfs/templates/postResponse.twig
+++ b/modules/adfs/templates/postResponse.twig
@@ -1,7 +1,7 @@
 <!DOCTYPE html>
 <html>
     <head>
-        <script src="{{ baseurlpath }}/assets/js/postResponse.js"></script>
+        <script src="/{{ baseurlpath }}module.php/adfs/assets/js/postResponse.js"></script>
     </head>
     <body>
         <form method="post" action="{{ url }}">
diff --git a/modules/authYubiKey/templates/yubikeylogin.twig b/modules/authYubiKey/templates/yubikeylogin.twig
index 8fa4385f2..cedb3f703 100644
--- a/modules/authYubiKey/templates/yubikeylogin.twig
+++ b/modules/authYubiKey/templates/yubikeylogin.twig
@@ -2,11 +2,11 @@
 {% extends "base.twig" %}
 
 {% block preload %}
-    <link rel="stylesheet" type="text/css" href="{{ baseurlpath }}assets/css/yubikey.css">
+    <link rel="stylesheet" href="/{{ baseurlpath }}module.php/authYubiKey/assets/css/yubikey.css">
 {% endblock %}
 
 {% block postload %}
-    <script src="{{ baseurlpath }}assets/js/autofocus.js"></script>
+    <script src="/{{ baseurlpath }}module.php/authYubiKey/assets/js/autofocus.js"></script>
 {% endblock %}
 
 {% block content %}
diff --git a/modules/consent/templates/consentform.twig b/modules/consent/templates/consentform.twig
index b1433046a..c8084207d 100644
--- a/modules/consent/templates/consentform.twig
+++ b/modules/consent/templates/consentform.twig
@@ -2,7 +2,7 @@
 {% extends "base.twig" %}
 
 {% block preload %}
-<link rel="stylesheet" type="text/css" href="{{ baseurlpath }}assets/css/consent.css" />
+<link rel="stylesheet" href="/{{ baseurlpath }}module.php/consent/assets/css/consent.css">
 {% endblock %}
 
 {% block content %}
diff --git a/modules/consentAdmin/templates/consentadmin.twig b/modules/consentAdmin/templates/consentadmin.twig
index d27b8a63d..aa1e81ff4 100644
--- a/modules/consentAdmin/templates/consentadmin.twig
+++ b/modules/consentAdmin/templates/consentadmin.twig
@@ -2,11 +2,11 @@
 {% extends "base.twig" %}
 
 {% block preload %}
-<link rel="stylesheet" type="text/css" href="{{ basepathurl }}assets/css/consentAdmin.css" />
+<link rel="stylesheet" href="/{{ baseurlpath }}module.php/consentAdmin/assets/css/consentAdmin.css">
 {% endblock %}
 
 {% block postload %}
-<script src="{{ baseurlpath }}assets/js/consentAdmin.js"></script>
+<script src="/{{ baseurlpath }}module.php/consentAdmin/assets/js/consentAdmin.js"></script>
 {% endblock %}
 
 {% block content %}
@@ -77,6 +77,6 @@
 <p>{{ '{consentAdmin:consentadmin:consentadmin_description2}'|trans|raw }}</p>
 
 <h2>Logout</h2>
-<p><a href="{{ baseurlpath }}consentAdmin.php?logout=1">Logout</a></p>
+<p><a href="/{{ baseurlpath }}module.php/consentAdmin/consentAdmin.php?logout=1">Logout</a></p>
 
 {% endblock %}
diff --git a/modules/cron/templates/croninfo.twig b/modules/cron/templates/croninfo.twig
index b00b8905b..d2ea32988 100644
--- a/modules/cron/templates/croninfo.twig
+++ b/modules/cron/templates/croninfo.twig
@@ -2,7 +2,7 @@
 {% extends "base.twig" %}
 
 {% block preload %}
-<link rel="stylesheet" type="text/css" href="{{ baseurlpath }}assets/css/cron.css">
+<link rel="stylesheet" href="/{{ baseurlpath }}module.php/cron/assets/css/cron.css">
 {% endblock %}
 
 {% block content %}
diff --git a/modules/discopower/templates/disco.twig b/modules/discopower/templates/disco.twig
index 5fd06df1b..bd7248393 100644
--- a/modules/discopower/templates/disco.twig
+++ b/modules/discopower/templates/disco.twig
@@ -2,14 +2,13 @@
 {% extends "base.twig" %}
 
 {% block preload %}
-    <link href="{{ baseurlpath }}style.css" rel="stylesheet" type="text/css" media="screen" />
-    <link rel="stylesheet" media="screen" type="text/css" href="/resources/uitheme1.8/jquery-ui.css" />
+    <link rel="stylesheet" media="screen" href="/{{ baseurlpath }}resources/uitheme1.8/jquery-ui.css">
 {% endblock %}
 {% block postload %}
-    <script type="text/javascript" src="/resources/jquery-1.8.js"></script>
-    <script type="text/javascript" src="/resources/jquery-ui-1.8.js"></script>
-    <script type="text/javascript" src="{{ baseurlpath }}js/jquery.livesearch.js"></script>
-    <script type="text/javascript" src="{{ baseurlpath }}js/{{ score }}.js"></script>
+    <script src="/{{ baseurlpath }}resources/jquery-1.8.js"></script>
+    <script src="/{{ baseurlpath }}resources/jquery-ui-1.8.js"></script>
+    <script src="/{{ baseurlpath }}module.php/discopower/js/jquery.livesearch.js"></script>
+    <script src="/{{ baseurlpath }}module.php/discopower/js/{{ score }}.js"></script>
     {{ search|raw }}
 {% endblock %}
 
diff --git a/modules/memcacheMonitor/templates/memcachestat.twig b/modules/memcacheMonitor/templates/memcachestat.twig
index fdc4af4bd..f14848515 100644
--- a/modules/memcacheMonitor/templates/memcachestat.twig
+++ b/modules/memcacheMonitor/templates/memcachestat.twig
@@ -2,7 +2,7 @@
 {% extends "base.twig" %}
 
 {% block preload %}
-    <link href="{{ baseurlpath }}assets/css/memcacheMonitor.css" rel="stylesheet" />
+    <link href="/{{ baseurlpath }}module.php/memcacheMonitor/assets/css/memcacheMonitor.css" rel="stylesheet">
 {% endblock %}
 
 {% block content %}
diff --git a/modules/negotiate/templates/redirect.twig b/modules/negotiate/templates/redirect.twig
index 3a69556ee..f8162a401 100644
--- a/modules/negotiate/templates/redirect.twig
+++ b/modules/negotiate/templates/redirect.twig
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML>
 <html lang="en-US">
     <head>
-        <script src="{{ baseurlpath }}/assets/js/redirect.js"></script>
+        <script src="/{{ baseurlpath }}modules.php/negotiate/assets/js/redirect.js"></script>
         <title>Redirect to login</title>
     </head>
     <body>
diff --git a/modules/statistics/templates/statistics.twig b/modules/statistics/templates/statistics.twig
index bcd02a049..fa6559e3a 100644
--- a/modules/statistics/templates/statistics.twig
+++ b/modules/statistics/templates/statistics.twig
@@ -2,14 +2,14 @@
 {% extends "base.twig" %}
 
 {% block preload %}
-    <link href="{{ baseurlpath }}assets/css/statistics.css" rel="stylesheet" />
-    <link rel="stylesheet" media="screen" type="text/css" href="/resources/uitheme1.8/jquery-ui.css" />
+    <link href="/{{ baseurlpath }}module.php/statistics/assets/css/statistics.css" rel="stylesheet">
+    <link rel="stylesheet" media="screen" href="/{{ baseurlpath }}resources/uitheme1.8/jquery-ui.css">
 {% endblock %}
 
 {% block postload %}
-<script type="text/javascript" src="/resources/jquery-1.8.js"></script>
-<script type="text/javascript" src="/resources/jquery-ui-1.8.js"></script>
-<script type="text/javascript" src="{{ baseurlpath }}assets/js/statistics.js"></script>
+<script src="/{{ baseurlpath }}resources/jquery-1.8.js"></script>
+<script src="/{{ baseurlpath }}resources/jquery-ui-1.8.js"></script>
+<script src="/{{ baseurlpath }}module.php/statistics/assets/js/statistics.js"></script>
 {% endblock %}
 
 {% block content %}
diff --git a/modules/statistics/templates/statmeta.twig b/modules/statistics/templates/statmeta.twig
index 09808e837..314a21b51 100644
--- a/modules/statistics/templates/statmeta.twig
+++ b/modules/statistics/templates/statmeta.twig
@@ -2,7 +2,7 @@
 {% extends "base.twig" %}
 
 {% block preload %}
-    <link href="{{ baseurlpath }}assets/css/statistics.css" rel="stylesheet" />
+    <link href="/{{ baseurlpath }}modules.php/statistics/assets/css/statistics.css" rel="stylesheet">
 {% endblock %}
 
 {% block content %}
@@ -35,5 +35,5 @@
         <tr><td>No metadata found</td></tr>
     {% endif %}
     </table>
-    <p>[ <a href="{{ baseurlpath }}showstats.php">Show statistics</a> ]</p>
+    <p>[ <a href="/{{ baseurlpath }}module.php/statistics/showstats.php">Show statistics</a> ]</p>
 {% endblock %}
diff --git a/templates/base.twig b/templates/base.twig
index 29228797c..e33257b76 100644
--- a/templates/base.twig
+++ b/templates/base.twig
@@ -4,11 +4,11 @@
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     <meta name="viewport" content="initial-scale=1.0">
     <title>{{ pagetitle }}</title>
-    <link rel="stylesheet" type="text/css" href="{{ asset("css/stylesheet.css") }}">
-    <link rel="icon" type="image/icon" href="/{{ baseurlpath }}resources/icons/favicon.ico">
+    <link rel="stylesheet" href="{{ asset("css/stylesheet.css") }}">
+    <link rel="icon" href="/{{ baseurlpath }}resources/icons/favicon.ico">
     {% if isRTL %}
 
-    <link rel="stylesheet" type="text/css" href="/{{ baseurlpath }}assets/css/src/default-rtl.css" />
+    <link rel="stylesheet" href="{{ asset("assets/css/src/default-rtl.css") }}">
     {% endif %}
 
     <meta name="robots" content="noindex, nofollow">
-- 
GitLab