Revision 4d4ca4a5
Von Bernd Bleßmann vor mehr als 3 Jahren hinzugefügt
SL/Presenter/FileObject.pm | ||
---|---|---|
2 | 2 |
|
3 | 3 |
use strict; |
4 | 4 |
|
5 |
use SL::Presenter::Tag qw(link_tag); |
|
5 | 6 |
use SL::Presenter::EscapedText qw(escape is_escaped); |
6 | 7 |
|
7 | 8 |
use Exporter qw(import); |
... | ... | |
12 | 13 |
sub file_object { |
13 | 14 |
my ($file_object, %params) = @_; |
14 | 15 |
|
15 |
my $link_start = '<a href="controller.pl?action=File/download&id=' . $file_object->id; |
|
16 |
$link_start .= '&version=' . $file_object->version if $file_object->version; |
|
17 |
$link_start .= '">'; |
|
18 | 16 |
|
19 |
my $link_end = '</a>'; |
|
20 |
|
|
21 |
my $text = join '', ( |
|
22 |
$params{no_link} ? '' : $link_start, |
|
23 |
escape($file_object->file_name), |
|
24 |
$params{no_link} ? '' : $link_end, |
|
25 |
); |
|
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 |
} |
|
26 | 23 |
|
27 | 24 |
is_escaped($text); |
28 | 25 |
} |
... | ... | |
45 | 42 |
=head1 SYNOPSIS |
46 | 43 |
|
47 | 44 |
my $file_object = SL::File->get(id => 1); |
48 |
my $html = SL::Presenter::File::file_object($file_object, no_link => 1); |
|
45 |
my $html = SL::Presenter::FileObject::file_object($file_object, no_link => 1);
|
|
49 | 46 |
|
50 | 47 |
=head1 FUNCTIONS |
51 | 48 |
|
Auch abrufbar als: Unified diff
SL::Presenter::FileObject: link_tag verwenden