experimental pager support in search
authordpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Thu, 23 Jun 2005 12:36:22 +0000 (12:36 +0000)
committerdpavlin <dpavlin@8392b6e1-25fa-0310-8288-cc32f8e212ea>
Thu, 23 Jun 2005 12:36:22 +0000 (12:36 +0000)
git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/BackupPC/trunk@9 8392b6e1-25fa-0310-8288-cc32f8e212ea

conf/config.pl
lib/BackupPC/CGI/SearchArchives.pm
lib/BackupPC/SearchLib.pm

index bfbc498..76be330 100644 (file)
@@ -1745,4 +1745,4 @@ $Conf{CgiCSSFile} = 'BackupPC_stnd.css';
 #
 # add search database using DBD::SQLite which will be created in $TopDir
 #
-$Conf{SearchDB} = "search.db";
+$Conf{SearchDB} = 'search.db';
index 2ecb773..5506572 100644 (file)
@@ -155,7 +155,7 @@ ENDSTR
        my $result;
        my $rows = "";
 
-       my $grid = BackupPC::SearchLib::displayGrid( BackupPC::SearchLib::getWhere(\%In), 0);
+       my $grid = BackupPC::SearchLib::displayGrid( BackupPC::SearchLib::getWhere(\%In), 1, $In{'offset'});
        $cont .= $grid;                 
     }
     Header( eval("qq{$Lang->{Search_archive}}"), "", 1, "", $cont );
index a18a446..4260839 100644 (file)
@@ -117,9 +117,10 @@ sub getWhere($) {
     return $retSQL;
 }
 
-sub getFiles($)
+sub getFiles($$)
   {
-      my ($where) = @_;
+      my ($where, $offset) = @_;
+      
       
       my $dbh = DBI->connect( "dbi:SQLite:dbname=${TopDir}/$Conf{SearchDB}",
         "", "", { RaiseError => 1, AutoCommit => 1 } );
@@ -143,7 +144,7 @@ sub getFiles($)
                        INNER JOIN hosts   ON hosts.ID = shares.hostID
                        INNER JOIN backups ON backups.hostID = hosts.ID
                        LEFT  JOIN dvds    ON dvds.ID = files.dvdid
-                   
+           
          };
 
       if (defined($where) && $where ne "")
@@ -151,11 +152,26 @@ sub getFiles($)
            $sql .= " WHERE ". $where;      
        }
 
+      $sql .=
+       q{          
+           ORDER BY files.id
+             LIMIT 100
+             OFFSET ? * 100 + 1
+       };
+      
+      
       
       my $st = $dbh->prepare(
          $sql
          );     
-
+      if (!defined($offset) && $offset ne "")
+      {
+       $st->bind_param(1, $offset);
+      }
+      else
+      {
+       $st->bind_param(1,0);
+      }
       $st->execute;
       
       my @ret = ();
@@ -307,59 +323,23 @@ EOF3
   
   }      
 
-sub displayGrid($$)
+sub displayGrid($$$)
   {
-      my ($where, $addForm) = @_;
+      my ($where, $addForm, $offset) = @_;
       my $retHTML = "";
       
       if ($addForm)
        {
-      $retHTML .= <<EOF3;
-<script language="javascript" type="text/javascript">
-<!--
-
-    function checkAll(location)
-    {
-      for (var i=0;i<document.forma.elements.length;i++)
-      {
-        var e = document.forma.elements[i];
-        if ((e.checked || !e.checked) && e.name != \'all\') {
-            if (eval("document.forma."+location+".checked")) {
-                e.checked = true;
-            } else {
-                e.checked = false;
-            }
-        }
-      }
-    }
-
-
-//-->
-</script>      
-EOF3
-             $retHTML .= q{<form name="forma" method="POST" action="}."$MyURL"."?action=burn\"";
-              $retHTML.= q{<input type="hidden" value="burn" name="action">};
+             $retHTML .= q{<form name="forma" method="POST" action="}."$MyURL"."?action=search\"";
+              $retHTML.= q{<input type="hidden" value="search" name="action">};
               $retHTML .= q{<input type="hidden" value="results" name="search_results">};
        }
       $retHTML .= "<table style=\"fview\">";
       $retHTML .= "<tr> ";
-      if ($addForm)
-       {
-           $retHTML .= "<td class=\"tableheader\"><input type=\"checkbox\" name=\"allFiles\" onClick=\"checkAll('allFiles');\"></td>";
-       }
       $retHTML .=  "<td class=\"tableheader\">Host</td> <td class=\"tableheader\">Name</td> <td class=\"tableheader\">Type</td> <td class=\"tableheader\">backup no.</td> <td class=\"tableheader\">size</td> <td class=\"tableheader\">date</td>  <td class=\"tableheader\">Media</td></tr>";
-      my @files = getFiles($where);
+      my @files = getFiles($where, $offset);
       my $file;
 
-      if ($addForm)
-       {
-           $retHTML .= "<tr>";
-           $retHTML .= "<td colspan=7 style=\"tableheader\">";
-           $retHTML .= "<input type=\"submit\" value=\"Burn selected files on medium\" name=\"submitBurner\">";
-           $retHTML .= "</td>";
-           $retHTML .= "</tr>";
-           
-       }
       foreach $file(@files)
        {
            my $ftype = "";
@@ -373,13 +353,6 @@ EOF3
                  $ftype = "file";
              }
            $retHTML .= "<tr>";
-           if ($addForm)
-             {
-                 $retHTML .= "<td class=\"fview\"> <input type=\"checkbox\" name=\"fcb"
-                   .$file->{'id'}
-                 ."\" value=\"".$file->{'id'}."\"> </td>";
-             }     
-           
            $retHTML .= "<td class=\"fviewborder\">" . $file->{'hname'} ."</td>";
            $retHTML .= "<td class=\"fviewborder\">" . $file->{'fname'} . "</td>";
            $retHTML .= "<td class=\"fviewborder\">" . $ftype . "</td>";
@@ -390,7 +363,21 @@ EOF3
            $retHTML .= "</tr>";
        }
       $retHTML .= "</table>";
-      if ($addForm)
+
+       
+
+      $retHTML .= "<INPUT TYPE=\"hidden\" VALUE=\"\" NAME=\"offset\">";
+      for (my $ii = 1; $ii <= $#files; $ii++)
+      {
+         $retHTML .= "<a href = \"#\" onclick=\"document.forma.offset.value=$ii;document.forma.submit();\">$ii</a>";
+         if ($ii < $#files)
+           {
+               $retHTML .= " | ";
+           }
+      }
+
+
+       if ($addForm)
        {
           $retHTML .= "</form>";
        }