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

% unless (@person_images) % { % } % else % { % my $cell_count = 1; % foreach my $person_image (@person_images) % { % if ($cell_count > 1) % { % if ($cell_count == 5) % { % $cell_count = 1; % next; % } % } % else % { % } % $cell_count++; % } % unless ($cell_count eq 1) % { % } % }

No images
<% $person_image->{">
% foreach my $people_res (@people_res) { % if ($people_res->{id} eq $person_image->{id}){ % my $movie_id=$people_res->{movie_id}; % my $name=$people_res->{"title_$display_set"}; % my $year=$people_res->{year_made}; <% $name %> (<% $year %>) %} %}
 
<% $person_image->{">
% foreach my $people_res (@people_res) { % if ($people_res->{id} eq $person_image->{id}){ % my $movie_id=$people_res->{movie_id}; % my $name=$people_res->{"title_$display_set"}; % my $year=$people_res->{year_made}; <% $name %> (<% $year %>) %} %}
<%init> ### 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 = new HKMDB::Database; my $user = HKMDB::User->new; my $logged_in = $user->authenticate; # Get image info my $person_images_stmt = <<"EOSQL"; SELECT i.id,i.thumbnail_path,i.thumbnail_height,i.thumbnail_width,i.description_$display_set FROM images as i,people_resources as pr,resources as r WHERE pr.people_id = ? AND r.id = pr.resource_id AND r.table_name = 'images' AND r.table_id = i.id ORDER by (i.thumbnail_width/i.thumbnail_height) EOSQL my @person_images = $db->select_rows( sql => $person_images_stmt, bind => [ $id ], hashref => 1 ); my $movie_res_stmt = <<"EOSQL"; SELECT i.id,i.description_$display_set,i.is_portrait,m.id as movie_id,m.title_$display_set,m.year_made FROM images as i,movie_resources as mr,resources as r,people_resources as pr, movies as m WHERE pr.people_id = ? AND r.id = pr.resource_id AND r.table_name = 'images' AND r.table_id = i.id AND mr.resource_id = pr.resource_id AND m.id=mr.movie_id EOSQL my @people_res = $db->select_rows( sql => $movie_res_stmt, bind => [ $id ], hashref => 1 );