language support added; Romanian language added; preparing to create jQuery UI video...
[living-lab-site.git] / application / controllers / video.php
1 <?php
2
3 /**
4  * Class Video controlls 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                 // Retrieve video information.
37                 $this->load->model('videos_model');
38                 $data['video'] = $this->videos_model->get_video($id, $name);
39                 $data['plugin_type'] = ($plugin === NULL ? 'auto' : $plugin);
40                 
41                 // Display page.
42                 $params = array(        'title' => $data['video']['title'] . ' -- '
43                                                                 . $this->config->item('site_name'),
44                                                         'css' => array('jquery-ui.css', 'NextShare_VLC_plugin.css'),
45                                                         'js' => array('jquery.min.js', 'jquery-ui.min.js', 'NextShare_VLC_plugin.js', 'video.js'),
46                                                         //'metas' => array('description'=>'','keywords'=>'')
47                                                         );
48                 $this->load->library('html_head_params', $params);
49                 $this->load->view('html_begin', $this->html_head_params);
50                 $this->load->view('header');
51                 
52                 // Preloading video plugin.
53                 // TODO plugin auto (type + definition)
54                 $data['plugin_content'] = $this->_plugin('ns-html5', 
55                         $data['video']['url'][0], TRUE);
56                 
57                 $this->load->view('video/watch_view', $data);
58                 
59                 $this->load->view('footer');
60                 $this->load->view('html_end');
61         }
62         
63         /**
64          * AJAX page which retrieves a video plugin.
65          *
66          * The view associated with this controller should be parameter type
67          * concatenated with '_plugin_view' and must be located in
68          * 'application/views/video'.
69          *
70          * @param       string $type    'ns-vlc', 'ns-html5'
71          */
72         public function plugin($type)
73         {
74                 $url = $this->input->post('url', TRUE);
75                 
76                 $this->_plugin($type, $url);
77         }
78         
79         /**
80          * Video plugin controller
81          *
82          * See plugin function for details. If the second parameter is TRUE
83          * the output is return instead of being displayed (used in preloading).
84          */
85         public function _plugin($type, $url, $return_output=FALSE)
86         {       
87                 if ($type == 'ns-html5')
88                         $data['url'] = 'tribe://' . $url;
89                 else if ($type == 'ns-vlc')
90                         $data['url'] = $url;
91                 
92                 $output = $this->load->view('video/'. $type . '_plugin_view', $data, 
93                         $return_output);
94                 
95                 if ($return_output)
96                         return $output;
97         }
98         
99 }
100
101 /* End of file video.php */
102 /* Location: ./application/controllers/video.php */