# 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 $pn = &get_product_name();
-my @mods = sort { $b->{'longdesc'} cmp $a->{'longdesc'} }
- grep { !$_->{'clone'} }
- grep { !$_->{'noui'} && !$_->{$pn.'_noui'} }
- &get_available_module_infos();
+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