Fixed import/export list
[clearscm.git] / maps / bin / list.cgi
index 3d82b09..0b391df 100755 (executable)
@@ -2,8 +2,8 @@
 ################################################################################
 #
 # File:         $RCSfile: list.cgi,v $
-# Revision:    $Revision: 1.1 $
-# Description: Manage lists
+# Revision:  $Revision: 1.1 $
+# Description:  Manage lists
 # Author:       Andrew@DeFaria.com
 # Created:      Mon Jan 16 20:25:32 PST 2006
 # Modified:     $Date: 2013/06/12 14:05:47 $
@@ -16,7 +16,8 @@ use strict;
 use warnings;
 
 use FindBin;
-$0 = $FindBin::Script;
+
+local $0 = $FindBin::Script;
 
 use lib $FindBin::Bin;
 
@@ -27,11 +28,11 @@ use MAPSWeb;
 use CGI qw (:standard *table start_div end_div);
 use CGI::Carp "fatalsToBrowser";
 
-my $next       = param ("next");
-my $lines      = param ("lines");
-my $type       = param ("type");
-my $message    = param ("message");
-my $Type       = ucfirst $type;
+my $next    = param("next");
+my $lines   = param("lines");
+my $type    = param("type");
+my $message = param("message");
+my $Type    = ucfirst $type;
 my $userid;
 my $prev;
 my $total;
@@ -42,29 +43,29 @@ sub Body {
   my $type = shift;
 
   if (defined $message) {
-    print div {-align  => "center"},
-      font {-class     => "error"}, $message;
+    print div {-align  => "center"},
+      font {-class  => "error"}, $message;
   } # if
 
   print start_form {
-    -method    => "post",
-    -action    => "processaction.cgi",
-    -name      => "list"
+    -method => "post",
+    -action => "processaction.cgi",
+    -name   => "list"
   };
 
   # Print some hidden fields to pass along
   print
-    hidden (-name      => "type",
-           -default    => $type),
-    hidden (-name      => "next",
-           -default    => $next);
+    hidden (-name    => "type",
+            -default => $type),
+    hidden (-name    => "next",
+            -default => $next);
 
   my $current = $next + 1;
 
   print div {-align => "center"}, b (
     "(" . $current . "-" . $last . " of " . $total . ")");
-  print start_div {-class      => "toolbar",
-                  -align       => "center"};
+  print start_div {-class  => "toolbar",
+                   -align  => "center"};
   my $prev_button = $prev >= 0 ?
     a ({-href => "list.cgi?type=$type;next=$prev"},
       "<img src=/maps/images/previous.gif border=0 alt=Previous align=middle>") : "";
@@ -72,33 +73,33 @@ sub Body {
     a {-href => "list.cgi?type=$type;next=" . ($next + $lines)},
       "<img src=/maps/images/next.gif border=0 alt=Next align=middle>" : "";
   print $prev_button,
-    submit ({-name     => "action",
-            -value     => "Add New Entry",
-            -onClick   => "return NoneChecked (document.list);"}),
-    submit ({-name     => "action",
-            -value     => "Delete Marked",
-            -onClick   => "return CheckAtLeast1Checked (document.list) && AreYouSure ('Are you sure you want to delete these entries?');"}),
-    submit ({-name     => "action",
-            -value     => "Modify Marked",
-            -onClick   => "return CheckAtLeast1Checked (document.list);"}),
-    submit ({-name     => "action",
-            -value     => "Reset Marks",
-            -onClick   => "return ClearAll (document.list);"}),
+    submit ({-name    => "action",
+             -value   => "Add New Entry",
+             -onClick => "return NoneChecked (document.list);"}),
+    submit ({-name    => "action",
+             -value   => "Delete Marked",
+             -onClick => "return CheckAtLeast1Checked (document.list) && AreYouSure ('Are you sure you want to delete these entries?');"}),
+    submit ({-name    => "action",
+             -value   => "Modify Marked",
+             -onClick => "return CheckAtLeast1Checked (document.list);"}),
+    submit ({-name    => "action",
+             -value   => "Reset Marks",
+             -onClick => "return ClearAll (document.list);"}),
     $next_button;
   print end_div;
-  print start_table {-align            => "center",
-                    -id                => $table_name,
-                    -border            => 0,
-                    -cellspacing       => 0,
-                    -cellpadding       => 4,
-                    -width             => "100%"};
+  print start_table {-align    => "center",
+         -id          => $table_name,
+         -border      => 0,
+         -cellspacing => 0,
+         -cellpadding => 4,
+         -width       => "100%"};
   print Tr [
-    th {-class => "tableleftend"},     "Seq",
-    th {-class => "tableheader"},      "Mark",
-    th {-class => "tableheader"},      "Username",
-    th {-class => "tableheader"},      "@",
-    th {-class => "tableheader"},      "Domain",
-    th {-class => "tablerightend"},    "Comments"
+    th {-class  => "tableleftend"},  "Seq",
+    th {-class  => "tableheader"},   "Mark",
+    th {-class  => "tableheader"},   "Username",
+    th {-class  => "tableheader"},   "@",
+    th {-class  => "tableheader"},   "Domain",
+    th {-class  => "tablerightend"}, "Comments"
   ];
 
   my @list = ReturnList $type, $next, $lines;
@@ -107,9 +108,9 @@ sub Body {
 
   foreach (@list) {
     %record = %{$_};
-    $record{pattern}   = "&nbsp;" if !defined $record{pattern};
-    $record{domain}    = "&nbsp;" if !defined $record{domain};
-    $record{comment}   = "&nbsp;" if !defined $record{comment};
+    $record{pattern}  = "&nbsp;" if !defined $record{pattern};
+    $record{domain}  = "&nbsp;" if !defined $record{domain};
+    $record{comment}  = "&nbsp;" if !defined $record{comment};
 
     my $leftclass  = ($i eq $lines || $record{sequence} eq $total) ?
       "tablebottomleft"  : "tableleftdata";
@@ -120,32 +121,34 @@ sub Body {
     $i++;
 
     print Tr [
-      td {-class       => $leftclass,
-         -align        => "center"}, $record{sequence},
-      td {-class       => $dataclass,
-         -align        => "center"},
-       checkbox ({-name        => "action$record{sequence}",
-                  -label       => ""}),
-      td {-class       => $dataclass,
-         -align        => "right"}, $record{pattern},
-      td {-class       => $dataclass,
-         -align        => "center"}, "\@",
-      td {-class       => $dataclass,
-         -align        => "left"}, $record{domain},
-      td {-class       => $rightclass,
-         -align        => "left"}, $record{comment}
+      td {-class  => $leftclass,
+          -align  => "center"}, $record{sequence},
+      td {-class  => $dataclass,
+          -align  => "center"},
+    checkbox ({-name  => "action$record{sequence}",
+               -label => ""}),
+      td {-class  => $dataclass,
+          -align  => "right"}, $record{pattern},
+      td {-class  => $dataclass,
+          -align  => "center"}, "\@",
+      td {-class  => $dataclass,
+          -align  => "left"}, $record{domain},
+      td {-class  => $rightclass,
+          -align  => "left"}, $record{comment}
     ];
   } # foreach
   print end_table;
   print end_form;
 
-  print div ({-align   => "center"},
+  print div ({-align  => "center"},
     a ({-href => "/maps/bin/exportlist.cgi?type=$type"},
-      submit ({-name   => "export",
-              -value   => "Export list"})),
+      submit ({-name  => "export",
+               -value  => "Export List"})),
     a ({-href => "/maps/bin/importlist.cgi?type=$type"},
-      submit ({-name   => "import",
-              -value   => "Import List"})));
+      submit ({-name  => "import",
+               -value  => "Import List"})));
+
+  return;
 } # Body
 
 # Main
@@ -177,7 +180,7 @@ $last = $next + $lines < $total ? $next + $lines : $total;
 if (($next - $lines) > 0) {
   $prev = $next - $lines;
 } else {
-  $prev = $next eq 0 ? -1 : 0;
+  $prev = $next == 0 ? -1 : 0;
 } # if
 
 Body $type;