You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
256 lines
11 KiB
256 lines
11 KiB
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
class Event_video_model extends CI_Model {
|
|
|
|
|
|
public function __construct() {
|
|
parent::__construct();
|
|
$this->db->query("SET @@group_concat_max_len =30000");
|
|
}
|
|
|
|
public function save_video($video) {
|
|
$data = array(
|
|
'image' => $video['image'],
|
|
'title' => $video['title'],
|
|
'duration' => $video['duration'],
|
|
'description' => $video['description'],
|
|
'embed' => $video['embed'],
|
|
'live_video_start_date' => $video['live_video_start_date'],
|
|
'live_video_end_date' => $video['live_video_end_date'],
|
|
'url' => $video['url'],
|
|
'owner' => $video['owner'],
|
|
'event_id' => $video['event_id']
|
|
);
|
|
$this->db->insert('event_videos', $data);
|
|
}
|
|
|
|
public function update_video($id, $video) {
|
|
$data = array(
|
|
'title' => $video['title'],
|
|
'description' => $video['description'],
|
|
'live_video_start_date' => $video['live_video_start_date'],
|
|
'live_video_end_date' => $video['live_video_end_date'],
|
|
);
|
|
$this->db->where('id', $id);
|
|
$this->db->update('event_videos', $data);
|
|
}
|
|
public function total_replay_videos_duration_spec($videos){
|
|
return "12h";
|
|
}
|
|
public function total_replay_videos_spec($videos){
|
|
$cpt = 0;
|
|
$date = isset($_GET["date"]) ? $_GET["date"] : date("Y-m-d H:i:s");
|
|
foreach($videos as $video){
|
|
if($video->live_video_start_date < $date && $video->live_video_end_date < $date)
|
|
$cpt++;
|
|
}
|
|
return $cpt;
|
|
}
|
|
|
|
public function get_videos_by_event_id($event_id) {
|
|
$this->db->select('*');
|
|
$this->db->where('event_id', $event_id);
|
|
$this->db->where('status', 1);
|
|
return $this->db->get('event_videos')->result();
|
|
}
|
|
|
|
public function get_videos_by_event_id_spec($event_id) {
|
|
if($event_id != "311")
|
|
return;
|
|
|
|
$videos = [];
|
|
$videos[0] = new \stdClass();
|
|
$videos[1] = new \stdClass();
|
|
$videos[2] = new \stdClass();
|
|
$videos[3] = new \stdClass();
|
|
$videos[4] = new \stdClass();
|
|
$videos[5] = new \stdClass();
|
|
|
|
$videos[0]->title = "Au tournant du siècle, les Etats-Unis dans l’ivresse de l’hyperpuissance";
|
|
$videos[0]->duration = "02:00:00";
|
|
$videos[0]->description = "Au tournant du siècle, les Etats-Unis dans l’ivresse de l’hyperpuissance";
|
|
$videos[0]->embed = <<<HERE
|
|
"<iframe src=\"https://player.vimeo.com/video/690207852?h=d41b2a1893&badge=0&autopause=0&player_id=0&app_id=227616\" width=\"1920\" height=\"1080\" frameborder=\"0\" allow=\"autoplay; fullscreen; picture-in-picture\" allowfullscreen title=\"YSL X ROSÉ NEW 마블팩트 MAIN FILM\"></iframe>"
|
|
HERE;
|
|
$videos[0]->url = "https://vimeo.com/690207852";
|
|
$videos[0]->live_video_start_date = "2022-04-07 19:00:00";
|
|
$videos[0]->live_video_end_date = "2022-04-07 21:00:00";
|
|
|
|
$videos[1]->title = "Attentats du 11 septembre 2001 : la réponse américaine, un enchaînement d’erreurs stratégiques majeures ";
|
|
$videos[1]->duration = "02:00:00";
|
|
$videos[1]->description = "Attentats du 11 septembre 2001 : la réponse américaine, un enchaînement d’erreurs stratégiques majeures ";
|
|
$videos[1]->embed = <<<HERE
|
|
"<iframe src=\"https://player.vimeo.com/video/1982076?h=d41b2a1893&badge=0&autopause=0&player_id=0&app_id=227616\" width=\"1920\" height=\"1080\" frameborder=\"0\" allow=\"autoplay; fullscreen; picture-in-picture\" allowfullscreen title=\"YSL X ROSÉ NEW 마블팩트 MAIN FILM\"></iframe>"
|
|
HERE;
|
|
$videos[1]->url = "https://vimeo.com/event/1982076";
|
|
$videos[1]->live_video_start_date = "2022-04-14 19:00:00";
|
|
$videos[1]->live_video_end_date = "2022-04-14 21:00:00";
|
|
|
|
$videos[2]->title = "La passion Obama (déraisonnable) et le pourquoi du trumpisme (encore plus déraisonnable)";
|
|
$videos[2]->duration = "02:00:00";
|
|
$videos[2]->description = "La passion Obama (déraisonnable) et le pourquoi du trumpisme (encore plus déraisonnable)";
|
|
$videos[2]->embed = <<<HERE
|
|
"<iframe src=\"https://player.vimeo.com/video/694372698?h=d41b2a1893&badge=0&autopause=0&player_id=0&app_id=227616\" width=\"1920\" height=\"1080\" frameborder=\"0\" allow=\"autoplay; fullscreen; picture-in-picture\" allowfullscreen title=\"YSL X ROSÉ NEW 마블팩트 MAIN FILM\"></iframe>"
|
|
HERE;
|
|
$videos[2]->url = "https://vimeo.com/694372698";
|
|
$videos[2]->live_video_start_date = "2022-04-21 19:00:00";
|
|
$videos[2]->live_video_end_date = "2022-04-21 21:00:00";
|
|
|
|
$videos[3]->title = "Les Etats-Unis et la Chine : de l’amitié à l’affrontement";
|
|
$videos[3]->duration = "02:00:00";
|
|
$videos[3]->description = "Les Etats-Unis et la Chine : de l’amitié à l’affrontement";
|
|
$videos[3]->embed = <<<HERE
|
|
"<iframe src=\"https://player.vimeo.com/video/694374796?h=d41b2a1893&badge=0&autopause=0&player_id=0&app_id=227616\" width=\"1920\" height=\"1080\" frameborder=\"0\" allow=\"autoplay; fullscreen; picture-in-picture\" allowfullscreen title=\"YSL X ROSÉ NEW 마블팩트 MAIN FILM\"></iframe>"
|
|
HERE;
|
|
$videos[3]->url = "https://vimeo.com/694374796";
|
|
$videos[3]->live_video_start_date = "2022-05-12 19:00:00";
|
|
$videos[3]->live_video_end_date = "2022-05-12 21:00:00";
|
|
|
|
$videos[4]->title = "Menaces sur la démocratie américaine : une mécanique institutionnelle déréglée";
|
|
$videos[4]->duration = "02:00:00";
|
|
$videos[4]->description = "Menaces sur la démocratie américaine : une mécanique institutionnelle déréglée";
|
|
$videos[4]->embed = <<<HERE
|
|
"<iframe src=\"https://player.vimeo.com/video/6bf8516668?h=d41b2a1893&badge=0&autopause=0&player_id=0&app_id=227616\" width=\"1920\" height=\"1080\" frameborder=\"0\" allow=\"autoplay; fullscreen; picture-in-picture\" allowfullscreen title=\"YSL X ROSÉ NEW 마블팩트 MAIN FILM\"></iframe>"
|
|
HERE;
|
|
$videos[4]->url = "https://vimeo.com/event/1989102/6bf8516668";
|
|
$videos[4]->live_video_start_date = "2022-05-19 19:00:00";
|
|
$videos[4]->live_video_end_date = "2022-05-19 21:00:00";
|
|
|
|
$videos[5]->title = "Des atouts toujours déterminants face aux autres « grands » : la Chine, la Russie, l’Union européenne…";
|
|
$videos[5]->duration = "02:00:00";
|
|
$videos[5]->description = "Des atouts toujours déterminants face aux autres « grands » : la Chine, la Russie, l’Union européenne…";
|
|
$videos[5]->embed = <<<HERE
|
|
"<iframe src=\"https://player.vimeo.com/video/694376759?h=d41b2a1893&badge=0&autopause=0&player_id=0&app_id=227616\" width=\"1920\" height=\"1080\" frameborder=\"0\" allow=\"autoplay; fullscreen; picture-in-picture\" allowfullscreen title=\"YSL X ROSÉ NEW 마블팩트 MAIN FILM\"></iframe>"
|
|
HERE;
|
|
$videos[5]->url = "https://vimeo.com/694376759";
|
|
$videos[5]->live_video_start_date = "2022-05-25 19:00:00";
|
|
$videos[5]->live_video_end_date = "2022-05-25 21:00:00";
|
|
|
|
return $videos;
|
|
}
|
|
|
|
public function get_next_course_from_id($event_id) {
|
|
$this->db->select('*');
|
|
$this->db->where('event_id', $event_id);
|
|
$this->db->where('status', 1);
|
|
$res = $this->db->get('event_videos')->result_array();
|
|
|
|
foreach($res as $r => $rr){
|
|
if($rr["live_video_start_date"] > date("Y-m-d H:i:s")){
|
|
return $rr;
|
|
}
|
|
}
|
|
return $res[count($res)-1];
|
|
}
|
|
|
|
public function get_next_course_from_id_spec($event_id) {
|
|
if(count($event_id)>0){
|
|
$date = isset($_GET["date"]) ? $_GET["date"] : date("Y-m-d H:i:s");
|
|
foreach((array)$event_id as $r){
|
|
if($r->live_video_start_date > $date){
|
|
return $r;
|
|
}
|
|
}
|
|
return $event_id[count($event_id)-1];
|
|
}
|
|
return;
|
|
}
|
|
|
|
public function get_video_by_id($id) {
|
|
$this->db->select('*');
|
|
$this->db->where('id', $id);
|
|
$this->db->where('status', 1);
|
|
return $this->db->get('event_videos')->row();
|
|
}
|
|
|
|
public function delete_video($id) {
|
|
$data = array(
|
|
'status' => 0
|
|
);
|
|
$this->db->where('id', $id);
|
|
$this->db->update('event_videos', $data);
|
|
}
|
|
|
|
public function format_video_duration($time) {
|
|
$minute = '00';
|
|
$hour = '0';
|
|
$second = '0';
|
|
$duration = explode(':', $time);
|
|
$h = (int)$duration[0];
|
|
$m = (int)$duration[1];
|
|
$s = (int)$duration[2];
|
|
$m = $m + floor($s/60);
|
|
$h = $h + floor($m/60);
|
|
$m = $m % 60;
|
|
$s = $s % 60;
|
|
$hour=(string) $h;
|
|
if($m<10)
|
|
$minute='0'. (string) $m;
|
|
else
|
|
$minute = (string)$m;
|
|
if($s<10)
|
|
$second = '0'. (string) $s;
|
|
else
|
|
$second = (string) $s;
|
|
if($h>0) {
|
|
return $hour.'h'.$minute;
|
|
}
|
|
return $minute.'min'.$second;
|
|
}
|
|
|
|
|
|
public function date_diff_array(DateTime $oDate1, DateTime $oDate2) {
|
|
$aIntervals = array(
|
|
'year' => 0,
|
|
'month' => 0,
|
|
'week' => 0,
|
|
'day' => 0,
|
|
'hour' => 0,
|
|
'minute' => 0,
|
|
'second' => 0,
|
|
);
|
|
|
|
foreach($aIntervals as $sInterval => &$iInterval) {
|
|
while($oDate1 <= $oDate2){
|
|
$oDate1->modify('+1 ' . $sInterval);
|
|
if ($oDate1 > $oDate2) {
|
|
$oDate1->modify('-1 ' . $sInterval);
|
|
break;
|
|
} else {
|
|
$iInterval++;
|
|
}
|
|
}
|
|
}
|
|
|
|
return $aIntervals;
|
|
}
|
|
|
|
public function total_video_duration($videos) {
|
|
$minute = '00';
|
|
$hour = '0';
|
|
$h = 0;
|
|
$m = 0;
|
|
$s = 0;
|
|
if(count($videos)>0) {
|
|
foreach($videos as $video) {
|
|
$dura= $this->date_diff_array(new DateTime($video->live_video_start_date),new DateTime($video->live_video_end_date));
|
|
$duration = explode(':', $dura["hour"].":".$dura["minute"].":".$dura["second"]);
|
|
$h += (int)$duration[0];
|
|
$m += (int)$duration[1];
|
|
$s += (int)$duration[2];
|
|
|
|
}
|
|
$m = $m + floor($s/60);
|
|
$h = $h + floor($m/60);
|
|
$m = $m % 60;
|
|
|
|
$hour = (string)$h;
|
|
if($m<10)
|
|
$minute='0'. (string) $m;
|
|
else
|
|
$minute = (string)$m;
|
|
}
|
|
return $hour.'h'.$minute;
|
|
}
|
|
|
|
}
|