% if ($movie_info->{"location_$display_set"})
% {
% my $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Country',
% display_set => $display_set );
|
<% $label %>: <% $movie_info->{"location_$display_set"} %>
|
% }
% if (@spoken_languages)
% {
% my $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Language',
% plural => (scalar @spoken_languages > 1) ? 1 : 0,
% display_set => $display_set );
|
<% $label %>:
% foreach my $entry (@spoken_languages)
% {
% my $spoken_language = $entry->{"spoken_language_$display_set"};
<% $spoken_language %>
% }
|
% }
% if (@circuits)
% {
% my $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Circuit',
% plural => (scalar @circuits > 1) ? 1 : 0,
% display_set => $display_set );
|
<% $label %>:
% foreach my $entry (@circuits)
% {
% my $circuit = $entry->{"circuit_$display_set"};
<% $circuit %>
% }
|
% }
% if (@genres)
% {
% my $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Genre',
% plural => (scalar @genres > 1) ? 1 : 0,
% display_set => $display_set );
|
<% $label %>:
% foreach my $entry (@genres)
% {
% my $genre = $entry->{"genre_$display_set"};
<% $genre %>
% }
|
% }
% if (@ratings)
% {
% my $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Rating',
% plural => (scalar @ratings > 1) ? 1 : 0,
% display_set => $display_set );
|
<% $label %>:
% foreach my $entry (@ratings)
% {
<% $entry->{rating} %> (<% $entry->{"location_$display_set"} %>)
% }
|
% }
% if ($movie_info->{fest_date_start} && $movie_info->{fest_date_start}!=0)
% {
|
% if ($display_set eq 'big5'){
上映日期 (<% $festival_name->{festival_big5} %>): <% $movie_info->{fest_date_start} %>
% } else {
Release Date (<% $festival_name->{festival_eng} %>): <% $movie_info->{fest_date_start} %>
% }
|
% }
% if ($movie_info->{init_date_start} && $movie_info->{init_date_start}!=0)
% {
|
% if ($display_set eq 'big5'){
上映日期 (<% $init_location->{location_big5} %>): <% $movie_info->{init_date_start} %>
% } else {
Release Date (<% $init_location->{location_eng} %>): <% $movie_info->{init_date_start} %>
% }
|
% }
% if ($movie_info->{date_start} && $movie_info->{date_start}!=0)
% {
|
% if ($movie_info->{date_end} && $movie_info->{date_end}!=0)
% {
% if ($display_set eq 'big5'){
發布日期: <% $movie_info->{date_start} %> - <% $movie_info->{date_end} %>
% } else {
Theatrical Run (HK): <% $movie_info->{date_start} %> - <% $movie_info->{date_end} %>
%}
% } else {
% if ($display_set eq 'big5'){
上映日期: <% $movie_info->{date_start} %>
% } else {
Release Date (HK): <% $movie_info->{date_start} %>
% }
% }
|
% }
% if ($movie_info->{gross} > 0)
% {
% my $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Box Office',
% display_set => $display_set );
% my $gross = $movie_info->{gross};
% 1 while $gross =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/g;
|
<% $label %>: HK $<% $gross %>
|
% }
| |
% {
% if (@directors)
% {
% my $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Director',
% plural => (scalar @directors > 1) ? 1 : 0,
% display_set => $display_set );
|
<% $label %>
|
% foreach my $director (@directors)
% {
% my $d_id = $director->{id};
% my $d_name = $director->{"name_$display_set"};
| |
<% $d_name %>
|
% }
| |
% }
|
% if (@writers)
% {
% my $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Screenwriter',
% plural => (scalar @writers > 1) ? 1 : 0,
% display_set => $display_set );
| <% $label %> |
% foreach my $writer (@writers)
% {
% my $w_id = $writer->{id};
% my $w_name = $writer->{"name_$display_set"};
| |
<% $w_name %>
|
% }
| |
% }
|
% my $ad_exclude;
% if (@action_directors)
% {
% my $label;
% my $ad_jid;
% my $ad_jid_c;
% my $jids=0;
% foreach my $action_director (@action_directors)
% {
% $ad_jid = $action_director->{job_id};
% last if($ad_jid eq 8);
% last if($ad_jid eq 355);
% last if($ad_jid eq 251);
% last if($ad_jid eq 250);
% last if($ad_jid eq 252);
% last if($ad_jid eq 510);
% }
% if ($ad_jid eq 8) {
% foreach my $action_director (@action_directors) {
% $ad_jid_c = $action_director->{job_id};
% if($ad_jid_c eq 8) { $jids++ }
% }
% $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Action Director',
% plural => ($jids > 1) ? 1 : 0,
% display_set => $display_set );
% } elsif($ad_jid eq 355) {
% foreach my $action_director (@action_directors) {
% $ad_jid_c = $action_director->{job_id};
% if($ad_jid_c eq 355) { $jids++ }
% }
% $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Martial Arts Director',
% plural => (scalar @action_directors > 1) ? 1 : 0,
% display_set => $display_set );
% } elsif($ad_jid eq 251) {
% foreach my $action_director (@action_directors) {
% $ad_jid_c = $action_director->{job_id};
% if($ad_jid_c eq 251) { $jids++ }
% }
% $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Action Choreographer',
% plural => (scalar @action_directors > 1) ? 1 : 0,
% display_set => $display_set );
% } elsif($ad_jid eq 250) {
% foreach my $action_director (@action_directors) {
% $ad_jid_c = $action_director->{job_id};
% if($ad_jid_c eq 250) { $jids++ }
% }
% $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Action Designer',
% plural => (scalar @action_directors > 1) ? 1 : 0,
% display_set => $display_set );
% } elsif($ad_jid eq 252) {
% foreach my $action_director (@action_directors) {
% $ad_jid_c = $action_director->{job_id};
% if($ad_jid_c eq 252) { $jids++ }
% }
% $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Stunt Choreographer',
% plural => ($jids > 1) ? 1 : 0,
% display_set => $display_set );
% } elsif($ad_jid eq 510) {
% foreach my $action_director (@action_directors) {
% $ad_jid_c = $action_director->{job_id};
% if($ad_jid_c eq 510) { $jids++ }
% }
% $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Martial Arts Designer',
% plural => ($jids > 1) ? 1 : 0,
% display_set => $display_set );
% }
|
<% $label %>
|
% foreach my $action_director (@action_directors)
% {
% my $ad_id = $action_director->{id};
% my $ad_name = $action_director->{"name_$display_set"};
% my $ad_jid_l = $action_director->{job_id};
% if($ad_jid_l eq $ad_jid){
| |
<% $ad_name %>
|
% }
% }
% $ad_exclude=$ad_jid;
| |
% }
|
% if (@producers)
% {
% my $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Producer',
% plural => (scalar @producers > 1) ? 1 : 0,
% display_set => $display_set );
|
<% $label %>
|
% foreach my $producer (@producers)
% {
% my $p_id = $producer->{id};
% my $p_name = $producer->{"name_$display_set"};
| |
<% $p_name %>
|
% }
| |
% }
|
|
% if ($poster_image)
% {
" BORDER="1">
% }
% else
% {
% }
|
| |
% if (@cast)
% {
% my $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Cast',
% display_set => $display_set );
| <% $label %> |
% foreach my $actor (@cast)
% {
% my $a_id = $actor->{id};
% my $a_name = $actor->{"name_$display_set"};
% my $role = $actor->{"role_$display_set"};
| |
<% $a_name %>
|
% if ($role)
% {
... |
<% $role %> |
% }
% else
% {
|
|
% }
% }
% }
|
| |
% if ($complete_credits)
% {
% if (@production_companies)
% {
% my $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Production Company',
% plural => (scalar @production_companies > 1) ? 1 : 0,
% display_set => $display_set );
| <% $label %> |
% foreach my $production_company (@production_companies)
% {
% my $pc_id = $production_company->{id};
% my $pc_name = $production_company->{"company_name_$display_set"};
| |
<% $pc_name %>
|
% }
% }
% if (@filming_companies)
% {
% my $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Filming Company',
% plural => (scalar @filming_companies > 1) ? 1 : 0,
% display_set => $display_set );
| |
| <% $label %> |
% foreach my $filming_company (@filming_companies)
% {
% my $fc_id = $filming_company->{id};
% my $fc_name = $filming_company->{"company_name_$display_set"};
| |
<% $fc_name %>
|
% }
% }
% if (@distributors)
% {
% my $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Distributor',
% plural => (scalar @distributors > 1) ? 1 : 0,
% display_set => $display_set );
| |
| <% $label %> |
% foreach my $distributor (@distributors)
% {
% my $d_id = $distributor->{id};
% my $d_name = $distributor->{"company_name_$display_set"};
% my $d_location = $distributor->{"location_$display_set"};
| |
<% $d_name %> (<% $d_location %>)
|
% }
% }
% my @misc_jobs_rowss = $db->select_rows( sql => "SELECT a.job_id,j.job_order,a.id,a.credit_order,j.job_$display_set,p.name_$display_set,a.people_id,\"people\" as type FROM appearances as a,people as p,jobs as j WHERE a.movie_id = ? AND a.job_id=j.id AND a.job_id != 13 AND a.people_id = p.id UNION SELECT a.job_id,j.job_order,a.id,a.credit_order,j.job_$display_set,c.company_name_$display_set,a.company_id,\"company\" as type FROM appearances as a,companies as c,jobs as j WHERE a.movie_id=? AND a.job_id=j.id AND a.company_id=c.id ORDER BY job_order,job_id,credit_order" , bind => [ $id,$id ], hashref => 1 );
% my $jc;
% my $idx;
% my $idx_outer;
% foreach my $mjrw (@misc_jobs_rowss) {
% my $jid = $mjrw->{job_id};
% next if ($jid eq $ad_exclude);
% $jc->{$jid}++;
% }
% my $job_id_prev;
% foreach my $misc_jobs_roww (@misc_jobs_rowss)
% {
% my $job_id = $misc_jobs_roww->{job_id};
% my $name = $misc_jobs_roww->{'name_' . $display_set};
% my $people_id = $misc_jobs_roww->{people_id};
% my $job_order = $misc_jobs_roww->{job_order};
% my $job_title = $misc_job_titles->{$job_id};
% next if ($job_id eq $ad_exclude);
% next unless ($job_title);
% if($job_id ne $job_id_prev){
| |
% my $job_title_pl = $m->comp('/db/common/phrases.mhtml',
% phrase => $job_title,
% plural => ($jc->{$job_id} > 1) ? 1 : 0,
% display_set => $display_set );
% if($job_title_pl and $job_title_pl ne $job_title) { $job_title=$job_title_pl; }
| <% $job_title %> |
%}
% if ($jc->{$job_id} gt 1){
% $idx->{$job_id}++;
% $idx_outer->{$job_id}++;
% if($idx_outer->{$job_id} eq 1){
%}
| |
%if($misc_jobs_roww->{type} eq "company") {
<% $name %>
%} else {
<% $name %>
%}
%if($idx_outer->{$job_id} eq $jc->{$job_id}){
%}
% $job_id_prev = $job_id;
% } else {
|
| |
%if($misc_jobs_roww->{type} eq "company") {
<% $name %>
%} else {
<% $name %>
%}
|
% $job_id_prev = $job_id;
% }
%if($idx->{$job_id} eq 3){
% $idx->{$job_id}=0;
% } else {
%}
% }
% }
% if (@filming_locations)
% {
% my $label = $m->comp('/db/common/phrases.mhtml',
% phrase => 'Filming Location',
% plural => (scalar @filming_locations > 1) ? 1 : 0,
% display_set => $display_set );
| |
| <% $label %> |
% foreach my $filming_location (@filming_locations)
% {
% my $fl_id = $filming_location->{id};
% my $fl_name = $filming_location->{"location_$display_set"};
| |
<% $fl_name %>
|
% }
% }
|
| |
% #}
% if ($movie_info->{'summary_' . $display_set}) {
| |
| Summary |
| |
<% $movie_info->{'summary_' . $display_set} %> |
|
% }
% }
<%init>
my $user = HKMDB::User->new;
my $logged_in = $user->authenticate;
use URI::Escape;
use Encode qw/encode decode/;
### Fetch the data
my $db = new HKMDB::Database;
# Get basic info
my $movie_stmt .= <<"EOSQL";
SELECT title_eng,title_big5,title_gd,title_py,year_made,gross,summary_$display_set,festival_id,init_location_id,location_$display_set,DATE_FORMAT(date_start, '%m/%d/%Y') as date_start, DATE_FORMAT(date_end, '%m/%d/%Y') as date_end, DATE_FORMAT(init_date_start, '%m/%d/%Y') as init_date_start, DATE_FORMAT(fest_date_start, '%m/%d/%Y') as fest_date_start
FROM movies LEFT OUTER JOIN locations ON movies.location_id=locations.id
WHERE movies.id = ?
EOSQL
my $movie_info = $db->select_rows( sql => $movie_stmt, bind => [ $id ], hashref => 1 );
my $init_location_stmt = <<"EOSQL";
SELECT location_$display_set
FROM locations
WHERE id = ?
EOSQL
my $init_location = $db->select_rows( sql => $init_location_stmt, bind => [ $movie_info->{init_location_id} ], hashref => 1 );
my $fest_stmt = <<"EOSQL";
SELECT festival_$display_set
FROM festivals
WHERE id = ?
EOSQL
my $festival_name = $db->select_rows( sql => $fest_stmt, bind => [ $movie_info->{festival_id} ], hashref => 1 );
my $poster_image_stmt = <<"EOF";
SELECT i.id,i.path,i.description_$display_set,i.width,i.height,i.thumbnail_path,i.thumbnail_width,i.thumbnail_height
FROM images as i, movies as m
WHERE m.id = ?
AND m.poster_image_id = i.id
EOF
my $poster_image = $db->select_rows( sql => $poster_image_stmt, bind => [ $id ], hashref => 1 );
# Get director info
my $directors_stmt = <<"EOSQL";
SELECT p.id,p.name_$display_set
FROM people AS p, appearances AS a
WHERE a.movie_id = ?
AND a.people_id = p.id
AND a.job_id = 3
ORDER BY credit_order
EOSQL
my @directors = $db->select_rows( sql => $directors_stmt, bind => [ $id ], hashref => 1 );
# Get producer info
my $producers_stmt = <<"EOSQL";
SELECT p.id,p.name_$display_set
FROM people AS p, appearances AS a
WHERE a.movie_id = ?
AND a.people_id = p.id
AND a.job_id = 1
ORDER BY credit_order
EOSQL
my @producers = $db->select_rows( sql => $producers_stmt, bind => [ $id ], hashref => 1 );
# Get writer info
my $writers_stmt = <<"EOSQL";
SELECT p.id,p.name_$display_set
FROM people AS p, appearances AS a
WHERE a.movie_id = ?
AND a.people_id = p.id
AND a.job_id = 5
ORDER BY credit_order
EOSQL
my @writers = $db->select_rows( sql => $writers_stmt, bind => [ $id ], hashref => 1 );
# Get action director info
my $action_directors_stmt = <<"EOSQL";
SELECT p.id,p.name_$display_set,a.job_id
FROM people AS p, appearances AS a
WHERE a.movie_id = ?
AND a.people_id = p.id
AND ( a.job_id = 8
OR a.job_id = 510
OR a.job_id = 355
OR a.job_id = 251
OR a.job_id = 250
OR a.job_id = 252 )
ORDER BY job_id,credit_order
EOSQL
my @action_directors = $db->select_rows( sql => $action_directors_stmt, bind => [ $id ], hashref => 1 );
# Get languages info
my $spoken_languages_stmt = <<"EOSQL";
SELECT sl.id,sl.spoken_language_$display_set
FROM spoken_languages AS sl, movie_languages AS ml
WHERE ml.movie_id = ?
AND ml.spoken_language_id = sl.id
EOSQL
my @spoken_languages = $db->select_rows( sql => $spoken_languages_stmt, bind => [ $id ], hashref => 1 );
# Get genre info
my $genres_stmt = <<"EOSQL";
SELECT g.id,g.genre_$display_set
FROM genres AS g, movie_genres AS mg
WHERE mg.movie_id = ?
AND mg.genre_id = g.id
EOSQL
my @genres = $db->select_rows( sql => $genres_stmt, bind => [ $id ], hashref => 1 );
# Get circuits info
my $circuits_stmt = <<"EOSQL";
SELECT c.id,c.circuit_$display_set
FROM circuits AS c, movie_circuits AS mc
WHERE mc.movie_id = ?
AND mc.circuit_id = c.id
EOSQL
my @circuits = $db->select_rows( sql => $circuits_stmt, bind => [ $id ], hashref => 1 );
# Get ratings info
my $ratings_stmt = <<"EOSQL";
SELECT l.id,l.location_$display_set,r.id,r.rating
FROM ratings AS r, movie_ratings AS mr, locations AS l
WHERE mr.movie_id = ?
AND l.id = r.location_id
AND mr.rating_id = r.id
EOSQL
my @ratings = $db->select_rows( sql => $ratings_stmt,
bind => [ $id ],
hashref => 1 );
# Get cast info
my $cast_stmt = <<"EOSQL";
SELECT p.id,p.name_$display_set,a.role_$display_set
FROM people AS p, appearances AS a
WHERE a.movie_id = ?
AND a.people_id = p.id
AND a.job_id = 13
ORDER BY credit_order
EOSQL
my @cast = $db->select_rows( sql => $cast_stmt,
bind => [ $id ],
hashref => 1 );
# Get other credits
my @distributors;
my @filming_companies;
my @production_companies;
my $misc_job_titles;
my $misc_jobs;
#if ($complete_credits)
#{
# Fetch distributors
my $distributors_stmt = <<"EOSQL";
SELECT locations.location_$display_set,companies.id,companies.company_name_$display_set
FROM locations,companies,movie_distributors
WHERE movie_distributors.movie_id = ?
AND companies.id = movie_distributors.company_id
AND locations.id = movie_distributors.location_id
EOSQL
@distributors = $db->select_rows ( sql => $distributors_stmt, bind => [ $id ], hashref => 1 );
# Fetch filming companies
my $filming_companies_stmt = <<"EOSQL";
SELECT companies.id,companies.company_name_$display_set
FROM companies,movie_filming_companies
WHERE movie_filming_companies.movie_id = ?
AND companies.id = movie_filming_companies.company_id
EOSQL
@filming_companies = $db->select_rows ( sql => $filming_companies_stmt, bind => [ $id ], hashref => 1 );
# Fetch production companies
my $production_companies_stmt = <<"EOSQL";
SELECT companies.id,companies.company_name_$display_set
FROM companies,movie_production_companies
WHERE movie_production_companies.movie_id = ?
AND companies.id = movie_production_companies.company_id
EOSQL
@production_companies = $db->select_rows( sql => $production_companies_stmt, bind => [ $id ], hashref => 1 );
# Fetch the rest of the crew
my @misc_job_title_rows = $db->select( table => 'jobs',
select => [ 'id',
'job_' . $display_set ],
where => [ [ 'id', '!=', 1],
[ 'id', '!=', 3],
[ 'id', '!=', 5],
[ 'id', '!=', 13] ] );
foreach my $misc_job_title_row (@misc_job_title_rows)
{
my $job_id = $misc_job_title_row->{id};
my $job_title = $misc_job_title_row->{'job_' . $display_set};
$misc_job_titles->{$job_id} = $job_title;
}
my $misc_jobs_stmt = <<"EOSQL";
SELECT p.name_$display_set,a.people_id,a.job_id,j.job_order
FROM appearances AS a,people AS p,jobs AS j
WHERE a.movie_id = ?
AND p.id = a.people_id
AND a.job_id = j.id
ORDER BY job_order
EOSQL
my @misc_jobs_rows = $db->select_rows( sql => $misc_jobs_stmt, bind => [ $id ], hashref => 1 );
# sort by job into %$misc_jobs
foreach my $misc_jobs_row (@misc_jobs_rows)
{
my $job_id = $misc_jobs_row->{job_id};
my $name = $misc_jobs_row->{'name_' . $display_set};
my $people_id = $misc_jobs_row->{people_id};
my $job_order = $misc_jobs_row->{job_order};
unless ($misc_jobs->{$job_id})
{
$misc_jobs->{$job_id} = [];
}
push(@{$misc_jobs->{$job_id}}, { people_id => $people_id, name => $name, jobs_order => $job_order } );
}
#}
my $aliases_stmt = q{
SELECT description, alias, language_id
FROM movie_aliases
WHERE movie_id = ?
};
my @aliases = $db->select_rows( sql => $aliases_stmt,
bind => [ $id ],
hashref => 1 );
my $filming_location_stmt = <<"EOSQL";
SELECT l.location_$display_set,l.id,mf.location_id
FROM locations as l,movie_filming_locations as mf
WHERE mf.movie_id = ?
AND mf.location_id = l.id
EOSQL
my @filming_locations = $db->select_rows( sql => $filming_location_stmt, bind => [ $id ], hashref => 1 );
%init>