<%args> $id => undef $display_set => 'eng' % { % # ALIASES - If they exist % my @aliases = ( $m->comp( 'aliases.mhtml', % id => $id, % display_set => $display_set ) ); % if (@aliases) { % #}
% my $ii=scalar @aliases; % foreach my $a (@aliases) { % $ii--; % if ($ii <= 0) { <% $a->{alias} %> % } else { <% $a->{alias} %>,  % } % } % } else { % } % # pinyin %#my @pinyin = ( $m->comp( 'pinyin.mhtml', %# id => $id, %# display_set => $display_set ) ); % #if ($display_set eq 'eng' && $person_info->{name_utf8_trad}) { % #
% #Cantonese: % #my $cant_str = Lingua::Han::Cantonese->new(); % #my @cant_str_split = csplit($person_info->{name_utf8_trad}); % #foreach my $cant_char (@cant_str_split){ % #if ($cant_char eq '(') { last; } % #<% $cant_str->han2Cantonese($cant_char) %> % #} % #} % #if ($display_set eq 'eng' && $person_info->{name_utf8_trad}) { % #   Mandarin: % #my $mand_str = Lingua::Han::PinYin->new(unicode => 1); % #my @mand_str_split = csplit($person_info->{name_utf8_trad}); % #foreach my $mand_char (@mand_str_split){ % #if ($mand_char eq '(') { last; } % #<% $mand_str->han2pinyin1($mand_char) %> % #} % #
% foreach my $person_image (@person_images) % { %}

% if ($person_info->{"bio_$display_set"}) % { % $person_info->{"bio_$display_set"} =~ s/\n\n/\/g; % }
%if (@filmography_rows){ % if ($year_min->{year_made} eq $year_max->{year_made}) { % foreach my $job (keys %$filmography) % { % my $job_title = $jobs->{$job}; % my $job_title_b5 = $jobs_b5->{$job}; % my $job_title_utf=encode("utf8", decode("big5", $jobs_b5->{$job})); % next unless ($job_title); % if ($job_title eq 'Actor') { % } else { % } % foreach my $appearance (@{$filmography->{$job}}) % { % my $movie_title = $appearance->{title}; % my $movie_title_big5 = $appearance->{title_b5}; % my $role = $appearance->{role}; % my $role_b5 = $appearance->{role_b5}; % my $movie_id = $appearance->{movie_id}; % my $year = $appearance->{year}; % } % } % } % }
 
影視作品 / Filmography (<% $year_min->{year_made} %>) % } else {
影視作品 / Filmography (<% $year_min->{year_made} %>-<% $year_max->{year_made} %>) % }
 
  <% $job_title_utf %> / <% $job_title %> (<% $year_min->{year_made} %>-<% $year_max->{year_made} %>) <% $job_title_utf %> / <% $job_title %>
    % my $movie_title_utf=encode("utf8", decode("big5", $appearance->{title_b5})); % my $role_utf=encode("utf8", decode("big5", $appearance->{role_b5})); <% $movie_title_utf %> / <% $movie_title %> (<% $year %>) % if ($role) % { ... <% $role_utf %> / <% $role %> % } % else % {    
 
 
Biography
 
  <% $person_info->{"bio_$display_set"} %>
 
% } <%init> use Encode qw/encode decode/; use Encode::HanConvert; use Lingua::Han::PinYin; use Lingua::Han::Cantonese; use Lingua::Han::Utils qw/Unihan_value csplit cdecode csubstr clength/; my $user = HKMDB::User->new; my $logged_in = $user->authenticate; ### Fetch the data my $db = new HKMDB::Database; my $portrait_image_stmt = <<"EOF"; SELECT i.id,i.description_$display_set,i.path,i.width,i.height,i.thumbnail_path,i.thumbnail_width,i.thumbnail_height FROM images as i, people as p WHERE p.id = ? AND p.portrait_image_id = i.id EOF my $portrait_image = $db->select_rows( sql => $portrait_image_stmt, bind => [ $id ], hashref => 1 ); # Get job titles my @job_rows = $db->select( table => 'jobs', select => [ 'id', 'job_' . 'eng' , 'job_' . 'big5' ] ); my $jobs; my $jobs_b5; foreach my $job_row (@job_rows) { my $job_id = $job_row->{id}; my $job_title = $job_row->{"job_$display_set"}; my $job_title_b5 = $job_row->{"job_big5"}; $jobs->{$job_id} = $job_title; $jobs_b5->{$job_id} = $job_title_b5; } ### Get filmography info my $filmography_stmt = <<"EOSQL"; SELECT m.id,m.title_eng,m.title_big5,m.year_made,a.job_id,a.role_eng,a.role_big5,m.title_big5 FROM appearances AS a,movies AS m WHERE a.people_id = ? AND m.id = a.movie_id ORDER BY m.year_made EOSQL my @filmography_rows = $db->select_rows( sql => $filmography_stmt, bind => [ $id ], hashref => 1 ); my $year_min_stmt = <<"EOSQL"; SELECT m.year_made FROM appearances AS a,movies AS m WHERE a.people_id = ? AND m.id = a.movie_id ORDER by year_made LIMIT 1 EOSQL my $year_min = $db->select_rows( sql => $year_min_stmt, bind => [ $id ], hashref => 1 ); my $year_max_stmt = <<"EOSQL"; SELECT m.year_made FROM appearances AS a,movies AS m WHERE a.people_id = ? AND m.id = a.movie_id ORDER by year_made DESC LIMIT 1 EOSQL my $year_max = $db->select_rows( sql => $year_max_stmt, bind => [ $id ], hashref => 1 ); 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 AND (i.thumbnail_height+25)>i.thumbnail_width AND i.is_portrait = 1 ORDER BY RAND() LIMIT 5 EOSQL my @person_images = $db->select_rows( sql => $person_images_stmt, bind => [ $id ], hashref => 1 ); # For all films the person has been in, sort by job my $filmography; foreach my $row (@filmography_rows) { my $job_id = $row->{job_id}; my $movie_title = $row->{"title_$display_set"}; my $movie_title_big5 = $row->{"title_big5"}; my $movie_id = $row->{id}; my $role = $row->{"role_eng"}; my $role_b5 = $row->{"role_big5"}; my $year = $row->{year_made}; unless ($filmography->{$job_id}) { $filmography->{$job_id} = []; } push(@{$filmography->{$job_id}}, { title => $movie_title, title_b5 => $movie_title_big5, role => $role, role_b5 => $role_b5, movie_id => $movie_id, year => $year } ); } my $person_stmt .= <<"EOSQL"; SELECT name_eng,name_big5,bio_$display_set,name_utf8_trad,birthplace_id,DATE_FORMAT(dob, '%M %D, %Y') as dob,DATE_FORMAT(dob, '%Y') as yob,DATE_FORMAT(dod, '%M %D, %Y') as dod,DATE_FORMAT(dod, '%Y') as yod FROM people WHERE id = ? EOSQL my $person_info = $db->select_rows( sql => $person_stmt, bind => [ $id ], hashref => 1 ); my $location_id = $person_info->{birthplace_id}; if ( $location_id ) { while ($location_id) { my $location_row = $db->select( table => 'locations', select => [ 'location_' . $display_set, 'located_in' ], keys => [ $location_id ] ); $person_info->{birthplace} .= ', ' . $location_row->{'location_' . $display_set}; $location_id = $location_row->{located_in}; } $person_info->{birthplace} =~ s/^, //; }