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