From ec59da2fbe26d27da96f59278944697d88d8e77f Mon Sep 17 00:00:00 2001
From: Quentin Pichollet <quentin.pichollet@ensiie.fr>
Date: Thu, 13 Dec 2018 16:17:00 +0100
Subject: [PATCH] =?UTF-8?q?premiere=20version=20de=20la=20recherche=20de?=
 =?UTF-8?q?=20fil=C3=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/WebApp/application/views/accueil.php  | 89 +++++++++++------------
 src/WebApp/application/views/getMovie.php |  8 ++
 2 files changed, 51 insertions(+), 46 deletions(-)

diff --git a/src/WebApp/application/views/accueil.php b/src/WebApp/application/views/accueil.php
index 013356b..29d7a4e 100644
--- a/src/WebApp/application/views/accueil.php
+++ b/src/WebApp/application/views/accueil.php
@@ -57,7 +57,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
               $this->load->library('session');
               if(isset($_SESSION['username'])){
                   echo('<li class="nav-item">');
-                  echo('<a class="nav-link js-scroll-trigger" href="index.php/User/deconnexion">Déconnexion</a>');
+                  echo('<a class="nav-link js-scroll-trigger" href="index.php/User/deconnexion">Décon<div class="col-xl-4 col-lg-7">…</div>nexion</a>');
                   echo('</li>');
               }
               else {
@@ -139,59 +139,56 @@ defined('BASEPATH') OR exit('No direct script access allowed');
         <br>
         <br>
         <br>
-        <br>
         <!-- Project One Row -->
-        <div class="row justify-content-center no-gutters mb-5 mb-lg-0">
-          <div class="col-lg-6">
-            <img class="img-fluid" src="<?php echo base_url(); ?>assets/img/demo-image-01.jpg" alt="">
-          </div>
-          <div class="col-lg-6">
-            <div class="bg-black text-center h-100 project">
-              <div class="d-flex h-100">
-                <div class="project-text w-100 my-auto text-center text-lg-left">
-                  <h4 class="text-white">Misty</h4>
-                  <p class="mb-0 text-white-50">An example of where you can put an image of a project, or anything else, along with a description.</p>
-                  <hr class="d-none d-lg-block mb-0 ml-0">
-                </div>
-              </div>
-            </div>
-          </div>
-        </div>
+        <div id="search" class="row align-items-center no-gutters mb-4 mb-lg-5">
+			<center>
+				<h3>Rechercher un film</h3>
+				<br/><br/>
+				<div>
+					<form method="POST" action="." >
+							<div class="form-group">
+								<input type="text" name="research" />
+								<br/><br/>
+								<input class="btn btn-primary text-white" type="submit" name="bouton" value="Rechercher">
+								<br/><br/>
+							</div>
+						</form>
+					</div>
+			</center>
+		</div>
+
+		  <?php
+            if (isset($_POST["research"]))
+			{ echo "<h3> Resultat de votre recherche </h3>" ;
+				$array=getResearchMovieArray($_POST["research"])?>
+		  <div id="class">
+				<table class="table borderless">
+					<tbody>
+					<tr>
+						<br/>
+						<?php
+						for($k=0; $k<1; $k++)
+						{
+							echo('<tr>');
+							for ($i = (0+5*$k); $i < min(5+5*$k,count($array)); $i++) {
+								echo('<td><br/><a href="fiche_film?id='.$array[$i]['id'].'" onclick="$(\'.loading\').fadeIn(1);"><img class="img-fluid img-thumbnail" width="100%" src="https://image.tmdb.org/t/p/w500/'.$array[$i]['poster_path'].'" alt="affiche du film"> <br/><br/><b><center>'.($i+1).'- '.$array[$i]['title'].'</center></b></a> </td>');
+							}
+							echo('</tr>');
+						}
+						?>
+					</tr>
+					</tbody>
+				</table>
+			  <?php } ?>
 
         <!-- Project Two Row -->
         <div class="row justify-content-center no-gutters">
-          <div class="col-lg-6">
-            <img class="img-fluid" src="<?php echo base_url(); ?>assets/img/demo-image-02.jpg" alt="">
-          </div>
-          <div class="col-lg-6 order-lg-first">
-            <div class="bg-black text-center h-100 project">
-              <div class="d-flex h-100">
-                <div class="project-text w-100 my-auto text-center text-lg-right">
-                  <h4 class="text-white">Mountains</h4>
-                  <p class="mb-0 text-white-50">Another example of a project with its respective description. These sections work well responsively as well, try this theme on a small screen!</p>
-                  <hr class="d-none d-lg-block mb-0 mr-0">
-                </div>
-              </div>
-            </div>
-          </div>
+
         </div>
 
         <!-- Project Three Row -->
         <div class="row justify-content-center no-gutters mb-5 mb-lg-0">
-          <div class="col-lg-6">
-            <img class="img-fluid" src="<?php echo base_url(); ?>assets/img/demo-image-01.jpg" alt="">
-          </div>
-          <div class="col-lg-6">
-            <div class="bg-black text-center h-100 project">
-              <div class="d-flex h-100">
-                <div class="project-text w-100 my-auto text-center text-lg-left">
-                  <h4 class="text-white">Misty</h4>
-                  <p class="mb-0 text-white-50">An example of where you can put an image of a project, or anything else, along with a description.</p>
-                  <hr class="d-none d-lg-block mb-0 ml-0">
-                </div>
-              </div>
-            </div>
-          </div>
+
         </div>
 
       </div>
diff --git a/src/WebApp/application/views/getMovie.php b/src/WebApp/application/views/getMovie.php
index 13fa062..88a83f3 100644
--- a/src/WebApp/application/views/getMovie.php
+++ b/src/WebApp/application/views/getMovie.php
@@ -47,6 +47,14 @@ function getMovieRecommendationArray($id)
 
 	return $movie_array;
 }
+function getResearchMovieArray($text)
+{
+	$tmdb_url='https://api.themoviedb.org/3/search/movie?api_key=7ac6810245f15284418f2a15b9b22225&language=fr-FR&query=' . $text . '&sort_by=vote_count.desc.';
+	$movie_json = file_get_contents($tmdb_url);
+	$movie_array = json_decode($movie_json, true);
+
+	return $movie_array['results'];
+}
 
 function getBestMovieArray($genre,$min_y,$max_y)
 {
-- 
GitLab