#!/usr/local/bin/perl
#theme_prebody - called just before the main body of every page, so it can print any HTML it likes.
#theme_postbody - called just after the main body of every page.
#theme_header - called instead of the normal header function, with the same parameters. You could use this to re-write the header function in your own style with help and index links wherever you want them.
#theme_footer - called instead of the footer function with the same parameters.
#theme_error - called instead of the error function, with the same parameters.
sub theme_header {
local @available = ("webmin", "system", "servers", "cluster", "hardware", "", "net", "kororaweb");
local($ll, %access);
print "\n";
print "\n";
if ($charset) {
print "\n";
}
local $os_type = $gconfig{'real_os_type'} ? $gconfig{'real_os_type'}
: $gconfig{'os_type'};
local $os_version = $gconfig{'real_os_version'} ? $gconfig{'real_os_version'}
: $gconfig{'os_version'};
print "
\n";
if (@_ > 0) {
if ($gconfig{'sysinfo'} == 1) {
printf "%s : %s on %s (%s %s)\n",
$_[0], $remote_user, &get_display_hostname(),
$os_type, $os_version;
}
elsif ($gconfig{'sysinfo'} == 4) {
printf "%s on %s (%s %s)\n",
$remote_user, &get_display_hostname(),
$os_type, $os_version;
}
else {
print "$_[0]\n";
}
print $_[7] if ($_[7]);
if ($gconfig{'sysinfo'} == 0 && $remote_user) {
print "\n";
}
}
@msc_modules = &get_visible_module_infos()
if (!scalar(@msc_modules));
print '';
if ($remote_user && @_ > 1) {
# Show basic header with webmin.com link and logout button
local $logout = $main::session_id ? "/session_login.cgi?logout=1"
: "/switch_user.cgi";
print qq~~;
}
local $one = @msc_modules == 1 && $gconfig{'gotoone'};
if (@_ > 1 && !$one && $remote_user) {
# Display module categories
print qq~~;
&read_file("$config_directory/webmin.catnames", \%catnames);
foreach $m (@msc_modules) {
$c = $m->{'category'};
next if ($cats{$c});
if (defined($catnames{$c})) {
$cats{$c} = $catnames{$c};
}
elsif ($text{"category_$c"}) {
$cats{$c} = $text{"category_$c"};
}
else {
# try to get category name from module ..
local %mtext = &load_language($m->{'dir'});
if ($mtext{"category_$c"}) {
$cats{$c} = $mtext{"category_$c"};
}
else {
$c = $m->{'category'} = "";
$cats{$c} = $text{"category_$c"};
}
}
}
@cats = sort { $b cmp $a } keys %cats;
$cats = @cats;
$per = $cats ? 100.0 / $cats : 100;
if (!defined($in{'cat'})) {
# Use default category
if (defined($gconfig{'deftab'}) &&
&indexof($gconfig{'deftab'}, @cats) >= 0) {
$in{'cat'} = $gconfig{'deftab'};
}
else {
$in{'cat'} = $cats[0];
}
}
elsif (!$cats{$in{'cat'}}) {
$in{'cat'} = "";
}
#####Navigation Bar START#####
print qq~
~;
foreach $c (@cats) {
$t = $cats{$c};
$inlist = "false";
foreach $testet (@available) {
if ($testet eq $c) {
$inlist = "true";
}
}
if ($in{'cat'} eq $c) {
if ($inlist eq "true") {
if ($c eq "") {
print qq~ ~;
} elsif ($c eq "webmin") {
if (@_ > 1) {
print qq~ ~;
} else {
print qq~ ~;
}
} else {
print qq~ ~;
}
} else {
print qq~ ~;
}
}
else {
if ($inlist eq "true") {
if ($c eq "") {
print qq~ ~;
} else {
print qq~ ~;
}
} else {
print qq~ ~;
}
}
}
print qq~
|
~;
print qq~
 |
~;
}
if (@_ > 1 && (!$_[5] || $ENV{'HTTP_WEBMIN_SERVERS'})) {
# Show tabs under module categories
print '';
if ($ENV{'HTTP_WEBMIN_SERVERS'}) {
&tab_start();
print "",
"$text{'header_servers'} \n";
&tab_end();
}
if (!$_[4]) { &tab_start; print "",
"$text{'header_module'}"; &tab_end;}
if (ref($_[2]) eq "ARRAY") {
&tab_start; print &hlink($text{'header_help'}, $_[2]->[0], $_[2]->[1]); &tab_end;
}
elsif (defined($_[2])) {
&tab_start;
print &hlink($text{'header_help'}, $_[2]);
&tab_end;
}
if ($_[3]) {
local %access = &get_module_acl();
if (!$access{'noconfig'}) {
&tab_start; print "",
$text{'header_config'},""; &tab_end;
}
}
foreach $t (split(/ /, $_[6])) {
if ($t =~ /\S/) {
&tab_start; print $t; &tab_end;
}
}
print " |
";
if (!$_[5]) {
# Show page title in tab
local $title = $_[0];
$title =~ s/ä/ä/g;
$title =~ s/ö/ö/g;
$title =~ s/ü/ü/g;
$title =~ s/ / /g;
# print "\n";
$usercol = defined($gconfig{'cs_header'}) ||
defined($gconfig{'cs_table'}) ||
defined($gconfig{'cs_page'});
# print "",
# " "," | \n";
# print " $title | \n";
# print "",
# " "," | \n";
# print "
|
";
print "$title";
&make_sep;
&theme_prebody;
}
}
@header_arguments = @_;
}
sub theme_prebody
{
print "| \n";
}
sub theme_postbody
{
print " |
\n" if (@header_arguments > 1 && !$header_arguments[5]);
}
sub theme_footer {
local $i;
print "
\n"
if (@header_arguments > 1 && !$header_arguments[5]);
print "\n";
for($i=0; $i+1<@_; $i+=2) {
local $url = $_[$i];
if ($url eq '/') {
$url = "/?cat=$module_info{'category'}";
}
elsif ($url eq '' && $module_name) {
$url = "/$module_name/";
}
elsif ($url =~ /^\?/ && $module_name) {
$url = "/$module_name/$url";
}
if ($i == 0) {
print " \n";
}
else {
print " |\n";
}
print " ",&text('main_return', $_[$i+1]),"\n";
}
print " |
\n";
print "
\n";
if (!$_[$i]) {
local $postbody = $tconfig{'postbody'};
if ($postbody) {
local $hostname = &get_display_hostname();
local $version = &get_webmin_version();
local $os_type = $gconfig{'real_os_type'} ?
$gconfig{'real_os_type'} : $gconfig{'os_type'};
local $os_version = $gconfig{'real_os_version'} ?
$gconfig{'real_os_version'} : $gconfig{'os_version'};
$postbody =~ s/%HOSTNAME%/$hostname/g;
$postbody =~ s/%VERSION%/$version/g;
$postbody =~ s/%USER%/$remote_user/g;
$postbody =~ s/%OS%/$os_type $os_version/g;
print "$postbody\n";
}
if ($tconfig{'postbodyinclude'}) {
open(INC, $module_name ?
"../$gconfig{'theme'}/$tconfig{'postbodyinclude'}" :
"$gconfig{'theme'}/$tconfig{'postbodyinclude'}");
while() {
print;
}
close(INC);
}
if (defined(&theme_postbody)) {
&theme_postbody(@_);
}
print "\n";
}
}
#sub theme_error {
#print "error";
#}
sub chop_font {
if (!$lang->{'titles'} || $gconfig{'texttitles'}) {
print $t;
} else {
foreach $l (split(//, $t)) {
$ll = ord($l);
if ($ll > 127 && $lang->{'charset'}) {
print "
{'charset'}.gif alt=\"$l\" align=bottom border=0>";
}
elsif ($l eq " ") {
print "
";
}
else {
print "
";
}
}
}
}
sub tab_start {
print qq~
 |
~;
}
sub tab_end {
print qq~ |
 |
| ~;
}
1;
sub make_sep {
print qq~
~;
}