--- trunk/web/browse.cgi 2005/11/14 16:15:27 49 +++ trunk/web/browse.cgi 2005/11/14 16:16:57 54 @@ -1,9 +1,13 @@ #!/usr/bin/perl -w +use strict; + use Cwd qw/abs_path/; use CGI::Carp qw(fatalsToBrowser); use CGI::Simple; use File::Slurp; +use Data::Dumper; +use Text::Iconv; use lib '../lib'; @@ -16,6 +20,9 @@ my $db_path = $abs_path . '/db/'; my $template = 'html_ffzg.tt'; +my $iconv_utf8 = new Text::Iconv('ISO-8859-2', 'UTF-8'); +my $iconv_loc = new Text::Iconv('UTF-8', 'ISO-8859-2'); + my $db = new WebPAC::DB( path => $db_path, read_only => 1, @@ -32,7 +39,7 @@ my $rec = $q->param('rec') || 1; -print $q->header; +print $q->header( -charset => 'utf-8' ); if ($q->path_info =~ m#xml#) { @@ -79,18 +86,58 @@ } elsif ($q->path_info =~ m#template#) { - my $tmpl = read_file($out->{'include_path'} . '/' . $template); - $tmpl = $q->escapeHTML($tmpl); + my @actions; + + if ($q->param('save_template')) { + + my $tmpl = $q->param('tt_template') || die "no template?"; + my $tmpl_file = $out->{'include_path'} . '/' . $template; + write_file($tmpl_file . '.new', $iconv_loc->convert($tmpl)) || die "can't save $tmpl_file: $!"; + rename $tmpl_file . '.new', $tmpl_file || die "can't rename to $tmpl_file: $!"; + + print qq{ + +$template saved + + + + + + }; + exit; + + } + + my $tmpl = read_file($out->{'include_path'} . '/' . $template) || die "can't read template $template: $!"; + $tmpl = $q->escapeHTML($iconv_utf8->convert($tmpl)); print qq{ - -
+ +
+ + +idle + + + +
-}; + }; + + exit; } else { print qq{ @@ -145,6 +192,7 @@ db_path = $db_path
+template = $template
@@ -156,6 +204,7 @@       +