[1/3] Help for GUI - ipfire theme code

Message ID 20200515213952.15127-2-ipfr@tfitzgeorge.me.uk
State New
Headers show
Series
  • Help for GUI
Related show

Commit Message

Tim FitzGeorge May 15, 2020, 9:39 p.m. UTC
Extracts help key from menu hash when building menus and adds help
link to the menu.

Signed-off-by: Tim FitzGeorge <ipfr@tfitzgeorge.me.uk>
---
 html/html/themes/ipfire/include/functions.pl | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

Patch

diff --git a/html/html/themes/ipfire/include/functions.pl b/html/html/themes/ipfire/include/functions.pl
index 9aec77497..6eb56c628 100644
--- a/html/html/themes/ipfire/include/functions.pl
+++ b/html/html/themes/ipfire/include/functions.pl
@@ -39,6 +39,8 @@  require "${General::swroot}/lang.pl";
 # @param submenu entries
 sub showsubmenu() {
 	my $submenus = shift;
+	my $uri = shift;
+	my $help;
 	
 	print "<ul>";
 	foreach my $item (sort keys %$submenus) {
@@ -54,16 +56,26 @@  sub showsubmenu() {
 		}
 		print '<a href="'.$link.'">'.$submenus->{$item}->{'caption'}.'</a>';
 
+		if (exists $submenus->{$item}->{'help'} and $link eq $uri) {
+			$help = $submenus->{$item}->{'help'};
+		}
+
 		&showsubmenu($subsubmenus) if ($subsubmenus);
 		print '</li>';
 	}
-	print "</ul>"
+	print "</ul>";
+
+	return $help;
 }
 
 ###############################################################################
 #
 # print menu html elements
 sub showmenu() {
+  $uri = shift;
+  my $help = '';
+  my $subhelp;
+
 	print '<div id="cssmenu" class="bigbox fixed">';
 
 	if ($settings{'SPEED'} ne 'off') {
@@ -82,10 +94,11 @@  EOF
 		next if (!is_menu_visible($link) or $link eq '');
 		print '<li class="has-sub "><a href="#"><span>'.$menu->{$k1}->{'caption'}.'</span></a>';
 		my $submenus = $menu->{$k1}->{'subMenu'};
-		&showsubmenu($submenus) if ($submenus);
+		$help .= &showsubmenu($submenus, $uri) if ($submenus);
 		print "</li>";
 	}
 
+	print '<li><a href="https://wiki.ipfire.org/'.$help.'" target="ipfire" class="help">?</a></li>' if ($help);
 	print "</ul></div>";
 }
 
@@ -168,7 +181,7 @@  print <<END
 END
 ;
 
-&showmenu() if ($suppressMenu != 1);
+&showmenu( $URI[0] ) if ($suppressMenu != 1);
 
 print <<END
 	<div class="bigbox fixed">