X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?p=living-lab-site.git;a=blobdiff_plain;f=application%2Fmodels%2Fvideos_model.php;h=c09673c52d14d81b10c79e6e3dba013c6767f458;hp=87b0d3b0e8d869ea5e7cf7a19ee907e9b0c4cf90;hb=b56dce7ae724d5b955a96d7d3d5b3b476d2e28fb;hpb=961611537619595dc7eed2104faafcd0c9cdc57b diff --git a/application/models/videos_model.php b/application/models/videos_model.php index 87b0d3b..c09673c 100644 --- a/application/models/videos_model.php +++ b/application/models/videos_model.php @@ -140,6 +140,7 @@ class Videos_model extends CI_Model { // Thumbnails $video['thumbs'] = $this->get_thumbs($video['name'], $video['thumbs_count']); + $video['json_thumbs'] = json_encode($video['thumbs']); // Ellipsized title //$video['shorted_title'] = ellipsize($video['title'], 45, 0.75); @@ -273,6 +274,8 @@ class Videos_model extends CI_Model { public function add_video($name, $title, $description, $tags, $duration, $formats, $category_id, $user_id, $uploaded_file) { + $this->load->config('content_ingestion'); + // Tags. $json_tags = array(); $tok = strtok($tags, ','); @@ -284,15 +287,19 @@ class Videos_model extends CI_Model { } $json_tags = json_encode($json_tags); - // TODO formats $json_formats = json_encode($formats); + // Thumbnail images + $thumbs_count = $this->config->item('thumbs_count'); + $default_thumb = rand(0, $thumbs_count - 1); + $query = $this->db->query("INSERT INTO `videos` (name, title, description, duration, formats, category_id, - user_id, tags, date) + user_id, tags, date, thumbs_count, default_thumb) VALUES ('$name', '$title', '$description', '$duration', '$json_formats', $category_id, - $user_id, '$json_tags', utc_timestamp())"); + $user_id, '$json_tags', utc_timestamp(), + $thumbs_count, $default_thumb)"); if ($query === FALSE) return FALSE; @@ -684,6 +691,7 @@ class Videos_model extends CI_Model { // Thumbnails $video['thumbs'] = $this->get_thumbs($video['name'], $video['thumbs_count']); + $video['json_thumbs'] = json_encode($video['thumbs']); // Ellipsized title //$video['shorted_title'] = ellipsize($video['title'], 45, 0.75);