Made UI settings into preferences

This commit is contained in:
Jamie Cameron 2008-01-07 22:46:23 +00:00
parent 6152f14609
commit 0ee83b2d1e
4 changed files with 39 additions and 32 deletions

View File

@ -74,7 +74,7 @@ elsif (@titles || @indexes) {
( map { "!".$_ } @indexes ), ( map { "!".$_ } @indexes ),
( map { "*".$_ } @views ), ( map { "*".$_ } @views ),
); );
if ($config{'style'}) { if ($displayconfig{'style'}) {
foreach $t (@titles) { foreach $t (@titles) {
local $c = &execute_sql($in{'db'}, local $c = &execute_sql($in{'db'},
"select count(*) from ".quotestr($t)); "select count(*) from ".quotestr($t));

View File

@ -33,6 +33,7 @@ if ($module_info{'usermin'}) {
$max_dbs = $userconfig{'max_dbs'}; $max_dbs = $userconfig{'max_dbs'};
$commands_file = "$user_module_config_directory/commands"; $commands_file = "$user_module_config_directory/commands";
$sql_charset = $userconfig{'charset'}; $sql_charset = $userconfig{'charset'};
%displayconfig = %userconfig;
} }
else { else {
# Webmin connects to the database as the user specified in the per-user # Webmin connects to the database as the user specified in the per-user
@ -54,6 +55,7 @@ else {
$max_dbs = $config{'max_dbs'}; $max_dbs = $config{'max_dbs'};
$commands_file = "$module_config_directory/commands"; $commands_file = "$module_config_directory/commands";
$sql_charset = $config{'charset'}; $sql_charset = $config{'charset'};
%displayconfig = %config;
} }
$authstr = &make_authstr(); $authstr = &make_authstr();
$master_db = 'mysql'; $master_db = 'mysql';
@ -444,14 +446,14 @@ else {
# Outputs a table that is split into two parts # Outputs a table that is split into two parts
sub split_table sub split_table
{ {
local $mid = int((@{$_[1]}+1) / 2); local $mid = int((@{$_[2]}+1) / 2);
local ($i, $j); local ($i, $j);
print "<table width=100%><tr>\n"; print "<table width=100%><tr>\n";
foreach $s ([0, $mid-1], [$mid, @{$_[1]}-1]) { foreach $s ([0, $mid-1], [$mid, @{$_[2]}-1]) {
print "<td width=50% valign=top>\n"; print "<td width=50% valign=top>\n";
# Header # Header
local @tds = ( "width=5" ); local @tds = $_[1] ? ( "width=5" ) : ( );
if ($s->[0] <= $s->[1]) { if ($s->[0] <= $s->[1]) {
local @hcols; local @hcols;
foreach $t (@{$_[0]}) { foreach $t (@{$_[0]}) {
@ -466,7 +468,12 @@ foreach $s ([0, $mid-1], [$mid, @{$_[1]}-1]) {
for($j=4; $j<@_; $j++) { for($j=4; $j<@_; $j++) {
push(@cols, $_[$j]->[$i]); push(@cols, $_[$j]->[$i]);
} }
print &ui_checked_columns_row(\@cols, \@tds, "d", $_[1]->[$i]); if ($_[1]) {
print &ui_checked_columns_row(\@cols, \@tds, "d", $_[1]->[$i]);
}
else {
print &ui_columns_row(\@cols, \@tds);
}
} }
if ($s->[0] <= $s->[1]) { if ($s->[0] <= $s->[1]) {
print &ui_columns_end(); print &ui_columns_end();

View File

@ -51,10 +51,10 @@ sub get_search_limit
local %in = %{$_[0]}; local %in = %{$_[0]};
$in{'start'} ||= 0; $in{'start'} ||= 0;
if ($module_name eq "mysql") { if ($module_name eq "mysql") {
return "limit $in{'start'},$config{'perpage'}"; return "limit $in{'start'},$displayconfig{'perpage'}";
} }
else { else {
return "limit $config{'perpage'} offset $in{'start'}"; return "limit $displayconfig{'perpage'} offset $in{'start'}";
} }
} }

View File

@ -45,22 +45,22 @@ $d = &execute_sql_safe($in{'db'},
"select count(*) from ".&quote_table($in{'table'})." ".$search); "select count(*) from ".&quote_table($in{'table'})." ".$search);
$total = int($d->{'data'}->[0]->[0]); $total = int($d->{'data'}->[0]->[0]);
if ($in{'jump'} > 0) { if ($in{'jump'} > 0) {
$in{'start'} = int($in{'jump'} / $config{'perpage'}) * $in{'start'} = int($in{'jump'} / $displayconfig{'perpage'}) *
$config{'perpage'}; $displayconfig{'perpage'};
if ($in{'start'} >= $total) { if ($in{'start'} >= $total) {
$in{'start'} = $total - $config{'perpage'}; $in{'start'} = $total - $displayconfig{'perpage'};
$in{'start'} = int(($in{'start'} / $config{'perpage'}) + 1) * $in{'start'} = int(($in{'start'} / $displayconfig{'perpage'}) + 1) *
$config{'perpage'}; $displayconfig{'perpage'};
} }
} }
else { else {
$in{'start'} = int($in{'start'}); $in{'start'} = int($in{'start'});
} }
if ($in{'new'} && $total > $config{'perpage'}) { if ($in{'new'} && $total > $displayconfig{'perpage'}) {
# go to the last screen for adding a row # go to the last screen for adding a row
$in{'start'} = $total - $config{'perpage'}; $in{'start'} = $total - $displayconfig{'perpage'};
$in{'start'} = int(($in{'start'} / $config{'perpage'}) + 1) * $in{'start'} = int(($in{'start'} / $displayconfig{'perpage'}) + 1) *
$config{'perpage'}; $displayconfig{'perpage'};
} }
# Get limiting and sorting SQL # Get limiting and sorting SQL
@ -114,7 +114,7 @@ elsif ($in{'save'}) {
$d = &execute_sql($in{'db'}, $where_select); $d = &execute_sql($in{'db'}, $where_select);
@t = map { $_->{'field'} } @str; @t = map { $_->{'field'} } @str;
$count = 0; $count = 0;
for($j=0; $j<$config{'perpage'}; $j++) { for($j=0; $j<$displayconfig{'perpage'}; $j++) {
next if (!defined($in{"${j}_$t[0]"})); next if (!defined($in{"${j}_$t[0]"}));
local (@where, @set); local (@where, @set);
local @r = @{$d->{'data'}->[$j]}; local @r = @{$d->{'data'}->[$j]};
@ -141,7 +141,7 @@ elsif ($in{'save'}) {
local $ij = $in{"${j}_$t[$i]"}; local $ij = $in{"${j}_$t[$i]"};
local $ijdef = $in{"${j}_$t[$i]_def"}; local $ijdef = $in{"${j}_$t[$i]_def"};
next if ($ijdef || !defined($ij)); next if ($ijdef || !defined($ij));
if (!$config{'blob_mode'} || !&is_blob($str[$i])) { if (!$displayconfig{'blob_mode'} || !&is_blob($str[$i])) {
$ij =~ s/\r//g; $ij =~ s/\r//g;
} }
push(@set, &quotestr($t[$i])." = ?"); push(@set, &quotestr($t[$i])." = ?");
@ -161,7 +161,7 @@ elsif ($in{'save'}) {
elsif ($in{'savenew'}) { elsif ($in{'savenew'}) {
# Adding a new row # Adding a new row
for($j=0; $j<@str; $j++) { for($j=0; $j<@str; $j++) {
if (!$config{'blob_mode'} || !&is_blob($str[$j])) { if (!$displayconfig{'blob_mode'} || !&is_blob($str[$j])) {
$in{$j} =~ s/\r//g; $in{$j} =~ s/\r//g;
} }
push(@set, $in{$j} eq '' ? undef : $in{$j}); push(@set, $in{$j} eq '' ? undef : $in{$j});
@ -180,23 +180,23 @@ elsif ($in{'cancel'} || $in{'new'}) {
$desc = &text('table_header', "<tt>$in{'table'}</tt>", "<tt>$in{'db'}</tt>"); $desc = &text('table_header', "<tt>$in{'table'}</tt>", "<tt>$in{'db'}</tt>");
&ui_print_header($desc, $text{'view_title'}, ""); &ui_print_header($desc, $text{'view_title'}, "");
if ($in{'start'} || $total > $config{'perpage'}) { if ($in{'start'} || $total > $displayconfig{'perpage'}) {
print "<center>\n"; print "<center>\n";
if ($in{'start'}) { if ($in{'start'}) {
printf "<a href='view_table.cgi?db=%s&table=%s&start=%s%s%s'>". printf "<a href='view_table.cgi?db=%s&table=%s&start=%s%s%s'>".
"<img src=/images/left.gif border=0 align=middle></a>\n", "<img src=/images/left.gif border=0 align=middle></a>\n",
$in{'db'}, $in{'table'}, $in{'db'}, $in{'table'},
$in{'start'} - $config{'perpage'}, $in{'start'} - $displayconfig{'perpage'},
$searchargs, $sortargs; $searchargs, $sortargs;
} }
print "<font size=+1>",&text('view_pos', $in{'start'}+1, print "<font size=+1>",&text('view_pos', $in{'start'}+1,
$in{'start'}+$config{'perpage'} > $total ? $total : $in{'start'}+$displayconfig{'perpage'} > $total ? $total :
$in{'start'}+$config{'perpage'}, $total),"</font>\n"; $in{'start'}+$displayconfig{'perpage'}, $total),"</font>\n";
if ($in{'start'}+$config{'perpage'} < $total) { if ($in{'start'}+$displayconfig{'perpage'} < $total) {
printf "<a href='view_table.cgi?db=%s&table=%s&start=%s%s%s'>". printf "<a href='view_table.cgi?db=%s&table=%s&start=%s%s%s'>".
"<img src=/images/right.gif border=0 align=middle></a> ", "<img src=/images/right.gif border=0 align=middle></a> ",
$in{'db'}, $in{'table'}, $in{'db'}, $in{'table'},
$in{'start'} + $config{'perpage'}, $in{'start'} + $displayconfig{'perpage'},
$searchargs, $sortargs; $searchargs, $sortargs;
} }
print "</center>\n"; print "</center>\n";
@ -227,7 +227,7 @@ if ($in{'sortfield'}) {
print "</table>\n"; print "</table>\n";
if ($config{'blob_mode'}) { if ($displayconfig{'blob_mode'}) {
print &ui_form_start("view_table.cgi", "form-data"); print &ui_form_start("view_table.cgi", "form-data");
} }
else { else {
@ -268,7 +268,7 @@ if ($total || $in{'new'}) {
$w = 10 if ($w < 10); $w = 10 if ($w < 10);
for($i=0; $i<@data; $i++) { for($i=0; $i<@data; $i++) {
local @d = map { $_ eq "NULL" ? undef : $_ } @{$data[$i]}; local @d = map { $_ eq "NULL" ? undef : $_ } @{$data[$i]};
if ($row{$i} && ($config{'add_mode'} || $has_blob)) { if ($row{$i} && ($displayconfig{'add_mode'} || $has_blob)) {
# Show multi-line row editor # Show multi-line row editor
$et = "<table border>\n"; $et = "<table border>\n";
$et .= "<tr $tb> <td><b>$text{'view_field'}</b></td> ". $et .= "<tr $tb> <td><b>$text{'view_field'}</b></td> ".
@ -277,7 +277,7 @@ if ($total || $in{'new'}) {
local $nm = $i == $realrows ? $j : local $nm = $i == $realrows ? $j :
"${i}_$str[$j]->{'field'}"; "${i}_$str[$j]->{'field'}";
$et .= "<tr $cb> <td><b>$str[$j]->{'field'}</b></td> <td>\n"; $et .= "<tr $cb> <td><b>$str[$j]->{'field'}</b></td> <td>\n";
if ($config{'blob_mode'} && if ($displayconfig{'blob_mode'} &&
&is_blob($str[$j]) && $d[$j]) { &is_blob($str[$j]) && $d[$j]) {
# Show as keep/upload inputs # Show as keep/upload inputs
$et .= &ui_radio($nm."_def", 1, $et .= &ui_radio($nm."_def", 1,
@ -285,7 +285,7 @@ if ($total || $in{'new'}) {
[ 0, $text{'view_set'} ] ])." ". [ 0, $text{'view_set'} ] ])." ".
&ui_upload($nm); &ui_upload($nm);
} }
elsif ($config{'blob_mode'} && elsif ($displayconfig{'blob_mode'} &&
&is_blob($str[$j])) { &is_blob($str[$j])) {
# Show upload input # Show upload input
$et .= &ui_upload($nm); $et .= &ui_upload($nm);
@ -323,7 +323,7 @@ if ($total || $in{'new'}) {
local $l = $d[$j] =~ tr/\n/\n/; local $l = $d[$j] =~ tr/\n/\n/;
local $nm = $i == $realrows ? $j : local $nm = $i == $realrows ? $j :
"${i}_$d->{'titles'}->[$j]"; "${i}_$d->{'titles'}->[$j]";
if ($config{'blob_mode'} && if ($displayconfig{'blob_mode'} &&
&is_blob($str[$j])) { &is_blob($str[$j])) {
# Cannot edit this blob # Cannot edit this blob
push(@cols, undef); push(@cols, undef);
@ -361,7 +361,7 @@ if ($total || $in{'new'}) {
local @cols; local @cols;
local $j = 0; local $j = 0;
foreach $c (@d) { foreach $c (@d) {
if ($config{'blob_mode'} && if ($displayconfig{'blob_mode'} &&
&is_blob($str[$j]) && $c ne '') { &is_blob($str[$j]) && $c ne '') {
# Show download link for blob # Show download link for blob
push(@cols, "<a href='download.cgi?db=$in{'db'}&table=$in{'table'}&start=$in{'start'}".$searchargs.$sortargs."&row=$i&col=$j'>$text{'view_download'}</a>"); push(@cols, "<a href='download.cgi?db=$in{'db'}&table=$in{'table'}&start=$in{'start'}".$searchargs.$sortargs."&row=$i&col=$j'>$text{'view_download'}</a>");
@ -417,7 +417,7 @@ else {
print &ui_form_end([ [ "new", $text{'view_new'} ] ]); print &ui_form_end([ [ "new", $text{'view_new'} ] ]);
} }
if (!$in{'field'} && $total > $config{'perpage'}) { if (!$in{'field'} && $total > $displayconfig{'perpage'}) {
# Show search and jump buttons # Show search and jump buttons
print "<hr>\n"; print "<hr>\n";
print "<table width=100%><tr>\n"; print "<table width=100%><tr>\n";