From 260b6ac6ea08dc3bf973580ab41ecea61635890f Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Mon, 29 Apr 2024 12:01:39 +0000
Subject: [PATCH] fixes #4090

Closes #4090

Merge request studip/studip!2934
---
 lib/classes/PageLayout.php      | 24 +++++++++++++++++++++++-
 lib/classes/helpbar/Helpbar.php |  3 ++-
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/lib/classes/PageLayout.php b/lib/classes/PageLayout.php
index fca69b5ad92..4eb422c047a 100644
--- a/lib/classes/PageLayout.php
+++ b/lib/classes/PageLayout.php
@@ -35,6 +35,11 @@ class PageLayout
      */
     private static $help_keyword;
 
+    /**
+     * current help URL (or null if unset)
+     */
+    private static ?string $help_url = null;
+
     /**
      * base item path for tab view (defaults to active item in top nav)
      */
@@ -179,7 +184,24 @@ class PageLayout
      */
     public static function getHelpKeyword()
     {
-        return isset(self::$help_keyword) ? self::$help_keyword : 'Basis.Allgemeines';
+        return self::$help_keyword ?? 'Basis.Allgemeines';
+    }
+
+    /**
+     * Set the help URL in the help bar. Pass null to fall back to the help keyword.
+     */
+    public static function setHelpUrl(?string $url): void
+    {
+        self::$help_url = $url;
+    }
+
+    /**
+     * Get the current help URL. If no URL is set explicitely, the URL for
+     * the help keyword is used.
+     */
+    public static function getHelpUrl(): ?string
+    {
+        return self::$help_url ?? format_help_url(self::getHelpKeyword());
     }
 
     /**
diff --git a/lib/classes/helpbar/Helpbar.php b/lib/classes/helpbar/Helpbar.php
index cfa98a34b8f..cc2c6192b33 100644
--- a/lib/classes/helpbar/Helpbar.php
+++ b/lib/classes/helpbar/Helpbar.php
@@ -253,7 +253,8 @@ class Helpbar extends WidgetContainer
         // add wiki link and remove it from navigation
         $this->addLink(
             _('Weiterführende Hilfe'),
-            format_help_url(PageLayout::getHelpKeyword()), Icon::create('link-extern', 'info_alt'),
+            PageLayout::getHelpUrl(),
+            Icon::create('link-extern', Icon::ROLE_INFO_ALT),
             '_blank',
             ['rel' => 'noopener noreferrer']
         );
-- 
GitLab