use Cwd;
use HTML::Template;
+use Template;
use SL::Template;
use CGI::Ajax;
use SL::DBUtils;
$main::lxdebug->leave_sub();
}
-sub parse_html_template {
+sub _prepare_html_template {
$main::lxdebug->enter_sub();
my ($self, $file, $additional_params) = @_;
die($info);
}
- my $template = HTML::Template->new("filename" => $file,
- "die_on_bad_params" => 0,
- "strict" => 0,
- "case_sensitive" => 1,
- "loop_context_vars" => 1,
- "global_vars" => 1);
-
- $additional_params = {} unless ($additional_params);
if ($self->{"DEBUG"}) {
$additional_params->{"DEBUG"} = $self->{"DEBUG"};
}
$additional_params->{"conf_latex_templates"} = $main::latex;
$additional_params->{"conf_opendocument_templates"} = $main::opendocument_templates;
- my @additional_param_names = keys(%{$additional_params});
+ $main::lxdebug->leave_sub();
+
+ return $file;
+}
+
+sub parse_html_template {
+ $main::lxdebug->enter_sub();
+
+ my ($self, $file, $additional_params) = @_;
+
+ $additional_params ||= { };
+
+ $file = $self->_prepare_html_template($file, $additional_params);
+
+ my $template = HTML::Template->new("filename" => $file,
+ "die_on_bad_params" => 0,
+ "strict" => 0,
+ "case_sensitive" => 1,
+ "loop_context_vars" => 1,
+ "global_vars" => 1);
+
foreach my $key ($template->param()) {
- my $param = $self->{$key};
- $param = $additional_params->{$key} if (grep(/^${key}$/, @additional_param_names));
+ my $param = $additional_params->{$key} || $self->{$key};
$param = [] if (($template->query("name" => $key) eq "LOOP") && (ref($param) ne "ARRAY"));
$template->param($key => $param);
}
return $output;
}
+sub parse_html_template2 {
+ $main::lxdebug->enter_sub();
+
+ my ($self, $file, $additional_params) = @_;
+
+ $additional_params ||= { };
+
+ $file = $self->_prepare_html_template($file, $additional_params);
+
+ my $template = Template->new({ 'INTERPOLATE' => 0,
+ 'PRE_CHOMP' => Template::Constants::CHOMP_COLLAPSE,
+ 'POST_CHOMP' => Template::Constants::CHOMP_COLLAPSE,
+ 'EVAL_PERL' => 0,
+ 'ABSOLUTE' => 1,
+ 'CACHE_SIZE' => 0,
+ }) || die;
+
+ map { $additional_params->{$_} ||= $self->{$_} } keys %{ $self };
+
+ my $output;
+ $template->process($file, $additional_params, \$output);
+ $main::lxdebug->message(0, $output);
+
+ $output = $main::locale->{iconv}->convert($output) if ($main::locale);
+
+ $main::lxdebug->leave_sub();
+
+ return $output;
+}
+
sub show_generic_error {
my ($self, $error, $title, $action) = @_;
{ "name" => "IO::Wrap", "url" => "http://search.cpan.org/~dskoll/" },
{ "name" => "Text::CSV_XS", "url" => "http://search.cpan.org/~hmbrand/" },
{ "name" => "List::Util", "url" => "http://search.cpan.org/~gbarr/" },
+ { "name" => "Template", "url" => "http://search.cpan.org/~abw/" },
);
sub module_available {
foreach my $col_name (@visible_columns) {
my $col = $row->{$col_name};
$col->{CELL_ROWS} = [ ];
- foreach my $i (0 .. scalar(@{ $col->{data} })) {
+ foreach my $i (0 .. scalar(@{ $col->{data} }) - 1) {
push @{ $col->{CELL_ROWS} }, {
'data' => $self->html_format($col->{data}->[$i]),
'link' => $col->{link}->[$i],
my $self = shift;
my $variables = $self->prepare_html_content();
- return $self->{form}->parse_html_template('report_generator/html_report', $variables);
+ return $self->{form}->parse_html_template2('report_generator/html_report', $variables);
}
sub verify_paper_size {
* Text::CSV_XS
* IO::Wrap (aus dem Paket IO::Stringy)
* YAML
+* Template
Diese Pakete können bei den unterschiedlichen Distributionen anders heißen.
-(Debian: apache, postgresql, libdbi-perl, libdbd-pg-perl, libpgperl, libhtml-template-perl, libclass-accessor-perl, libarchive-zip-perl, libtext-iconv-perl, libyaml-perl, libtext-csv-perl, libio-stringy-perl)
+(Debian: apache, postgresql, libdbi-perl, libdbd-pg-perl, libpgperl, libhtml-template-perl, libclass-accessor-perl, libarchive-zip-perl, libtext-iconv-perl, libyaml-perl, libtext-csv-perl, libio-stringy-perl, libtemplate-perl)
(Fedora: httpd, postgresql-server, perl-DBI, perl-DBD-Pg)
-(SuSE: apache2, postgresql-server, perl-DBI, perl-DBD-Pg, perl-Archive-Zip, perl-Class-Accessor, perl-Text-Iconv, perl-Text-CSV_XS, perl-HTML-Template, perl-IO-stringy)
+(SuSE: apache2, postgresql-server, perl-DBI, perl-DBD-Pg, perl-Archive-Zip, perl-Class-Accessor, perl-Text-Iconv, perl-Text-CSV_XS, perl-HTML-Template, perl-IO-stringy, perl-Template-Toolkit)
Da Perl-CGI-Ajax nicht als Paket für Distributionen bereit steht, muß es mit der CPAN-Shell installiert werden.
Bitte beachten Sie auch die Liste der benötigten Perl-Module am Anfang
der Datei "doc/INSTALL". Besonders nach einem Upgrade auf 2.4.2 muss
sichergestellt werden, dass das Modul "YAML" installiert ist. v2.6.0
-benötigt zusätzlich die Module "Text::CSV_XS" und "IO::Wrap".
+benötigt zusätzlich die Module "Text::CSV_XS", "IO::Wrap" (aus dem
+Paket "IO::Stringy") sowie "Template" (Paket "Template-Toolkit").
Das Datenbankupgrade wird automatisch gestartet, wenn sich der erste
Benutzer nach dem Upgrade der Dateien an Lx-Office anmeldet.
}
# is this a template call?
- if (/parse_html_template\s*\(\s*[\"\']([\w\/]+)/) {
+ if (/parse_html_template2?\s*\(\s*[\"\']([\w\/]+)/) {
my $newfile = "$basedir/templates/webpages/$1_master.html";
if (-f $newfile) {
# &scanhtmlfile($newfile);
-<body>
+[% USE HTML %]<body>
<script type="text/javascript">
<!--
-->
</script>
- <TMPL_IF MESSAGE>
- <p><TMPL_VAR MESSAGE></p>
- </TMPL_IF>
+ [% IF MESSAGE %]
+ <p>[% MESSAGE %]</p>
+ [% END %]
- <div class="listtop" width="100%"><TMPL_VAR TITLE></div>
+ <div class="listtop" width="100%">[% TITLE %]</div>
- <TMPL_IF TOP_INFO_TEXT>
- <p><TMPL_VAR TOP_INFO_TEXT></p>
- </TMPL_IF>
+ [% IF TOP_INFO_TEXT %]
+ <p>[% TOP_INFO_TEXT %]</p>
+ [% END %]
- <TMPL_VAR RAW_TOP_INFO_TEXT>
+ [% RAW_TOP_INFO_TEXT %]
<p>
<table width="100%">
<tr>
- <TMPL_LOOP COLUMN_HEADERS>
- <th class="listheading"><TMPL_IF link><a href="<TMPL_VAR link>"></TMPL_IF><TMPL_VAR text ESCAPE=HTML><TMPL_IF link><TMPL_IF show_sort_indicator><img border="0" src="image/<TMPL_IF sort_indicator_direction>down<TMPL_ELSE>up</TMPL_IF>.png"></TMPL_IF></a><TMPL_ELSE><TMPL_IF show_sort_indicator><img src="image/<TMPL_IF sort_indicator_direction>down<TMPL_ELSE>up</TMPL_IF>.png"></TMPL_IF></TMPL_IF></th>
- </TMPL_LOOP>
+ [% FOREACH col = COLUMN_HEADERS %]
+ <th class="listheading">[% IF col.link %]<a href="[% col.link %]">[% END %][% HTML.escape(col.text) %][% IF col.link %][% IF col.show_sort_indicator %]<img border="0" src="image/[% IF col.sort_indicator_direction %]down[% ELSE %]up[% END %].png">[% END %]</a>[% ELSE %][% IF col.show_sort_indicator %]<img src="image/[% IF col.sort_indicator_direction %]down[% ELSE %]up[% END %].png">[% END %][% END %]</th>
+ [% END %]
</tr>
- <TMPL_LOOP ROWS>
- <TMPL_IF IS_CONTROL>
- <TMPL_IF IS_SEPARATOR><tr><td colspan="<TMPL_VAR NUM_COLUMNS>"><hr size="3" noshade></td></tr></TMPL_IF><TMPL_IF IS_COLSPAN_DATA><tr><td colspan="<TMPL_VAR NUM_COLUMNS>"><TMPL_VAR data></td></tr></TMPL_IF>
- <TMPL_ELSE>
- <tr class="listrow<TMPL_VAR outer_idx_odd>">
- <TMPL_LOOP COLUMNS><td<TMPL_IF align> align="<TMPL_VAR align>"</TMPL_IF><TMPL_IF valign> valign="<TMPL_VAR valign>"</TMPL_IF><TMPL_IF class> class="<TMPL_VAR class>"</TMPL_IF>><TMPL_IF raw_data><TMPL_VAR raw_data></TMPL_IF><TMPL_LOOP CELL_ROWS><TMPL_IF data><TMPL_IF link><a href="<TMPL_VAR link>"></TMPL_IF><TMPL_VAR data><TMPL_IF link></a></TMPL_IF></TMPL_IF><TMPL_UNLESS __last__><br></TMPL_UNLESS></TMPL_LOOP></td>
- </TMPL_LOOP>
+ [% FOREACH row = ROWS %]
+ [% IF row.IS_CONTROL %]
+ [% IF row.IS_SEPARATOR %]<tr><td colspan="[% row.NUM_COLUMNS %]"><hr size="3" noshade></td></tr>[% END %][% IF row.IS_COLSPAN_DATA %]<tr><td colspan="[% row.NUM_COLUMNS %]">[% row.data %]</td></tr>[% END %]
+ [% ELSE %]
+ <tr class="listrow[% row.outer_idx_odd %]">
+ [% FOREACH col = row.COLUMNS %]<td[% IF col.align %] align="[% col.align %]"[% END %][% IF col.valign %] valign="[% col.valign %]"[% END %][% IF col.class %] class="[% col.class %]"[% END %]>[% IF col.raw_data %][% col.raw_data %][% END %][% USE iterator(col.CELL_ROWS) %][% FOREACH cell_row = iterator %][% IF cell_row.data %][% IF cell_row.link %]<a href="[% cell_row.link %]">[% END %][% cell_row.data %][% IF cell_row.link %]</a>[% END %][% END %][% UNLESS iterator.last %]<br>aa[% END %][% END %]</td>
+ [% END %]
</tr>
- </TMPL_IF>
- </TMPL_LOOP>
+ [% END %]
+ [% END %]
- <tr><td colspan="<TMPL_VAR NUM_COLUMNS>"><hr size="3" noshade></td></tr>
+ <tr><td colspan="[% NUM_COLUMNS %]"><hr size="3" noshade></td></tr>
</table>
</p>
- <TMPL_VAR RAW_BOTTOM_INFO_TEXT>
+ [% RAW_BOTTOM_INFO_TEXT %]
- <TMPL_IF BOTTOM_INFO_TEXT>
- <p><TMPL_VAR BOTTOM_INFO_TEXT></p>
- </TMPL_IF>
+ [% IF BOTTOM_INFO_TEXT %]
+ <p>[% BOTTOM_INFO_TEXT %]</p>
+ [% END %]
- <TMPL_IF SHOW_EXPORT_BUTTONS>
- <form action="<TMPL_VAR script ESCAPE=HTML>" name="report_generator_form" method="post">
- <input type="hidden" name="login" value="<TMPL_VAR login ESCAPE=HTML>">
- <input type="hidden" name="password" value="<TMPL_VAR password ESCAPE=HTML>">
+ [% IF SHOW_EXPORT_BUTTONS %]
+ <form action="[% HTML.escape(script) %]" name="report_generator_form" method="post">
+ <input type="hidden" name="login" value="[% HTML.escape(login) %]">
+ <input type="hidden" name="password" value="[% HTML.escape(password) %]">
- <TMPL_LOOP EXPORT_VARIABLES><input type="hidden" name="report_generator_hidden_<TMPL_VAR key ESCAPE=HTML>" value="<TMPL_VAR value ESCAPE=HTML>">
- </TMPL_LOOP>
+ [% FOREACH var = EXPORT_VARIABLES %]<input type="hidden" name="report_generator_hidden_[% var.key %]" value="[% HTML.escape(var.value) %]">
+ [% END %]
- <input type="hidden" name="report_generator_nextsub" value="<TMPL_VAR EXPORT_NEXTSUB ESCAPE=HTML>">
- <input type="hidden" name="report_generator_variable_list" value="<TMPL_VAR EXPORT_VARIABLE_LIST ESCAPE=HTML>">
+ <input type="hidden" name="report_generator_nextsub" value="[% HTML.escape(EXPORT_NEXTSUB) %]">
+ <input type="hidden" name="report_generator_variable_list" value="[% HTML.escape(EXPORT_VARIABLE_LIST) %]">
<input type="hidden" name="report_generator_dispatch_to" value="">
<input type="hidden" name="action" value="report_generator_dispatcher">
<p>
Listenexport<br>
- <TMPL_IF ALLOW_PDF_EXPORT><button type="button" class="submit" onclick="submit_report_generator_form('report_generator_export_as_pdf')">Als PDF exportieren</button></TMPL_IF>
- <TMPL_IF ALLOW_CSV_EXPORT><button type="button" class="submit" onclick="submit_report_generator_form('report_generator_export_as_csv')">Als CSV exportieren</button></TMPL_IF>
+ [% IF ALLOW_PDF_EXPORT %]<button type="button" class="submit" onclick="submit_report_generator_form('report_generator_export_as_pdf')">Als PDF exportieren</button>[% END %]
+ [% IF ALLOW_CSV_EXPORT %]<button type="button" class="submit" onclick="submit_report_generator_form('report_generator_export_as_csv')">Als CSV exportieren</button>[% END %]
</p>
</form>
- </TMPL_IF>
+ [% END %]
</body>
-<body>
+[% USE HTML %]<body>
<script type="text/javascript">
<!--
-->
</script>
- <TMPL_IF MESSAGE>
- <p><TMPL_VAR MESSAGE></p>
- </TMPL_IF>
+ [% IF MESSAGE %]
+ <p>[% MESSAGE %]</p>
+ [% END %]
- <div class="listtop" width="100%"><TMPL_VAR TITLE></div>
+ <div class="listtop" width="100%">[% TITLE %]</div>
- <TMPL_IF TOP_INFO_TEXT>
- <p><TMPL_VAR TOP_INFO_TEXT></p>
- </TMPL_IF>
+ [% IF TOP_INFO_TEXT %]
+ <p>[% TOP_INFO_TEXT %]</p>
+ [% END %]
- <TMPL_VAR RAW_TOP_INFO_TEXT>
+ [% RAW_TOP_INFO_TEXT %]
<p>
<table width="100%">
<tr>
- <TMPL_LOOP COLUMN_HEADERS>
- <th class="listheading"><TMPL_IF link><a href="<TMPL_VAR link>"></TMPL_IF><TMPL_VAR text ESCAPE=HTML><TMPL_IF link><TMPL_IF show_sort_indicator><img border="0" src="image/<TMPL_IF sort_indicator_direction>down<TMPL_ELSE>up</TMPL_IF>.png"></TMPL_IF></a><TMPL_ELSE><TMPL_IF show_sort_indicator><img src="image/<TMPL_IF sort_indicator_direction>down<TMPL_ELSE>up</TMPL_IF>.png"></TMPL_IF></TMPL_IF></th>
- </TMPL_LOOP>
+ [% FOREACH col = COLUMN_HEADERS %]
+ <th class="listheading">[% IF col.link %]<a href="[% col.link %]">[% END %][% HTML.escape(col.text) %][% IF col.link %][% IF col.show_sort_indicator %]<img border="0" src="image/[% IF col.sort_indicator_direction %]down[% ELSE %]up[% END %].png">[% END %]</a>[% ELSE %][% IF col.show_sort_indicator %]<img src="image/[% IF col.sort_indicator_direction %]down[% ELSE %]up[% END %].png">[% END %][% END %]</th>
+ [% END %]
</tr>
- <TMPL_LOOP ROWS>
- <TMPL_IF IS_CONTROL>
- <TMPL_IF IS_SEPARATOR><tr><td colspan="<TMPL_VAR NUM_COLUMNS>"><hr size="3" noshade></td></tr></TMPL_IF><TMPL_IF IS_COLSPAN_DATA><tr><td colspan="<TMPL_VAR NUM_COLUMNS>"><TMPL_VAR data></td></tr></TMPL_IF>
- <TMPL_ELSE>
- <tr class="listrow<TMPL_VAR outer_idx_odd>">
- <TMPL_LOOP COLUMNS><td<TMPL_IF align> align="<TMPL_VAR align>"</TMPL_IF><TMPL_IF valign> valign="<TMPL_VAR valign>"</TMPL_IF><TMPL_IF class> class="<TMPL_VAR class>"</TMPL_IF>><TMPL_IF raw_data><TMPL_VAR raw_data></TMPL_IF><TMPL_LOOP CELL_ROWS><TMPL_IF data><TMPL_IF link><a href="<TMPL_VAR link>"></TMPL_IF><TMPL_VAR data><TMPL_IF link></a></TMPL_IF></TMPL_IF><TMPL_UNLESS __last__><br></TMPL_UNLESS></TMPL_LOOP></td>
- </TMPL_LOOP>
+ [% FOREACH row = ROWS %]
+ [% IF row.IS_CONTROL %]
+ [% IF row.IS_SEPARATOR %]<tr><td colspan="[% row.NUM_COLUMNS %]"><hr size="3" noshade></td></tr>[% END %][% IF row.IS_COLSPAN_DATA %]<tr><td colspan="[% row.NUM_COLUMNS %]">[% row.data %]</td></tr>[% END %]
+ [% ELSE %]
+ <tr class="listrow[% row.outer_idx_odd %]">
+ [% FOREACH col = row.COLUMNS %]<td[% IF col.align %] align="[% col.align %]"[% END %][% IF col.valign %] valign="[% col.valign %]"[% END %][% IF col.class %] class="[% col.class %]"[% END %]>[% IF col.raw_data %][% col.raw_data %][% END %][% USE iterator(col.CELL_ROWS) %][% FOREACH cell_row = iterator %][% IF cell_row.data %][% IF cell_row.link %]<a href="[% cell_row.link %]">[% END %][% cell_row.data %][% IF cell_row.link %]</a>[% END %][% END %][% UNLESS iterator.last %]<br>aa[% END %][% END %]</td>
+ [% END %]
</tr>
- </TMPL_IF>
- </TMPL_LOOP>
+ [% END %]
+ [% END %]
- <tr><td colspan="<TMPL_VAR NUM_COLUMNS>"><hr size="3" noshade></td></tr>
+ <tr><td colspan="[% NUM_COLUMNS %]"><hr size="3" noshade></td></tr>
</table>
</p>
- <TMPL_VAR RAW_BOTTOM_INFO_TEXT>
+ [% RAW_BOTTOM_INFO_TEXT %]
- <TMPL_IF BOTTOM_INFO_TEXT>
- <p><TMPL_VAR BOTTOM_INFO_TEXT></p>
- </TMPL_IF>
+ [% IF BOTTOM_INFO_TEXT %]
+ <p>[% BOTTOM_INFO_TEXT %]</p>
+ [% END %]
- <TMPL_IF SHOW_EXPORT_BUTTONS>
- <form action="<TMPL_VAR script ESCAPE=HTML>" name="report_generator_form" method="post">
- <input type="hidden" name="login" value="<TMPL_VAR login ESCAPE=HTML>">
- <input type="hidden" name="password" value="<TMPL_VAR password ESCAPE=HTML>">
+ [% IF SHOW_EXPORT_BUTTONS %]
+ <form action="[% HTML.escape(script) %]" name="report_generator_form" method="post">
+ <input type="hidden" name="login" value="[% HTML.escape(login) %]">
+ <input type="hidden" name="password" value="[% HTML.escape(password) %]">
- <TMPL_LOOP EXPORT_VARIABLES><input type="hidden" name="report_generator_hidden_<TMPL_VAR key ESCAPE=HTML>" value="<TMPL_VAR value ESCAPE=HTML>">
- </TMPL_LOOP>
+ [% FOREACH var = EXPORT_VARIABLES %]<input type="hidden" name="report_generator_hidden_[% var.key %]" value="[% HTML.escape(var.value) %]">
+ [% END %]
- <input type="hidden" name="report_generator_nextsub" value="<TMPL_VAR EXPORT_NEXTSUB ESCAPE=HTML>">
- <input type="hidden" name="report_generator_variable_list" value="<TMPL_VAR EXPORT_VARIABLE_LIST ESCAPE=HTML>">
+ <input type="hidden" name="report_generator_nextsub" value="[% HTML.escape(EXPORT_NEXTSUB) %]">
+ <input type="hidden" name="report_generator_variable_list" value="[% HTML.escape(EXPORT_VARIABLE_LIST) %]">
<input type="hidden" name="report_generator_dispatch_to" value="">
<input type="hidden" name="action" value="report_generator_dispatcher">
<p>
- <translate>List export</translate><br>
- <TMPL_IF ALLOW_PDF_EXPORT><button type="button" class="submit" onclick="submit_report_generator_form('report_generator_export_as_pdf')"><translate>Export as PDF</translate></button></TMPL_IF>
- <TMPL_IF ALLOW_CSV_EXPORT><button type="button" class="submit" onclick="submit_report_generator_form('report_generator_export_as_csv')"><translate>Export as CSV</translate></button></TMPL_IF>
+ Listenexport<br>
+ [% IF ALLOW_PDF_EXPORT %]<button type="button" class="submit" onclick="submit_report_generator_form('report_generator_export_as_pdf')">Als PDF exportieren</button>[% END %]
+ [% IF ALLOW_CSV_EXPORT %]<button type="button" class="submit" onclick="submit_report_generator_form('report_generator_export_as_csv')">Als CSV exportieren</button>[% END %]
</p>
</form>
- </TMPL_IF>
+ [% END %]
</body>