From 135fa1be6b233313feff59ecb3716591f6787d86 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Fri, 19 Dec 2008 23:03:47 +0000 Subject: [PATCH] More CSS classes --- blue-theme/theme.pl | 295 +++++--------------------------------------- ui-lib.pl | 9 +- web-lib-funcs.pl | 4 +- 3 files changed, 36 insertions(+), 272 deletions(-) diff --git a/blue-theme/theme.pl b/blue-theme/theme.pl index 93f79e42a..11596fad1 100755 --- a/blue-theme/theme.pl +++ b/blue-theme/theme.pl @@ -46,7 +46,7 @@ my ($i, $need_tr); my $cols = $_[3] ? $_[3] : 4; my $per = int(100.0 / $cols); print "
\n"; -print "\n"; +print "
\n"; for($i=0; $i<@{$_[0]}; $i++) { if ($i%$cols == 0) { print "\n"; } print "
\n"; @@ -104,101 +104,6 @@ else { print "\n"; } -# theme_post_save_domains([domain, action]+) -# Called after multiple domains are updated, to refresh the left menu -sub theme_post_save_domains -{ -print "\n"; -} - -# Called by VM2 after a server is updated, to refresh the left menu -sub theme_post_save_server -{ -local ($s, $action) = @_; -if ($action eq 'create' || $action eq 'delete' || - !$done_theme_post_save_server++) { - print "\n"; - } -} - -# theme_select_server(&server) -# Called by VM2 when a page for a server is displayed, to select it on the -# left menu. -sub theme_select_server -{ -local ($server) = @_; -print < -if (window.parent && window.parent.frames[0]) { - var leftdoc = window.parent.frames[0].document; - var leftform = leftdoc.forms[0]; - if (leftform) { - var serversel = leftform['sid']; - if (serversel && serversel.value != '$server->{'id'}') { - // Need to change value - serversel.value = '$server->{'id'}'; - window.parent.frames[0].location = - '$gconfig{'webprefix'}/left.cgi?mode=vm2&sid=$server->{'id'}'; - } - } - } - -EOF -} - -# theme_select_domain(&server) -# Called by Virtualmin when a page for a server is displayed, to select it on -# the left menu. -sub theme_select_domain -{ -local ($server) = @_; -print < -if (window.parent && window.parent.frames[0]) { - var leftdoc = window.parent.frames[0].document; - var leftform = leftdoc.forms[0]; - if (leftform) { - var domsel = leftform['dom']; - if (domsel && domsel.value != '$d->{'id'}') { - // Need to change value - domsel.value = '$d->{'id'}'; - window.parent.frames[0].location = - '$gconfig{'webprefix'}/left.cgi?mode=virtualmin&dom=$d->{'id'}'; - } - } - } - -EOF -} - -# theme_post_save_folder(&folder, action) -# Called after some folder is changed, to refresh the left frame. The action -# may be 'create', 'delete', 'modify' or 'read' -sub theme_post_save_folder -{ -local ($folder, $action) = @_; -my $ref; -if ($action eq 'create' || $action eq 'delete' || $action eq 'modify') { - # Always refresh - $ref = 1; - } -else { - # Only refesh if showing unread count - if (defined(&should_show_unread) && &should_show_unread($folder)) { - $ref = 1; - } - } -if ($ref) { - print "\n"; - } -} - sub theme_post_change_modules { print <\n"; $main::ui_table_cols = $cols || 4; $main::ui_table_pos = 0; $main::ui_table_default_tds = $tds; @@ -328,7 +234,7 @@ $rv .= "\n"; # Output the tabs my $imgdir = "$gconfig{'webprefix'}/images"; $rv .= &ui_hidden($name, $sel)."\n"; -$rv .= "\n"; +$rv .= "
\n"; $rv .= "\n"; foreach my $t (@$tabs) { if ($t ne $tabs[0]) { # Spacer - $rv .= "\n"; } my $tabid = "tab_".$t->[0]; - $rv .= "
"; if ($ENV{'HTTP_USER_AGENT'} !~ /msie/i) { # For some reason, the 1-pixel space above the tabs appears huge on IE! @@ -340,11 +246,11 @@ $rv .= "". + $rv .= "". ""; + $rv .= ""; $rv .= ""; if ($t->[0] eq $sel) { # Selected tab @@ -376,7 +282,8 @@ $rv .= "
\n"; if ($border) { # All tabs are within a grey box - $rv .= "\n"; + $rv .= "
\n"; $rv .= "\n"; $rv .= "\n"; $rv .= "\n"; @@ -397,7 +304,7 @@ $theme_ui_columns_row_toggle = 0; if (!$noborder && !$WRAPPER_OPEN) { $rv .= "
\n"; + . "% class='ui_columns'>\n"; $rv .= "\n"; + $rv .= "". + "\n"; } -$rv .= "\n"; +$rv .= "\n"; my $i; for($i=0; $i<@$heads; $i++) { $rv .= "
\n"; } $WRAPPER_OPEN++; @@ -407,10 +314,11 @@ push(@classes, "sortable") if (!$href); $rv .= "\n"; if ($heading) { - $rv .= "
$heading
$heading
[$i].">". @@ -465,23 +373,25 @@ my $rv = "
\n"; -$rv .= "\n"; if ($title) { - $rv .= "\n"; + $rv .= " ". + "\n"; } $rv .= "\n"; my $i; for($i=0; $i<@$elements; $i++) { - $rv .= "" if ($i%$cols == 0); - $rv .= "\n"; + $rv .= "" if ($i%$cols == 0); + $rv .= "\n"; $rv .= "" if ($i%$cols == $cols-1); } if ($i%$cols) { while($i%$cols) { - $rv .= "\n"; + $rv .= "\n"; $i++; } $rv .= "\n"; @@ -556,7 +466,7 @@ sub theme_select_all_link local ($field, $form, $text) = @_; $form = int($form); $text ||= $text{'ui_selall'}; -return "$text"; +return "$text"; } # theme_select_invert_link(field, form, text) @@ -566,7 +476,7 @@ sub theme_select_invert_link local ($field, $form, $text) = @_; $form = int($form); $text ||= $text{'ui_selinv'}; -return "$text"; +return "$text"; } # theme_select_status_link(name, form, &folder, &mails, start, end, status, label) @@ -592,7 +502,7 @@ my $js = "var sel = [ ".join(",", @sel)." ]; "; $js .= "var f = document.forms[$formno]; "; $js .= "for(var i=0; i$label"; +return "$label"; } sub theme_select_rows_link @@ -602,7 +512,7 @@ $form = int($form); my $js = "var sel = { ".join(",", map { "\""."e_escape($_)."\":1" } @$rows)." }; "; $js .= "for(var i=0; i$text"; +return "$text"; } sub theme_ui_checked_columns_row @@ -617,9 +527,9 @@ my $mycb = $cb; if ($checked) { $mycb =~ s/mainbody/mainsel/g; } -$mycb =~ s/class='/class='row$theme_ui_columns_row_toggle /; +$mycb =~ s/class='/class='row$theme_ui_columns_row_toggle ui_checked_columns/; $rv .= "\n"; -$rv .= "\n"; my $i; @@ -651,8 +561,9 @@ if ($checked) { $mycb =~ s/mainbody/mainsel/g; } +$mycb =~ s/class='/class='ui_radio_columns /; $rv .= "\n"; -$rv .= "
$title
$title
[$i%$cols]." valign=top>".$elements->[$i]."
[$i%$cols]." valign=top class='ui_grid_cell'>". + $elements->[$i]."
[$i%$cols].">
[$i%$cols]." class='ui_grid_cell'>
[0].">". +$rv .= "[0]." class='ui_checked_checkbox'>". &ui_checkbox($checkname, $checkvalue, undef, $checked, "onClick=\"document.getElementById('$rid').className = this.checked ? 'mainhighsel' : 'mainhigh';\"", $disabled). "
[0].">". +$rv .= "[0]." class='ui_radio_radio'>". &ui_oneradio($checkname, $checkvalue, undef, $checked, "onClick=\"for(i=0; i\n"; my $i; @@ -744,154 +655,6 @@ if (!$_[$i]) { } } -$right_frame_sections_file = "$config_directory/$current_theme/sections"; - -# get_right_frame_sections() -# Returns a hash containg details of visible right-frame sections -sub get_right_frame_sections -{ -local %sects; -&read_file($right_frame_sections_file, \%sects); -if ($sects{'global'}) { - # Force use of global settings - return \%sects; - } -else { - # Can try personal settings, but fall back to global - local %usersects; - if (&read_file($right_frame_sections_file.".".$remote_user, - \%usersects)) { - return \%usersects; - } - else { - return \%sects; - } - } -} - -# save_right_frame_sections(§s) -sub save_right_frame_sections -{ -local ($sects) = @_; -&make_dir("$config_directory/$current_theme", 0700); -if ($sects->{'global'}) { - # Update global settings, for all users - &write_file($right_frame_sections_file, $sects); - } -else { - # Save own, and turn off global flag (if this is the master admin) - if (&foreign_check("virtual-server")) { - &foreign_require("virtual-server", "virtual-server-lib.pl"); - if (&virtual_server::master_admin()) { - local %globalsect; - &read_file($right_frame_sections_file, \%globalsect); - $globalsect{'global'} = 0; - &write_file($right_frame_sections_file, \%globalsect); - } - } - &write_file($right_frame_sections_file.".".$remote_user, $sects); - } -} - -# list_right_frame_sections() -# Returns a list of possible sections for the current user, as hash refs -sub list_right_frame_sections -{ -local ($hasvirt, $level, $hasvm2) = &get_virtualmin_user_level(); -local @rv; -if ($level == 0) { - # Master admin - @rv = ( 'system' ); - if ($hasvirt) { - push(@rv, 'updates', 'status', 'newfeatures', 'virtualmin', - 'quotas', 'bw', 'ips', 'sysinfo'); - } - if ($hasvm2) { - push(@rv, 'vm2servers'); - } - } -elsif ($level == 2) { - # Domain owner - push(@rv, 'virtualmin'); - } -elsif ($level == 1) { - # Reseller - push(@rv, 'reseller', 'quotas', 'bw'); - } -elsif ($level == 4) { - # VM2 system owner - push(@rv, 'owner', 'vm2servers'); - } -else { - # Usermin - push(@rv, 'system'); - } -@rv = map { { 'name' => $_, 'title' => $text{'right_'.$_.'header'} } } @rv; -# Add plugin-defined sections -if (($level == 0 || $level == 1 || $level == 2) && $hasvirt && - defined(&virtual_server::list_plugin_sections)) { - push(@rv, &virtual_server::list_plugin_sections($level)); - } -return @rv; -} - -# get_virtualmin_user_level() -# Returns three numbers - the first being a flag if virtualmin is installed, -# the second a user type (3=usermin, 2=domain, 1=reseller, 0=master, 4=system -# owner), the third a flag for VM2 -sub get_virtualmin_user_level -{ -local ($hasvirt, $hasvm2, $level); -$hasvm2 = &foreign_available("server-manager"); -$hasvirt = &foreign_available("virtual-server"); -if ($hasvm2) { - &foreign_require("server-manager", "server-manager-lib.pl"); - } -if ($hasvirt) { - &foreign_require("virtual-server", "virtual-server-lib.pl"); - } -if ($hasvm2) { - $level = $server_manager::access{'owner'} ? 4 : 0; - } -elsif ($hasvirt) { - $level = &virtual_server::master_admin() ? 0 : - &virtual_server::reseller_admin() ? 1 : 2; - } -elsif (&get_product_name() eq "usermin") { - $level = 3; - } -else { - $level = 0; - } -return ($hasvirt, $level, $hasvm2); -} - -# Don't show virtualmin menu -sub theme_redirect -{ -local ($orig, $url) = @_; -if ($module_name eq "virtual-server" && $orig eq "" && - $url =~ /^((http|https):\/\/([^\/]+))\//) { - $url = "$1/right.cgi"; - } -print "Location: $url\n\n"; -} - -sub get_virtualmin_docs -{ -local ($level) = @_; -return $level == 0 ? "http://www.virtualmin.com/documentation/id,virtualmin_administrators_guide/" : - $level == 1 ? "http://www.virtualmin.com/documentation/id,virtualmin_resellers_guide/" : - $level == 2 ? "http://www.virtualmin.com/documentation/id,virtualmin_virtual_server_owners_guide/" : - "http://www.virtualmin.com/documentation/"; -} - -sub get_vm2_docs -{ -local ($level) = @_; -return "http://www.virtualmin.com/documentation/id,vm2_manual/"; -} - # theme_ui_hidden_javascript() # Returns