Add support for template variables to help pages
This commit is contained in:
parent
4021b6d8bb
commit
e60be7133b
31
help.cgi
31
help.cgi
@ -10,24 +10,41 @@ use WebminCore;
|
||||
$ENV{'PATH_INFO'} !~ /[\\\&\;\`\'\"\|\*\?\~\<\>\^\(\)\[\]\{\}\$\n\r]/ ||
|
||||
&error($text{'help_epath'});
|
||||
$ENV{'PATH_INFO'} =~ /^\/(\S+)\/(\S+)$/ || &error($text{'help_epath'});
|
||||
$module = $1; $file = $2;
|
||||
my $module = $1;
|
||||
my $file = $2;
|
||||
&ReadParse();
|
||||
|
||||
# if it ends with .gif assume it is a direct URL
|
||||
if ($file =~ /\.(gif|jpg|jpeg|png)$/i) {
|
||||
&redirect("$module/$file");
|
||||
exit;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
# read the help file
|
||||
$help = &read_help_file($module, $file);
|
||||
my $help = &read_help_file($module, $file);
|
||||
$help || &helperror(&text('help_efile3',
|
||||
&html_escape($file), &html_escape($module)));
|
||||
my %hash;
|
||||
|
||||
# Modify help file based on module
|
||||
if (&foreign_exists($module) &&
|
||||
&foreign_require($module) &&
|
||||
&foreign_defined($module, 'help_pre_load')) {
|
||||
$help = &foreign_call($module, "help_pre_load", $help);
|
||||
&foreign_require($module)) {
|
||||
if (&foreign_defined($module, 'help_pre_load')) {
|
||||
$help = &foreign_call($module, "help_pre_load", $help);
|
||||
}
|
||||
if (&foreign_defined($module, 'help_template')) {
|
||||
%hash = &foreign_call($module, "help_template");
|
||||
}
|
||||
}
|
||||
|
||||
# if any template variables were given as URL params, substitute them into the file
|
||||
foreach my $k (keys %in) {
|
||||
if ($k =~ /^tmpl_(\S+)$/i) {
|
||||
$hash{$1} = $in{$k};
|
||||
}
|
||||
}
|
||||
if (%hash) {
|
||||
$help = &substitute_template($help, \%hash);
|
||||
}
|
||||
|
||||
# find and replace the <header> section
|
||||
|
@ -1721,8 +1721,6 @@ of the subtext parameter :
|
||||
|
||||
=item below - HTML to be displayed below the title. Typically this is used for application or server version information.
|
||||
|
||||
|
||||
|
||||
=cut
|
||||
sub ui_print_header
|
||||
{
|
||||
|
@ -4079,13 +4079,15 @@ The actual help pages are in each module's help sub-directory, in files with
|
||||
=cut
|
||||
sub hlink
|
||||
{
|
||||
my ($txt, $page, $mod, $width, $height, $tmpl) = @_;
|
||||
$mod ||= &get_module_name();
|
||||
if (defined(&theme_hlink)) {
|
||||
return &theme_hlink(@_);
|
||||
}
|
||||
my $mod = $_[2] ? $_[2] : &get_module_name();
|
||||
my $width = $_[3] || $tconfig{'help_width'} || $gconfig{'help_width'} || 600;
|
||||
my $height = $_[4] || $tconfig{'help_height'} || $gconfig{'help_height'} || 400;
|
||||
return "<a onClick='window.open(\"@{[&get_webprefix()]}/help.cgi/$mod/$_[1]\", \"help\", \"toolbar=no,menubar=no,scrollbars=yes,width=$width,height=$height,resizable=yes\"); return false' href=\"@{[&get_webprefix()]}/help.cgi/$mod/$_[1]\">$_[0]</a>";
|
||||
$width ||= $tconfig{'help_width'} || $gconfig{'help_width'} || 600;
|
||||
$height ||= $tconfig{'help_height'} || $gconfig{'help_height'} || 400;
|
||||
my $params = $tmpl ? join("&", map { "tmpl_".&urlize($_)."=".&urlize($tmpl->{$_}) } keys %$tmpl) : "";
|
||||
return "<a onClick='window.open(\"@{[&get_webprefix()]}/help.cgi/$mod/$page?$params\", \"help\", \"toolbar=no,menubar=no,scrollbars=yes,width=$width,height=$height,resizable=yes\"); return false' href=\"@{[&get_webprefix()]}/help.cgi/$mod/$page?$params\">$txt</a>";
|
||||
}
|
||||
|
||||
=head2 user_chooser_button(field, multiple, [form])
|
||||
|
Loading…
x
Reference in New Issue
Block a user