interface modified
[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                 // **
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                                                         //'metas' => array('description'=>'','keywords'=>'')
51                                                         );
52                 $this->load->library('html_head_params', $params);
53                 
54                 // **
55                 // ** LOADING VIEWS
56                 // **
57                 $this->load->view('html_begin', $this->html_head_params);
58                 $this->load->view('header', array('selected_menu' => 'Home'));
59                 
60                 $this->load->view('catalog/index_view', $data);
61                 
62                 $this->load->view('footer');
63                 $this->load->view('html_end');
64         }
65         
66         public function test($page = 0)
67         {
68                 $this->load->helper('url');
69                 
70                 $str = '800x600';
71                 
72                 echo substr($str, strpos($str, 'x') + 1);
73         }
74         
75         public function category($category_id, $offset = 0)
76         {
77                 // **
78                 // ** LOADING MODEL
79                 // **
80                 // Retrieve videos summary.
81                 $this->load->model('videos_model');
82                 $vs_data['videos'] = $this->videos_model->get_videos_summary(
83                         $category_id, intval($offset),
84                         $this->config->item('videos_per_page'));
85                 
86                 // Video Category
87                 $categories = $this->config->item('categories');
88                 $category_name = $categories[$category_id];
89                 $vs_data['category_title'] = $category_name ?
90                         $this->lang->line("ui_categ_$category_name") : $category_name;
91                 $vs_data['category_id'] = $category_id;
92                 
93                 // Pagination
94                 $this->load->library('pagination');
95                 $pg_config['base_url'] = site_url("catalog/category/$category_id/");
96                 $pg_config['uri_segment'] = 4;
97                 $pg_config['total_rows'] = $this->videos_model->get_videos_count(
98                         $category_id);
99                 $pg_config['per_page'] = $this->config->item('videos_per_page');
100                 $this->pagination->initialize($pg_config);
101                 $vs_data['pagination'] = $this->pagination->create_links();
102                 
103                 // Video Summary
104                 $data['video_summary'] = $this->load->view('catalog/videos_summary_view',
105                         $vs_data, TRUE);
106                 
107                 $params = array(        'title' => $this->config->item('site_name'),
108                                                         'css' => array('catalog.css'),
109                                                         //'js' => array(),
110                                                         //'metas' => array('description'=>'','keywords'=>'')
111                                                         );
112                 $this->load->library('html_head_params', $params);
113                 
114                 // **
115                 // ** LOADING VIEWS
116                 // **
117                 $this->load->view('html_begin', $this->html_head_params);
118                 $this->load->view('header');
119                 
120                 $this->load->view('catalog/category_view', $data);
121                 
122                 $this->load->view('footer');
123                 $this->load->view('html_end');
124         }
125         
126         public function search($query_str)
127         {
128                 echo $query_str;
129         }
130 }
131
132 /* End of file catalog.php */
133 /* Location: ./application/controllers/catalog.php */