diff --git a/classes/components/movies.php b/classes/components/movies.php new file mode 100644 index 0000000..8603e2e --- /dev/null +++ b/classes/components/movies.php @@ -0,0 +1,63 @@ +db->select($this::MOVIES_TABLE, $condition, $condValues); + + //Check if we got a response + if(count($result) == 0) + return array(); + + return $this->parse_db_infos($result[0]); + + } + + /** + * Parse a video informations + * + * @param array $db_infos Informations about the movie from + * the database + * @return array Parsed informations about the video + */ + private function parse_db_infos(array $db_infos) : array { + + $infos = array(); + + //Get informations + $infos["id"] = $db_infos["ID"]; + $infos["uri"] = $db_infos["URL"]; + $infos["url"] = path_user_data($infos['uri']); + $infos["userID"] = $db_infos["ID_user"]; + $infos["name"] = $db_infos["nom_video"]; + $infos["file_type"] = $db_infos["file_type"]; + $infos["size"] = $db_infos["size"]; + + return $infos; + + } + +} + +//Register component +Components::register("movies", new Movies()); \ No newline at end of file diff --git a/classes/components/posts.php b/classes/components/posts.php index 84f9990..752972d 100644 --- a/classes/components/posts.php +++ b/classes/components/posts.php @@ -168,6 +168,14 @@ class Posts { //Video specific $info["video_id"] = $src["idvideo"]; + //Get informations about the video + if(!is_null($info['video_id'])){ + $info['video_infos'] = CS::get()->components->movies->get_infos($info['video_id']); + } + else { + $info['video_infos'] = null; + } + //Countdown timer specific $info["year_end"] = $src["annee_fin"]; $info["month_end"] = $src["mois_fin"];