--- trunk/web/browse.cgi 2005/11/14 16:14:49 47
+++ trunk/web/browse.cgi 2005/11/15 14:30:11 57
@@ -1,8 +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';
@@ -13,6 +18,10 @@
$abs_path =~ s#/[^/]*$#/../#;
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,
@@ -30,39 +39,104 @@
my $rec = $q->param('rec') || 1;
-print $q->header;
+print $q->header( -charset => 'utf-8' );
if ($q->path_info =~ m#xml#) {
my @ds = $db->load_ds($rec);
- if (@ds) {
+ if (@ds && $#ds > 0) {
print qq{
-
+
}, $out->apply(
- template => 'html_ffzg.tt',
+ template => $template,
data => \@ds,
), qq{
-
-
};
exit;
} else {
- print qq{
- Record $rec not found!
- };
+ print qq{
+
+
+Record $rec not found!
+
+
+
+
+
+};
+ exit;
}
+} elsif ($q->path_info =~ m#template#) {
+
+ 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{
+
+}, Dumper($q->Vars), qq{
+
+
+
+
+ };
+
+ exit;
+
} else {
print qq{
@@ -78,15 +152,14 @@
var url = '$self';
function update_status(text) {
- var el = iwfGetById('divRecordNr');
+ var el = iwfGetById('div_record_nr');
if (el) el.innerHTML = text;
}
-
function load_rec(nr) {
update_status(nr+'...');
- iwfRequest( url+'/xml/?rec='+nr, 'divRecord' );
- iwfOpacity('divRecord', 30);
+ iwfRequest( url+'/xml/?rec='+nr, 'div_record' );
+ iwfOpacity('div_record', 30);
}
function inc_rec() {
@@ -106,24 +179,41 @@
return false;
}
+function init_page() {
+ load_rec(rec);
+ // load template
+ iwfRequest( url+'/template/', 'div_template' );
+}
+
-
+
db_path = $db_path
+template = $template
+
+
+
⇦
-
none
+
none
⇨
↺
+
▤
+
-
+
+ no template loaded yet.
+
+
+
no record loaded yet.
+
};