changelog: Liste gefixter Bugs für neues Release
[kivitendo-erp.git] / SL / Presenter / FileObject.pm
1 package SL::Presenter::FileObject;
2
3 use strict;
4
5 use SL::Presenter::Tag         qw(link_tag);
6 use SL::Presenter::EscapedText qw(escape is_escaped);
7
8 use Exporter qw(import);
9 our @EXPORT_OK = qw(file_object);
10
11 use Carp;
12
13 sub file_object {
14   my ($file_object, %params) = @_;
15
16
17   my $text = escape($file_object->file_name);
18   if (! delete $params{no_link}) {
19     my $href  = 'controller.pl?action=File/download&id=' . $file_object->id;
20     $href    .= '&version=' . $file_object->version if $file_object->version;
21     $text     = link_tag($href, $text, %params);
22   }
23
24   is_escaped($text);
25 }
26
27 1;
28
29
30 __END__
31
32 =pod
33
34 =encoding utf8
35
36 =head1 NAME
37
38 SL::Presenter::FileObject - Presenter module for SL::File::Object(s), the
39 file objects of the filemanagement. (Note, that this are not instances of
40 SL::DB::File)
41
42 =head1 SYNOPSIS
43
44   my $file_object = SL::File->get(id => 1);
45   my $html        = SL::Presenter::FileObject::file_object($file_object, no_link => 1);
46
47 =head1 FUNCTIONS
48
49 =over 4
50
51 =item C<file_object $file_object, %params>
52
53 Returns a rendered version (actually an instance of
54 L<SL::Presenter::EscapedText>) of the file object
55 C<$file_object>.
56
57 C<%params> can include:
58
59 =over 2
60
61 =item * no_link
62
63 If falsish (the default) then the file name of the object will be linked
64 to the "download action" for that file.
65
66 =back
67
68 =back
69
70 =head1 BUGS
71
72 Nothing here yet.
73
74 =head1 AUTHOR
75
76 Bernd Bleßmann E<lt>bernd@kivitendo-premium.deE<gt>
77
78 =cut