6 use CGI::Carp qw(fatalsToBrowser);
15 use WebPAC::Output::TT;
17 my $abs_path = abs_path($0);
18 $abs_path =~ s#/[^/]*$#/../#;
20 my $db_path = $abs_path . '/db/';
21 my $template = 'html_ffzg.tt';
23 my $iconv_utf8 = new Text::Iconv('ISO-8859-2', 'UTF-8');
24 my $iconv_loc = new Text::Iconv('UTF-8', 'ISO-8859-2');
26 my $db = new WebPAC::DB(
32 my $out = new WebPAC::Output::TT(
33 include_path => "$abs_path/conf/output/tt",
34 filters => { foo => sub { shift } },
37 my $q = new CGI::Simple;
38 my $self = $q->url( '-path_info'=>1, '-query'=>0, '-full'=>0 );
40 my $rec = $q->param('rec') || 1;
42 print $q->header( -charset => 'utf-8' );
44 if ($q->path_info =~ m#xml#) {
46 my @ds = $db->load_ds($rec);
48 if (@ds && $#ds > 0) {
50 <action type='html' target='div_record' errorCode='' errorMessage='' >
51 }, $iconv_utf8->convert( $out->apply(
52 template => $template,
57 <action type='javascript' errorCode='' errorMessage='' >
59 var el = iwfGetById('div_record_nr');
60 if (el) el.innerHTML = '# <b>$rec</b>';
61 //iwfShow('div_record');
62 iwfOpacity('div_record', 100);
70 <action type='html' target='div_record' errorCode='' errorMessage='' >
72 <b>Record $rec not found!</b>
74 <action type='javascript' errorCode='' errorMessage='' >
76 var el = iwfGetById('div_record_nr');
77 if (el) el.innerHTML = '<strike> $rec </strike>';
85 } elsif ($q->path_info =~ m#template#) {
89 if ($q->param('save_template')) {
91 my $tmpl = $iconv_loc->convert( $q->param('tt_template') ) || die "no template?";
93 my $t = shift || return;
94 return $iconv_loc->convert(chr(hex($t)));
96 $tmpl =~ s/%u([a-fA-F0-9]{4})/_conv_js($1)/gex;
98 my $tmpl_file = $out->{'include_path'} . '/' . $template;
99 write_file($tmpl_file . '.new', $tmpl) || die "can't save $tmpl_file: $!";
100 rename $tmpl_file . '.new', $tmpl_file || die "can't rename to $tmpl_file: $!";
103 <action type='html' target='div_status' errorCode='' errorMessage='' >
104 <tt>$template</tt> saved
108 iwfShow('div_status', 1);
110 iwfHideGentlyDelay('div_status', 2, 2000, 1);
119 my $tmpl = read_file($out->{'include_path'} . '/' . $template) || die "can't read template $template: $!";
120 $tmpl = $q->escapeHTML($iconv_utf8->convert($tmpl));
123 <action type='html' target='div_template' errorCode='' errorMessage='' >
124 <pre>}, Dumper($q->Vars), qq{</pre>
126 <form name="frmEditor" action="$self" method="post" iwfTarget="div_status" >
128 <textarea name="tt_template" cols="80" rows="10" style="display: block;">
133 <input type="button" name="save_template" value="Save" onclick="javascript:iwfRequest(this);" />
135 <input type="checkbox" name="checkin_template" id="checkin_checkbox" label="checkin" /> checkin
137 <span id="div_status" style="color: #808080;">idle</span>
139 <input type='hidden' value='hidden post value' name='hidValue' />
145 iwfHideGentlyDelay('div_status', 2, 2000, 1);
157 <title>WebPAC simple browse interface</title>
158 <script type='text/javascript' src='iwf/iwfcore.js'></script>
159 <script type='text/javascript' src='iwf/iwfgui.js'></script>
160 <script type='text/javascript' src='iwf/iwfxml.js'></script>
161 <script type='text/javascript' src='iwf/iwfajax.js'></script>
162 <script type='text/javascript'>
167 function update_status(text) {
168 var el = iwfGetById('div_record_nr');
169 if (el) el.innerHTML = text;
172 function load_rec(nr) {
174 iwfHide('a_left_arr', 1);
176 iwfShow('a_left_arr', 1);
178 update_status(nr+'...');
179 iwfRequest( url+'/xml/?rec='+nr, 'div_record' );
180 iwfOpacity('div_record', 30);
197 function reload_rec() {
202 function init_page() {
205 iwfRequest( url+'/template/', 'div_template' );
210 <body onload="init_page();">
212 db_path = <tt>$db_path</tt><br/>
213 template = <tt>$template</tt><br/>
215 <div id="iwfLog" style="display: none;">
218 <div style="background: #e0e0e0; padding: 0.5em; display: block;">
219 <a id="a_left_arr" href="$self?rec=}, $rec - 1, qq{" onClick="return dec_rec();">⇦</a>
220 <span id="div_record_nr"> none </span>
222 <a id="a_right_arr" href="$self?rec=}, $rec + 1, qq{" onClick="return inc_rec();">⇨</a>
223 <a id="a_reload" href="$self?rec=}, $rec, qq{" onClick="return reload_rec();">↺</a>
224 <a href="#" onClick="iwfRefreshLog(); return false;">▤</a>
228 <div id="div_template">
229 <span style="color: #808080;"> no template loaded yet. </span>
232 <div id="div_record" style="display: block;">
233 <span style="color: #808080;"> no record loaded yet. </span>