OMatic/searchForm.pm untested

filter: Statementstmt 0.0% 0 / 68 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 103 CC 13 SCAR 48.3
CC
13
Cov
0%
main
182.0
BEGIN
2.0
BEGIN
2.0
CRAP 125.2
1 ##############################################################################
2 # The Faq-O-Matic is Copyright 1997 by Jon Howell, all rights reserved. #
3 # #
4 # This program is free software; you can redistribute it and/or #
5 # modify it under the terms of the GNU General Public License #
6 # as published by the Free Software Foundation; either version 2 #
7 # of the License, or (at your option) any later version. #
8 # #
9 # This program is distributed in the hope that it will be useful, #
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
12 # GNU General Public License for more details. #
13 # #
14 # You should have received a copy of the GNU General Public License #
15 # along with this program; if not, write to the Free Software #
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.#
17 # #
18 # Jon Howell can be contacted at: #
19 # 6211 Sudikoff Lab, Dartmouth College #
20 # Hanover, NH 03755-3510 #
21 # jonh@cs.dartmouth.edu #
22 # #
23 # An electronic copy of the GPL is available at: #
24 # http://www.gnu.org/copyleft/gpl.html #
25 # #
26 ##############################################################################
27  
28 use strict;
29  
30 package FAQ::OMatic::searchForm;
31  
32 use CGI;
33 use FAQ::OMatic;
34 use FAQ::OMatic::I18N;
35 use FAQ::OMatic::HelpMod;
36 use FAQ::OMatic::SearchMod;
37  
38 sub main {
39 my $cgi = FAQ::OMatic::dispatch::cgi();
40
41 my $params = FAQ::OMatic::getParams($cgi);
42  
43 my $page = '';
44  
45 $page.=FAQ::OMatic::pageHeader($params, ['help', 'faq']);
46  
47 my $useTable = not $params->{'simple'};
48  
49 my $labelColor = $FAQ::OMatic::Config::regularPartColor || '#ffff0f';
50 my $labelColorCmd = "bgcolor=\"$labelColor\"";
51 $page.="<table width=\"100%\">\n" if $useTable;
52 $page.="<tr><td $labelColorCmd>\n" if $useTable;
53 $page.=gettext("search for keywords");
54 $page.="</td></tr>\n" if $useTable;
55 $page.="<tr><td valign=top>\n" if $useTable;
56 $page .= FAQ::OMatic::makeAref('search', {}, 'GET');
57 $page .= "<input type=\"submit\" name=\"_submit\" "
58 ."value=\"".gettext("Search for")."\">\n";
59 $page .= "<input type=\"text\" name=\"_search\"> ".gettext("matching")."\n";
60 $page .= "<select name=\"_minMatches\">\n";
61 $page .= "<option value=\"\">".gettext("all")."\n";
62 $page .= "<option value=\"1\">".gettext("any")."\n";
63 $page .= "<option value=\"2\">".gettext("two")."\n";
64 $page .= "<option value=\"3\">".gettext("three")."\n";
65 $page .= "<option value=\"4\">".gettext("four")."\n";
66 $page .= "<option value=\"5\">".gettext("five")."\n";
67 $page .= "</select>\n";
68 $page .= gettext("words").".\n";
69 $page .= "</form>\n";
70 $page.="</td></tr>\n" if $useTable;
71 $page.="</table>\n" if $useTable;
72  
73 ## Recent documents
74 $page.="<table width=\"100%\">\n" if $useTable;
75 $page.="<tr><td $labelColorCmd>\n" if $useTable;
76 $page.=gettext("search for recent changes");
77 $page.="</td></tr>\n" if $useTable;
78 $page.="<tr><td valign=top>\n" if $useTable;
79 $page .= FAQ::OMatic::makeAref('recent',
80 {'showLastModified'=>'show'}, 'GET');
81 $page .= "<input type=\"submit\" name=\"_submit\" "
82 ."value=\"".gettext("Show documents")."\">\n";
83 $page .= " ".gettext("modified in the last")." \n";
84 $page .= "<select name=\"_duration\">\n";
85 my $recentMap = FAQ::OMatic::SearchMod::getRecentMap();
86 foreach my $numDays (sort {$a <=> $b} keys %$recentMap) {
87 # default to "week"
88 my $selected = ($numDays == 7) ? " SELECTED" : "";
89 $page .= "<option value=\"${numDays}\"${selected}>"
90 .gettext($recentMap->{$numDays}).".\n";
91 }
92 $page .= "</select>\n";
93 $page .= "</form>\n";
94 $page.="</td></tr></table>\n" if $useTable;
95  
96 # $page.=FAQ::OMatic::button(
97 # FAQ::OMatic::makeAref('-command'=>''),
98 # 'Return to the FAQ')."<br>\n";
99  
100 $page.=FAQ::OMatic::HelpMod::helpFor($params,
101 'Search Tips', "<br>");
102  
103 $page.= FAQ::OMatic::pageFooter($params, ['help','faq']);
104  
105 print $page;
106 }
107  
108 1;