- fixed configure.pl and makeDist.
[BackupPC.git] / lib / BackupPC / CGI / DirHistory.pm
index 45bb01d..3a9b0c0 100644 (file)
@@ -28,7 +28,7 @@
 #
 #========================================================================
 #
 #
 #========================================================================
 #
-# Version 2.1.0_CVS, released 3 Jul 2003.
+# Version 3.0.0alpha, released 23 Jan 2006.
 #
 # See http://backuppc.sourceforge.net.
 #
 #
 # See http://backuppc.sourceforge.net.
 #
@@ -71,7 +71,8 @@ sub action
         ErrorExit($Lang->{Nice_try__but_you_can_t_put});
     }
 
         ErrorExit($Lang->{Nice_try__but_you_can_t_put});
     }
 
-    for ( $i = 0 ; $i < @Backups ; $i++ ) {
+    my @backupList = $view->backupList($share, $dir);
+    foreach $i ( @backupList ) {
        my $backupTime  = timeStamp2($Backups[$i]{startTime});
        my $num = $Backups[$i]{num};
        $backupNumStr  .= "<td align=center><a href=\"$MyURL?action=browse"
        my $backupTime  = timeStamp2($Backups[$i]{startTime});
        my $num = $Backups[$i]{num};
        $backupNumStr  .= "<td align=center><a href=\"$MyURL?action=browse"
@@ -84,9 +85,10 @@ sub action
        my %inode2name;
        my $nameCnt = 0;
        (my $fDisp  = "${EscHTML($f)}") =~ s/ /&nbsp;/g;
        my %inode2name;
        my $nameCnt = 0;
        (my $fDisp  = "${EscHTML($f)}") =~ s/ /&nbsp;/g;
-       $fileStr   .= "<tr><td align=left>$fDisp</td>";
+       $fileStr   .= "<tr><td align=\"left\"  class=\"histView\">$fDisp</td>";
        my($colSpan, $url, $inode, $type);
        my($colSpan, $url, $inode, $type);
-       for ( $i = 0 ; $i < @Backups ; $i++ ) {
+       my $tdClass = ' class="histView"';
+       foreach $i ( @backupList ) {
            my($path);
            if ( $colSpan > 0 ) {
                #
            my($path);
            if ( $colSpan > 0 ) {
                #
@@ -102,11 +104,23 @@ sub action
                    $colSpan++;
                    next;
                }
                    $colSpan++;
                    next;
                }
-               $fileStr .= "<td align=center colspan=$colSpan>$url</td>";
+               #
+               # Also handle the case of a sequence of missing files
+               #
+               if ( !defined($hist->{$f}[$i]) && $inode == -3 ) {
+                   $colSpan++;
+                   next;
+               }
+               $fileStr .= "<td align=center colspan=$colSpan$tdClass>"
+                         . "$url</td>";
                $colSpan = 0;
                $colSpan = 0;
+               $tdClass = ' class="histView"';
            }
            if ( !defined($hist->{$f}[$i]) ) {
            }
            if ( !defined($hist->{$f}[$i]) ) {
-               $fileStr .= "<td></td>";
+               $colSpan = 1;
+               $url     = "&nbsp;";
+               $inode   = -3;                  # special value for missing
+               $tdClass = ' class="histViewMis"';
                next;
            }
             if ( $dir eq "" ) {
                next;
            }
             if ( $dir eq "" ) {
@@ -118,17 +132,21 @@ sub action
            $path =~ s/([^\w.\/-])/uc sprintf("%%%02X", ord($1))/eg;
            my $num = $hist->{$f}[$i]{backupNum};
            if ( $hist->{$f}[$i]{type} == BPC_FTYPE_DIR ) {
            $path =~ s/([^\w.\/-])/uc sprintf("%%%02X", ord($1))/eg;
            my $num = $hist->{$f}[$i]{backupNum};
            if ( $hist->{$f}[$i]{type} == BPC_FTYPE_DIR ) {
-               $inode = -2;
+               $inode = -2;                    # special value for dir
                $type  = $hist->{$f}[$i]{type};
                $url   = <<EOF;
                $type  = $hist->{$f}[$i]{type};
                $url   = <<EOF;
-<a href="$MyURL?action=dirHistory&host=${EscURI($host)}&num=$num&share=$shareURI&dir=$path">dir</a>
+<a href="$MyURL?action=dirHistory&host=${EscURI($host)}&num=$num&share=$shareURI&dir=$path">$Lang->{DirHistory_dirLink}</a>
 EOF
            } else {
                $inode = $hist->{$f}[$i]{inode};
                $type  = $hist->{$f}[$i]{type};
 EOF
            } else {
                $inode = $hist->{$f}[$i]{inode};
                $type  = $hist->{$f}[$i]{type};
+               #
+               # special value for empty file
+               #
                $inode = -1 if ( $hist->{$f}[$i]{size} == 0 );
                if ( !defined($inode2name{$inode}) ) {
                $inode = -1 if ( $hist->{$f}[$i]{size} == 0 );
                if ( !defined($inode2name{$inode}) ) {
-                   $inode2name{$inode} = "v$nameCnt";
+                   $inode2name{$inode}
+                               = "$Lang->{DirHistory_fileLink}$nameCnt";
                    $nameCnt++;
                }
                $url = <<EOF;
                    $nameCnt++;
                }
                $url = <<EOF;
@@ -138,7 +156,7 @@ EOF
            $colSpan = 1;
        }
        if ( $colSpan > 0 ) {
            $colSpan = 1;
        }
        if ( $colSpan > 0 ) {
-           $fileStr .= "<td align=center colspan=$colSpan>$url</td>";
+           $fileStr .= "<td align=center colspan=$colSpan$tdClass>$url</td>";
            $colSpan = 0;
        }
        $fileStr .= "</tr>\n";
            $colSpan = 0;
        }
        $fileStr .= "</tr>\n";
@@ -148,11 +166,8 @@ EOF
     $dirDisplay =~ s{//+}{/}g;
     $dirDisplay =~ s{/+$}{}g;
     $dirDisplay = "/" if ( $dirDisplay eq "" );
     $dirDisplay =~ s{//+}{/}g;
     $dirDisplay =~ s{/+$}{}g;
     $dirDisplay = "/" if ( $dirDisplay eq "" );
-
-    Header(eval("qq{$Lang->{DirHistory_backup_for__host}}"));
-
-    print (eval("qq{$Lang->{DirHistory_for__host}}"));
-
+    my $content = eval("qq{$Lang->{DirHistory_for__host}}");
+    Header(eval("qq{$Lang->{DirHistory_backup_for__host}}"), $content);
     Trailer();
 }
 
     Trailer();
 }