mirror of
https://github.com/webmin/webmin.git
synced 2026-10-28 14:11:03 +00:00
This PR adds a "Page layout" setting to the Framed Theme, with a new single page layout that shows the menu on every page instead of in a frame. It's meant for people who can't or don't want to use frames, so the Legacy Theme is no longer the only option without frames. The menu code moved out of `left.cgi` into a shared menu-lib.pl, so both layouts build the same menu, frames look the same as before, and `left.cgi` shrinks from about 400 lines to about 60. The menu's module search box now follows the global "webminsearch" permission, which the old frame code never actually checked. One exception to be aware of. A server opened through Webmin Servers Index always uses frames, because that index only rewrites the links and redirects of framed pages.
152 lines
4.5 KiB
Perl
Executable File
152 lines
4.5 KiB
Perl
Executable File
#!/usr/local/bin/perl
|
|
|
|
require "gray-theme/gray-theme-lib.pl";
|
|
require "gray-theme/theme.pl";
|
|
&ReadParse();
|
|
|
|
# Work out which module to open by default
|
|
$hasvirt = &foreign_available("virtual-server");
|
|
$hasvm2 = &foreign_available("server-manager");
|
|
if ($in{'dom'} && $hasvirt) {
|
|
# Caller has requested a specific domain ..
|
|
&foreign_require("virtual-server", "virtual-server-lib.pl");
|
|
$d = &virtual_server::get_domain($in{'dom'});
|
|
if ($d) {
|
|
$goto = &virtual_server::can_config_domain($d) ?
|
|
"virtual-server/edit_domain.cgi?dom=$d->{'id'}" :
|
|
"virtual-server/view_domain.cgi?dom=$d->{'id'}";
|
|
$left = "left.cgi?dom=$d->{'id'}";
|
|
}
|
|
}
|
|
if (!$goto) {
|
|
# Default is determined by theme or Webmin config,
|
|
# defaults to system info page
|
|
local $sects = &get_right_frame_sections();
|
|
$minfo = &get_goto_module();
|
|
if ($sects->{'list'} == 1 && $hasvirt) {
|
|
$goto = "virtual-server/";
|
|
}
|
|
elsif ($sects->{'list'} == 2 && $hasvm2) {
|
|
$goto = "server-manager/";
|
|
}
|
|
elsif ($minfo &&
|
|
$minfo->{'dir'} ne 'virtual-server' &&
|
|
$minfo->{'dir'} ne 'server-manager') {
|
|
$goto = "$minfo->{'dir'}/";
|
|
}
|
|
else {
|
|
$goto = "right.cgi".
|
|
"?open=system&auto=status&open=updates&".
|
|
"open=common&open=owner&open=reseller&open=vm2limits&".
|
|
"open=vm2usage";
|
|
}
|
|
$left = "left.cgi";
|
|
if ($minfo) {
|
|
$left .= "?$minfo->{'category'}=1";
|
|
}
|
|
}
|
|
|
|
if (&theme_single_page()) {
|
|
# The single page layout has no frameset, so the first page opens by
|
|
# itself and brings its own menu
|
|
&theme_local_redirect("/$goto");
|
|
exit;
|
|
}
|
|
|
|
# Work out the title that includes the version
|
|
if ($hasvirt) {
|
|
%minfo = &get_module_info("virtual-server");
|
|
$title = &text('index_virtualmintitle', $minfo{'version'});
|
|
}
|
|
elsif ($hasvm2) {
|
|
%minfo = &get_module_info("server-manager");
|
|
$title = &text('index_cloudmintitle', $minfo{'version'});
|
|
}
|
|
elsif (&get_product_name() eq 'usermin') {
|
|
$title = &text('index_usermintitle', &get_webmin_version());
|
|
}
|
|
else {
|
|
$title = &text('index_webmintitle', &get_webmin_version());
|
|
}
|
|
$title = &get_html_title($title);
|
|
|
|
# Work out if we have a top frame
|
|
if ($hasvirt) {
|
|
%vconfig = &foreign_config("virtual-server");
|
|
}
|
|
$upperframe = $vconfig{'theme_topframe'} ||
|
|
$gconfig{'theme_topframe'};
|
|
$upperrows = $vconfig{'theme_toprows'} ||
|
|
$gconfig{'theme_toprows'} || 200;
|
|
if ($upperframe =~ /\$LEVEL|\$\{LEVEL/) {
|
|
# Sub in user level
|
|
$levelnum = &get_virtualmin_user_level();
|
|
$level = $levelnum == 0 ? "master" :
|
|
$levelnum == 1 ? "reseller" :
|
|
$levelnum == 2 ? "domain" :
|
|
$levelnum == 3 ? "usermin" :
|
|
$levelnum == 4 ? "owner" : "unknown";
|
|
$upperframe = &substitute_template($upperframe, { 'level' => $level });
|
|
}
|
|
|
|
# Show frameset
|
|
&PrintHeader();
|
|
$cols = &get_left_frame_width();
|
|
$frame1 = "<frame name=left title=Navigation src='$left' scrolling=auto>";
|
|
$frame2 = "<frame name=right title=Content src='$goto' noresize scrolling=auto>";
|
|
$fscols = "$cols,*";
|
|
if ($current_lang_info->{'rtl'} || $current_lang eq "ar") {
|
|
($frame1, $frame2) = ($frame2, $frame1);
|
|
$fscols = "*,$cols";
|
|
}
|
|
|
|
# Page head. The frameset declares the same color scheme as its frames,
|
|
# since browsers give a frame the scheme of the page holding it. When no
|
|
# scheme is forced, the script keeps it steady across reloads. The
|
|
# stylesheet paints the page ground behind a frame that is still loading.
|
|
$scheme = &theme_color_scheme();
|
|
print "<html".($scheme ? " data-scheme='$scheme'" : "").">\n";
|
|
print "<head>\n";
|
|
print "<meta name='color-scheme' content='".($scheme || "light dark")."'>\n";
|
|
print &theme_scheme_script() if (!$scheme);
|
|
print "<link rel='stylesheet' type='text/css' href='".&get_webprefix().
|
|
"/unauthenticated/gray-theme.css?".
|
|
&theme_asset_key("gray-theme.css")."'>\n";
|
|
print &ui_switch_theme_javascript();
|
|
print "<title>$title</title>\n";
|
|
print &theme_favicons();
|
|
print "</head>\n";
|
|
|
|
# Upper custom frame
|
|
if ($upperframe) {
|
|
print "<frameset rows='$upperrows,*' border=0>\n";
|
|
if ($upperframe =~ /^\//) {
|
|
# Local file to serve
|
|
print "<frame name=top src='top.cgi' scrolling=auto>\n";
|
|
}
|
|
else {
|
|
# Absolute URL
|
|
print "<frame name=top src='$upperframe' scrolling=auto>\n";
|
|
}
|
|
}
|
|
|
|
# Left and right frames
|
|
print "<frameset cols='$fscols' border=0>\n";
|
|
print $frame1,"\n";
|
|
print $frame2,"\n";
|
|
|
|
# What if no frames?
|
|
print "<noframes>\n";
|
|
print "<body>\n";
|
|
print "<p>This page uses frames, but your browser doesn't support them.</p>\n";
|
|
print "</body>\n";
|
|
print "</noframes>\n";
|
|
|
|
# End of the frames and page
|
|
if ($upperframe) {
|
|
print "</frameset>\n";
|
|
}
|
|
print "</frameset>\n";
|
|
print "</html>\n";
|
|
|