changing permissions on templates and scripts
[koha.git] / help.pl
1 #!/usr/bin/perl
2
3 # Copyright 2006 Katipo Communications
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
10 # version.
11 #
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA  02111-1307 USA
19
20 use strict;
21 require Exporter;
22 use C4::Output;    # contains gettemplate
23 use C4::Output;
24
25 # use C4::Auth;
26 use C4::Context;
27 use CGI;
28
29 my $query = new CGI;
30
31 # find the script that called the online help using the CGI referer()
32
33 my $refer = $query->referer();
34
35 # workaround for popup not functioning correctly in IE
36 my $referurl = $query->param('url');
37 if ($referurl) {
38     $refer = $query->param('url');
39 }
40
41 $refer =~ /.*koha\/(.*)\.pl.*/;
42 my $from = "help/$1.tmpl";
43
44 my $template = gethelptemplate( $from, "intranet" );
45
46 # my $template
47 output_html_with_http_headers $query, "", $template->output;
48
49 sub gethelptemplate {
50     my ($tmplbase) = @_;
51
52     my $htdocs;
53     $htdocs = C4::Context->config('intrahtdocs');
54     my ( $theme, $lang ) = themelanguage( $htdocs, $tmplbase, "intranet" );
55     unless ( -e "$htdocs/$theme/$lang/$tmplbase" ) {
56         $tmplbase = "help/nohelp.tmpl";
57         ( $theme, $lang ) = themelanguage( $htdocs, $tmplbase, "intranet" );
58     }
59     my $template = HTML::Template->new(
60         filename          => "$htdocs/$theme/$lang/$tmplbase",
61         die_on_bad_params => 0,
62         global_vars       => 1,
63         path              => ["$htdocs/$theme/$lang/includes"]
64     );
65
66     # XXX temporary patch for Bug 182 for themelang
67     $template->param(
68         themelang => '/intranet-tmpl' . "/$theme/$lang",
69         interface => '/intranet-tmpl',
70         theme     => $theme,
71         lang      => $lang
72     );
73     return $template;
74 }