From: Bernd Bleßmann Date: Fri, 19 Mar 2021 14:52:40 +0000 (+0100) Subject: Einfachen Presenter f. Webdav-Objekte X-Git-Tag: kivitendo-mebil_0.1-0~9^2~406 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=13b00f5a77d95d98d14856f6a8058753d28861e3;p=kivitendo-erp.git Einfachen Presenter f. Webdav-Objekte --- diff --git a/SL/Presenter/WebdavObject.pm b/SL/Presenter/WebdavObject.pm new file mode 100644 index 000000000..7318f0ce6 --- /dev/null +++ b/SL/Presenter/WebdavObject.pm @@ -0,0 +1,79 @@ +package SL::Presenter::WebdavObject; + +use strict; + +use SL::Presenter::Tag qw(link_tag); +use SL::Presenter::EscapedText qw(escape is_escaped); + +use Exporter qw(import); +our @EXPORT_OK = qw(webdav_object); + +use Carp; + +sub webdav_object { + my ($webdav_object, %params) = @_; + + + my $text = escape($webdav_object->filename); + if (! delete $params{no_link}) { + my $href = SL::Presenter::EscapedText::escape($webdav_object->full_filedescriptor); + $text = link_tag($href, $text, %params); + } + + is_escaped($text); +} + +1; + + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::Presenter::WebdavObject - Presenter module for SL::Webdav::Object(s). + +=head1 SYNOPSIS + + my $webdav = SL::Webdav->new( + type => 'sales_order', + number => '1234', + ); + my @all_objects = $webdav->get_all_objects; + my $html = SL::Presenter::WebdavObject::webdav_object($all_objects[0], no_link => 1); + +=head1 FUNCTIONS + +=over 4 + +=item C + +Returns a rendered version (actually an instance of +L) of the webdav object +C<$webdav_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 path for that file. + +=back + +=back + +=head1 BUGS + +Nothing here yet. + +=head1 AUTHOR + +Bernd Bleßmann Ebernd@kivitendo-premium.deE + +=cut