From: Bernd Bleßmann Date: Thu, 18 Mar 2021 15:17:59 +0000 (+0100) Subject: SL::Presenter::FileObject: link_tag verwenden X-Git-Tag: kivitendo-mebil_0.1-0~9^2~407 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=4d4ca4a599d0a4728c24278c7010005e17aacbbb;p=kivitendo-erp.git SL::Presenter::FileObject: link_tag verwenden --- diff --git a/SL/Presenter/FileObject.pm b/SL/Presenter/FileObject.pm index 62671eaeb..a339f9482 100644 --- a/SL/Presenter/FileObject.pm +++ b/SL/Presenter/FileObject.pm @@ -2,6 +2,7 @@ package SL::Presenter::FileObject; use strict; +use SL::Presenter::Tag qw(link_tag); use SL::Presenter::EscapedText qw(escape is_escaped); use Exporter qw(import); @@ -12,17 +13,13 @@ use Carp; sub file_object { my ($file_object, %params) = @_; - my $link_start = ''; - my $link_end = ''; - - my $text = join '', ( - $params{no_link} ? '' : $link_start, - escape($file_object->file_name), - $params{no_link} ? '' : $link_end, - ); + my $text = escape($file_object->file_name); + if (! delete $params{no_link}) { + my $href = 'controller.pl?action=File/download&id=' . $file_object->id; + $href .= '&version=' . $file_object->version if $file_object->version; + $text = link_tag($href, $text, %params); + } is_escaped($text); } @@ -45,7 +42,7 @@ SL::DB::File) =head1 SYNOPSIS my $file_object = SL::File->get(id => 1); - my $html = SL::Presenter::File::file_object($file_object, no_link => 1); + my $html = SL::Presenter::FileObject::file_object($file_object, no_link => 1); =head1 FUNCTIONS