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

% if ( @aliases ) % { % foreach my $entry (@aliases) % { %# Hack alert % if ($display_set eq 'eng' && $entry->{language_id} ne $db->language_id('eng')) % { % } % else % { % } % } % }
% if ($entry->{description}) % { % if ( HKMDB::Convert::contains_big5($entry->{description}) ) % { <% encode("utf8", decode("big5",$entry->{description})) %> % } % else % { <% $entry->{description} %> % } % } % else % { % } % if ( HKMDB::Convert::contains_big5($entry->{alias}) ) % { % my $utf_alias=encode("utf8", decode("big5",$entry->{alias})); <% $utf_alias %> % } % else % { % #my $utf_alias=encode("utf8", decode("big5",$entry->{alias})); <% $entry->{alias} %> % }
<% $entry->{description} || '' %> <% $entry->{alias} %>
 
% foreach my $company_logo (@company_logo) { % } % }
<% $company_logo->{" BORDER="0">
% if (@produced) % { %if ($display_set eq "eng"){ % } else { %} % foreach my $movie (@produced) % { % my $m_id = $movie->{id}; % my $m_title = $movie->{'title_' . $display_set}; % my $m_year = $movie->{year_made}; % } % } % if (@filmed) % { %if ($display_set eq "eng"){ % } else { %} % foreach my $movie (@filmed) % { % my $m_id = $movie->{id}; % my $m_title = $movie->{'title_' . $display_set}; % my $m_year = $movie->{year_made}; % } % } % if (@distributed) % { %if ($display_set eq "eng"){ % } else { %} % foreach my $movie (@distributed) % { % my $m_id = $movie->{id}; % my $m_title = $movie->{'title_' . $display_set}; % my $m_year = $movie->{year_made}; % } % } % #if (keys %$filmography) { % #if($display_set eq "eng"){ % #if ($year_min->{year_made} eq $year_max->{year_made}) { % # % #} % if (keys %$filmography) { % foreach my $job (keys %$filmography) % { % my $job_title = $jobs->{$job}; % next unless ($job_title); % my $num_films=@{$filmography->{$job}}; % if ($num_films > 1) { % if($display_set eq "eng") { % } elsif ($display_set eq "big5") { % } % } else { % if($display_set eq "eng"){ % } elsif ($display_set eq "big5") { % } % } % foreach my $appearance (@{$filmography->{$job}}) % { % my $movie_title = $appearance->{title}; % my $role = $appearance->{role}; % my $movie_id = $appearance->{movie_id}; % my $year = $appearance->{year}; % } % } % }
 
Production 出品公司
  <% $m_title %> (<% $m_year %>)
 
Filming 攝製公司
  <% $m_title %> (<% $m_year %>)
 
Distributor發行公司
  <% $m_title %> (<% $m_year %>)
 
Filmography (<% $year_min->{year_made} %>) % #} else { % #
Filmography (<% $year_min->{year_made} %>-<% $year_max->{year_made} %>) % #} % #} elsif ($display_set eq "big5") { % #if ($year_min->{year_made} eq $year_max->{year_made}) { % #
影視作品 (<% $year_min->{year_made} %>) % #} else { % #
影視作品 (<% $year_min->{year_made} %>-<% $year_max->{year_made} %>) % #} % #} % #
<% $job_title %><% $job_title %> <% $job_title %> <% $job_title %>
  <% $movie_title %> (<% $year %>)
 
 
% if ($company_info->{"description_$display_set"}) % { % $company_info->{"description_$display_set"} =~ s/\n\n/\/g;
 
 
 
  <% $company_info->{"description_$display_set"} %>
 
% $m->comp('/db/common/footer.mhtml'); <%init> #if ( ! $display_set || $display_set eq 'default') #{ # my $cgi = new CGI(%ARGS); # $display_set = $cgi->cookie('display_set') || 'eng'; #} ### 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); # 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 $company_logo_stmt = <<"EOSQL"; SELECT i.id,i.thumbnail_path,i.thumbnail_height,i.thumbnail_width,i.description_$display_set FROM images as i,company_resources as cr,resources as r WHERE cr.company_id = ? AND r.id = cr.resource_id AND r.table_name = 'images' AND r.table_id = i.id LIMIT 5 EOSQL my @company_logo = $db->select_rows( sql => $company_logo_stmt, bind => [ $id ], hashref => 1 ); # Get filmography info my $filmed_stmt = <<"EOSQL"; SELECT movies.id,movies.title_$display_set,movies.year_made FROM movies,movie_filming_companies WHERE movie_filming_companies.company_id = ? AND movie_filming_companies.movie_id = movies.id ORDER BY movies.year_made,date_start EOSQL my @filmed = $db->select_rows( sql => $filmed_stmt, bind => [ $id ], hashref => 1 ); my $produced_stmt = <<"EOSQL"; SELECT movies.id,movies.title_$display_set,movies.year_made FROM movies,movie_production_companies WHERE movie_production_companies.company_id = ? AND movie_production_companies.movie_id = movies.id ORDER BY movies.year_made,date_start EOSQL my @produced = $db->select_rows( sql => $produced_stmt, bind => [ $id ], hashref => 1 ); my $distributed_stmt = <<"EOSQL"; SELECT movies.id,movies.title_$display_set,movies.year_made FROM movies,movie_distributors WHERE movie_distributors.company_id = ? AND movie_distributors.movie_id = movies.id ORDER BY movies.year_made,date_start EOSQL my @distributed = $db->select_rows( sql => $distributed_stmt, bind => [ $id ], hashref => 1 ); my $aliases_stmt = q{ SELECT description, alias, language_id FROM company_aliases WHERE company_id = ? }; my @aliases = $db->select_rows( sql => $aliases_stmt, bind => [ $id ], hashref => 1 ); my @job_rows = $db->select( table => 'jobs', select => [ 'id','job_' . $display_set ] ); my $jobs; foreach my $job_row (@job_rows) { my $job_id = $job_row->{id}; my $job_title = $job_row->{"job_$display_set"}; $jobs->{$job_id} = $job_title; } my $filmography_stmt = <<"EOSQL"; SELECT m.id,m.title_$display_set,m.year_made,a.job_id FROM appearances AS a,movies AS m WHERE a.company_id = ? AND m.id = a.movie_id ORDER BY m.year_made,date_start EOSQL my @filmography_rows = $db->select_rows( sql => $filmography_stmt,bind => [ $id ],hashref => 1 ); my $filmography; foreach my $row (@filmography_rows) { my $job_id = $row->{job_id}; my $movie_title = $row->{"title_$display_set"}; my $movie_id = $row->{id}; my $role = $row->{"role_$display_set"}; my $year = $row->{year_made}; unless ($filmography->{$job_id}) { $filmography->{$job_id} = []; } push(@{$filmography->{$job_id}}, { title => $movie_title,role => $role,movie_id => $movie_id,year => $year } ); } my $year_min_stmt = <<"EOSQL"; SELECT m.year_made FROM appearances AS a,movies AS m WHERE a.company_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.company_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 $company_info = $db->select( table => 'companies', select => [ 'description_eng', 'description_big5' ], keys => [ $id ] );