3 # Copyright 2007 Liblime Ltd
5 # This file is part of Koha.
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
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.
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
27 my $type = $input->param('type');
28 my $referer = $input->param('referer');
29 my $oldreferer = $referer;
30 my $help = $input->param('help');
33 my ( $template, $loggedinuser, $cookie ) = get_template_and_user
(
35 template_name
=> "help/edithelp.tmpl",
45 reserveforothers
=> 1,
55 if ( $type eq 'addnew' ) {
58 elsif ( $type eq 'create' || $type eq 'save' ) {
59 $referer =~ /.*koha\/(.*)\
.pl
.*/;
60 my $from = "help/$1.tmpl";
61 my $htdocs = C4
::Context
->config('intrahtdocs');
62 # my ( $theme, $lang ) = themelanguage( $htdocs, $from, "intranet" );
63 my $theme = C4
::Context
->preference('template');
64 my $lang = C4
::Context
->preference('language') || 'en';
66 # if (! -e "$htdocs/$theme/$lang/$from") {
69 open( OUTFILE
, ">$htdocs/$theme/$lang/modules/$from" ) || die "Can't open file";
72 $error = "Cant open file $htdocs/$theme/$lang/modules/$from";
76 # file is open write to it
77 print OUTFILE
"<!-- TMPL_INCLUDE name=\"help-top.inc\" -->\n";
78 if ($type eq 'create'){
79 print OUTFILE
"<div class=\"main\">\n";
81 print OUTFILE
"$help\n";
82 if ($type eq 'create'){
83 print OUTFILE
"</div>\n";
85 print OUTFILE
"<!-- TMPL_INCLUDE name=\"help-bottom.inc\" -->\n";
87 print $input->redirect("/cgi-bin/koha/help.pl?url=$oldreferer");
94 elsif ( $type eq 'modify' ) {
96 # open file load data, kill include calls, pass data to the template
97 $referer =~ /.*koha\/(.*)\
.pl
.*/;
98 my $from = "help/$1.tmpl";
99 my $htdocs = C4
::Context
->config('intrahtdocs');
100 my ( $theme, $lang ) = themelanguage
( $htdocs, $from, "intranet" );
102 open( INFILE
, "$htdocs/$theme/$lang/modules/$from" ) || die "Can't open file";
105 $error = "Cant open file $htdocs/$theme/$lang/modules/$from";
108 while ( my $inp = <INFILE
> ) {
109 if ( $inp =~ /TMPL\_INCLUDE/ ) {
116 $template->param( 'help' => $help );
122 'referer' => $referer,
128 output_html_with_http_headers
$input, "", $template->output;