From 2b6b46fefd21ebee3ddd76b499ddc0f72b893fed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Mon, 15 Mar 2021 15:20:40 +0100 Subject: [PATCH] =?utf8?q?einfacher=20Presenter=20f=C3=BCr=20SL::File::Obj?= =?utf8?q?ect?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Presenter/ALL.pm | 1 + SL/Presenter/FileObject.pm | 81 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 SL/Presenter/FileObject.pm diff --git a/SL/Presenter/ALL.pm b/SL/Presenter/ALL.pm index aa404decf..9fe2db34f 100644 --- a/SL/Presenter/ALL.pm +++ b/SL/Presenter/ALL.pm @@ -29,6 +29,7 @@ our %presenters = ( delivery_order => 'SL::Presenter::DeliveryOrder', dunning => 'SL::Presenter::Dunning', escaped_text => 'SL::Presenter::EscapedText', + file_object => 'SL::Presenter::FileObject', invoice => 'SL::Presenter::Invoice', gl => 'SL::Presenter::GL', letter => 'SL::Presenter::Letter', diff --git a/SL/Presenter/FileObject.pm b/SL/Presenter/FileObject.pm new file mode 100644 index 000000000..62671eaeb --- /dev/null +++ b/SL/Presenter/FileObject.pm @@ -0,0 +1,81 @@ +package SL::Presenter::FileObject; + +use strict; + +use SL::Presenter::EscapedText qw(escape is_escaped); + +use Exporter qw(import); +our @EXPORT_OK = qw(file_object); + +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, + ); + + is_escaped($text); +} + +1; + + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::Presenter::FileObject - Presenter module for SL::File::Object(s), the +file objects of the filemanagement. (Note, that this are not instances of +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); + +=head1 FUNCTIONS + +=over 4 + +=item C + +Returns a rendered version (actually an instance of +L) of the file object +C<$file_object>. + +C<%params> can include: + +=over 2 + +=item * no_link + +If falsish (the default) then the file name of the object will be linked +to the "download action" for that file. + +=back + +=back + +=head1 BUGS + +Nothing here yet. + +=head1 AUTHOR + +Bernd Bleßmann Ebernd@kivitendo-premium.deE + +=cut -- 2.20.1