/[BackupPC]/trunk/lib/BackupPC/CGI/SearchArchives.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/BackupPC/CGI/SearchArchives.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 59 - (show annotations)
Sun Aug 21 15:29:24 2005 UTC (18 years, 8 months ago) by dpavlin
File size: 2595 byte(s)
Add permantent serach form using HTML::FillInForm, fixed offset+1 bug,
added no results message

1 ####################################################################
2 # SearchArchives.pm - module for searching through archived files #
3 # via a sqlite database #
4 ####################################################################
5 package BackupPC::CGI::SearchArchives;
6
7
8 use strict;
9 use BackupPC::CGI::Lib qw(:all);
10 use BackupPC::SearchLib;
11 use Data::Dumper;
12 use HTML::FillInForm;
13 use vars qw($Cgi %In $MyURL $User %Conf $TopDir $BinDir $bpc);
14
15 sub action() {
16 my $hosts_html = "";
17
18
19 BackupPC::CGI::Lib::NewRequest();
20 my @hosts = BackupPC::SearchLib::getUnits();
21
22 foreach my $host (@hosts) {
23 $hosts_html .= "<option value=" . $host->{'id'} . "> " . $host->{'share'} . " </option>\n";
24 }
25
26 sub date_from_to_html {
27 my $name = shift || return;
28 return qq{
29 <input type="text" name="${name}_day_from" size="2">
30 <input type="text" name="${name}_month_from" size="2">
31 <input type="text" name="${name}_year_from" size="4">
32 -
33 <input type="text" name="${name}_day_to" size="2">
34 <input type="text" name="${name}_month_to" size="2">
35 <input type="text" name="${name}_year_to" size="4">
36 };
37 }
38
39 my $form .= qq{
40 <form name="searchForm" method="GET" action="$MyURL">
41 <p>
42 Filename:
43 <input type="text" name="search_filename" size="50">
44 &nbsp;
45 on share
46 &nbsp;
47 <select name="search_host">$hosts_html</select>
48 &nbsp;&nbsp;&nbsp;
49 <input type="submit" value="Search">
50 </p>
51
52 <p style="color:gray;">
53 file(s) between:
54 } . date_from_to_html('search') . qq{
55 &nbsp;&nbsp;
56 backups between:
57 } . date_from_to_html('search_backup') . qq{
58 (yyyy-mm-dd)
59 </p>
60
61 <input type="hidden" value="search" name="action">
62 <input type="hidden" value="results" name="search_results">
63 </form>
64 };
65
66 my $html = eval(q{ ${h1("Search")}});
67
68 if ( !defined($In{search_results}) ) {
69 $html .= eval(q{ ${h2("Search criteria")}});
70 $html .= $form;
71 } else {
72 $html .= eval(q{ ${h2("Search results")}});
73 my $fif = new HTML::FillInForm;
74 $html .= $fif->fill(scalarref => \$form, fdat => \%In);
75
76 my ($where, $from_f, $to_f, $from_b, $to_b) = BackupPC::SearchLib::getWhere(\%In);
77
78 my $q = $In{'search_filename'};
79
80 # DEBUG
81 #$html .= "<small>";
82 #$html .= "Filename filter: $q</br>" if ($q);
83 #$html .= "Files date limit: $from_f - $to_f</br>" if ($from_f || $to_f);
84 #$html .= "Backup date limit: $from_b - $to_b</br>" if ($from_b || $to_b);
85 #$html .= "</small>";
86
87 $html .= BackupPC::SearchLib::displayGrid( $where, 1, $In{'offset'}, $q);
88 }
89
90 Header( eval("qq{$Lang->{Search_archive}}"), "", 1, "", $html );
91 Trailer();
92 }
93
94 1;

  ViewVC Help
Powered by ViewVC 1.1.26