From 1d5eb7fa478e9152c39d3211f23d1e328a6ee62a Mon Sep 17 00:00:00 2001 From: Osma Suominen Date: Thu, 18 Apr 2024 12:38:40 +0300 Subject: [PATCH 01/14] pass whole GlobalConfig to Twig templates instead of individual config settings (cherry picked from commit 80a7c9e4b98cf95a0934d74e6fdbba554036591d) --- controller/WebController.php | 12 ++---------- view/about.twig | 2 +- view/light.twig | 6 +++--- view/topbar.twig | 4 ++-- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/controller/WebController.php b/controller/WebController.php index 8aa9df882..55e35bb92 100644 --- a/controller/WebController.php +++ b/controller/WebController.php @@ -41,17 +41,9 @@ public function __construct($model) $this->twig->addExtension(new Twig_Extensions_Extension_I18n()); // used for setting the base href for the relative urls $this->twig->addGlobal("BaseHref", $this->getBaseHref()); - // setting the service name string from the config.ttl - $this->twig->addGlobal("ServiceName", $this->model->getConfig()->getServiceName()); - // setting the service custom css file from the config.ttl - if ($this->model->getConfig()->getCustomCss() !== null) { - $this->twig->addGlobal("ServiceCustomCss", $this->model->getConfig()->getCustomCss()); - } - // used for displaying the ui language selection as a dropdown - if ($this->model->getConfig()->getUiLanguageDropdown() !== null) { - $this->twig->addGlobal("LanguageDropdown", $this->model->getConfig()->getUiLanguageDropdown()); - } + // pass the GlobalConfig object to templates so they can access configuration + $this->twig->addGlobal("GlobalConfig", $this->model->getConfig()); // setting the list of properties to be displayed in the search results $this->twig->addGlobal("PreferredProperties", array('skos:prefLabel', 'skos:narrower', 'skos:broader', 'skosmos:memberOf', 'skos:altLabel', 'skos:related')); diff --git a/view/about.twig b/view/about.twig index 8057e9989..63e29fbaf 100644 --- a/view/about.twig +++ b/view/about.twig @@ -12,7 +12,7 @@
-

{% if ServiceName != 'SERVICE_NAME' %}{{ ServiceName }}{% else %}Skosmos{% endif %} {% trans "layout designed by Hahmo" %}

+

{% if GlobalConfig.serviceName != 'SERVICE_NAME' %}{{ GlobalConfig.serviceName }}{% else %}Skosmos{% endif %} {% trans "layout designed by Hahmo" %}

{% set version = request.version %} diff --git a/view/light.twig b/view/light.twig index 18eb955fb..f11a2915b 100644 --- a/view/light.twig +++ b/view/light.twig @@ -12,12 +12,12 @@ -{% if ServiceCustomCss %} - +{% if GlobalConfig.customCss %} + {% endif %} {% for plugin, files in request.plugins.pluginsCSS %}{% for file in files %}{% endfor %}{% endfor %} -{{ ServiceName }}{% block title %}{% endblock %} +{{ GlobalConfig.serviceName }}{% block title %}{% endblock %}
-{% if LanguageDropdown %} +{% if GlobalConfig.uiLanguageDropdown %}