18 |
$abs_path =~ s#/[^/]*$#/../#; |
$abs_path =~ s#/[^/]*$#/../#; |
19 |
|
|
20 |
my $db_path = $abs_path . '/db/'; |
my $db_path = $abs_path . '/db/'; |
21 |
my $template_file = 'html_ffzg.tt'; |
my $template_path = "$abs_path/conf/output/tt"; |
22 |
|
opendir(my $dir, $template_path) || die "can't open template path $template_path: $!"; |
23 |
|
my @templates = grep { /\.tt$/i } readdir($dir); |
24 |
my $css_file = 'user.css'; |
my $css_file = 'user.css'; |
25 |
|
|
26 |
my $iconv_utf8 = new Text::Iconv('ISO-8859-2', 'UTF-8'); |
my $iconv_utf8 = new Text::Iconv('ISO-8859-2', 'UTF-8'); |
33 |
); |
); |
34 |
|
|
35 |
my $out = new WebPAC::Output::TT( |
my $out = new WebPAC::Output::TT( |
36 |
include_path => "$abs_path/conf/output/tt", |
include_path => $template_path, |
37 |
filters => { foo => sub { shift } }, |
filters => { foo => sub { shift } }, |
38 |
); |
); |
39 |
|
|
41 |
my $self = $q->url( '-path_info'=>1, '-query'=>0, '-full'=>0 ); |
my $self = $q->url( '-path_info'=>1, '-query'=>0, '-full'=>0 ); |
42 |
|
|
43 |
my $rec = $q->param('rec') || 1; |
my $rec = $q->param('rec') || 1; |
44 |
|
my $template_filename = $q->param('template') || $templates[0]; |
45 |
|
|
46 |
print $q->header( -charset => 'utf-8' ); |
print $q->header( -charset => 'utf-8' ); |
47 |
|
|
75 |
return $content; |
return $content; |
76 |
} |
} |
77 |
|
|
78 |
|
sub template_list_html($) { |
79 |
|
my $current = shift || die; |
80 |
|
|
81 |
|
my $html = qq{ Template\n<ul> }; |
82 |
|
|
83 |
|
foreach my $t (sort @templates) { |
84 |
|
if ($t eq $current) { |
85 |
|
$html .= qq{ <li><b>$t</b></li> }; |
86 |
|
} else { |
87 |
|
$html .= qq{ <li><a href="#" onClick="load_template('$t'); return false;">$t</a></li> }; |
88 |
|
} |
89 |
|
} |
90 |
|
|
91 |
|
$html .= qq{ </ul> }; |
92 |
|
return $html; |
93 |
|
} |
94 |
|
|
95 |
##---- |
##---- |
96 |
|
|
97 |
if ($q->path_info =~ m#xml#) { |
if ($q->path_info =~ m#xml#) { |
102 |
print qq{<response> |
print qq{<response> |
103 |
<action type='html' target='div_record' errorCode='' errorMessage='' > |
<action type='html' target='div_record' errorCode='' errorMessage='' > |
104 |
}, $iconv_utf8->convert( $out->apply( |
}, $iconv_utf8->convert( $out->apply( |
105 |
template => $template_file, |
template => $template_filename, |
106 |
data => $ds, |
data => $ds, |
107 |
) ), qq{ |
) ), qq{ |
108 |
|
|
135 |
exit; |
exit; |
136 |
} |
} |
137 |
|
|
138 |
|
} elsif ($q->path_info =~ m#template_list#) { |
139 |
|
|
140 |
|
print qq{<response> |
141 |
|
<action type='html' target='div_template_list' errorCode='' errorMessage='' > |
142 |
|
<div>} . template_list_html($template_filename) . qq{</div> |
143 |
|
</action> |
144 |
|
</response> |
145 |
|
}; |
146 |
|
|
147 |
|
exit; |
148 |
|
|
149 |
} elsif ($q->path_info =~ m#template#) { |
} elsif ($q->path_info =~ m#template#) { |
150 |
|
|
151 |
my $template_path = $out->{'include_path'} . '/' . $template_file; |
my $template_path = $out->{'include_path'} . '/' . $template_filename; |
152 |
|
|
153 |
if ($q->param('save_template')) { |
if ($q->param('save_template')) { |
154 |
|
|
156 |
|
|
157 |
print qq{<response> |
print qq{<response> |
158 |
<action type='html' target='div_template_status' errorCode='' errorMessage='' > |
<action type='html' target='div_template_status' errorCode='' errorMessage='' > |
159 |
<tt>$template_file</tt> saved |
<tt>$template_filename</tt> saved |
160 |
</action> |
</action> |
161 |
<action type='js'> |
<action type='js'> |
162 |
<!-- |
<!-- |
189 |
--> |
--> |
190 |
<span id="div_template_status" style="color: #808080;">idle</span> |
<span id="div_template_status" style="color: #808080;">idle</span> |
191 |
|
|
192 |
<input type='hidden' value='hidden post value' name='hidValue' /> |
<input type="hidden" name="template" value="$template_filename" /> |
193 |
|
|
194 |
</form> |
</form> |
195 |
</action> |
</action> |
196 |
<action type='js'> |
<action type='js'> |
197 |
<!-- |
<!-- |
198 |
|
iwfOpacity('div_template', 100); |
199 |
iwfHideGentlyDelay('div_template_status', 2, 2000, 1); |
iwfHideGentlyDelay('div_template_status', 2, 2000, 1); |
200 |
--> |
--> |
201 |
</action> |
</action> |
259 |
exit; |
exit; |
260 |
|
|
261 |
} else { |
} else { |
262 |
|
|
263 |
|
my $template_list_html = template_list_html($template_filename); |
264 |
|
|
265 |
print <<"_END_OF_HEAD_"; |
print <<"_END_OF_HEAD_"; |
266 |
<html> |
<html> |
267 |
<head> |
<head> |
278 |
|
|
279 |
var rec = $rec ; |
var rec = $rec ; |
280 |
var url = '$self'; |
var url = '$self'; |
281 |
|
var template_filename = '$template_filename'; |
282 |
|
|
283 |
var css_rnd = 0; |
var css_rnd = 0; |
284 |
|
|
294 |
iwfShow('a_left_arr', 1); |
iwfShow('a_left_arr', 1); |
295 |
} |
} |
296 |
update_status(nr+'...'); |
update_status(nr+'...'); |
297 |
iwfRequest( url+'/xml/?rec='+nr, 'div_record' ); |
iwfRequest( url+'/xml/?template='+template_filename+'&rec='+nr, 'div_record' ); |
298 |
iwfOpacity('div_record', 30); |
iwfOpacity('div_record', 30); |
299 |
} |
} |
300 |
|
|
329 |
return false; |
return false; |
330 |
} |
} |
331 |
|
|
332 |
|
function load_template(name) { |
333 |
|
iwfLog('changing template to '+name); |
334 |
|
iwfOpacity('div_template', 30); |
335 |
|
template_filename = name; |
336 |
|
// load template editor |
337 |
|
iwfRequest( url+'/template/?template='+template_filename, 'div_template' ); |
338 |
|
load_rec(rec); |
339 |
|
|
340 |
|
// refresh template list |
341 |
|
iwfRequest( url+'/template_list/?template='+template_filename, 'div_template_list' ); |
342 |
|
} |
343 |
|
|
344 |
function init_page() { |
function init_page() { |
345 |
iwfLog('div_css = ' + iwfX('div_css') + ':' + iwfY('div_css')); |
iwfLog('div_css = ' + iwfX('div_css') + ':' + iwfY('div_css')); |
346 |
iwfLog('div_template = ' + iwfX('div_template') + ':' + iwfY('div_template')); |
iwfLog('div_template = ' + iwfX('div_template') + ':' + iwfY('div_template')); |
350 |
|
|
351 |
iwfLog('div_css = ' + iwfX('div_css') + ':' + iwfY('div_css')); |
iwfLog('div_css = ' + iwfX('div_css') + ':' + iwfY('div_css')); |
352 |
|
|
353 |
load_rec(rec); |
// load template editor and record |
354 |
|
load_template(template_filename); |
355 |
|
|
|
// load template editor |
|
|
iwfRequest( url+'/template/', 'div_template' ); |
|
356 |
// load css editor |
// load css editor |
357 |
iwfRequest( url+'/css/', 'div_css' ); |
iwfRequest( url+'/css/', 'div_css' ); |
358 |
} |
} |
366 |
</div> |
</div> |
367 |
|
|
368 |
db_path = <tt>$db_path</tt><br/> |
db_path = <tt>$db_path</tt><br/> |
|
template = <tt>$template_file</tt><br/> |
|
369 |
css = <tt>$css_file</tt> |
css = <tt>$css_file</tt> |
370 |
|
|
371 |
<div style="background: #e0e0e0; padding: 0.5em; display: block;"> |
<div style="background: #e0e0e0; padding: 0.5em; display: block;"> |
378 |
|
|
379 |
</div> |
</div> |
380 |
|
|
381 |
|
|
382 |
|
<div id="div_template_list" style="display: inline; border: 2px solid #ffcc88; float: right; z-index: 10;"> |
383 |
|
$template_list_html |
384 |
|
</div> |
385 |
|
|
386 |
<div> |
<div> |
387 |
|
|
388 |
<div style="display: block;"> |
<div style="border: 2px solid #ffff80;"> |
389 |
|
|
390 |
Editor |
Editor |
391 |
<a id="a_template" href="#" onClick="return edit_template();">template</a> |
<a id="a_template" href="#" onClick="return edit_template();">template</a> |
392 |
<a id="a_css" href="#" onClick="return edit_css();">css</a> |
<a id="a_css" href="#" onClick="return edit_css();">css</a> |
393 |
|
|
394 |
|
|
395 |
<div id="div_template"> |
<div id="div_template"> |
396 |
<span style="color: #808080;"> no template loaded yet. </span> |
<span style="color: #808080;"> no template loaded yet. </span> |
397 |
</div> |
</div> |