# Functions for searching the webmin docs and UI
-=head2 search_webmin(phrase, [callback-function])
+=head2 search_webmin(phrase, [callback-function], [&modules])
Searches all Webmin help pages, UI text, module names and config.info files
for entries matching the given phrase or word. Returns them sorted by relevance
=cut
sub search_webmin
{
-my ($re, $cbfunc) = @_;
+my ($re, $cbfunc, $onlymods) = @_;
# Work out this Webmin's URL base
my $urlhost = $ENV{'HTTP_HOST'};
# Search module names and add to results list
my @rv = ( );
-my @mods = sort { $b->{'longdesc'} cmp $a->{'longdesc'} }
- grep { !$_->{'clone'} } &get_available_module_infos();
+my $pn = &get_product_name();
+my @mods;
+if ($onlymods) {
+ # Modules specified by caller
+ @mods = grep { &foreign_available($_->{'dir'}) } @$onlymods;
+ }
+else {
+ # All reasonable modules
+ @mods = &get_available_module_infos();
+ }
+@mods = grep { !$_->{'clone'} }
+ grep { !$_->{'noui'} && !$_->{$pn.'_noui'} } @mods;
+@mods = sort { $b->{'longdesc'} cmp $a->{'longdesc'} } @mods;
foreach my $m (@mods) {
if ($m->{'desc'} =~ /\Q$re\E/i) {
# Module description match
'link' => $m->{'dir'}.'/',
'text' => $m->{'desc'} });
}
+ elsif ($m->{'longdesc'} =~ /\Q$re\E/i) {
+ # Module long description match
+ push(@rv, { 'mod' => $m,
+ 'rank' => 9.5,
+ 'type' => 'mod',
+ 'link' => $m->{'dir'}.'/',
+ 'text' => $m->{'longdesc'} });
+ }
elsif ($m->{'dir'} =~ /\Q$re\E/i) {
# Module directory match
push(@rv, { 'mod' => $m,
local %mtext = &load_language($m);
$rv = $mtext{$msg};
}
-elsif ($data =~ /(^|\s)header\(\s*(\$text{'([^']+)'|\$text{"([^"]+)"|\&text\('([^']+)'|\&text\("([^"]+)")/) {
+elsif ($data =~ /(^|\s|mail_page_)header\(\s*(\$text{'([^']+)'|\$text{"([^"]+)"|\&text\('([^']+)'|\&text\("([^"]+)")/) {
# Old header function
local $msg = $3 || $4 || $5 || $6;
local %mtext = &load_language($m);