1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
|
|
3 |
|
use strict; |
4 |
|
|
5 |
use Cwd qw/abs_path/; |
use Cwd qw/abs_path/; |
6 |
use CGI::Carp qw(fatalsToBrowser); |
use CGI::Carp qw(fatalsToBrowser); |
7 |
use CGI::Simple; |
use CGI::Simple; |
8 |
|
use File::Slurp; |
9 |
|
use Data::Dumper; |
10 |
|
use Text::Iconv; |
11 |
|
|
12 |
use lib '../lib'; |
use lib '../lib'; |
13 |
|
|
18 |
$abs_path =~ s#/[^/]*$#/../#; |
$abs_path =~ s#/[^/]*$#/../#; |
19 |
|
|
20 |
my $db_path = $abs_path . '/db/'; |
my $db_path = $abs_path . '/db/'; |
21 |
|
my $template = 'html_ffzg.tt'; |
22 |
|
|
23 |
|
my $iconv_utf8 = new Text::Iconv('ISO-8859-2', 'UTF-8'); |
24 |
|
my $iconv_loc = new Text::Iconv('UTF-8', 'ISO-8859-2'); |
25 |
|
|
26 |
my $db = new WebPAC::DB( |
my $db = new WebPAC::DB( |
27 |
path => $db_path, |
path => $db_path, |
39 |
|
|
40 |
my $rec = $q->param('rec') || 1; |
my $rec = $q->param('rec') || 1; |
41 |
|
|
42 |
print $q->header; |
print $q->header( -charset => 'utf-8' ); |
43 |
|
|
44 |
if ($q->path_info =~ m#xml#) { |
if ($q->path_info =~ m#xml#) { |
45 |
|
|
46 |
my @ds = $db->load_ds($rec); |
my @ds = $db->load_ds($rec); |
47 |
|
|
48 |
if (@ds) { |
if (@ds && $#ds > 0) { |
49 |
print qq{<response> |
print qq{<response> |
50 |
<action type='html' target='divRecord' errorCode='' errorMessage='' > |
<action type='html' target='div_record' errorCode='' errorMessage='' > |
51 |
}, $out->apply( |
}, $iconv_utf8->convert( $out->apply( |
52 |
template => 'html_ffzg.tt', |
template => $template, |
53 |
data => \@ds, |
data => \@ds, |
54 |
), qq{ |
) ), qq{ |
55 |
|
|
56 |
<script type='text/javascript'> |
</action> |
57 |
|
<action type='javascript' errorCode='' errorMessage='' > |
58 |
<!-- |
<!-- |
59 |
var el = iwfGetById('divRecordNr'); |
var el = iwfGetById('div_record_nr'); |
60 |
if (el) el.innerHTML = '# <b>$rec</b>'; |
if (el) el.innerHTML = '# <b>$rec</b>'; |
61 |
//iwfShow('divRecord'); |
//iwfShow('div_record'); |
62 |
iwfOpacity('divRecord', 100); |
iwfOpacity('div_record', 100); |
63 |
//--> |
//--> |
|
</script> |
|
|
|
|
64 |
</action> |
</action> |
65 |
</response> |
</response> |
66 |
}; |
}; |
67 |
exit; |
exit; |
68 |
} else { |
} else { |
69 |
print qq{ |
print qq{<response> |
70 |
<b>Record $rec not found!</b> |
<action type='html' target='div_record' errorCode='' errorMessage='' > |
71 |
}; |
|
72 |
|
<b>Record $rec not found!</b> |
73 |
|
</action> |
74 |
|
<action type='javascript' errorCode='' errorMessage='' > |
75 |
|
<!-- |
76 |
|
var el = iwfGetById('div_record_nr'); |
77 |
|
if (el) el.innerHTML = '<strike> $rec </strike>'; |
78 |
|
//--> |
79 |
|
</action> |
80 |
|
</response> |
81 |
|
}; |
82 |
|
exit; |
83 |
} |
} |
84 |
|
|
85 |
|
} elsif ($q->path_info =~ m#template#) { |
86 |
|
|
87 |
|
my @actions; |
88 |
|
|
89 |
|
if ($q->param('save_template')) { |
90 |
|
|
91 |
|
my $tmpl = $iconv_loc->convert( $q->param('tt_template') ) || die "no template?"; |
92 |
|
sub _conv_js { |
93 |
|
my $t = shift || return; |
94 |
|
return $iconv_loc->convert(chr(hex($t))); |
95 |
|
} |
96 |
|
$tmpl =~ s/%u([a-fA-F0-9]{4})/_conv_js($1)/gex; |
97 |
|
|
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: $!"; |
101 |
|
|
102 |
|
print qq{<response> |
103 |
|
<action type='html' target='div_status' errorCode='' errorMessage='' > |
104 |
|
<tt>$template</tt> saved |
105 |
|
</action> |
106 |
|
<action type='js'> |
107 |
|
<!-- |
108 |
|
iwfShow('div_status', 1); |
109 |
|
reload_rec(); |
110 |
|
iwfHideGentlyDelay('div_status', 2, 2000, 1); |
111 |
|
--> |
112 |
|
</action> |
113 |
|
</response> |
114 |
|
}; |
115 |
|
exit; |
116 |
|
|
117 |
|
} |
118 |
|
|
119 |
|
my $tmpl = read_file($out->{'include_path'} . '/' . $template) || die "can't read template $template: $!"; |
120 |
|
$tmpl = $q->escapeHTML($iconv_utf8->convert($tmpl)); |
121 |
|
|
122 |
|
print qq{<response> |
123 |
|
<action type='html' target='div_template' errorCode='' errorMessage='' > |
124 |
|
<pre>}, Dumper($q->Vars), qq{</pre> |
125 |
|
|
126 |
|
<form name="frmEditor" action="$self" method="post" iwfTarget="div_status" > |
127 |
|
|
128 |
|
<textarea name="tt_template" cols="80" rows="10" style="display: block;"> |
129 |
|
$tmpl |
130 |
|
</textarea> |
131 |
|
|
132 |
|
<br/> |
133 |
|
<input type="button" name="save_template" value="Save" onclick="javascript:iwfRequest(this);" /> |
134 |
|
<!-- |
135 |
|
<input type="checkbox" name="checkin_template" id="checkin_checkbox" label="checkin" /> checkin |
136 |
|
--> |
137 |
|
<span id="div_status" style="color: #808080;">idle</span> |
138 |
|
|
139 |
|
<input type='hidden' value='hidden post value' name='hidValue' /> |
140 |
|
|
141 |
|
</form> |
142 |
|
</action> |
143 |
|
<action type='js'> |
144 |
|
<!-- |
145 |
|
iwfHideGentlyDelay('div_status', 2, 2000, 1); |
146 |
|
--> |
147 |
|
</action> |
148 |
|
</response> |
149 |
|
}; |
150 |
|
|
151 |
|
exit; |
152 |
|
|
153 |
} else { |
} else { |
154 |
print qq{ |
print qq{ |
155 |
<html> |
<html> |
165 |
var url = '$self'; |
var url = '$self'; |
166 |
|
|
167 |
function update_status(text) { |
function update_status(text) { |
168 |
var el = iwfGetById('divRecordNr'); |
var el = iwfGetById('div_record_nr'); |
169 |
if (el) el.innerHTML = text; |
if (el) el.innerHTML = text; |
170 |
} |
} |
|
|
|
171 |
|
|
172 |
function load_rec(nr) { |
function load_rec(nr) { |
173 |
|
if (nr == 1) { |
174 |
|
iwfHide('a_left_arr', 1); |
175 |
|
} else { |
176 |
|
iwfShow('a_left_arr', 1); |
177 |
|
} |
178 |
update_status(nr+'...'); |
update_status(nr+'...'); |
179 |
iwfRequest( url+'/xml/?rec='+nr, 'divRecord' ); |
iwfRequest( url+'/xml/?rec='+nr, 'div_record' ); |
180 |
iwfOpacity('divRecord', 30); |
iwfOpacity('div_record', 30); |
181 |
} |
} |
182 |
|
|
183 |
function inc_rec() { |
function inc_rec() { |
187 |
} |
} |
188 |
|
|
189 |
function dec_rec() { |
function dec_rec() { |
190 |
rec--; |
if (rec > 1) { |
191 |
load_rec(rec); |
rec--; |
192 |
|
load_rec(rec); |
193 |
|
} |
194 |
return false; |
return false; |
195 |
} |
} |
196 |
|
|
199 |
return false; |
return false; |
200 |
} |
} |
201 |
|
|
202 |
|
function init_page() { |
203 |
|
load_rec(rec); |
204 |
|
// load template |
205 |
|
iwfRequest( url+'/template/', 'div_template' ); |
206 |
|
} |
207 |
|
|
208 |
</script> |
</script> |
209 |
</head> |
</head> |
210 |
<body onload="load_rec($rec);"> |
<body onload="init_page();"> |
211 |
|
|
212 |
db_path = <tt>$db_path</tt><br/> |
db_path = <tt>$db_path</tt><br/> |
213 |
|
template = <tt>$template</tt><br/> |
214 |
|
|
215 |
|
<div id="iwfLog" style="display: none;"> |
216 |
|
</div> |
217 |
|
|
218 |
<div style="background: #e0e0e0; padding: 0.5em; display: block;"> |
<div style="background: #e0e0e0; padding: 0.5em; display: block;"> |
219 |
<a href="$self?rec=}, $rec - 1, qq{" onClick="return dec_rec();">⇦</a> |
<a id="a_left_arr" href="$self?rec=}, $rec - 1, qq{" onClick="return dec_rec();">⇦</a> |
220 |
<span id="divRecordNr"> none </span> |
<span id="div_record_nr"> none </span> |
221 |
|
|
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> |
225 |
|
|
|
<a href="$self?rec=}, $rec + 1, qq{" onClick="return inc_rec();">⇨</a> |
|
|
<a href="$self?rec=}, $rec, qq{" onClick="return reload_rec();">↺</a> |
|
226 |
</div> |
</div> |
227 |
|
|
228 |
<div id="divRecord"> |
<div id="div_template"> |
229 |
|
<span style="color: #808080;"> no template loaded yet. </span> |
230 |
|
</div> |
231 |
|
|
232 |
|
<div id="div_record" style="display: block;"> |
233 |
<span style="color: #808080;"> no record loaded yet. </span> |
<span style="color: #808080;"> no record loaded yet. </span> |
234 |
</div> |
</div> |
235 |
|
|
236 |
|
|
237 |
</body> |
</body> |
238 |
</html>}; |
</html>}; |
239 |
|
|