Some ui-lib conversion
authorJamie Cameron <jcameron@webmin.com>
Sun, 31 Aug 2008 15:47:12 +0000 (15:47 +0000)
committerJamie Cameron <jcameron@webmin.com>
Sun, 31 Aug 2008 15:47:12 +0000 (15:47 +0000)
postfix/delete_queues.cgi
postfix/mailq.cgi
postfix/postfix-lib.pl

index 8aa9e02..1d2f14c 100755 (executable)
@@ -51,14 +51,11 @@ else {
        else {
                # Ask for confirmation
                &ui_print_header(undef, $text{'delq_titles'}, "");
-               print "<center>\n";
-               print &ui_form_start("delete_queues.cgi", "post");
-               print &text('delq_rusure', scalar(@files)),"<p>\n";
-               foreach $f (@files) {
-                       print &ui_hidden("file", $f),"\n";
-                       }
-               print &ui_form_end([ [ "confirm", $text{'delq_confirm'} ] ]);
-               print "</center>\n";
+               print &ui_confirmation_form("delete_queues.cgi",
+                       &text('delq_rusure', scalar(@files)),
+                       [ map { [ 'f', $_ ] } @files ],
+                       [ [ 'confirm', $text{'delq_confirm'} ] ],
+                       );
                &ui_print_footer("mailq.cgi", $text{'mailq_return'});
                exit;
                }
index e9ce50c..596d1b6 100755 (executable)
@@ -57,26 +57,21 @@ if (@qfiles) {
        &mailq_table([ @qfiles[$s .. $e] ]);
 
        # Show queue search form
-       print "<form action=mailq_search.cgi>\n";
+       print &ui_form_start("mailq_search.cgi");
        print "<b>$text{'mailq_search'}</b>\n";
-       print "<select name=field>\n";
-       foreach $f ('from', 'to', 'date', 'size', '',
-                   '!from', '!to', '!date', '!size') {
-               printf "<option value='%s'>%s\n", $f, $text{"match_$f"};
-               }
-       print "</select>\n";
-       print "<input name=match size=20>\n";
-       print "&nbsp;<input type=submit value='$text{'mail_ok'}'>\n";
-       print "</form><p>\n";
+       print &ui_select("field", "from",
+               [ map { [ $_, $text{'match_'.$_} ] }
+                   ('from', 'to', 'date', 'size', '',
+                    '!from', '!to', '!date', '!size') ]);
+       print &ui_textbox("match", undef, 40);
+       print &ui_submit($text{'mail_ok'});
+       print &ui_form_end();
 
        # Show flush button, if the needed command is installed
        if (&has_command($config{'postfix_queue_command'})) {
                print &ui_hr();
-               print "<table width=100%><tr><form action=flushq.cgi>\n";
-               print "<td><input type=submit ",
-                     "value='$text{'mailq_flush'}'></td>\n";
-               print "<td>$text{'mailq_flushdesc'}</td>\n";
-               print "</form></tr></table>\n";
+               print &ui_buttons_row("flushq.cgi", $text{'mailq_flush'},
+                                     $text{'mailq_flushdesc'});
                }
        }
 else {
index a6d741d..7e09824 100644 (file)
@@ -1622,24 +1622,12 @@ sub mailq_table
 {
 local ($qfiles) = @_;
 
-# Show queued messages
-print "<form action=delete_queues.cgi method=post>\n";
-local @links = ( &select_all_link("file", 0),
-                &select_invert_link("file", 0) );
-print &ui_links_row(\@links);
-
-# Table header
-local @tds = ( "width=5" );
-print &ui_columns_start([
-       "",
-       $text{'mailq_id'},
-       $text{'mailq_date'},
-       $text{'mailq_from'},
-       $text{'mailq_to'},
-       $text{'mailq_size'},
-       $text{'mailq_status'} ], 100, 0, \@tds);
+# Build table data
+my @table;
 foreach my $q (@$qfiles) {
        local @cols;
+       push(@cols, { 'type' => 'checkbox', 'name' => 'file',
+                     'value' => $q->{'id'} });
        push(@cols, "<a href='view_mailq.cgi?id=$q->{'id'}'>$q->{'id'}</a>");
        local $size = &nice_size($q->{'size'});
        push(@cols, "<font size=1>$q->{'date'}</font>");
@@ -1647,24 +1635,23 @@ foreach my $q (@$qfiles) {
        push(@cols, "<font size=1>".&html_escape($q->{'to'})."</font>");
        push(@cols, "<font size=1>$size</font>");
        push(@cols, "<font size=1>".&html_escape($q->{'status'})."</font>");
-       print &ui_checked_columns_row(\@cols, \@tds, "file", $q->{'id'});
-       }
-print &ui_columns_end();
-print &ui_links_row(\@links);
-print "<input type=submit value='$text{'mailq_delete'}'>\n";
-if ($postfix_version >= 1.1) {
-       # Show button to re-queue
-       print "&nbsp;\n";
-       print &ui_submit($text{'mailq_move'}, "move");
-       }
-if ($postfix_version >= 2) {
-       # Show button to hold and un-hold
-       print "&nbsp;\n";
-       print &ui_submit($text{'mailq_hold'}, "hold");
-       print &ui_submit($text{'mailq_unhold'}, "unhold");
-       }
-print "<p>\n";
-print "</form>\n";
+       push(@table, \@cols);
+       }
+
+# Show the table and form
+print &ui_form_columns_table("delete_queues.cgi",
+       [ [ undef, $text{'mailq_delete'} ],
+         $postfix_version >= 1.1 ? ( [ 'move', $text{'mailq_move'} ] ) : ( ),
+         $postfix_version >= 2 ? ( [ 'hold', $text{'mailq_hold'} ],
+                                   [ 'unhold', $text{'mailq_unhold'} ] ) : ( ),
+       ],
+       1,
+       undef,
+       undef,
+       [ "", $text{'mailq_id'}, $text{'mailq_date'}, $text{'mailq_from'},
+          $text{'mailq_to'}, $text{'mailq_size'}, $text{'mailq_status'} ],
+       100,
+       \@table);
 }
 
 # is_table_comment(line, [force-prefix])