1 package SL::Presenter::Project;
 
   5 use parent qw(Exporter);
 
   7 use Exporter qw(import);
 
   8 our @EXPORT = qw(project);
 
  13   my ($self, $project, %params) = @_;
 
  15   return '' unless $project;
 
  17   $params{display} ||= 'inline';
 
  19   croak "Unknown display type '$params{display}'" unless $params{display} =~ m/^(?:inline|table-cell)$/;
 
  21   $params{style} ||= 'both';
 
  24   if ($params{style} =~ m/number/) {
 
  25     $description = $project->projectnumber;
 
  27   } elsif ($params{style} =~ m/description/) {
 
  28     $description = $project->description;
 
  31     $description = $project->projectnumber;
 
  32     if ($project->description && do { my $desc = quotemeta $project->description; $project->projectnumber !~ m/$desc/ }) {
 
  33       $description .= ' (' . $project->description . ')';
 
  38     $params{no_link} ? '' : '<a href="controller.pl?action=Project/edit&id=' . $self->escape($project->id) . '">',
 
  39     $self->escape($description),
 
  40     $params{no_link} ? '' : '</a>',
 
  42   return $self->escaped_text($text);
 
  55 SL::Presenter::Project - Presenter module for project Rose::DB objects
 
  59   my $project = SL::DB::Manager::Project->get_first;
 
  60   my $html    = SL::Presenter->get->project($project, display => 'inline');
 
  66 =item C<project $object, %params>
 
  68 Returns a rendered version (actually an instance of
 
  69 L<SL::Presenter::EscapedText>) of the project object C<$customer>.
 
  71 C<%params> can include:
 
  77 Either C<inline> (the default) or C<table-cell>. At the moment both
 
  78 representations are identical and produce the project's description
 
  79 (controlled by the C<style> parameter) linked to the corresponding
 
  84 Determines what exactly will be output. Can be one of the values with
 
  85 C<both> being the default if it is missing:
 
  89 =item C<projectnumber> (or simply C<number>)
 
  91 Outputs only the project's number.
 
  93 =item C<projectdescription> (or simply C<description>)
 
  95 Outputs only the project's description.
 
  99 Outputs the project's number followed by its description in
 
 100 parenthesis (e.g. "12345 (Secret Combinations)"). If the project's
 
 101 description is already part of the project's number then it will not
 
 108 If falsish (the default) then the project's description will be linked to
 
 109 the "edit project" dialog from the master data menu.
 
 121 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>