# 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 = @$onlymods;
+ }
+else {
+ # All reasonabel modules
+ @mods = grep { !$_->{'clone'} }
+ grep { !$_->{'noui'} && !$_->{$pn.'_noui'} }
+ &get_available_module_infos();
+ }
+@mods = sort { $b->{'longdesc'} cmp $a->{'longdesc'} } @mods;
foreach my $m (@mods) {
if ($m->{'desc'} =~ /\Q$re\E/i) {
# Module description match
#!/usr/local/bin/perl
# Search Webmin modules and help pages and text and config.info
+$trust_unknown_referers = 1;
BEGIN { push(@INC, ".."); };
use WebminCore;
# Do the search
print &text('wsearch_searching', "<i>".&html_escape($re)."</i>"),"\n";
-@rv = &search_webmin($re, \&print_search_dot);
+@rv = &search_webmin($re, \&print_search_dot,
+ $in{'mod'} ? [ split(/\0/, $in{'mod'}) ] : undef);
print &text('wsearch_found', scalar(@rv)),"<p>\n";
# Show in table