diff --git a/updown/CHANGELOG b/updown/CHANGELOG index 1a3a672f3..51ac0b54f 100644 --- a/updown/CHANGELOG +++ b/updown/CHANGELOG @@ -6,3 +6,4 @@ Added the ability to extract tar.bz2 files. Added a popup progress window to track large uploads. ---- Changes since 1.390 ---- Tabs are now used to layout the upload, download and fetch forms on the module's main page. +Converted all user interface code to use the new Webmin UI library. diff --git a/updown/cancel.cgi b/updown/cancel.cgi index 10cb77606..d5242b953 100755 --- a/updown/cancel.cgi +++ b/updown/cancel.cgi @@ -33,5 +33,5 @@ foreach $i (@ids) { } } &webmin_log("cancel", undef, undef, { 'ids' => \@ids }); -&redirect(""); +&redirect("index.cgi?mode=download"); diff --git a/updown/download.cgi b/updown/download.cgi index 47f4155e0..54689b334 100755 --- a/updown/download.cgi +++ b/updown/download.cgi @@ -127,7 +127,7 @@ if ($in{'bg'} && $can_background) { } } - &redirect(""); + &redirect("index.cgi?mode=download"); } else { # Download it now, and show the results @@ -146,7 +146,7 @@ else { print "

",&text('download_failed', $error),"

\n"; } - &ui_print_footer("", $text{'index_return'}); + &ui_print_footer("index.cgi?mode=download", $text{'index_return'}); } &webmin_log("download", undef, undef, { 'urls' => \@urls, 'time' => $download{'time'} }); diff --git a/updown/index.cgi b/updown/index.cgi index b58baf4fb..5a7e5e081 100755 --- a/updown/index.cgi +++ b/updown/index.cgi @@ -26,147 +26,127 @@ $form = 0; if ($can_download) { # Show form for downloading print &ui_tabs_start_tab("mode", "download"); - print "

\n"; - print "\n"; - print "\n"; - print "
$text{'index_header1'}
\n"; + print $text{'index_descdownload'},"

\n"; - print "

\n"; - print "\n"; + print &ui_form_start("download.cgi", "post"); + print &ui_table_start($text{'index_header1'}, "width=100%", 4); - print "\n"; - print "\n"; + # URLs to download + print &ui_table_row($text{'index_urls'}, + &ui_textarea("urls", undef, 4, 70), 3); + + # Destination directory + print &ui_table_row($text{'index_ddir'}, + &ui_textbox("dir", $download_dir, 60)." ". + &file_chooser_button("dir", 1, $form)."
". + &ui_checkbox("mkdir", 1, $text{'index_mkdir'}, 0), 3); if ($can_mode != 3) { # Ask for user and group to download as - print "\n"; - print "\n"; + print &ui_table_row($text{'index_user'}, + &ui_user_textbox("user", $download_user, $form)); - print "\n"; - printf "\n"; + print &ui_table_row($text{'index_group'}, + &ui_opt_textbox("group", $download_group, 13, + $text{'default'})." ". + &group_chooser_button("group", 0, $form)); } if ($can_schedule) { # Download time can be selected, for scheduling with At - print "\n", $now[2], $now[1]; + print &ui_table_row($text{'index_bg'}, + &ui_radio("bg", 0, [ [ 0, $text{'index_bg0'}."
" ], + [ 1, $text{'index_bg1'} ] ])." ". + &ui_textbox("day", $now[3], 2)."/". + &ui_select("month", $now[4], + [ map { [ $_, $text{"smonth_".($_+1)} ] } + (0 .. 11) ])."/". + &ui_textbox("year", $now[5]+1900, 4)." ". + &date_chooser_button("day", "month", "year", $form)." ". + $text{'index_time'}."\n". + &ui_textbox("hour", sprintf("%2.2d", $now[2]), 2).":". + &ui_textbox("min", sprintf("%2.2d", $now[1]), 2), 3); } elsif ($can_background) { # Download must be immediate, but can be backgrounded - print "
$text{'index_urls'}
$text{'index_ddir'} ", - &file_chooser_button("dir", 1, $form); - print " $text{'index_mkdir'}\n"; - print "
$text{'index_user'}",&unix_user_input("user", $download_user, $form), - "$text{'index_group'} %s\n", - $download_group ? "" : "checked", $text{'default'}; - printf "\n", - $download_group ? "checked" : ""; - printf &unix_group_input("group", $download_group, $form), - "
$text{'index_bg'} \n"; - print " $text{'index_bg0'}
\n"; - print " $text{'index_bg1'}\n"; - @now = localtime(time()); - printf "/", $now[3]; - print "/"; - printf "\n", $now[5] + 1900; - print &date_chooser_button("day", "month", "year", $form),"\n"; - - print "$text{'index_time'}\n"; - printf ":
$text{'index_bg'} \n"; - print " $text{'index_bg0'}
\n"; - print " $text{'index_bg1u'}\n"; + print &ui_table_row($text{'index_bg'}, + &ui_radio("bg", 0, [ [ 0, $text{'index_bg0'} ], + [ 1, $text{'index_bg1u'} ] ])); } else { # Download is always right now } - print "
\n"; - print "
\n"; + print &ui_table_end(); + print &ui_form_end([ [ undef, $text{'index_down'} ] ]); $form++; # Show current list of scheduled or active downloads @downs = grep { &can_as_user($_->{'user'}) } &list_downloads(); if (@downs) { + @tds = $notdone ? ( "width=5" ) : ( ); local ($notdone) = grep { !$_->{'complete'} } @downs; - print "
\n"; - print "\n"; - print " ", - $notdone ? "" : "", - " ", - " ", - " ", - " ", - "\n"; + print &ui_form_start("cancel.cgi"); + print &ui_columns_start([ + $notdone ? ( "" ) : ( ), + $text{'index_urls'}, $text{'index_dest'}, + $text{'index_when'}, $text{'index_user'}, + $text{'index_prog'} ], 100, 0, \@tds); foreach $d (@downs) { - print "\n"; - if (!$d->{'complete'}) { - printf "\n", $d->{'id'}; - } - elsif ($notdone) { - print "\n"; - } - print "\n"; - printf "\n", $d->{'dir'}; - print "\n"; - printf "\n", $d->{'user'}; - print "\n"; - print "\n"; } - print "

$text{'index_urls'}$text{'index_dest'}$text{'index_when'}$text{'index_user'}$text{'index_prog'}

\n"; + local @cols; local $count = 0; while($url = $d->{"url_$count"}) { print "
\n" if ($count); if (length($url) > 70 && $url =~ /^([^:]+:\/\/[^\/]+\/)(.*)(\/[^\/]+)$/) { - print "$1 .. $3"; + push(@cols, &html_escape("$1 .. $3")); } else { - print $url; + push(@cols, &html_escape($url)); } $count++; } - print "
%s", - $d->{'time'} ? &make_date($d->{'time'}) - : $text{'index_imm'},"%s"; + push(@cols, &html_escape($d->{'dir'})); + push(@cols, $d->{'time'} ? &make_date($d->{'time'}) + : $text{'index_imm'}); + push(@cols, &html_escape($d->{'user'})); if ($d->{'error'}) { - print "\n"; - if ($count > 1) { - print &text('index_upto', - $d->{'upto'}+1, $count),"\n"; - } - print "$d->{'error'}\n"; + push(@cols, "". + ($count > 1 ? &text('index_upto', + $d->{'upto'}+1, $count)." " : ""). + "$d->{'error'}"); &delete_download($d); } elsif (!defined($d->{'upto'})) { - print $text{'index_noprog'}; + push(@cols, $text{'index_noprog'}); } elsif ($d->{'complete'}) { - print "$text{'index_done'} (", - &nice_size($d->{'total'}),")\n"; + push(@cols, "". + "$text{'index_done'} (". + &nice_size($d->{'total'}).")"); &delete_download($d); } else { - if ($count > 1) { - print &text('index_upto', - $d->{'upto'}+1, $count),"\n"; - } - local $sz = &nice_size($d->{'got'}); - print "$sz\n"; - if ($d->{'size'}) { - print "(".int($d->{'got'}*100/$d->{'size'}). - "%)\n"; - } + push(@cols, ($count > 1 ? + &text('index_upto', + $d->{'upto'}+1, $count)." " : ""). + &nice_size($d->{'got'})." ". + ($d->{'size'} ? + "(".int($d->{'got'}*100/$d->{'size'}). + "%)" : "")); + } + if (!$d->{'complete'}) { + print &ui_checked_columns_row(\@cols, \@tds, + "cancel", $d->{'id'}); + } + else { + @cols = ( "", @cols ) if ($notdone); + print &ui_columns_row(\@cols, \@tds); } - print "
\n"; - print "\n" - if ($notdone); - print "
\n"; + print &ui_columns_end(); + print &ui_form_end($notdone ? + [ [ undef, $text{'index_cancel'} ] ] : [ ]); $form++; } print &ui_tabs_end_tab(); @@ -175,6 +155,7 @@ if ($can_download) { if ($can_upload) { # Show form for uploading print &ui_tabs_start_tab("mode", "upload"); + print $text{'index_descupload'},"

\n"; local $upid = time().$$; print &ui_form_start("upload.cgi?id=$upid", "form-data", undef, &read_parse_mime_javascript($upid, @@ -223,22 +204,21 @@ if ($can_upload) { if ($can_fetch) { # Show form to download fetch from server to PC print &ui_tabs_start_tab("mode", "fetch"); - print "

\n"; - print "\n"; - print "\n"; - print "
$text{'index_header3'}
\n"; + print $text{'index_descfetch'},"

\n"; + print &ui_form_start("fetch.cgi"); + print &ui_table_start($text{'index_header3'}, "width=100%", 4); - print "

\n"; - print "\n"; + # File to fetch + print &ui_table_row($text{'index_fetch'}, + &ui_textbox("fetch", $fetch_file, 50)." ". + &file_chooser_button("fetch", 0, $form), 3); - print "\n"; - print "\n"; + # Show in browser? + print &ui_table_row($text{'index_show'}, + &ui_yesno_radio("show", $fetch_show)); - print "
$text{'index_fetch'}\n"; - print &ui_textbox("fetch", $fetch_file, 50),"\n", - &file_chooser_button("fetch", 0, $form); - print "
$text{'index_show'}",&ui_yesno_radio("show", $fetch_show),"
\n"; - print "
\n"; + print &ui_table_end(); + print &ui_form_end([ [ undef, $text{'index_ok2'} ] ]); $form++; print &ui_tabs_end_tab(); } diff --git a/updown/lang/en b/updown/lang/en index 6b3fd8a27..12bcaaf6a 100644 --- a/updown/lang/en +++ b/updown/lang/en @@ -34,6 +34,9 @@ index_show=Show in browser if possible? index_tabdownload=Download from web index_tabupload=Upload to server index_tabfetch=Download from server +index_descdownload=This form allows you to download files or web pages from HTTP or FTP URLs to the system running Webmin. The download can be done immediately, or scheduled for some time in the future. +index_descupload=This page allows you to upload one or more files from the PC on which your web browser runs to the system running Webmin. +index_descfetch=This page is for downloading a file from the system running Webmin for display in your browser or saving on the same system. upload_title=Upload Files upload_err=Failed to upload files diff --git a/updown/upload.cgi b/updown/upload.cgi index fb3230c92..e835a64e8 100755 --- a/updown/upload.cgi +++ b/updown/upload.cgi @@ -177,5 +177,5 @@ else { &webmin_log("upload", undef, undef, { 'uploads' => \@uploads }); -&ui_print_footer("", $text{'index_return'}); +&ui_print_footer("index.cgi?mode=upload", $text{'index_return'});