fixing acqui-search.pl
[koha.git] / help.pl
1 #!/usr/bin/perl
2
3 use strict;
4 use HTML::Template::Pro;
5
6 use C4::Output;    # contains gettemplate
7 # use C4::Auth;
8 use C4::Context;
9 use CGI;
10
11 my $query = new CGI;
12
13 # find the script that called the online help using the CGI referer()
14 our $refer = $query->referer();
15
16 # workaround for popup not functioning correctly in IE
17 my $referurl = $query->param('url');
18 if ($referurl) {
19     $refer = $query->param('url');
20 }
21
22 $refer =~ /.*koha\/(.*)\.pl.*/;
23 my $from = "modules/help/$1.tmpl";
24
25 my $template = gethelptemplate( $from, "intranet" );
26
27 # my $template
28 output_html_with_http_headers $query, "", $template->output;
29
30 sub gethelptemplate {
31     my ($tmplbase) = @_;
32
33     my $htdocs;
34     $htdocs = C4::Context->config('intrahtdocs');
35     my ( $theme, $lang ) = themelanguage( $htdocs, $tmplbase, "intranet", $query );
36     unless ( -e "$htdocs/$theme/$lang/$tmplbase" ) {
37         $tmplbase = "modules/help/nohelp.tmpl";
38         ( $theme, $lang ) = themelanguage( $htdocs, $tmplbase, "intranet", $query );
39     }
40     my $template = HTML::Template::Pro->new(
41         filename          => "$htdocs/$theme/$lang/$tmplbase",
42         die_on_bad_params => 0,
43         global_vars       => 1,
44         path              => ["$htdocs/$theme/$lang/includes"]
45     );
46
47     # XXX temporary patch for Bug 182 for themelang
48     $template->param(
49         themelang => '/intranet-tmpl' . "/$theme/$lang",
50         interface => '/intranet-tmpl',
51         theme     => $theme,
52         lang      => $lang,
53         intranetcolorstylesheet =>
54           C4::Context->preference("intranetcolorstylesheet"),
55         intranetstylesheet => C4::Context->preference("intranetstylesheet"),
56         IntranetNav        => C4::Context->preference("IntranetNav"),
57                 yuipath => (C4::Context->preference("yuipath") eq "local"?"/intranet-tmpl/$theme/$lang/lib/yui":C4::Context->preference("yuipath")),
58         referer            => $refer,
59     );
60     return $template;
61 }