From 4727bc68c05d61385c0c5e34f32ace1361b48892 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sun, 20 Nov 2005 01:50:47 +0000 Subject: [PATCH] r8984@llin: dpavlin | 2005-11-20 02:51:47 +0100 drop down to select template git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@72 07558da8-63fa-0310-ba24-9fe276d99e06 --- web/browse.cgi | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/web/browse.cgi b/web/browse.cgi index 3981a86..0ea35b9 100755 --- a/web/browse.cgi +++ b/web/browse.cgi @@ -18,7 +18,9 @@ my $abs_path = abs_path($0); $abs_path =~ s#/[^/]*$#/../#; my $db_path = $abs_path . '/db/'; -my $template_file = 'html_ffzg.tt'; +my $template_path = "$abs_path/conf/output/tt"; +opendir(my $dir, $template_path) || die "can't open template path $template_path: $!"; +my @templates = grep { /\.tt$/i } readdir($dir); my $css_file = 'user.css'; my $iconv_utf8 = new Text::Iconv('ISO-8859-2', 'UTF-8'); @@ -31,7 +33,7 @@ my $db = new WebPAC::DB( ); my $out = new WebPAC::Output::TT( - include_path => "$abs_path/conf/output/tt", + include_path => $template_path, filters => { foo => sub { shift } }, ); @@ -39,6 +41,7 @@ my $q = new CGI::Simple; my $self = $q->url( '-path_info'=>1, '-query'=>0, '-full'=>0 ); my $rec = $q->param('rec') || 1; +my $template_filename = $q->param('template') || $templates[0]; print $q->header( -charset => 'utf-8' ); @@ -82,7 +85,7 @@ if ($q->path_info =~ m#xml#) { print qq{ }, $iconv_utf8->convert( $out->apply( - template => $template_file, + template => $template_filename, data => $ds, ) ), qq{ @@ -117,7 +120,7 @@ if ($q->path_info =~ m#xml#) { } elsif ($q->path_info =~ m#template#) { - my $template_path = $out->{'include_path'} . '/' . $template_file; + my $template_path = $out->{'include_path'} . '/' . $template_filename; if ($q->param('save_template')) { @@ -125,7 +128,7 @@ if ($q->path_info =~ m#xml#) { print qq{ -$template_file saved +$template_filename saved