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