mirror of
https://github.com/webmin/webmin.git
synced 2026-03-20 16:50:24 +00:00
Allow linker to specify modules to search
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# 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
|
||||
@@ -19,7 +19,7 @@ order, each as a hash ref with the following keys :
|
||||
=cut
|
||||
sub search_webmin
|
||||
{
|
||||
my ($re, $cbfunc) = @_;
|
||||
my ($re, $cbfunc, $onlymods) = @_;
|
||||
|
||||
# Work out this Webmin's URL base
|
||||
my $urlhost = $ENV{'HTTP_HOST'};
|
||||
@@ -31,10 +31,18 @@ my $urlbase = ($ENV{'HTTPS'} eq 'ON' ? 'https://' : 'http://').$urlhost;
|
||||
# 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
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/usr/local/bin/perl
|
||||
# Search Webmin modules and help pages and text and config.info
|
||||
|
||||
$trust_unknown_referers = 1;
|
||||
BEGIN { push(@INC, ".."); };
|
||||
use WebminCore;
|
||||
|
||||
@@ -23,7 +24,8 @@ $re =~ s/\s+$//;
|
||||
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user