a jQuery UI plugin named nsvideo, that plays videos using html5, was implemented...
[living-lab-site.git] / application / controllers / catalog.php
1 <?php
2
3 /**
4  * Class Catalog controlls video hierarchy and searching
5  *
6  * @category    Controller
7  * @author              Călin-Andrei Burloiu
8  */
9 class Catalog extends CI_Controller {
10         
11         public function __construct()
12         {
13                 parent::__construct();
14                 
15                 //$this->lang->load('catalog');
16         }       
17         
18         public function index()
19         {
20                 // Retrieve videos summary.
21                 $this->load->model('videos_model');
22                 foreach ($this->config->item('categories') as $id => $name)
23                 {
24                         // Videos
25                         $vs_data['videos'] = $this->videos_model->get_videos_summary(
26                                 $id, 0, $this->config->item('videos_per_row'));
27                         
28                         // Category
29                         $vs_data['category_title'] = $name ?
30                                 $this->lang->line("ui_categ_$name") : $name;
31                         $vs_data['category_id'] = $id;
32                         
33                         // Pagination (not required)
34                         $vs_data['pagination'] = '';
35                         
36                         $data['videos_summaries'][] = 
37                                 $this->load->view('catalog/videos_summary_view', 
38                                 $vs_data, TRUE);
39                 }
40                 
41                 $params = array(        'title' => $this->config->item('site_name'),
42                                                         'css' => array('catalog.css'),
43                                                         //'js' => array(),
44                                                         //'metas' => array('description'=>'','keywords'=>'')
45                                                         );
46                 $this->load->library('html_head_params', $params);
47                 $this->load->view('html_begin', $this->html_head_params);
48                 $this->load->view('header');
49                 
50                 $this->load->view('catalog/index_view', $data);
51                 
52                 $this->load->view('footer');
53                 $this->load->view('html_end');
54         }
55         
56         public function test($page = 0)
57         {
58                 $this->load->helper('url');
59                 
60                 $str = '[{"def":"1080p"},{"def":"600p"}]';
61                 $a = json_decode($str);
62                 
63                 echo count($a);
64         }
65         
66         public function category($category_id, $offset = 0)
67         {
68                 // Retrieve videos summary.
69                 $this->load->model('videos_model');
70                 $vs_data['videos'] = $this->videos_model->get_videos_summary(
71                         $category_id, intval($offset),
72                         $this->config->item('videos_per_page'));
73                 
74                 // Video Category
75                 $categories = $this->config->item('categories');
76                 $category_name = $categories[$category_id];
77                 $vs_data['category_title'] = $category_name ?
78                         $this->lang->line("ui_categ_$category_name") : $category_name;
79                 $vs_data['category_id'] = $category_id;
80                 
81                 // Pagination
82                 $this->load->library('pagination');
83                 $pg_config['base_url'] = site_url("catalog/category/$category_id/");
84                 $pg_config['uri_segment'] = 4;
85                 $pg_config['total_rows'] = $this->videos_model->get_videos_count(
86                         $category_id);
87                 $pg_config['per_page'] = $this->config->item('videos_per_page');
88                 $this->pagination->initialize($pg_config);
89                 $vs_data['pagination'] = $this->pagination->create_links();
90                 
91                 // Video Summary
92                 $data['video_summary'] = $this->load->view('catalog/videos_summary_view',
93                         $vs_data, TRUE);
94                 
95                 $params = array(        'title' => $this->config->item('site_name'),
96                                                         'css' => array('catalog.css'),
97                                                         //'js' => array(),
98                                                         //'metas' => array('description'=>'','keywords'=>'')
99                                                         );
100                 $this->load->library('html_head_params', $params);
101                 $this->load->view('html_begin', $this->html_head_params);
102                 $this->load->view('header');
103                 
104                 $this->load->view('catalog/category_view', $data);
105                 
106                 $this->load->view('footer');
107                 $this->load->view('html_end');
108         }
109         
110         public function search($query_str)
111         {
112                 echo $query_str;
113         }
114 }
115
116 /* End of file catalog.php */
117 /* Location: ./application/controllers/catalog.php */