layout improved; About page completed
[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                 $main_params['content'] = $this->load->view('catalog/index_view', $data, TRUE);
61                 // TODO: side
62                 $main_params['side'] = '<h1>Side Box</h1><p>TODO: Put side box content here</p>';
63                 $this->load->view('main', $main_params);
64                 
65                 $this->load->view('footer');
66                 $this->load->view('html_end');
67         }
68         
69         public function test($page = 0)
70         {
71                 $params = array(        'title' => 'Test - '. $this->config->item('site_name'),
72                                                         'css' => array(
73                                                                 'jquery-ui.css'
74                                                                 ),
75                                                         //'js' => array(),
76                                                         //'metas' => array('description'=>'','keywords'=>'')
77                         );
78                 $this->load->library('html_head_params', $params);
79                 
80                 // **
81                 // ** LOADING VIEWS
82                 // **
83                 $this->load->view('html_begin', $this->html_head_params);
84                 $this->load->view('header', array('selected_menu' => 'home'));
85                 
86                 $this->load->view('echo', array('output'=>'Test Page', 'clear'=>TRUE));
87                 
88                 $this->load->view('footer');
89                 $this->load->view('html_end');
90         }
91         
92         public function category($category_id, $offset = 0)
93         {
94                 // **
95                 // ** LOADING MODEL
96                 // **
97                 // Retrieve videos summary.
98                 $this->load->model('videos_model');
99                 $vs_data['videos'] = $this->videos_model->get_videos_summary(
100                         $category_id, intval($offset),
101                         $this->config->item('videos_per_page'));
102                 
103                 // Video Category
104                 $categories = $this->config->item('categories');
105                 $category_name = $categories[$category_id];
106                 $vs_data['category_title'] = $category_name ?
107                         $this->lang->line("ui_categ_$category_name") : $category_name;
108                 $vs_data['category_id'] = $category_id;
109                 
110                 // Pagination
111                 $this->load->library('pagination');
112                 $pg_config['base_url'] = site_url("catalog/category/$category_id/");
113                 $pg_config['uri_segment'] = 4;
114                 $pg_config['total_rows'] = $this->videos_model->get_videos_count(
115                         $category_id);
116                 $pg_config['per_page'] = $this->config->item('videos_per_page');
117                 $this->pagination->initialize($pg_config);
118                 $vs_data['pagination'] = $this->pagination->create_links();
119                 
120                 // Video Summary
121                 $data['video_summary'] = $this->load->view('catalog/videos_summary_view',
122                         $vs_data, TRUE);
123                 
124                 $params = array(        'title' => $this->config->item('site_name'),
125                                                         'css' => array(
126                                                                 'catalog.css', 
127                                                                 'jquery-ui.css'
128                                                                 ),
129                                                         //'js' => array(),
130                                                         //'metas' => array('description'=>'','keywords'=>'')
131                                                         );
132                 $this->load->library('html_head_params', $params);
133                 
134                 // **
135                 // ** LOADING VIEWS
136                 // **
137                 $this->load->view('html_begin', $this->html_head_params);
138                 $this->load->view('header');
139                 
140                 $main_params['content'] = $this->load->view('catalog/category_view', $data, TRUE);
141                 // TODO: side
142                 $main_params['side'] = '<h1>Side Box</h1><p>TODO: Put side box content here</p>';
143                 $this->load->view('main', $main_params);
144                 
145                 $this->load->view('footer');
146                 $this->load->view('html_end');
147         }
148         
149         public function search($query_str)
150         {
151                 echo $query_str;
152         }
153 }
154
155 /* End of file catalog.php */
156 /* Location: ./application/controllers/catalog.php */