From 29d100e8eb3150351e62fa60d1298a24f9a8cde2 Mon Sep 17 00:00:00 2001 From: Ilia Ross Date: Thu, 6 Nov 2025 21:03:50 +0200 Subject: [PATCH] Add support for displaying theme config link if supported [no-build] --- acl/edit_user.cgi | 15 ++++++++++++++- change-user/index.cgi | 16 ++++++++++++++-- usermin/edit_themes.cgi | 20 ++++++++++++++++---- usermin/lang/en | 4 ++-- webmin/edit_themes.cgi | 18 +++++++++++++++--- webmin/lang/en | 7 ++++--- 6 files changed, 65 insertions(+), 15 deletions(-) diff --git a/acl/edit_user.cgi b/acl/edit_user.cgi index d2b225c5e..c2871f2ce 100755 --- a/acl/edit_user.cgi +++ b/acl/edit_user.cgi @@ -238,6 +238,18 @@ my @themes = grep { !$_->{'overlay'} } @all; my @overlays = grep { $_->{'overlay'} } @all; if ($access{'theme'}) { + my $tconf_link; + my %tinfo = &webmin::get_theme_info($user{'theme'}); + if ($user{'theme'} && $user{'theme'} eq $tinfo{'dir'} && + $user{'name'} eq $remote_user && + $tinfo{'config_link'}) { + $tconf_link = &ui_tag('span', &ui_link( + "@{[&get_webprefix()]}/$tinfo{'config_link'}", + &ui_tag('span', '⚙', + { class => 'theme-config-char', + title => $text{'themes_configure'} }), + 'text-link'), { style => 'position: relative;' }); + } # Current theme my @topts = ( ); push(@topts, !$user{'theme'} ? [ '', $text{'edit_themedef'} ] : ()); @@ -247,7 +259,8 @@ if ($access{'theme'}) { print &ui_table_row($text{'edit_theme'}, &ui_radio("theme_def", defined($user{'theme'}) ? 0 : 1, [ [ 1, $text{'edit_themeglobal'} ], - [ 0, &ui_select("theme", $user{'theme'}, \@topts) ] ])); + [ 0, &ui_select("theme", $user{'theme'}, \@topts). + $tconf_link ] ])); } if ($access{'theme'} && @overlays) { diff --git a/change-user/index.cgi b/change-user/index.cgi index e514ecbf4..4d8deb75e 100755 --- a/change-user/index.cgi +++ b/change-user/index.cgi @@ -126,10 +126,11 @@ if ($access{'locale'}) { if ($access{'theme'}) { # Show personal theme + my %tinfo = (); my $tname; if ($gconfig{'theme'}) { my ($gtheme, $goverlay) = split(/\s+/, $gconfig{'theme'}); - my %tinfo = &webmin::get_theme_info($gtheme); + %tinfo = &webmin::get_theme_info($gtheme); $tname = $tinfo{'desc'}; } else { @@ -140,6 +141,16 @@ if ($access{'theme'}) { my @overlays = grep { $_->{'overlay'} } @all; # Main theme + my $tconf_link; + if ($user->{'theme'} && $user->{'theme'} eq $tinfo{'dir'} && + $tinfo{'config_link'}) { + $tconf_link = &ui_tag('span', &ui_link( + "@{[&get_webprefix()]}/$tinfo{'config_link'}", + &ui_tag('span', '⚙', + { class => 'theme-config-char', + title => $text{'themes_configure'} }), + 'text-link'), { style => 'position: relative;' }); + } print &ui_table_row($text{'index_theme'}, &ui_radio("theme_def", defined($user->{'theme'}) ? 0 : 1, [ [ 1, &text('index_themeglobal', $tname)."
" ], @@ -149,7 +160,8 @@ if ($access{'theme'}) { ? [ '', $text{'index_themedef'} ] : (), map { [ $_->{'dir'}, $_->{'desc'} ] } - @themes ]), undef, [ "valign=top","valign=top" ]); + @themes ]).$tconf_link, + undef, [ "valign=top","valign=top" ]); # Overlay, if any if (@overlays) { diff --git a/usermin/edit_themes.cgi b/usermin/edit_themes.cgi index 3775a0104..d0c50f32a 100755 --- a/usermin/edit_themes.cgi +++ b/usermin/edit_themes.cgi @@ -11,6 +11,10 @@ $access{'themes'} || &error($text{'acl_ecannot'}); @themes = &list_visible_themes($uconfig{'theme'}); $prog = "edit_themes.cgi?mode="; +($gtheme) = split(/\s+/, $gconfig{'theme'}); +$curr_theme_selected = $gconfig{"theme_$base_remote_user"} || $gtheme; +($curr_theme) = grep { $_->{'dir'} eq $curr_theme_selected } @themes; + # Start tabs if (@themes) { @tabs = ( [ "change", $text{'themes_tabchange'}, $prog."change" ] ); @@ -28,11 +32,19 @@ if (@themes) { print &ui_tabs_start_tab("mode", "change"); print "$text{'themes_desc'}

\n"; print &ui_form_start("change_theme.cgi"); - print "$text{'themes_sel'}\n"; + print "$text{'themes_sel'}  \n"; print &ui_select("theme", $uconfig{'theme'}, [ !$uconfig{'theme'} ? [ '', $text{'themes_default'} ] : (), - map { [ $_->{'dir'}, &html_escape($_->{'desc'}) ] } - @themes ]),"

\n"; + map { [ $_->{'dir'}, &html_escape($_->{'desc'}) ] } @themes ]); + if ($curr_theme->{'config_link'} && + $uconfig{'theme'} eq $curr_theme->{'dir'}) { + print &ui_link( + "@{[&get_webprefix()]}/$curr_theme->{'config_link'}", + &ui_tag('span', '⚙', + { class => 'theme-config-char', + title => $text{'themes_configure'} }), + 'text-link'); + } print &ui_form_end([ [ undef, $text{'themes_change'} ] ]); print &ui_tabs_end_tab("mode", "change"); } @@ -62,7 +74,7 @@ if (@delthemes) { print &ui_tabs_start_tab("mode", "delete"); print "$text{'themes_delete'}

\n"; print &ui_form_start("delete_mod.cgi"); - print "$text{'themes_delok'}\n"; + print "$text{'themes_delok'}  \n"; print &ui_select("mod", undef, [ map { [ $_->{'dir'}, &html_escape($_->{'desc'}) ] } @delthemes ]),"
\n"; diff --git a/usermin/lang/en b/usermin/lang/en index e725a3412..96fee368d 100644 --- a/usermin/lang/en +++ b/usermin/lang/en @@ -83,7 +83,7 @@ session_forgot=Allow forgotten password recovery? themes_title=Usermin Themes themes_desc=Themes control the appearance of the Usermin user interface, including icons, colours, backgrounds and possibly the layout of pages. The selection box below can be used to choose one of the themes installed on your system that will be the default for Usermin users. -themes_sel=Current theme : +themes_sel=Current theme themes_default=Legacy Theme themes_change=Change themes_installdesc=Use the form below to install a new Usermin theme on your system. Themes are typically distributed in .wbt files, but can also be installed from RPM files if supported by your operating system. @@ -108,7 +108,7 @@ themes_erpm=Not a Usermin theme RPM themes_eirpm=RPM install failed : $1 themes_ok=Theme changed successfully .. redirecting to the Webmin index page. themes_delete=This form can be used to delete one of the themes installed on your system that is not currently in use. -themes_delok=Theme to delete : +themes_delok=Theme to delete themes_desc4=Installed themes can be exported as a wbt.gz file using the form below. A theme file can then be installed onto another system running Usermin. diff --git a/webmin/edit_themes.cgi b/webmin/edit_themes.cgi index 08524c494..0919030fb 100755 --- a/webmin/edit_themes.cgi +++ b/webmin/edit_themes.cgi @@ -12,6 +12,9 @@ require './webmin-lib.pl'; @overlays = grep { $_->{'overlay'} } @all; $prog = "edit_themes.cgi?mode="; +$curr_theme_selected = $gconfig{"theme_$base_remote_user"} || $gtheme; +($curr_theme) = grep { $_->{'dir'} eq $curr_theme_selected } @themes; + # Start tabs if (@themes) { @tabs = ( [ "change", $text{'themes_tabchange'}, $prog."change" ] ); @@ -35,10 +38,19 @@ if (@themes) { print &ui_tabs_start_tab("mode", "change"); print "$text{'themes_desc'}

\n"; print &ui_form_start("change_theme.cgi"); - print "$text{'themes_sel'}\n"; + print "$text{'themes_sel'}  \n"; print &ui_select("theme", $gtheme, [ !$gtheme ? [ '', $text{'themes_default'} ] : (), - map { [ $_->{'dir'}, $_->{'desc'} ] } @themes ]),"

\n"; + map { [ $_->{'dir'}, $_->{'desc'} ] } @themes ]); + if ($curr_theme->{'config_link'} && + $gtheme eq $curr_theme->{'dir'}) { + print &ui_link( + "@{[&get_webprefix()]}/$curr_theme->{'config_link'}", + &ui_tag('span', '⚙', + { class => 'theme-config-char', + title => $text{'themes_configure'} }), + 'text-link'); + } print &ui_form_end([ [ undef, $text{'themes_change'} ] ]); print &ui_tabs_end_tab("mode", "change"); } @@ -82,7 +94,7 @@ if (!&shared_root_directory() && @all) { print &ui_tabs_start_tab("mode", "delete"); print "$text{'themes_delete'}

\n"; print &ui_form_start("delete_mod.cgi"); - print "$text{'themes_delok'}\n"; + print "$text{'themes_delok'}  \n"; print &ui_select("mod", undef, [ map { [ $_->{'dir'}, $_->{'desc'} ] } @all ]),"
\n"; print &ui_form_end([ [ undef, $text{'delete'} ] ]); diff --git a/webmin/lang/en b/webmin/lang/en index 7e98cc203..27cac98f2 100644 --- a/webmin/lang/en +++ b/webmin/lang/en @@ -752,12 +752,13 @@ log_letsencryptcleanup=Removed Let's Encrypt DNS record for $1 themes_title=Webmin Themes themes_desc=Themes control the appearance of the Webmin user interface, including icons, colours, backgrounds and the layout of pages. The selection box below can be used to choose one of the themes installed on your system. -themes_sel=Current theme : +themes_sel=Current theme +themes_configure=Open theme configuration page themes_default=Legacy Theme themes_none=None - let theme decide themes_change=Change themes_overdesc=Overlays modify the appearance of a theme, by changing the colors, backgrounds and icons. They do not change the layout. -themes_overlay=Current overlay : +themes_overlay=Current overlay themes_installdesc=Use the form below to install a new Webmin theme on your system. Themes are typically distributed in .wbt files, but can also be installed from RPM files if supported by your operating system. themes_installok=Install Theme themes_tabchange=Change theme @@ -787,7 +788,7 @@ themes_eirpm=RPM install failed : $1 themes_ok=Theme changed successfully—redirecting now .. themes_ok2=Theme overlay changed successfully—redirecting now .. themes_delete=This form can be used to delete one of the themes installed on your system that is not currently in use. -themes_delok=Theme to delete : +themes_delok=Theme to delete themes_return=themes list themes_err4=Failed to change overlay theme themes_eoverlay=Selected overlay is not compatible with the current global theme