<%args> $id => undef $display_set => undef

% unless (@movie_reviews) { % } else { % $x = 0; % foreach my $review (@movie_reviews) { % } % }

No reviews
% my $x = 0; % #foreach my $review (@movie_reviews) { % # #my $summary = $review->{summary} ? $review->{summary} : substr($review->{review}, 0, 20) . '...'; % # my $summary = $review->{summary} ? $review->{summary} : next; % #}


Reviewed by: <% $review->{username} %>
Date: <% $review->{date} %>
% if ($review->{summary}) { Summary: <% $review->{summary} %> % } % my $review_text = HTML::FromText::text2html($review->{review}, lines => 1);

<% $review_text %>

% if ($review->{score} > 0 ) { Reviewer Score: <% $review->{score} %> % }

<%init> use Date::Manip (); use HTML::Entities; ### Check for errors # This'll be passed to /db/common/error.mhtml if # required args are missing my @missing_args; # Required args push(@missing_args, 'id') unless ($id); push(@missing_args, 'display_set') unless ($display_set); # Call error.mhtml if we're missing something if (@missing_args) { $m->comp('/db/common/error.mhtml', errors => [ { description => 'Missing arguments', args => \@missing_args } ], display_set => $display_set ); } my $db = HKMDB::Database->new; # Get review info my $movie_reviews_stmt = q{ SELECT review, summary, username, last_updated, score FROM movie_reviews WHERE movie_id = ? }; my $bind = [ $id ]; if ($display_set ne 'big5') { $movie_reviews_stmt .= ' AND language_id = ?'; push @$bind, $db->language_id($display_set); } my @movie_reviews = $db->select_rows( sql => $movie_reviews_stmt, bind => $bind, hashref => 1 ); foreach (@movie_reviews) { $_->{last_updated} = Date::Manip::ParseDate($_->{last_updated}); $_->{date} = Date::Manip::UnixDate($_->{last_updated}, '%m/%d/%Y'); } @movie_reviews = reverse sort {$a->{last_updated} cmp $b->{last_updated}} @movie_reviews;