Fix to factor out read_help_file sub to be accessible by theme

This commit is contained in:
iliajie
2023-05-06 12:01:06 +03:00
parent 9a29c6f98e
commit 4e96552b03
3 changed files with 40 additions and 37 deletions

View File

@ -59,42 +59,6 @@ $help =~ s/<if\s+([^>]*)>([\000-\177]*?)<\/if>/ifhelp($1, $2)/ige;
print $help;
&popup_footer();
# read_help_file(module, file)
# Reads the contents of a help file, either unpacked or from a ZIP
sub read_help_file
{
my ($module, $file) = @_;
my $path = &help_file($module, $file);
if (-r $path) {
return &read_file_contents($path);
}
my $gzpath = $path.".gz";
if (-r $gzpath) {
my $out = &backquote_command(
"gunzip -c ".quotemeta($gzpath)." 2>/dev/null");
return $? ? undef : $out;
}
my $zip = $path;
$zip =~ s/\/[^\/]+$/\/help.zip/;
if (-r $zip) {
my @files;
foreach my $o (@lang_order_list) {
next if ($o eq "en");
push(@files, $file.".".$o.".auto.html");
push(@files, $file.".".$o.".html");
}
push(@files, $file.".html");
foreach my $f (@files) {
my $out = &backquote_command(
"unzip -p ".quotemeta($zip)." ".
quotemeta($f)." 2>/dev/null");
return $out if ($out && !$?);
}
return undef;
}
return undef;
}
# inchelp(path)
sub inchelp
{