View | Details | Raw Unified | Return to bug 6649
Collapse All | Expand All

(-)a/edithelp.pl (-15 / +16 lines)
Lines 41-47 my $error; Link Here
41
41
42
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
42
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
43
    {
43
    {
44
        template_name   => "help/edithelp.tmpl",
44
        template_name   => "help/edithelp.tt",
45
        query           => $input,
45
        query           => $input,
46
        type            => "intranet",
46
        type            => "intranet",
47
        authnotrequired => 0,
47
        authnotrequired => 0,
Lines 63-91 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
63
63
64
sub _get_filepath ($;$) {
64
sub _get_filepath ($;$) {
65
    my $referer = shift;
65
    my $referer = shift;
66
    $referer =~ /.*koha\/(.+)\.pl.*/;
66
    $referer =~ /koha\/(.*)\.pl/;
67
    my $from   = "help/$1.tmpl";
67
    my $from = "help/$1.tt";
68
    my $htdocs = C4::Context->config('intrahtdocs');
68
    my $htdocs = C4::Context->config('intrahtdocs');
69
    my ($theme, $lang) = themelanguage( $htdocs, $from, "intranet", $input );
69
    my ($theme, $lang) = themelanguage( $htdocs, $from, "intranet", $input );
70
	$debug and print STDERR "help filepath: $htdocs/$theme/$lang/modules/$from";
70
	$debug and print STDERR "help filepath: $htdocs/$theme/$lang/modules/$from";
71
	return "$htdocs/$theme/$lang/modules/$from";
71
	return "$htdocs/$theme/$lang/modules/$from";
72
}
72
}
73
73
74
if ( $type eq 'addnew' ) {
74
$type = 'create' if $type eq 'addnew';
75
    $type = 'create';
75
if ( $type eq 'create' || $type eq 'save' ) {
76
}
77
elsif ( $type eq 'create' || $type eq 'save' ) {
78
	my $file = _get_filepath($referer);
76
	my $file = _get_filepath($referer);
79
	unless (open (OUTFILE, ">$file")) {$error = "Cannot write file: '$file'";} else {
77
    open my $fh, ">", $file;
80
        #open (OUTFILE, ">$file") or die "Cannot write file: '$file'";	# unlikely death, since we just checked
78
    if ( $fh ) {
81
        # file is open write to it
79
        # file is open write to it
82
        print OUTFILE "<!-- TMPL_INCLUDE NAME=\"help-top.inc\" -->\n";
80
        print $fh
83
		print OUTFILE ($type eq 'create') ? "<div class=\"main\">\n$help\n</div>" : $help;
81
            " [% INCLUDE 'help-top.inc' %]\n",
84
        print OUTFILE "\n<!-- TMPL_INCLUDE NAME=\"help-bottom.inc\" -->\n";
82
		    $type eq 'create' ? "<div class=\"main\">\n$help\n</div>" : $help,
85
        close OUTFILE;
83
            "\n[% INCLUDE 'help-bottom.inc' %]\n";
84
        close $fh;
86
		print $input->redirect("/cgi-bin/koha/help.pl?url=$oldreferer");
85
		print $input->redirect("/cgi-bin/koha/help.pl?url=$oldreferer");
87
    }
86
    }
88
    
87
    else {
88
        $error = "Cannot write file: '$file'";
89
    }
89
}
90
}
90
elsif ( $type eq 'modify' ) {
91
elsif ( $type eq 'modify' ) {
91
    # open file load data, kill include calls, pass data to the template
92
    # open file load data, kill include calls, pass data to the template
Lines 98-104 elsif ( $type eq 'modify' ) { Link Here
98
    	open (INFILE, $file) or die "Cannot read file '$file'";		# unlikely death, since we just checked
99
    	open (INFILE, $file) or die "Cannot read file '$file'";		# unlikely death, since we just checked
99
		my $help = '';
100
		my $help = '';
100
		while ( my $inp = <INFILE> ) {
101
		while ( my $inp = <INFILE> ) {
101
			unless ( $inp =~ /TMPL\_INCLUDE/ ) {
102
			unless ( $inp =~ /INCLUDE/ ) {
102
				$help .= $inp;
103
				$help .= $inp;
103
			}
104
			}
104
		}
105
		}
(-)a/help.pl (-2 / +2 lines)
Lines 28-34 use CGI; Link Here
28
my $query = new CGI;
28
my $query = new CGI;
29
29
30
# find the script that called the online help using the CGI referer()
30
# find the script that called the online help using the CGI referer()
31
our $refer = $query->referer();
31
our $refer = $query->param('url') || $query->referer();
32
32
33
$refer =~ /koha\/(.*)\.pl/;
33
$refer =~ /koha\/(.*)\.pl/;
34
my $from = "modules/help/$1.tt";
34
my $from = "modules/help/$1.tt";
Lines 40-45 unless ( -e "$htdocs/$theme/$lang/$from" ) { Link Here
40
    ( $theme, $lang ) = themelanguage( $htdocs, $from, "intranet", $query );
40
    ( $theme, $lang ) = themelanguage( $htdocs, $from, "intranet", $query );
41
}
41
}
42
my $template = C4::Templates->new('intranet', "$htdocs/$theme/$lang/$from");
42
my $template = C4::Templates->new('intranet', "$htdocs/$theme/$lang/$from");
43
$template->param( referer => $refer );
43
44
44
output_html_with_http_headers $query, "", $template->output;
45
output_html_with_http_headers $query, "", $template->output;
45
46
46
- 

Return to bug 6649