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'; |
my $template_file = 'html_ffzg.tt'; |
22 |
|
my $css_file = 'user.css'; |
23 |
|
|
24 |
my $iconv_utf8 = new Text::Iconv('ISO-8859-2', 'UTF-8'); |
my $iconv_utf8 = new Text::Iconv('ISO-8859-2', 'UTF-8'); |
25 |
my $iconv_loc = new Text::Iconv('UTF-8', 'ISO-8859-2'); |
my $iconv_loc = new Text::Iconv('UTF-8', 'ISO-8859-2'); |
42 |
|
|
43 |
print $q->header( -charset => 'utf-8' ); |
print $q->header( -charset => 'utf-8' ); |
44 |
|
|
45 |
|
##---- some handy subs |
46 |
|
|
47 |
|
sub update_file($$) { |
48 |
|
my ($path, $content) = @_; |
49 |
|
|
50 |
|
$content = $iconv_loc->convert( $content ) || die "no content?"; |
51 |
|
|
52 |
|
sub _conv_js { |
53 |
|
my $t = shift || return; |
54 |
|
return $iconv_loc->convert(chr(hex($t))); |
55 |
|
} |
56 |
|
$content =~ s/%u([a-fA-F0-9]{4})/_conv_js($1)/gex; |
57 |
|
$content =~ s/^[\n\r]+//s; |
58 |
|
$content =~ s/[\n\r]+$//s; |
59 |
|
|
60 |
|
write_file($path . '.new', $content) || die "can't save ${path}.new $!"; |
61 |
|
rename $path . '.new', $path || die "can't rename to $path: $!"; |
62 |
|
} |
63 |
|
|
64 |
|
sub get_file_in_html($) { |
65 |
|
my ($path) = @_; |
66 |
|
|
67 |
|
die "no path?" unless ($path); |
68 |
|
|
69 |
|
my $content = read_file($path) || die "can't read $path: $!"; |
70 |
|
$content = $q->escapeHTML($iconv_utf8->convert($content)); |
71 |
|
|
72 |
|
return $content; |
73 |
|
} |
74 |
|
|
75 |
|
##---- |
76 |
|
|
77 |
if ($q->path_info =~ m#xml#) { |
if ($q->path_info =~ m#xml#) { |
78 |
|
|
79 |
my @ds = $db->load_ds($rec); |
my $ds = $db->load_ds($rec); |
80 |
|
|
81 |
if (@ds && $#ds > 0) { |
if ($ds) { |
82 |
print qq{<response> |
print qq{<response> |
83 |
<action type='html' target='div_record' errorCode='' errorMessage='' > |
<action type='html' target='div_record' errorCode='' errorMessage='' > |
84 |
}, $out->apply( |
}, $iconv_utf8->convert( $out->apply( |
85 |
template => $template, |
template => $template_file, |
86 |
data => \@ds, |
data => $ds, |
87 |
), qq{ |
) ), qq{ |
88 |
|
|
89 |
</action> |
</action> |
90 |
<action type='javascript' errorCode='' errorMessage='' > |
<action type='javascript' errorCode='' errorMessage='' > |
107 |
<action type='javascript' errorCode='' errorMessage='' > |
<action type='javascript' errorCode='' errorMessage='' > |
108 |
<!-- |
<!-- |
109 |
var el = iwfGetById('div_record_nr'); |
var el = iwfGetById('div_record_nr'); |
110 |
if (el) el.innerHTML = '<strike>$rec</strike>'; |
if (el) el.innerHTML = '<strike> $rec </strike>'; |
111 |
//--> |
//--> |
112 |
</action> |
</action> |
113 |
</response> |
</response> |
117 |
|
|
118 |
} elsif ($q->path_info =~ m#template#) { |
} elsif ($q->path_info =~ m#template#) { |
119 |
|
|
120 |
my @actions; |
my $template_path = $out->{'include_path'} . '/' . $template_file; |
121 |
|
|
122 |
if ($q->param('save_template')) { |
if ($q->param('save_template')) { |
123 |
|
|
124 |
my $tmpl = $q->param('tt_template') || die "no template?"; |
update_file($template_path, $q->param('tt_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: $!"; |
|
125 |
|
|
126 |
print qq{<response> |
print qq{<response> |
127 |
<action type='html' target='div_status' errorCode='' errorMessage='' > |
<action type='html' target='div_template_status' errorCode='' errorMessage='' > |
128 |
$template saved |
<tt>$template_file</tt> saved |
129 |
</action> |
</action> |
130 |
<action type='js'> |
<action type='js'> |
131 |
<!-- |
<!-- |
132 |
|
iwfShow('div_template_status', 1); |
133 |
reload_rec(); |
reload_rec(); |
134 |
|
iwfHideGentlyDelay('div_template_status', 2, 2000, 1); |
135 |
--> |
--> |
136 |
</action> |
</action> |
137 |
</response> |
</response> |
140 |
|
|
141 |
} |
} |
142 |
|
|
143 |
my $tmpl = read_file($out->{'include_path'} . '/' . $template) || die "can't read template $template: $!"; |
my $tmpl = get_file_in_html($template_path); |
|
$tmpl = $q->escapeHTML($iconv_utf8->convert($tmpl)); |
|
144 |
|
|
145 |
print qq{<response> |
print qq{<response> |
146 |
<action type='html' target='div_template' errorCode='' errorMessage='' > |
<action type='html' target='div_template' errorCode='' errorMessage='' > |
|
<pre>}, Dumper($q->Vars), qq{</pre> |
|
147 |
|
|
148 |
<form name="frmEditor" action="$self" method="post" |
<form name="frmEditor" action="$self" method="post" iwfTarget="div_template_status" > |
|
iwfTarget="div_status" |
|
|
> |
|
149 |
|
|
150 |
<textarea name="tt_template" cols="80" rows="10" style="display: block;"> |
<textarea name="tt_template" cols="80" rows="10" style="display: block;"> |
151 |
$tmpl |
$tmpl |
153 |
|
|
154 |
<br/> |
<br/> |
155 |
<input type="button" name="save_template" value="Save" onclick="javascript:iwfRequest(this);" /> |
<input type="button" name="save_template" value="Save" onclick="javascript:iwfRequest(this);" /> |
156 |
<input type="checkbox" name="checkin_template" id="checkin_checkbox" label="checkin" /> |
<!-- |
157 |
<span id="div_status" style="color: #808080;">idle</span> |
<input type="checkbox" name="checkin_template" id="checkin_checkbox" label="checkin" /> checkin |
158 |
|
--> |
159 |
|
<span id="div_template_status" style="color: #808080;">idle</span> |
160 |
|
|
161 |
<input type='hidden' value='hidden post value' name='hidValue' /> |
<input type='hidden' value='hidden post value' name='hidValue' /> |
162 |
|
|
163 |
</form> |
</form> |
164 |
</action> |
</action> |
165 |
|
<action type='js'> |
166 |
|
<!-- |
167 |
|
iwfHideGentlyDelay('div_template_status', 2, 2000, 1); |
168 |
|
--> |
169 |
|
</action> |
170 |
|
</response> |
171 |
|
}; |
172 |
|
|
173 |
|
exit; |
174 |
|
|
175 |
|
} elsif ($q->path_info =~ m#css#) { |
176 |
|
|
177 |
|
my $css_path = $abs_path . '/web/' . $css_file; |
178 |
|
|
179 |
|
|
180 |
|
if ($q->param('save_css')) { |
181 |
|
update_file($css_path, $q->param('user_css')); |
182 |
|
|
183 |
|
print qq{<response> |
184 |
|
<action type='html' target='div_css_status' errorCode='' errorMessage='' > |
185 |
|
<tt>$css_file</tt> saved |
186 |
|
</action> |
187 |
|
<action type='js'> |
188 |
|
<!-- |
189 |
|
iwfShow('div_css_status', 1); |
190 |
|
// switch css |
191 |
|
css_rnd++; |
192 |
|
iwfLog('loading user.css?'+css_rnd); |
193 |
|
iwfGetById('user_css_link').href = 'user.css?'+css_rnd; |
194 |
|
iwfHideGentlyDelay('div_css_status', 2, 2000, 1); |
195 |
|
--> |
196 |
|
</action> |
197 |
|
</response> |
198 |
|
}; |
199 |
|
exit; |
200 |
|
|
201 |
|
} |
202 |
|
|
203 |
|
my $user_css = get_file_in_html($css_path); |
204 |
|
|
205 |
|
print qq{<response> |
206 |
|
<action type='html' target='div_css' errorCode='' errorMessage='' > |
207 |
|
|
208 |
|
<form name="frmCSSEditor" action="$self" method="post" iwfTarget="div_css_status" > |
209 |
|
|
210 |
|
<textarea name="user_css" cols="80" rows="10" style="display: block; width: 100%;"> |
211 |
|
$user_css |
212 |
|
</textarea> |
213 |
|
|
214 |
|
<br/> |
215 |
|
<input type="button" name="save_css" value="Save" onclick="javascript:iwfRequest(this);" /> |
216 |
|
<span id="div_css_status" style="color: #808080;">idle</span> |
217 |
|
</form> |
218 |
|
</action> |
219 |
|
<action type='js'> |
220 |
|
<!-- |
221 |
|
iwfLog('loaded CSS template'); |
222 |
|
--> |
223 |
|
</action> |
224 |
</response> |
</response> |
225 |
}; |
}; |
226 |
|
|
227 |
exit; |
exit; |
228 |
|
|
229 |
} else { |
} else { |
230 |
print qq{ |
print <<"_END_OF_HEAD_"; |
231 |
<html> |
<html> |
232 |
<head> |
<head> |
233 |
<title>WebPAC simple browse interface</title> |
<title>WebPAC simple browse interface</title> |
234 |
|
|
235 |
|
<link id="user_css_link" href="user.css" type="text/css" rel="stylesheet"> |
236 |
|
|
237 |
<script type='text/javascript' src='iwf/iwfcore.js'></script> |
<script type='text/javascript' src='iwf/iwfcore.js'></script> |
238 |
<script type='text/javascript' src='iwf/iwfgui.js'></script> |
<script type='text/javascript' src='iwf/iwfgui.js'></script> |
239 |
<script type='text/javascript' src='iwf/iwfxml.js'></script> |
<script type='text/javascript' src='iwf/iwfxml.js'></script> |
240 |
<script type='text/javascript' src='iwf/iwfajax.js'></script> |
<script type='text/javascript' src='iwf/iwfajax.js'></script> |
241 |
|
<script type='text/javascript' src='iwf/iwconfig.js'></script> |
242 |
<script type='text/javascript'> |
<script type='text/javascript'> |
243 |
|
|
244 |
var rec = $rec ; |
var rec = $rec ; |
245 |
var url = '$self'; |
var url = '$self'; |
246 |
|
|
247 |
|
var css_rnd = 0; |
248 |
|
|
249 |
function update_status(text) { |
function update_status(text) { |
250 |
var el = iwfGetById('div_record_nr'); |
var el = iwfGetById('div_record_nr'); |
251 |
if (el) el.innerHTML = text; |
if (el) el.innerHTML = text; |
252 |
} |
} |
253 |
|
|
254 |
function load_rec(nr) { |
function load_rec(nr) { |
255 |
|
if (nr == 1) { |
256 |
|
iwfHide('a_left_arr', 1); |
257 |
|
} else { |
258 |
|
iwfShow('a_left_arr', 1); |
259 |
|
} |
260 |
update_status(nr+'...'); |
update_status(nr+'...'); |
261 |
iwfRequest( url+'/xml/?rec='+nr, 'div_record' ); |
iwfRequest( url+'/xml/?rec='+nr, 'div_record' ); |
262 |
iwfOpacity('div_record', 30); |
iwfOpacity('div_record', 30); |
269 |
} |
} |
270 |
|
|
271 |
function dec_rec() { |
function dec_rec() { |
272 |
rec--; |
if (rec > 1) { |
273 |
load_rec(rec); |
rec--; |
274 |
|
load_rec(rec); |
275 |
|
} |
276 |
return false; |
return false; |
277 |
} |
} |
278 |
|
|
281 |
return false; |
return false; |
282 |
} |
} |
283 |
|
|
284 |
|
function edit_template() { |
285 |
|
iwfHideGently('div_css', 30, 1); |
286 |
|
iwfShowGently('div_template', 30, 1); |
287 |
|
return false; |
288 |
|
} |
289 |
|
|
290 |
|
function edit_css() { |
291 |
|
iwfHideGently('div_template', 30, 1); |
292 |
|
iwfShowGently('div_css', 30, 1); |
293 |
|
return false; |
294 |
|
} |
295 |
|
|
296 |
function init_page() { |
function init_page() { |
297 |
|
iwfLog('div_css = ' + iwfX('div_css') + ':' + iwfY('div_css')); |
298 |
|
iwfLog('div_template = ' + iwfX('div_template') + ':' + iwfY('div_template')); |
299 |
|
|
300 |
|
iwfX('div_css', iwfX('div_template')); |
301 |
|
iwfY('div_css', iwfY('div_template')); |
302 |
|
|
303 |
|
iwfLog('div_css = ' + iwfX('div_css') + ':' + iwfY('div_css')); |
304 |
|
|
305 |
load_rec(rec); |
load_rec(rec); |
306 |
// load template |
|
307 |
|
// load template editor |
308 |
iwfRequest( url+'/template/', 'div_template' ); |
iwfRequest( url+'/template/', 'div_template' ); |
309 |
|
// load css editor |
310 |
|
iwfRequest( url+'/css/', 'div_css' ); |
311 |
} |
} |
312 |
|
|
313 |
</script> |
</script> |
314 |
|
|
315 |
</head> |
</head> |
316 |
<body onload="init_page();"> |
<body onload="init_page();"> |
317 |
|
|
318 |
db_path = <tt>$db_path</tt><br/> |
<div id="iwfLog"> |
|
template = <tt>$template</tt><br/> |
|
|
|
|
|
<div id="iwfLog" style="display: none;"> |
|
319 |
</div> |
</div> |
320 |
|
|
321 |
|
db_path = <tt>$db_path</tt><br/> |
322 |
|
template = <tt>$template_file</tt><br/> |
323 |
|
css = <tt>$css_file</tt> |
324 |
|
|
325 |
<div style="background: #e0e0e0; padding: 0.5em; display: block;"> |
<div style="background: #e0e0e0; padding: 0.5em; display: block;"> |
326 |
<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> |
327 |
<span id="div_record_nr"> none </span> |
<span id="div_record_nr"> none </span> |
328 |
|
|
329 |
<a href="$self?rec=}, $rec + 1, qq{" onClick="return inc_rec();">⇨</a> |
<a id="a_right_arr" href="$self?rec=}, $rec + 1, qq{" onClick="return inc_rec();">⇨</a> |
330 |
<a href="$self?rec=}, $rec, qq{" onClick="return reload_rec();">↺</a> |
<a id="a_reload" href="$self?rec=}, $rec, qq{" onClick="return reload_rec();">↺</a> |
331 |
<a href="#" onClick="iwfRefreshLog(); return false;">▤</a> |
<a href="#" onClick="iwfShowLog(); return false;">▤</a> |
332 |
|
|
333 |
</div> |
</div> |
334 |
|
|
335 |
|
<div> |
336 |
|
|
337 |
|
<div style="display: block;"> |
338 |
|
Editor |
339 |
|
<a id="a_template" href="#" onClick="return edit_template();">template</a> |
340 |
|
<a id="a_css" href="#" onClick="return edit_css();">css</a> |
341 |
|
|
342 |
<div id="div_template"> |
<div id="div_template"> |
343 |
<span style="color: #808080;"> no template loaded yet. </span> |
<span style="color: #808080;"> no template loaded yet. </span> |
344 |
</div> |
</div> |
345 |
|
|
346 |
|
<div id="div_css" style="position: absolute; display: none;"> |
347 |
|
<span style="color: #808080;"> no CSS loaded yet. </span> |
348 |
|
</div> |
349 |
|
|
350 |
|
</div> |
351 |
|
|
352 |
<div id="div_record" style="display: block;"> |
<div id="div_record" style="display: block;"> |
353 |
<span style="color: #808080;"> no record loaded yet. </span> |
<span style="color: #808080;"> no record loaded yet. </span> |
354 |
</div> |
</div> |
355 |
|
|
356 |
|
|
357 |
</body> |
</body> |
358 |
</html>}; |
</html> |
359 |
|
_END_OF_HEAD_ |
360 |
|
|
361 |
}; |
} |