X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=blobdiff_plain;f=application%2Fmodels%2Fvideos_model.php;h=f42eb744b88c3b21e29ca8f1e2831199af36a00b;hb=a4b67ff4aaa76dc95e774be78724909193999ee4;hp=59ff7d383f1c2dbe049db7ebc4cefb0d7755c567;hpb=44e76cbf029fbec96b9a91837963b872f4984004;p=living-lab-site.git diff --git a/application/models/videos_model.php b/application/models/videos_model.php index 59ff7d3..f42eb74 100644 --- a/application/models/videos_model.php +++ b/application/models/videos_model.php @@ -36,7 +36,8 @@ class Videos_model extends CI_Model { $query = $this->db->query( 'SELECT id, name, title, duration, user_id, views, thumbs_count, default_thumb - FROM `videos`'); + FROM `videos` + ORDER BY name'); // TODO summary order $videos = $query->result_array(); foreach ($videos as & $video) @@ -46,7 +47,7 @@ class Videos_model extends CI_Model { $video['id'], $video['name'])); // Thumbnails - $video['thumbs'] = $this->getThumbs($video['name'], + $video['thumbs'] = $this->get_thumbs($video['name'], $video['thumbs_count']); } @@ -97,26 +98,27 @@ class Videos_model extends CI_Model { // Convert JSON encoded string to arrays. $video['formats'] = json_decode($video['formats'], TRUE); $video['tags'] = json_decode($video['tags'], TRUE); + asort($video['tags']); + $video['tags'] = array_reverse($video['tags'], true); // Torrents $video['torrents'] = array(); foreach ($video['formats'] as $format) { - $pos = strpos($format, ' '); - if($pos !== FALSE) - $format = substr($format, 0, $pos); + $ext = isset($format['ext']) ? + $format['ext'] : $this->config->item('default_video_ext'); $video['torrents'][] = site_url('data/torrents/'. $video['name'] . '_' - . $format . '.'. $this->config->item('default_video_ext') + . $format['def'] . '.'. $ext . '.'. $this->config->item('default_torrent_ext')); } // Thumbnails - $video['thumbs'] = $this->getThumbs($video['name'], $video['thumbs_count']); + $video['thumbs'] = $this->get_thumbs($video['name'], $video['thumbs_count']); return $video; } - public function getThumbs($name, $count) + public function get_thumbs($name, $count) { $thumbs = array();