language support added; Romanian language added; preparing to create jQuery UI video...
[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                 $this->load->library('pagination');
60                 
61                 $config['base_url'] = site_url('catalog/test/');
62                 $config['total_rows'] = '160';
63                 $this->pagination->initialize($config);
64                 echo $this->pagination->create_links();
65         }
66         
67         public function category($category_id, $offset = 0)
68         {
69                 // Retrieve videos summary.
70                 $this->load->model('videos_model');
71                 $vs_data['videos'] = $this->videos_model->get_videos_summary(
72                         $category_id, intval($offset),
73                         $this->config->item('videos_per_page'));
74                 
75                 // Video Category
76                 $categories = $this->config->item('categories');
77                 $category_name = $categories[$category_id];
78                 $vs_data['category_title'] = $category_name ?
79                         $this->lang->line("ui_categ_$category_name") : $category_name;
80                 $vs_data['category_id'] = $category_id;
81                 
82                 // Pagination
83                 $this->load->library('pagination');
84                 $pg_config['base_url'] = site_url("catalog/category/$category_id/");
85                 $pg_config['uri_segment'] = 4;
86                 $pg_config['total_rows'] = $this->videos_model->get_videos_count(
87                         $category_id);
88                 $pg_config['per_page'] = $this->config->item('videos_per_page');
89                 $this->pagination->initialize($pg_config);
90                 $vs_data['pagination'] = $this->pagination->create_links();
91                 
92                 // Video Summary
93                 $data['video_summary'] = $this->load->view('catalog/videos_summary_view',
94                         $vs_data, TRUE);
95                 
96                 $params = array(        'title' => $this->config->item('site_name'),
97                                                         'css' => array('catalog.css'),
98                                                         //'js' => array(),
99                                                         //'metas' => array('description'=>'','keywords'=>'')
100                                                         );
101                 $this->load->library('html_head_params', $params);
102                 $this->load->view('html_begin', $this->html_head_params);
103                 $this->load->view('header');
104                 
105                 $this->load->view('catalog/category_view', $data);
106                 
107                 $this->load->view('footer');
108                 $this->load->view('html_end');
109         }
110         
111         public function search($query_str)
112         {
113                 echo $query_str;
114         }
115 }
116
117 /* End of file catalog.php */
118 /* Location: ./application/controllers/catalog.php */