homepage, categories pages; javascript and stylesheets renamed to js and css resp.
[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         
16         public function index()
17         {
18                 // Retrieve videos summary.
19                 $data['categories'] = $this->config->item('categories');
20                 $this->load->model('videos_model');
21                 foreach ($data['categories'] as $id => $name)
22                 {
23                         $data['videos'][$id] = $this->videos_model->get_videos_summary(
24                                 $id, 0, $this->config->item('videos_per_row'));
25                 }
26                 
27                 $params = array(        'title' => $this->config->item('site_name'),
28                                                         'css' => array('catalog.css'),
29                                                         //'js' => array(),
30                                                         //'metas' => array('description'=>'','keywords'=>'')
31                                                         );
32                 $this->load->library('html_head_params', $params);
33                 $this->load->view('html_begin', $this->html_head_params);
34                 $this->load->view('header');
35                 
36                 $this->load->view('catalog/index_view', $data);
37                 
38                 $this->load->view('footer');
39                 $this->load->view('html_end');
40         }
41         
42         public function test($page = 0)
43         {
44                 $this->load->helper('url');
45                 $this->load->library('pagination');
46                 
47                 $config['base_url'] = site_url('catalog/test/');
48                 $config['total_rows'] = '160';
49                 $this->pagination->initialize($config);
50                 echo $this->pagination->create_links();
51         }
52         
53         public function category($category_id, $offset = 0)
54         {
55                 // Retrieve videos summary.
56                 $this->load->model('videos_model');
57                 $data['videos'] = $this->videos_model->get_videos_summary(
58                         $category_id, intval($offset),
59                         $this->config->item('videos_per_page'));
60                 $categories = $this->config->item('categories');
61                 $data['category'] = $categories[$category_id];
62                 $data['category_id'] = $category_id;
63                 
64                 // Pagination
65                 $this->load->library('pagination');
66                 $pg_config['base_url'] = site_url("catalog/category/$category_id/");
67                 $pg_config['uri_segment'] = 4;
68                 $pg_config['total_rows'] = $this->videos_model->get_videos_count(
69                         $category_id);
70                 $pg_config['per_page'] = $this->config->item('videos_per_page');
71                 $this->pagination->initialize($pg_config);
72                 $data['pagination'] = $this->pagination->create_links();
73                 
74                 $params = array(        'title' => $this->config->item('site_name'),
75                                                         'css' => array('catalog.css'),
76                                                         //'js' => array(),
77                                                         //'metas' => array('description'=>'','keywords'=>'')
78                                                         );
79                 $this->load->library('html_head_params', $params);
80                 $this->load->view('html_begin', $this->html_head_params);
81                 $this->load->view('header');
82                 
83                 $this->load->view('catalog/category_view', $data);
84                 
85                 $this->load->view('footer');
86                 $this->load->view('html_end');
87         }
88         
89         public function search($query_str)
90         {
91                 echo $query_str;
92         }
93 }
94
95 /* End of file catalog.php */
96 /* Location: ./application/controllers/catalog.php */