From e6ade61c57759b1f5f1b6d269a7d17c09c14c67f Mon Sep 17 00:00:00 2001
From: Quentin Pichollet <quentin.pichollet@ensiie.fr>
Date: Tue, 30 Oct 2018 21:41:18 +0100
Subject: [PATCH] avancement de la page fiche_film

---
 src/WebApp/application/views/fiche_film.php | 67 +++++++++++++++++++--
 src/WebApp/application/views/getMovie.php   | 18 ++++++
 2 files changed, 80 insertions(+), 5 deletions(-)

diff --git a/src/WebApp/application/views/fiche_film.php b/src/WebApp/application/views/fiche_film.php
index 38cf887..fd7ac53 100644
--- a/src/WebApp/application/views/fiche_film.php
+++ b/src/WebApp/application/views/fiche_film.php
@@ -106,11 +106,29 @@ include('getMovie.php');
 					</tr>
 					<tr>
 						<td style="text-align: right;">De :</td>
-						<td>undefined</td>
+						<td>
+							<?php foreach(getMovieCastArray(297762)['crew'] as $tab)
+							{
+								if($tab['job']=="Director")
+								{
+									echo($tab['name'].' / ');
+								}
+							}
+							?>
+						</td>
 					</tr>
 					<tr>
 						<td style="text-align: right;">Ecrit par :</td>
-						<td>undefined</td>
+						<td>
+							<?php foreach(getMovieCastArray(297762)['crew'] as $tab)
+							{
+								if($tab['job']=="Story")
+								{
+									echo($tab['name'].' / ');
+								}
+							}
+							?>
+						</td>
 					</tr>
 					<tr>
 						<td style="text-align: right;">Date de sortie :</td>
@@ -151,7 +169,7 @@ include('getMovie.php');
 
 	<div class="row align-items-center no-gutters mb-4 mb-lg-5">
 		<div class="featured-text text-center text-lg-left">
-			<h4>Casting</h4>
+			<h3>Casting</h3>
 
 			<div>
 				<table class="table borderless">
@@ -162,7 +180,7 @@ include('getMovie.php');
 						{
 							echo('<tr>');
 							for ($i = (0+5*$k); $i < (5+5*$k); $i++) {
-								echo('<td><img class="img-fluid" src="https://image.tmdb.org/t/p/w500/'.getMovieCastArray(297762)['cast'][$i]['profile_path'].'" alt="photo de l\'acteur/actrice"> '.getMovieCastArray(297762)['cast'][$i]['name'].'<br/><p class="text-black-50 mb-0">as '.getMovieCastArray(297762)['cast'][$i]['character'].'</p></td>');
+								echo('<td><img class="img-fluid img-thumbnail" width="100%" src="https://image.tmdb.org/t/p/w500/'.getMovieCastArray(297762)['cast'][$i]['profile_path'].'" alt="photo de l\'acteur/actrice"> <br/>'.getMovieCastArray(297762)['cast'][$i]['name'].'<br/><p class="text-black-50 mb-0">'.getMovieCastArray(297762)['cast'][$i]['character'].'</p></td>');
 							}
 							echo('</tr>');
 						}
@@ -173,8 +191,47 @@ include('getMovie.php');
 			</div>
 		</div>
 	</div>
-</div>
+	<br/>
+	<div class="row align-items-center no-gutters mb-4 mb-lg-5">
+		<div class="featured-text text-center text-lg-left">
+		<h3>Trailer</h3>
+		</div>
+	</div>
+	<div class="row align-items-center no-gutters mb-4 mb-lg-5">
+		<div class="col-xl-2 col-lg-2">
+		</div>
+		<div class="col-xl-8 col-lg-8">
+			<center><iframe width="100%" height="350" src="https://www.youtube.com/embed/<?php echo(getMovieVideoArray(297762)['results']['0']['key'])?>" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe></center>
+		</div>
+		<div class="col-xl-2 col-lg-2">
+		</div>
+	</div>
+
+
+	<div class="row align-items-center no-gutters mb-4 mb-lg-5">
+		<div class="featured-text text-center text-lg-left">
+			<h3>Si vous aimez ce film vous aimerez aussi :</h3>
 
+			<div>
+				<table class="table borderless">
+					<tbody>
+					 	<tr>
+							<?php
+							{
+								for ($i = 0; $i < 5; $i++) {
+									echo('<td><img class="img-fluid img-thumbnail"  width="100%" src="https://image.tmdb.org/t/p/w500/'.getMovieRecommendationArray(297762)['results'][$i]['poster_path'].'" alt="photo du film"> <br/><center>'.getMovieRecommendationArray(297762)['results'][$i]['title']).'</center>';
+								}
+							}
+							?>
+						</tr>
+					</tbody>
+				</table>
+			</div>
+		</div>
+	</div>
+
+
+</div>
 </body>
 </html>
 
diff --git a/src/WebApp/application/views/getMovie.php b/src/WebApp/application/views/getMovie.php
index a3d0a2d..fc47223 100644
--- a/src/WebApp/application/views/getMovie.php
+++ b/src/WebApp/application/views/getMovie.php
@@ -30,6 +30,24 @@ function getMovieCastArray($id)
 	return $movie_array;
 }
 
+function getMovieVideoArray($id)
+{
+	$tmdb_url = 'https://api.themoviedb.org/3/movie/' . $id . '/videos?api_key=7ac6810245f15284418f2a15b9b22225&language=fr-FR';
+	$movie_json = file_get_contents($tmdb_url);
+	$movie_array = json_decode($movie_json, true);
+
+	return $movie_array;
+}
+
+function getMovieRecommendationArray($id)
+{
+	$tmdb_url = 'https://api.themoviedb.org/3/movie/'. $id .'/recommendations?api_key=7ac6810245f15284418f2a15b9b22225&language=fr-FR';
+	$movie_json = file_get_contents($tmdb_url);
+	$movie_array = json_decode($movie_json, true);
+
+	return $movie_array;
+}
+
 function getRandomMovie()
 {
     $input = array(28,329,299536,157336,578,13183,597,118340,111,68718,1271,16869,348,807,27205,553974,1895,274,497,78,65,238,769,500,3082,37165,200,300,600,100,550,115,155,165,175,180,185,215,235,240,275,280,380,415,435,440,475,565,595,605,620,640,650,680,710,406,313369,11324);
-- 
GitLab