/\n\n/gi;
$data =~ s/
/\n/gi;
$data =~ s/<[^>]+>//g;
if ($data =~ /\Q$re\E/i) {
&match_row(
$m,
&hlink($title, $page, $m->{'dir'}),
$text{'wsearch_help'},
$data,
1,
);
}
}
}
closedir(DIR);
}
# Then do text strings
MODULE: foreach $m (@mods) {
%mtext = &load_language($m->{'dir'});
foreach $k (keys %mtext) {
if ($mtext{$k} =~ /\Q$re\E/i) {
@cgis = &find_cgi_text(
[ "\$text{'$k'}",
"\$text{\"$k\"}",
"\$text{$k}" ], $m);
if (@cgis == 0) {
$link = "$m->{'desc'}";
}
else {
$link = &ui_links_row([
map { "$_" } @cgis ]);
$link =~ s/
//;
}
&match_row(
$m,
$link,
$text{'wsearch_text'},
$mtext{$k},
@cgis ? 1 : 0,
);
#next MODULE;
}
}
}
if (!$count) {
print "",&text('wsearch_enone',
"".&html_escape($re).""),"
\n";
}
&ui_print_footer();
# Returns text with the search term bolded, and truncated to 60 characters
sub highlight_text
{
local ($str, $len) = @_;
$len ||= 90;
local $hlen = $len / 2;
if ($str =~ /(.*)(\Q$re\E)(.*)/i) {
local ($before, $match, $after) = ($1, $2, $3);
if (length($before) > $hlen) {
$before = "...".substr($before, length($before)-$hlen);
}
if (length($after) > $hlen) {
$after = substr($after, 0, $hlen)."...";
}
$str = $before."".&html_escape($match)."".$after;
}
return $str;
}
sub match_row
{
local ($m, $link, $what, $text, $module_link) = @_;
print "$link\n";
if ($module_link) {
print " (".&text('wsearch_inmod',
"$m->{'desc'}").")";
}
print "
\n";
if ($text) {
print &highlight_text($text),"
\n";
}
print "$m->{'desc'} - $what
\n";
$count++;
}
# find_cgi_text(®exps, module)
# Returns the relative URLs of CGIs that matches some regexps, in the given
# module.
sub find_cgi_text
{
local ($res, $m) = @_;
local $mdir = &module_root_directory($m);
local @rv;
foreach my $f (glob("$mdir/*.cgi")) {
local $found = 0;
open(CGI, $f);
LINE: while(my $line =