first stage finished: ready to publish to production; does not support users and...
[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_name, $offset = 0)
89         {
90                 // **
91                 // ** LOADING MODEL
92                 // **
93                 // Video Category
94                 $categories = $this->config->item('categories');
95                 $category_id = array_search($category_name, $categories);
96                 $vs_data['category_name'] = $category_name;
97                 $vs_data['category_id'] = $category_id;
98                 $vs_data['category_title'] = $category_name ?
99                 $this->lang->line("ui_categ_$category_name") : $category_name;          
100                 
101                 // Retrieve videos summary.
102                 $this->load->model('videos_model');
103                 $vs_data['videos'] = $this->videos_model->get_videos_summary(
104                         $vs_data['category_id'], intval($offset),
105                         $this->config->item('videos_per_page'));
106                 
107                 // Pagination
108                 $this->load->library('pagination');
109                 $pg_config['base_url'] = site_url("catalog/category/$category_id/");
110                 $pg_config['uri_segment'] = 4;
111                 $pg_config['total_rows'] = $this->videos_model->get_videos_count(
112                         $category_id);
113                 $pg_config['per_page'] = $this->config->item('videos_per_page');
114                 $this->pagination->initialize($pg_config);
115                 $vs_data['pagination'] = $this->pagination->create_links();
116                 
117                 // Video Summary
118                 $data['video_summary'] = $this->load->view('catalog/videos_summary_view',
119                         $vs_data, TRUE);
120                 
121                 $params = array(        'title' => $this->config->item('site_name'),
122                                                         'css' => array(
123                                                                 'catalog.css'
124                                                         ),
125                                                         //'js' => array(),
126                                                         //'metas' => array('description'=>'','keywords'=>'')
127                                                         );
128                 $this->load->library('html_head_params', $params);
129                 
130                 // **
131                 // ** LOADING VIEWS
132                 // **
133                 $this->load->view('html_begin', $this->html_head_params);
134                 $this->load->view('header');
135                 
136                 $main_params['content'] = $this->load->view('catalog/category_view', $data, TRUE);
137                 $main_params['side'] = $this->load->view('side_default.php', NULL, TRUE);
138                 $this->load->view('main', $main_params);
139                 
140                 $this->load->view('footer');
141                 $this->load->view('html_end');
142         }
143         
144         public function search($query_str)
145         {
146                 echo $query_str;
147         }
148 }
149
150 /* End of file catalog.php */
151 /* Location: ./application/controllers/catalog.php */