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 |
|
|
79 |
|
|
80 |
if ($q->path_info =~ m#xml#) { |
if ($q->path_info =~ m#xml#) { |
81 |
|
|
82 |
my @ds = $db->load_ds($rec); |
my $ds = $db->load_ds($rec); |
83 |
|
|
84 |
if (@ds && $#ds > 0) { |
if ($ds) { |
85 |
print qq{<response> |
print qq{<response> |
86 |
<action type='html' target='div_record' errorCode='' errorMessage='' > |
<action type='html' target='div_record' errorCode='' errorMessage='' > |
87 |
}, $iconv_utf8->convert( $out->apply( |
}, $iconv_utf8->convert( $out->apply( |
88 |
template => $template_file, |
template => $template_filename, |
89 |
data => \@ds, |
data => $ds, |
90 |
) ), qq{ |
) ), qq{ |
91 |
|
|
92 |
</action> |
</action> |
120 |
|
|
121 |
} elsif ($q->path_info =~ m#template#) { |
} elsif ($q->path_info =~ m#template#) { |
122 |
|
|
123 |
my $template_path = $out->{'include_path'} . '/' . $template_file; |
my $template_path = $out->{'include_path'} . '/' . $template_filename; |
124 |
|
|
125 |
if ($q->param('save_template')) { |
if ($q->param('save_template')) { |
126 |
|
|
128 |
|
|
129 |
print qq{<response> |
print qq{<response> |
130 |
<action type='html' target='div_template_status' errorCode='' errorMessage='' > |
<action type='html' target='div_template_status' errorCode='' errorMessage='' > |
131 |
<tt>$template_file</tt> saved |
<tt>$template_filename</tt> saved |
132 |
</action> |
</action> |
133 |
<action type='js'> |
<action type='js'> |
134 |
<!-- |
<!-- |
161 |
--> |
--> |
162 |
<span id="div_template_status" style="color: #808080;">idle</span> |
<span id="div_template_status" style="color: #808080;">idle</span> |
163 |
|
|
164 |
<input type='hidden' value='hidden post value' name='hidValue' /> |
<input type="hidden" name="template" value="$template_filename" /> |
165 |
|
|
166 |
</form> |
</form> |
167 |
</action> |
</action> |
230 |
exit; |
exit; |
231 |
|
|
232 |
} else { |
} else { |
233 |
|
|
234 |
|
my $template_form = qq{ |
235 |
|
<form action="$self" method="get" style="display: inline;"> |
236 |
|
<select name="template"> |
237 |
|
}; |
238 |
|
foreach my $t (@templates) { |
239 |
|
my $s = ''; |
240 |
|
$s = ' selected' if ($t eq $template_filename); |
241 |
|
$template_form .= qq{<option$s>$t</option>}; |
242 |
|
} |
243 |
|
$template_form .= qq{ |
244 |
|
</select> |
245 |
|
<input type="submit" name="ch_template" value="Switch"/> |
246 |
|
</form> |
247 |
|
}; |
248 |
|
|
249 |
print <<"_END_OF_HEAD_"; |
print <<"_END_OF_HEAD_"; |
250 |
<html> |
<html> |
251 |
<head> |
<head> |
262 |
|
|
263 |
var rec = $rec ; |
var rec = $rec ; |
264 |
var url = '$self'; |
var url = '$self'; |
265 |
|
var template_filename = '$template_filename'; |
266 |
|
|
267 |
var css_rnd = 0; |
var css_rnd = 0; |
268 |
|
|
278 |
iwfShow('a_left_arr', 1); |
iwfShow('a_left_arr', 1); |
279 |
} |
} |
280 |
update_status(nr+'...'); |
update_status(nr+'...'); |
281 |
iwfRequest( url+'/xml/?rec='+nr, 'div_record' ); |
iwfRequest( url+'/xml/?template='+template_filename+'&rec='+nr, 'div_record' ); |
282 |
iwfOpacity('div_record', 30); |
iwfOpacity('div_record', 30); |
283 |
} |
} |
284 |
|
|
325 |
load_rec(rec); |
load_rec(rec); |
326 |
|
|
327 |
// load template editor |
// load template editor |
328 |
iwfRequest( url+'/template/', 'div_template' ); |
iwfRequest( url+'/template/?template='+template_filename, 'div_template' ); |
329 |
// load css editor |
// load css editor |
330 |
iwfRequest( url+'/css/', 'div_css' ); |
iwfRequest( url+'/css/', 'div_css' ); |
331 |
} |
} |
339 |
</div> |
</div> |
340 |
|
|
341 |
db_path = <tt>$db_path</tt><br/> |
db_path = <tt>$db_path</tt><br/> |
342 |
template = <tt>$template_file</tt><br/> |
template = $template_form<br/> |
343 |
css = <tt>$css_file</tt> |
css = <tt>$css_file</tt> |
344 |
|
|
345 |
<div style="background: #e0e0e0; padding: 0.5em; display: block;"> |
<div style="background: #e0e0e0; padding: 0.5em; display: block;"> |