layout corrections in watch video page
[living-lab-site.git] / application / controllers / video.php
1 <?php
2
3 /**
4  * Class Video controls video items handling: watching, commenting, rating,
5  * adding etc.
6  *
7  * @category    Controller
8  * @author              Călin-Andrei Burloiu
9  */
10 class Video extends CI_Controller {
11
12         public function __construct()
13         {
14                 parent::__construct();
15                 
16                 //$this->lang->load('video');
17         }
18         
19         public function index()
20         {
21                 
22         }
23         
24         /**
25          * The page used for watching a video
26          *
27          * @param       string $id      DB id of the video
28          * @param       string $name    `name` of the video from DB
29          * @param       string $plugin  video plugin ('ns-vlc', 'ns-html5'). If it's set 
30          * to NULL or 'auto', the plugin is automatically selected.
31          */
32         public function watch($id, $name = NULL, $plugin = NULL)
33         {
34                 $this->load->helper('url');
35                 
36                 // **
37                 // ** LOADING MODEL
38                 // **
39                 // Retrieve video information.
40                 $this->load->model('videos_model');
41                 $data['video'] = $this->videos_model->get_video($id, $name);
42                 $data['plugin_type'] = ($plugin === NULL ? 'auto' : $plugin);
43                 
44                 // Display page.
45                 $params = array(        'title' => $data['video']['title'] . ' -- '
46                                                                 . $this->config->item('site_name'),
47                                                         'css' => array(
48                                                                 'jquery-ui.css',
49                                                                 'jquery.ui.nsvideo.css',
50                                                                 'video.css'
51                                                         ),
52                                                         'js' => array(
53                                                                 'jquery.js',
54                                                                 'jquery-ui.js',
55                                                                 'jquery.ui.nsvideo.js'
56                                                         ),
57                                                         //'metas' => array('description'=>'','keywords'=>'')
58                                                         );
59                 $this->load->library('html_head_params', $params);
60                 
61                 // Preloading video plugin.
62                 // TODO plugin auto: type and format
63                 if ($data['plugin_type'] == 'auto')
64                         $data['plugin_type'] = 'ns-html5';
65                 $data['asset_index'] = 0;
66                 
67                 // TODO remove old AJAX plugin content
68 //              $data['plugin_content'] = $this->_plugin('ns-html5', 
69 //                      $data['video']['url'][0], TRUE);
70                 
71                 // **
72                 // ** LOADING VIEWS
73                 // **
74                 $this->load->view('html_begin', $this->html_head_params);
75                 $this->load->view('header');
76                 
77                 //$main_params['content'] = $this->load->view('video/watch_view', $data, TRUE);
78                 $this->load->view('video/watch_view', $data);
79                 
80                 $this->load->view('footer');
81                 $this->load->view('html_end');
82         }
83         
84         /**
85          * AJAX page which retrieves a video plugin.
86          *
87          * The view associated with this controller should be parameter type
88          * concatenated with '_plugin_view' and must be located in
89          * 'application/views/video'.
90          *
91          * @param       string $type    'ns-vlc', 'ns-html5'
92          */
93         public function plugin($type)
94         {
95                 $url = $this->input->post('url', TRUE);
96                 
97                 $this->_plugin($type, $url);
98         }
99         
100         /**
101          * Video plugin controller
102          *
103          * See plugin function for details. If the second parameter is TRUE
104          * the output is return instead of being displayed (used in preloading).
105          */
106         public function _plugin($type, $url, $return_output=FALSE)
107         {       
108                 if ($type == 'ns-html5')
109                         $data['url'] = 'tribe://' . $url;
110                 else if ($type == 'ns-vlc')
111                         $data['url'] = $url;
112                 
113                 $output = $this->load->view('video/'. $type . '_plugin_view', $data, 
114                         $return_output);
115                 
116                 if ($return_output)
117                         return $output;
118         }
119         
120 }
121
122 /* End of file video.php */
123 /* Location: ./application/controllers/video.php */