layout improved; About page completed
[living-lab-site.git] / application / models / videos_model.php
index 922efd4..ec7bb39 100644 (file)
@@ -7,7 +7,7 @@
  * @author             Călin-Andrei Burloiu
  */
 class Videos_model extends CI_Model {
-       private $db = NULL;
+       public $db = NULL;
        
        public function __construct()
        {
@@ -119,6 +119,8 @@ class Videos_model extends CI_Model {
         */
        public function get_video($id, $name = NULL)
        {
+               $this->load->helper('video');
+               
                $query = $this->db->query('SELECT * 
                                                                FROM `videos` 
                                                                WHERE id = ?', $id);
@@ -143,6 +145,12 @@ class Videos_model extends CI_Model {
                asort($video['tags']);
                $video['tags'] = array_reverse($video['tags'], TRUE);
                
+               // Sort assets by their megapixels number.
+               function access_function($a) { return $a['res']; }
+               function assets_cmp($a, $b) 
+                       { return megapixels_cmp($a, $b, "access_function"); }
+               usort($video['assets'], "assets_cmp");
+               
                // Torrents
                $video['url'] = array();
                foreach ($video['assets'] as & $asset)