Add support for displaying theme config link if supported

[no-build]
This commit is contained in:
Ilia Ross
2025-11-06 21:03:50 +02:00
parent 4e4234c87e
commit 29d100e8eb
6 changed files with 65 additions and 15 deletions

View File

@@ -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) {

View File

@@ -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)."<br>" ],
@@ -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) {

View File

@@ -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'}<p>\n";
print &ui_form_start("change_theme.cgi");
print "<b>$text{'themes_sel'}</b>\n";
print "<b>$text{'themes_sel'}</b>&nbsp;&nbsp;\n";
print &ui_select("theme", $uconfig{'theme'},
[ !$uconfig{'theme'} ? [ '', $text{'themes_default'} ] : (),
map { [ $_->{'dir'}, &html_escape($_->{'desc'}) ] }
@themes ]),"<p>\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'}<p>\n";
print &ui_form_start("delete_mod.cgi");
print "<b>$text{'themes_delok'}</b>\n";
print "<b>$text{'themes_delok'}</b>&nbsp;&nbsp;\n";
print &ui_select("mod", undef,
[ map { [ $_->{'dir'}, &html_escape($_->{'desc'}) ] }
@delthemes ]),"<br>\n";

View File

@@ -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 <tt>.wbt</tt> 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.

View File

@@ -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'}<p>\n";
print &ui_form_start("change_theme.cgi");
print "<b>$text{'themes_sel'}</b>\n";
print "<b>$text{'themes_sel'}</b>&nbsp;&nbsp;\n";
print &ui_select("theme", $gtheme,
[ !$gtheme ? [ '', $text{'themes_default'} ] : (),
map { [ $_->{'dir'}, $_->{'desc'} ] } @themes ]),"<p>\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'}<p>\n";
print &ui_form_start("delete_mod.cgi");
print "<b>$text{'themes_delok'}</b>\n";
print "<b>$text{'themes_delok'}</b>&nbsp;&nbsp;\n";
print &ui_select("mod", undef,
[ map { [ $_->{'dir'}, $_->{'desc'} ] } @all ]),"<br>\n";
print &ui_form_end([ [ undef, $text{'delete'} ] ]);

View File

@@ -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 <tt>.wbt</tt> 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