# theme.pl # Override functions for the OSX theme # XXX always starts with 'other' category? # header(title, image, [help], [config], [nomodule], [nowebmin], [rightside], # [header], [body], [below]) sub theme_header { print "\n"; print "\n"; print $_[7]; print "$_[0]\n"; print "\n"; if ($charset) { print "\n"; } print "\n"; print "\n"; # Get all modules visible to this user @osx_modules = &get_available_module_infos() if (!scalar(@osx_modules)); # Show table of categories local $one = @osx_modules == 1 && $gconfig{'gotoone'}; local $notabs = $gconfig{"notabs_${base_remote_user}"} == 2 || $gconfig{"notabs_${base_remote_user}"} == 0 && $gconfig{'notabs'}; if (@_ > 1 && !$one && $remote_user && !$notabs) { local $logout; if (!$ENV{'ANONYMOUS_USER'} && !$ENV{'SSL_USER'} && !$ENV{'LOCAL_USER'} && !$ENV{'HTTP_WEBMIN_SERVERS'}) { if ($main::session_id) { $logout = &ui_link("/session_login.cgi?logout=1",$text{'main_logout'}); } else { $logout = &ui_link("/switch_user.cgi",$text{'main_switch'}); } } &start_osx_table("Module Categories", $logout); local %catnames; &read_file("$config_directory/webmin.catnames", \%catnames); foreach $m (@osx_modules) { local $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; # Actually show category icons # XXX spacing? local (@icons, @titles, @links); foreach $c (@cats) { local $t = $cats{$c}; push(@titles, $t); push(@icons, -r "$root_directory/$current_theme/cats/$c.gif" ? "/$current_theme/cats/$c.gif" : "/$current_theme/cats/unknown.gif"); push(@links, "/?cat=$c"); } &icons_table(\@links, \@titles, \@icons, @links > 7 ? scalar(@links) : 7); &end_osx_table(); } if (@_ > 1) { # Open table for main page local @right; if ($ENV{'HTTP_WEBMIN_SERVERS'}) { push(@right, "". "$text{'header_servers'}"); } if (!$_[4]) { # Module index link local $idx = $module_info{'index_link'}; local $mi = $module_index_link || "/$module_name/$idx"; push(@right, "". "$text{'header_module'}"); } if (ref($_[2]) eq "ARRAY" && !$ENV{'ANONYMOUS_USER'}) { # Help link push(@right, &hlink($text{'header_help'}, $_[2]->[0], $_[2]->[1])); } elsif (defined($_[2]) && !$ENV{'ANONYMOUS_USER'}) { # Help link push(@right, &hlink($text{'header_help'}, $_[2])); } if ($_[3]) { local %access = &get_module_acl(); if (!$access{'noconfig'} && !$config{'noprefs'}) { local $cprog = $user_module_config_directory ? "uconfig.cgi" : "config.cgi"; push(@right, "$text{'header_config'}"); } } push(@right, split(/
/, $_[6])); &start_osx_table($_[0], join(" | ", @right)); if ($_[9]) { print "
", "$_[9]
\n"; } $started_osx_table++; } } sub theme_footer { if ($started_osx_table) { # Close table for main page &end_osx_table(); } # Show footer links print "\n"; print "\n"; } # start_osx_table(title, rightstuff, width) sub start_osx_table { local ($title, $right, $width) = @_; $width ||= 100; print <
  $title $right
EOF } sub end_osx_table { print <
EOF } sub theme_ui_post_header { local ($text) = @_; local $rv; if (defined($text)) { $rv .= "
$text

\n"; } return $rv; } sub theme_ui_pre_footer { return ""; } # Hack to prevent the display of
lines #package miniserv; #sub PRINT #{ #if ($_[1] !~ /^
(

|
)?\s*$/) { # $r = shift; # $$r++; # &write_to_sock(@_); # } #}