article engine for static pages was integrated
[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                                                         //'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                 
69         }
70         
71         public function category($category_id, $offset = 0)
72         {
73                 // **
74                 // ** LOADING MODEL
75                 // **
76                 // Retrieve videos summary.
77                 $this->load->model('videos_model');
78                 $vs_data['videos'] = $this->videos_model->get_videos_summary(
79                         $category_id, intval($offset),
80                         $this->config->item('videos_per_page'));
81                 
82                 // Video Category
83                 $categories = $this->config->item('categories');
84                 $category_name = $categories[$category_id];
85                 $vs_data['category_title'] = $category_name ?
86                         $this->lang->line("ui_categ_$category_name") : $category_name;
87                 $vs_data['category_id'] = $category_id;
88                 
89                 // Pagination
90                 $this->load->library('pagination');
91                 $pg_config['base_url'] = site_url("catalog/category/$category_id/");
92                 $pg_config['uri_segment'] = 4;
93                 $pg_config['total_rows'] = $this->videos_model->get_videos_count(
94                         $category_id);
95                 $pg_config['per_page'] = $this->config->item('videos_per_page');
96                 $this->pagination->initialize($pg_config);
97                 $vs_data['pagination'] = $this->pagination->create_links();
98                 
99                 // Video Summary
100                 $data['video_summary'] = $this->load->view('catalog/videos_summary_view',
101                         $vs_data, TRUE);
102                 
103                 $params = array(        'title' => $this->config->item('site_name'),
104                                                         'css' => array('catalog.css'),
105                                                         //'js' => array(),
106                                                         //'metas' => array('description'=>'','keywords'=>'')
107                                                         );
108                 $this->load->library('html_head_params', $params);
109                 
110                 // **
111                 // ** LOADING VIEWS
112                 // **
113                 $this->load->view('html_begin', $this->html_head_params);
114                 $this->load->view('header');
115                 
116                 $this->load->view('catalog/category_view', $data);
117                 
118                 $this->load->view('footer');
119                 $this->load->view('html_end');
120         }
121         
122         public function search($query_str)
123         {
124                 echo $query_str;
125         }
126 }
127
128 /* End of file catalog.php */
129 /* Location: ./application/controllers/catalog.php */