3 # Search help for the selected modules and display the results
5 require './help-lib.pl';
7 &error_setup($text{'search_err'});
9 # Parse and validate inputs
10 $in{'terms'} || &error($text{'search_eterms'});
12 @mods = map { $_->[0] } &list_modules();
15 $in{'mods'} || &error($text{'search_emods'});
16 @mods = split(/\0/, $in{'mods'});
19 &ui_print_header(undef, $text{'search_title'}, "", "search");
22 ($terms = $in{'terms'}) =~ s/\\/\\\\/g;
24 local %minfo = &get_module_info($m);
25 local $dir = "../$m/help";
28 while($f = readdir(DIR)) {
29 push(@pfx, $1) if ($f =~ /^([^\.]+)\.html$/);
32 foreach $p (&unique(@pfx)) {
33 local $file = &help_file($dir, $p);
35 local @st = stat($file);
36 read(HELP, $help, $st[7]);
38 if ($help =~ /<header>([^<]+)<\/header>/) {
42 $help =~ s/<include\s+(\S+)>/inchelp($1)/ge;
43 $help =~ s/<[^>]+>//g;
44 if ($help =~ /(.*)(\Q$terms\E)(.*)/i) {
45 push(@match, [ $m, $minfo{'desc'}, $p,
46 $header, "$1<b>$2</b>$3" ] );
53 print "<b>",&text('search_results', "<tt>$terms</tt>"),"</b><p>\n";
54 print "<table border width=100%>\n";
55 print "<tr $tb> <td><b>$text{'search_page'}</b></td> ",
56 "<td><b>$text{'search_mod'}</b></td> ",
57 "<td><b>$text{'search_line'}</b></td> </tr>\n";
60 print "<td>",&hlink($m->[3], $m->[2], $m->[0]),"</td>\n";
61 print "<td>$m->[1]</td>\n";
62 print "<td>$m->[4]</td>\n";
65 print "</table><p>\n";
68 print "<p><b>$text{'search_none'}</b> <p>\n";
70 &ui_print_footer("", $text{'index_return'});
73 # help_file(dir, prefix)
76 local $lang = "$_[0]/$_[1].$current_lang.html";
77 local $def = "$_[0]/$_[1].html";
78 return -r $lang ? $lang : $def;
85 local $ipath = &help_file($dir, $_[0]);
86 open(INC, $ipath) || return "<i>".&text('search_einclude', $_[0])."</i><br>\n";
87 local @st = stat(INC);
88 read(INC, $inc, $st[7]);