small bug with side box fixed
[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                                                                 'jquery-ui.css'
48                                                         ),
49                                                         'js' => array(
50                                                                 'jquery.js',
51                                                                 'jquery-ui.js'
52                                                         ),
53                                                         //'metas' => array('description'=>'','keywords'=>'')
54                                                         );
55                 $this->load->library('html_head_params', $params);
56                 
57                 // **
58                 // ** LOADING VIEWS
59                 // **
60                 $this->load->view('html_begin', $this->html_head_params);
61                 $this->load->view('header', array('selected_menu' => 'home'));
62                 
63                 $main_params['content'] = $this->load->view('catalog/index_view', $data, TRUE);
64                 $main_params['side'] = $this->load->view('side_default.php', NULL, TRUE);
65                 $this->load->view('main', $main_params);
66                 
67                 $this->load->view('footer');
68                 $this->load->view('html_end');
69         }
70         
71         public function test($page = 0)
72         {
73                 $params = array(        'title' => 'Test - '. $this->config->item('site_name'),
74                                                         'css' => array(
75                                                                 'jquery-ui.css'
76                                                                 ),
77                                                         'js' => array(
78                                                                 'jquery.js',
79                                                                 'jquery-ui.js'
80                                                         ),
81                                                         //'metas' => array('description'=>'','keywords'=>'')
82                         );
83                 $this->load->library('html_head_params', $params);
84                 
85                 // **
86                 // ** LOADING VIEWS
87                 // **
88                 $this->load->view('html_begin', $this->html_head_params);
89                 $this->load->view('header', array('selected_menu' => 'home'));
90                 
91                 $this->load->view('echo', array('output'=>'Test Page', 'clear'=>TRUE));
92                 
93                 $this->load->view('footer');
94                 $this->load->view('html_end');
95         }
96         
97         public function category($category_id, $offset = 0)
98         {
99                 // **
100                 // ** LOADING MODEL
101                 // **
102                 // Retrieve videos summary.
103                 $this->load->model('videos_model');
104                 $vs_data['videos'] = $this->videos_model->get_videos_summary(
105                         $category_id, intval($offset),
106                         $this->config->item('videos_per_page'));
107                 
108                 // Video Category
109                 $categories = $this->config->item('categories');
110                 $category_name = $categories[$category_id];
111                 $vs_data['category_title'] = $category_name ?
112                         $this->lang->line("ui_categ_$category_name") : $category_name;
113                 $vs_data['category_id'] = $category_id;
114                 
115                 // Pagination
116                 $this->load->library('pagination');
117                 $pg_config['base_url'] = site_url("catalog/category/$category_id/");
118                 $pg_config['uri_segment'] = 4;
119                 $pg_config['total_rows'] = $this->videos_model->get_videos_count(
120                         $category_id);
121                 $pg_config['per_page'] = $this->config->item('videos_per_page');
122                 $this->pagination->initialize($pg_config);
123                 $vs_data['pagination'] = $this->pagination->create_links();
124                 
125                 // Video Summary
126                 $data['video_summary'] = $this->load->view('catalog/videos_summary_view',
127                         $vs_data, TRUE);
128                 
129                 $params = array(        'title' => $this->config->item('site_name'),
130                                                         'css' => array(
131                                                                 'catalog.css', 
132                                                                 'jquery-ui.css'
133                                                         ),
134                                                         'js' => array(
135                                                                 'jquery.js',
136                                                                 'jquery-ui.js'
137                                                         ),
138                                                         //'metas' => array('description'=>'','keywords'=>'')
139                                                         );
140                 $this->load->library('html_head_params', $params);
141                 
142                 // **
143                 // ** LOADING VIEWS
144                 // **
145                 $this->load->view('html_begin', $this->html_head_params);
146                 $this->load->view('header');
147                 
148                 $main_params['content'] = $this->load->view('catalog/category_view', $data, TRUE);
149                 $main_params['side'] = $this->load->view('side_default.php', NULL, TRUE);
150                 $this->load->view('main', $main_params);
151                 
152                 $this->load->view('footer');
153                 $this->load->view('html_end');
154         }
155         
156         public function search($query_str)
157         {
158                 echo $query_str;
159         }
160 }
161
162 /* End of file catalog.php */
163 /* Location: ./application/controllers/catalog.php */