plugin detection created as a widget; can't tell yet if swarmplayer is installed
[living-lab-site.git] / application / controllers / catalog.php
1 <?php
2
3 /**
4  * Class Catalog controls 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                 // **
21                 // ** LOADING MODEL
22                 // **
23                 // Retrieve videos summary.
24                 $this->load->model('videos_model');
25                 foreach ($this->config->item('categories') as $id => $name)
26                 {
27                         // Videos
28                         $vs_data['videos'] = $this->videos_model->get_videos_summary(
29                                 $id, 0, $this->config->item('videos_per_row'));
30                         
31                         // Category
32                         $vs_data['category_title'] = $name ?
33                                 $this->lang->line("ui_categ_$name") : $name;
34                         $vs_data['category_id'] = $id;
35                         
36                         // Pagination (not required)
37                         $vs_data['pagination'] = '';
38                         
39                         $data['videos_summaries'][] = 
40                                 $this->load->view('catalog/videos_summary_view', 
41                                 $vs_data, TRUE);
42                 }
43                 
44                 $params = array(        'title' => $this->config->item('site_name'),
45                                                         'css' => array(
46                                                                 'catalog.css'
47                                                         ),
48                                                         //'js' => array(),
49                                                         //'metas' => array('description'=>'','keywords'=>'')
50                                                         );
51                 $this->load->library('html_head_params', $params);
52                 
53                 // **
54                 // ** LOADING VIEWS
55                 // **
56                 $this->load->view('html_begin', $this->html_head_params);
57                 $this->load->view('header', array('selected_menu' => 'home'));
58                 
59                 $main_params['content'] = $this->load->view('catalog/index_view', $data, TRUE);
60                 $main_params['side'] = $this->load->view('side_default.php', NULL, TRUE);
61                 $this->load->view('main', $main_params);
62                 
63                 $this->load->view('footer');
64                 $this->load->view('html_end');
65         }
66         
67         public function test($page = 0)
68         {
69                 $params = array(        'title' => 'Test - '. $this->config->item('site_name'),
70                                                         //'css' => array(),
71                                                         //'js' => array(),
72                                                         //'metas' => array('description'=>'','keywords'=>'')
73                         );
74                 $this->load->library('html_head_params', $params);
75                 
76                 // **
77                 // ** LOADING VIEWS
78                 // **
79                 $this->load->view('html_begin', $this->html_head_params);
80                 $this->load->view('header', array('selected_menu' => 'home'));
81                 
82                 $this->load->view('echo', array('output'=>'Test Page', 'clear'=>TRUE));
83                 
84                 $this->load->view('footer');
85                 $this->load->view('html_end');
86         }
87         
88         public function category($category_id, $offset = 0)
89         {
90                 // **
91                 // ** LOADING MODEL
92                 // **
93                 // Retrieve videos summary.
94                 $this->load->model('videos_model');
95                 $vs_data['videos'] = $this->videos_model->get_videos_summary(
96                         $category_id, intval($offset),
97                         $this->config->item('videos_per_page'));
98                 
99                 // Video Category
100                 $categories = $this->config->item('categories');
101                 $category_name = $categories[$category_id];
102                 $vs_data['category_title'] = $category_name ?
103                         $this->lang->line("ui_categ_$category_name") : $category_name;
104                 $vs_data['category_id'] = $category_id;
105                 
106                 // Pagination
107                 $this->load->library('pagination');
108                 $pg_config['base_url'] = site_url("catalog/category/$category_id/");
109                 $pg_config['uri_segment'] = 4;
110                 $pg_config['total_rows'] = $this->videos_model->get_videos_count(
111                         $category_id);
112                 $pg_config['per_page'] = $this->config->item('videos_per_page');
113                 $this->pagination->initialize($pg_config);
114                 $vs_data['pagination'] = $this->pagination->create_links();
115                 
116                 // Video Summary
117                 $data['video_summary'] = $this->load->view('catalog/videos_summary_view',
118                         $vs_data, TRUE);
119                 
120                 $params = array(        'title' => $this->config->item('site_name'),
121                                                         'css' => array(
122                                                                 'catalog.css'
123                                                         ),
124                                                         //'js' => array(),
125                                                         //'metas' => array('description'=>'','keywords'=>'')
126                                                         );
127                 $this->load->library('html_head_params', $params);
128                 
129                 // **
130                 // ** LOADING VIEWS
131                 // **
132                 $this->load->view('html_begin', $this->html_head_params);
133                 $this->load->view('header');
134                 
135                 $main_params['content'] = $this->load->view('catalog/category_view', $data, TRUE);
136                 $main_params['side'] = $this->load->view('side_default.php', NULL, TRUE);
137                 $this->load->view('main', $main_params);
138                 
139                 $this->load->view('footer');
140                 $this->load->view('html_end');
141         }
142         
143         public function search($query_str)
144         {
145                 echo $query_str;
146         }
147 }
148
149 /* End of file catalog.php */
150 /* Location: ./application/controllers/catalog.php */