small bug with side box fixed
[living-lab-site.git] / application / controllers / catalog.php
index 3447167..4318325 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 
 /**
- * Class Catalog controlls video hierarchy and searching
+ * Class Catalog controls video hierarchy and searching
  *
  * @category   Controller
  * @author             Călin-Andrei Burloiu
@@ -11,29 +11,58 @@ class Catalog extends CI_Controller {
        public function __construct()
        {
                parent::__construct();
+               
+               //$this->lang->load('catalog');
        }       
        
        public function index()
        {
+               // **
+               // ** LOADING MODEL
+               // **
                // Retrieve videos summary.
-               $data['categories'] = $this->config->item('categories');
                $this->load->model('videos_model');
-               foreach ($data['categories'] as $id => $name)
+               foreach ($this->config->item('categories') as $id => $name)
                {
-                       $data['videos'][$id] = $this->videos_model->get_videos_summary(
+                       // Videos
+                       $vs_data['videos'] = $this->videos_model->get_videos_summary(
                                $id, 0, $this->config->item('videos_per_row'));
+                       
+                       // Category
+                       $vs_data['category_title'] = $name ?
+                               $this->lang->line("ui_categ_$name") : $name;
+                       $vs_data['category_id'] = $id;
+                       
+                       // Pagination (not required)
+                       $vs_data['pagination'] = '';
+                       
+                       $data['videos_summaries'][] = 
+                               $this->load->view('catalog/videos_summary_view', 
+                               $vs_data, TRUE);
                }
                
                $params = array(        'title' => $this->config->item('site_name'),
-                                                       'css' => array('catalog.css'),
-                                                       //'js' => array(),
+                                                       'css' => array(
+                                                               'catalog.css', 
+                                                               'jquery-ui.css'
+                                                       ),
+                                                       'js' => array(
+                                                               'jquery.js',
+                                                               'jquery-ui.js'
+                                                       ),
                                                        //'metas' => array('description'=>'','keywords'=>'')
                                                        );
                $this->load->library('html_head_params', $params);
+               
+               // **
+               // ** LOADING VIEWS
+               // **
                $this->load->view('html_begin', $this->html_head_params);
-               $this->load->view('header');
+               $this->load->view('header', array('selected_menu' => 'home'));
                
-               $this->load->view('catalog/index_view', $data);
+               $main_params['content'] = $this->load->view('catalog/index_view', $data, TRUE);
+               $main_params['side'] = $this->load->view('side_default.php', NULL, TRUE);
+               $this->load->view('main', $main_params);
                
                $this->load->view('footer');
                $this->load->view('html_end');
@@ -41,25 +70,47 @@ class Catalog extends CI_Controller {
        
        public function test($page = 0)
        {
-               $this->load->helper('url');
-               $this->load->library('pagination');
+               $params = array(        'title' => 'Test - '. $this->config->item('site_name'),
+                                                       'css' => array(
+                                                               'jquery-ui.css'
+                                                               ),
+                                                       'js' => array(
+                                                               'jquery.js',
+                                                               'jquery-ui.js'
+                                                       ),
+                                                       //'metas' => array('description'=>'','keywords'=>'')
+                       );
+               $this->load->library('html_head_params', $params);
+               
+               // **
+               // ** LOADING VIEWS
+               // **
+               $this->load->view('html_begin', $this->html_head_params);
+               $this->load->view('header', array('selected_menu' => 'home'));
+               
+               $this->load->view('echo', array('output'=>'Test Page', 'clear'=>TRUE));
                
-               $config['base_url'] = site_url('catalog/test/');
-               $config['total_rows'] = '160';
-               $this->pagination->initialize($config);
-               echo $this->pagination->create_links();
+               $this->load->view('footer');
+               $this->load->view('html_end');
        }
        
        public function category($category_id, $offset = 0)
        {
+               // **
+               // ** LOADING MODEL
+               // **
                // Retrieve videos summary.
                $this->load->model('videos_model');
-               $data['videos'] = $this->videos_model->get_videos_summary(
+               $vs_data['videos'] = $this->videos_model->get_videos_summary(
                        $category_id, intval($offset),
                        $this->config->item('videos_per_page'));
+               
+               // Video Category
                $categories = $this->config->item('categories');
-               $data['category'] = $categories[$category_id];
-               $data['category_id'] = $category_id;
+               $category_name = $categories[$category_id];
+               $vs_data['category_title'] = $category_name ?
+                       $this->lang->line("ui_categ_$category_name") : $category_name;
+               $vs_data['category_id'] = $category_id;
                
                // Pagination
                $this->load->library('pagination');
@@ -69,18 +120,34 @@ class Catalog extends CI_Controller {
                        $category_id);
                $pg_config['per_page'] = $this->config->item('videos_per_page');
                $this->pagination->initialize($pg_config);
-               $data['pagination'] = $this->pagination->create_links();
+               $vs_data['pagination'] = $this->pagination->create_links();
+               
+               // Video Summary
+               $data['video_summary'] = $this->load->view('catalog/videos_summary_view',
+                       $vs_data, TRUE);
                
                $params = array(        'title' => $this->config->item('site_name'),
-                                                       'css' => array('catalog.css'),
-                                                       //'js' => array(),
+                                                       'css' => array(
+                                                               'catalog.css', 
+                                                               'jquery-ui.css'
+                                                       ),
+                                                       'js' => array(
+                                                               'jquery.js',
+                                                               'jquery-ui.js'
+                                                       ),
                                                        //'metas' => array('description'=>'','keywords'=>'')
                                                        );
                $this->load->library('html_head_params', $params);
+               
+               // **
+               // ** LOADING VIEWS
+               // **
                $this->load->view('html_begin', $this->html_head_params);
                $this->load->view('header');
                
-               $this->load->view('catalog/category_view', $data);
+               $main_params['content'] = $this->load->view('catalog/category_view', $data, TRUE);
+               $main_params['side'] = $this->load->view('side_default.php', NULL, TRUE);
+               $this->load->view('main', $main_params);
                
                $this->load->view('footer');
                $this->load->view('html_end');