X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/d445880375bce1462b8f9a8b1a502b34c296d41f..5b5dbec0272c91697acf33c4842ee9d63f041f22:/SL/Presenter/Project.pm?ds=inline diff --git a/SL/Presenter/Project.pm b/SL/Presenter/Project.pm new file mode 100644 index 000000000..650995c7f --- /dev/null +++ b/SL/Presenter/Project.pm @@ -0,0 +1,123 @@ +package SL::Presenter::Project; + +use strict; + +use parent qw(Exporter); + +use Exporter qw(import); +our @EXPORT = qw(project); + +use Carp; + +sub project { + my ($self, $project, %params) = @_; + + return '' unless $project; + + $params{display} ||= 'inline'; + + croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/; + + $params{style} ||= 'both'; + my $description; + + if ($params{style} =~ m/number/) { + $description = $project->projectnumber; + + } elsif ($params{style} =~ m/description/) { + $description = $project->description; + + } else { + $description = $project->projectnumber; + if ($project->description && do { my $desc = quotemeta $project->description; $project->projectnumber !~ m/$desc/ }) { + $description .= ' (' . $project->description . ')'; + } + } + + my $text = join '', ( + $params{no_link} ? '' : '', + $self->escape($description), + $params{no_link} ? '' : '', + ); + return $self->escaped_text($text); +} + +1; + +__END__ + +=pod + +=encoding utf8 + +=head1 NAME + +SL::Presenter::Project - Presenter module for project Rose::DB objects + +=head1 SYNOPSIS + + my $project = SL::DB::Manager::Project->get_first; + my $html = SL::Presenter->get->project($project, display => 'inline'); + +=head1 FUNCTIONS + +=over 4 + +=item C + +Returns a rendered version (actually an instance of +L) of the project object C<$customer>. + +C<%params> can include: + +=over 2 + +=item * display + +Either C (the default) or C. At the moment both +representations are identical and produce the project's description +(controlled by the C