From 203c2117f7cf7bf2e4cfb4bce08e5eea462a2e09 Mon Sep 17 00:00:00 2001
From: Kevin XU <kevin-xu@hotmail.fr>
Date: Tue, 18 Dec 2018 20:37:39 +0100
Subject: [PATCH] =?UTF-8?q?Int=C3=A9gration=20graphes=20pour=20Youtube?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 page_profile/profil.php   | 96 +++++++++++++++++++++++++++++++++++++--
 page_welcome/register.php |  1 +
 youtube-api/userInfos.php |  4 +-
 3 files changed, 96 insertions(+), 5 deletions(-)

diff --git a/page_profile/profil.php b/page_profile/profil.php
index c638235..43541ce 100644
--- a/page_profile/profil.php
+++ b/page_profile/profil.php
@@ -130,6 +130,8 @@ $youtube_fav = $_SESSION['youtube'];
 						}
 					?>
 					<br/> <h5></h5> </div>
+		</br><br/>
+		</div>
 			</div>
 	</div>
 
@@ -143,8 +145,13 @@ $youtube_fav = $_SESSION['youtube'];
 					echo "<a href='#b'> Evolution of Tweets Retweets</a>";
 				}
 				elseif ($socialNetwork === "Youtube") {
-					echo "<a href='#a'> Evolution of Views</a>";
+					echo "<a href='#a'> Evolution of Views of recent videos</a>";
+					echo "</div>";
+					echo "<div>";
+					echo "<a href='#b'> Evolution of Likes of recent videos</a>";
 					echo "</div>";
+					echo "<div>";
+					echo "<a href='#c'> Evolution of Dislikes of recent videos</a>";
 				}
 			?>
 		</div>
@@ -157,7 +164,7 @@ $youtube_fav = $_SESSION['youtube'];
 					echo "Evolution of Tweets Likes";
 				}
 				elseif ($socialNetwork === "Youtube") {
-					echo "Evolution of Views";
+					echo "Evolution of Views of recent videos";
 				}
 			?>
 		</span><br/><br/>
@@ -176,7 +183,16 @@ $youtube_fav = $_SESSION['youtube'];
 				    lineGraphMean($chartName, $caption, $xAxisName, $yAxisName, $likes, 700, 400);
 				}
 				elseif ($socialNetwork === "Youtube") {
-					echo "";
+					$count = 10;
+
+				    $chartName = "chart3";
+				    $caption = "Evolution of views : Last ".$count." videos";
+				    $xAxisName = "Video (from most recent to oldest)";
+				    $yAxisName =  "Number of Views";
+
+				    $views = getviewCountOfRecentVideo($id, $count);
+
+				    lineGraphMean($chartName, $caption, $xAxisName, $yAxisName, $views, 700, 400);
 				}
 			?>
 		</br><br/>
@@ -187,7 +203,7 @@ $youtube_fav = $_SESSION['youtube'];
 					echo "Evolution of Tweets Retweets";
 				}
 				elseif ($socialNetwork === "Youtube") {
-					echo "";
+					echo "Evolution of Likes of recent videos";
 				}
 			?>
 		</span><br/><br/>
@@ -206,11 +222,83 @@ $youtube_fav = $_SESSION['youtube'];
 				    lineGraphMean($chartName, $caption, $xAxisName, $yAxisName, $retweets, 700, 400);
 				}
 				elseif ($socialNetwork === "Youtube") {
+				    $count = 10;
+
+				    $chartName = "chart4";
+				    $caption = "Evolution of likes : Last ".$count." videos";
+				    $xAxisName = "Video (from most recent to oldest)";
+				    $yAxisName =  "Number of Likes";
+
+				    $likes = getLikeCountOfRecentVideo($id, $count);
+
+				    lineGraphMean($chartName, $caption, $xAxisName, $yAxisName, $likes, 700, 400);
+				}
+		    ?>
+		</br><br/>
+		</div>
+		<div id='c'><br/><br/><span class="title_graphs">
+			<?php
+				if ($socialNetwork === "Twitter") {
 					echo "";
 				}
+				elseif ($socialNetwork === "Youtube") {
+					echo "Evolution of Dislikes of recent videos";
+				}
+			?>
+		</span><br/><br/>
+			<?php
+				if ($socialNetwork === "Twitter") {
+				    echo "";
+				}
+				elseif ($socialNetwork === "Youtube") {
+				    $count = 10;
+
+				    $chartName = "chart5";
+				    $caption = "Evolution of dislikes : Last ".$count." videos";
+				    $xAxisName = "Video (from most recent to oldest)";
+				    $yAxisName =  "Number of Dislikes";
+
+				    $dislikes = getDislikeCountOfRecentVideo($id, $count);
+
+				    lineGraphMean($chartName, $caption, $xAxisName, $yAxisName, $dislikes, 700, 400);
+				}
 		    ?>
 		</br><br/>
 		</div>
+		<!-- <div id='d'><br/><br/><span class="title_graphs">
+			<?php
+				// if ($socialNetwork === "Twitter") {
+				// 	echo "";
+				// }
+				// elseif ($socialNetwork === "Youtube") {
+				// 	echo "Evolution of views of most popular videos";
+				// }
+			?>
+		</span><br/><br/>
+			<?php
+				// if ($socialNetwork === "Twitter") {
+				//     echo "";
+				// }
+				// elseif ($socialNetwork === "Youtube") {
+				//     $count = 10;
+
+				//     $chartName = "chart6";
+				//     $caption = "Evolution of views : ".$count." most popular videos";
+				//     $xAxisName = "Video (from most recent to oldest)";
+				//     $yAxisName =  "Number of Views";
+
+				//     $videosID = getCountTopVideos($id, $count);
+				//     $views = [];
+				//     for ($i = 0; $i < $count; $i++) {
+				//     	$views[] = getVideoViewCountById($videosID[$i]);
+				//     }
+
+				//     lineGraphMean($chartName, $caption, $xAxisName, $yAxisName, $views, 700, 400);
+				// }
+		    ?>
+		</br><br/>
+		</div> -->
+
 	</div>
 
 </div>
diff --git a/page_welcome/register.php b/page_welcome/register.php
index dda3227..b059ae2 100644
--- a/page_welcome/register.php
+++ b/page_welcome/register.php
@@ -47,6 +47,7 @@ if (isset($_POST['register'])) {
   }
   $empty_array = array();
   // Finally, register user if there are no errors in the form
+  echo $errors[0];
   if (count($errors) == 0) {
 
   	$password = md5($password_1);//encrypt the password before saving in the database
diff --git a/youtube-api/userInfos.php b/youtube-api/userInfos.php
index 40148af..f0beb13 100644
--- a/youtube-api/userInfos.php
+++ b/youtube-api/userInfos.php
@@ -109,7 +109,7 @@ function getVideoViewCountById($id){
 
 
 /**
- * Search Get the most populare count videos's id in a channel by channelID
+ * Search Get the most popular count videos's id in a channel by channelID
  * @param  $channelId
  * @param  $count
  * @return an array including the id of the most populare count videos
@@ -189,5 +189,7 @@ function getLikeCountOfRecentVideo($channelId,$count)
 }
 
 
+//print_r(getCountTopVideos("UCWeg2Pkate69NFdBeuRFTAw", 10));
+
 
 
-- 
GitLab